Commit fdd4be2f by 翁国栋 Committed by 284718418@qq.com

8小时后台--

日志列表
parent bb27dea0
......@@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @Description TODO
......@@ -15,9 +16,10 @@ public class OrderImportInfo implements Serializable {
private static final long serialVersionUID = -6208327653541160864L;
private String uuid;
private String single_serial_no;
private String third_uuid;
private String total_money;
private String endorsement_file;
private String err_msg;
private List err_list;
private List<Map> err_list;
private String err_content;
}
......@@ -51,28 +51,27 @@ public class CallBackContorll {
@ApiOperationSupport(order = 2)
private Map insuredCallBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap();
map.put("status","error");
if(StringUtils.isNullOrEmpty(pid)||StringUtils.isNullOrEmpty(sign)&&StringUtils.isNullOrEmpty(timestamp)){
map.put("status", "error");
if (StringUtils.isNullOrEmpty(pid) || StringUtils.isNullOrEmpty(sign) && StringUtils.isNullOrEmpty(timestamp)) {
return map;
}
if(!pid.equals(appidq)){
if (!pid.equals(appidq)) {
return map;
}
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
byte[] b = new byte[4096];
for (int n; (n = is.read(b)) != -1;)
{
for (int n; (n = is.read(b)) != -1; ) {
sb.append(new String(b, 0, n));
}
String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString());
if(!value.equals(sign)){
if (!value.equals(sign)) {
return map;
}
CallBack callBack=JSONObject.parseObject(sb.toString(), CallBack.class);
CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
Map trueMap = Maps.newHashMap();
trueMap.put("status","1");
trueMap.put("status", "1");
return trueMap;
}
......@@ -81,67 +80,75 @@ public class CallBackContorll {
@ApiOperationSupport(order = 2)
private Map callBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap();
map.put("status","error");
int type = 7;
Integer policyId = null;
if(StringUtils.isNullOrEmpty(pid)||StringUtils.isNullOrEmpty(sign)&&StringUtils.isNullOrEmpty(timestamp)){
map.put("status", "error");
if (StringUtils.isNullOrEmpty(pid) || StringUtils.isNullOrEmpty(sign) && StringUtils.isNullOrEmpty(timestamp)) {
return map;
}
if(!pid.equals(appidq)){
if (!pid.equals(appidq)) {
return map;
}
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
byte[] b = new byte[4096];
for (int n; (n = is.read(b)) != -1;)
{
for (int n; (n = is.read(b)) != -1; ) {
sb.append(new String(b, 0, n));
}
String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString());
if(!value.equals(sign)){
if (!value.equals(sign)) {
return map;
}
Map paramsMap = Maps.newHashMap();
paramsMap.put("pid",pid);
paramsMap.put("timestamp",timestamp);
paramsMap.put("sign",sign);
CallBack callBack=JSONObject.parseObject(sb.toString(), CallBack.class);
if(callBack.getStatus().equals("1")) {
log.info("callBack" + JSONObject.toJSONString(callBack));
List<InsureUser> list = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo, callBack.getOrder_import_info().getUuid()).eq(InsureUser::getInsureStatus,3));
paramsMap.put("pid", pid);
paramsMap.put("timestamp", timestamp);
paramsMap.put("sign", sign);
CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
log.info("callBack=====" + sb.toString());
if (callBack.getStatus().equals("1")) {
List<InsureUser> list = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo, callBack.getOrder_import_info().getUuid()).eq(InsureUser::getInsureStatus, 3));
list.forEach(i -> {
i.setInsureStatus(1);
i.updateById();
YgglMainEmp.builder().isInsure(1).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId()));
});
List<InsureUser> oldlist = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getReplaceTransId, callBack.getOrder_import_info().getUuid()));
if(oldlist!=null&&oldlist.size()>0) {
if (oldlist != null && oldlist.size() > 0) {
oldlist.forEach(i -> {
i.setInsureStatus(4);
i.setStatus("2");
i.updateById();
YgglMainEmp.builder().isInsure(0).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId()));
});
type=8;
}
InsurePolicy insurePolicy= InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getPolicyNo,list.get(0).getPolicyNo()));
policyId=insurePolicy.getId();
if(oldlist==null||oldlist.size()==0) {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getPolicyNo, list.get(0).getPolicyNo()));
if (oldlist == null || oldlist.size() == 0) {
insurePolicy.setTotalPremium(String.valueOf(Double.valueOf(insurePolicy.getTotalPremium()) + Double.valueOf(callBack.getOrder_import_info().getTotal_money())));
}
insurePolicy.setPolicyFile(callBack.getOrder_import_info().getEndorsement_file());
insurePolicy.setUpdateTime(new Date());
insurePolicy.updateById();
}else{
InsureLog.builder().requestParam(JSONObject.toJSONString(paramsMap)).type(7)
.requestData(sb.toString()).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(callBack)).requestPath(base_api_url + "/callBack/policy/CallBack")
.returnCode(callBack.getStatus()).returnMsg("更新成功").policyId(insurePolicy.getId()).build().insert();
} else {
String errorMsg = "";
InsureLog insureLog = InsureLog.builder().build().selectOne(new QueryWrapper<InsureLog>().lambda().eq(InsureLog::getTransId, callBack.getOrder_import_info().getThird_uuid()));
List<Map> errMap = callBack.getOrder_import_info().getErr_list();
if (errMap.size() > 0) {
for (int i = 0; i < errMap.size(); i++) {
errorMsg = errorMsg + ("姓名:"+errMap.get(i).get("name").toString()+",错误:"+errMap.get(i).get("err_content").toString() + ',');
}
} else {
errorMsg = callBack.getErr_msg();
}
//TODO 写入日志
InsureLog.builder().requestParam(JSONObject.toJSONString(paramsMap)).type(7)
.requestData(sb.toString()).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(callBack)).requestPath(base_api_url + "/callBack/policy/CallBack")
.returnCode(callBack.getStatus()).returnMsg(errorMsg).policyId(insureLog.getPolicyId()).build().insert();
}
Map trueMap = Maps.newHashMap();
trueMap.put("status","1");
InsureLog.builder().requestParam(JSONObject.toJSONString(paramsMap)).type(type)
.requestData(sb.toString()).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(callBack)).requestPath(base_api_url+"/callBack/policy/CallBack")
.returnCode(callBack.getStatus()).returnMsg(callBack.getOrder_import_info().getErr_msg()).policyId(policyId).build().insert();
trueMap.put("status", "1");
return trueMap;
}
}
......@@ -14,12 +14,17 @@ import java.util.Map;
import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsureProduct;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dao.insure.InsureLogMapper;
import cn.timer.api.dto.insure.PolicyLogDto;
import cn.timer.api.utils.Page;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -33,8 +38,6 @@ import javax.servlet.http.HttpServletResponse;
/**
*
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-03-22 09:55:46
......@@ -43,7 +46,7 @@ import javax.servlet.http.HttpServletResponse;
@RestController
@Transactional
@RequestMapping(value = "/insureLog", produces = {"application/json"})
public class InsureLogController{
public class InsureLogController {
@Autowired
private InsureLogMapper insureLogMapper;
......@@ -51,16 +54,17 @@ public class InsureLogController{
@ApiOperation(value = "12.日志列表", httpMethod = "Get", notes = "日志列表")
public Result<Object> logList(@RequestParam("policyId") String policyId) {
List<InsureLog> list = insureLogMapper.selectListById(policyId);
if (list.size()>0) {
if (list.size() > 0) {
return ResultUtil.data(list);
}
return ResultUtil.error("暂无日志");
}
@GetMapping(value = "/downUserExcel")
@ApiOperation(value = "12.人员清单", httpMethod = "Get", notes = "人员清单")
public void downUserExcel(@RequestParam("logId") String logId, HttpServletRequest request, HttpServletResponse response) {
InsureLog insureLog = InsureLog.builder().id(Integer.parseInt(logId)).build().selectById();
if(insureLog==null|| StringUtils.isNullOrEmpty(insureLog.getFileUrl())){
if (insureLog == null || StringUtils.isNullOrEmpty(insureLog.getFileUrl())) {
return;
}
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
......@@ -68,10 +72,10 @@ public class InsureLogController{
BufferedInputStream bis = null;
try {
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=" + new String((dtf2.format(LocalDateTime.now())+".xlsx").getBytes("UTF8"), "ISO-8859-1"));
response.setHeader("content-disposition", "attachment; filename=" + new String((dtf2.format(LocalDateTime.now()) + ".xlsx").getBytes("UTF8"), "ISO-8859-1"));
response.setCharacterEncoding("UTF-8");
sos = response.getOutputStream();
String destUrl ="http:"+insureLog.getFileUrl();
String destUrl = "http:" + insureLog.getFileUrl();
URL url = new URL(destUrl);
HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection();
//连接指定的网络资源
......@@ -100,4 +104,14 @@ public class InsureLogController{
}
}
@PostMapping(value = "/insureLogList")
@ApiOperation(value = "日志列表--8小时端", httpMethod = "Get", notes = "日志列表")
public Result<Object> insureLogList(@CurrentUser UserBean userBean, @RequestBody Page page) {
Map map = Maps.newHashMap();
List<PolicyLogDto> list = insureLogMapper.selectLogListByOrgCode(userBean.getOrgCode(),page);
map.put("list", list);
map.put("total", insureLogMapper.selectLogTotalByOrgCode(userBean.getOrgCode()));
return ResultUtil.data(map);
}
}
package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.dto.insure.PolicyLogDto;
import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -19,5 +22,7 @@ import java.util.List;
public interface InsureLogMapper extends BaseMapper<InsureLog> {
List<InsureLog> selectListById(@Param("policyId")String policyId);
List<InsureLog> selectListByIds(@Param("array")Integer[] ids);
List<PolicyLogDto> selectLogListByOrgCode(@Param("orgCode") Integer orgCode, @Param("page") Page page);
Integer selectLogTotalByOrgCode(@Param("orgCode") Integer orgCode);
}
......@@ -184,4 +184,18 @@
#{id}
</foreach>
</select>
<select id="selectLogListByOrgCode" resultType="cn.timer.api.dto.insure.PolicyLogDto">
select ip.policy_no as policyNo,il.return_code as returnCode,il.return_msg as returnMsg,il.type as type,il.create_time as createTime from insure_log il
LEFT JOIN insure_policy ip on ip.id=il.policy_id
WHERE ip.org_code = #{orgCode}
<if test="page.currentPage != null and page.totalPage != null">
limit #{page.offset}, #{page.totalPage}
</if>
</select>
<select id="selectLogTotalByOrgCode" resultType="java.lang.Integer">
select count(il.id) from insure_log il
LEFT JOIN insure_policy ip on ip.id=il.policy_id
WHERE ip.org_code = #{orgCode}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment