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

8小时后台--

日志列表
parent bb27dea0
...@@ -4,6 +4,7 @@ import lombok.Data; ...@@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description TODO * @Description TODO
...@@ -15,9 +16,10 @@ public class OrderImportInfo implements Serializable { ...@@ -15,9 +16,10 @@ public class OrderImportInfo implements Serializable {
private static final long serialVersionUID = -6208327653541160864L; private static final long serialVersionUID = -6208327653541160864L;
private String uuid; private String uuid;
private String single_serial_no; private String single_serial_no;
private String third_uuid;
private String total_money; private String total_money;
private String endorsement_file; private String endorsement_file;
private String err_msg; private String err_msg;
private List err_list; private List<Map> err_list;
private String err_content; private String err_content;
} }
...@@ -51,28 +51,27 @@ public class CallBackContorll { ...@@ -51,28 +51,27 @@ public class CallBackContorll {
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
private Map insuredCallBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException { private Map insuredCallBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap(); Map map = Maps.newHashMap();
map.put("status","error"); map.put("status", "error");
if(StringUtils.isNullOrEmpty(pid)||StringUtils.isNullOrEmpty(sign)&&StringUtils.isNullOrEmpty(timestamp)){ if (StringUtils.isNullOrEmpty(pid) || StringUtils.isNullOrEmpty(sign) && StringUtils.isNullOrEmpty(timestamp)) {
return map; return map;
} }
if(!pid.equals(appidq)){ if (!pid.equals(appidq)) {
return map; return map;
} }
InputStream is = null; InputStream is = null;
is = request.getInputStream(); is = request.getInputStream();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
byte[] b = new byte[4096]; 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)); sb.append(new String(b, 0, n));
} }
String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString()); String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString());
if(!value.equals(sign)){ if (!value.equals(sign)) {
return map; return map;
} }
CallBack callBack=JSONObject.parseObject(sb.toString(), CallBack.class); CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
Map trueMap = Maps.newHashMap(); Map trueMap = Maps.newHashMap();
trueMap.put("status","1"); trueMap.put("status", "1");
return trueMap; return trueMap;
} }
...@@ -81,67 +80,75 @@ public class CallBackContorll { ...@@ -81,67 +80,75 @@ public class CallBackContorll {
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
private Map callBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException { private Map callBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap(); Map map = Maps.newHashMap();
map.put("status","error"); map.put("status", "error");
int type = 7; if (StringUtils.isNullOrEmpty(pid) || StringUtils.isNullOrEmpty(sign) && StringUtils.isNullOrEmpty(timestamp)) {
Integer policyId = null;
if(StringUtils.isNullOrEmpty(pid)||StringUtils.isNullOrEmpty(sign)&&StringUtils.isNullOrEmpty(timestamp)){
return map; return map;
} }
if(!pid.equals(appidq)){ if (!pid.equals(appidq)) {
return map; return map;
} }
InputStream is = null; InputStream is = null;
is = request.getInputStream(); is = request.getInputStream();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
byte[] b = new byte[4096]; 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));
sb.append(new String(b, 0, n)); }
}
String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString()); String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString());
if(!value.equals(sign)){ if (!value.equals(sign)) {
return map; return map;
} }
Map paramsMap = Maps.newHashMap(); Map paramsMap = Maps.newHashMap();
paramsMap.put("pid",pid); paramsMap.put("pid", pid);
paramsMap.put("timestamp",timestamp); paramsMap.put("timestamp", timestamp);
paramsMap.put("sign",sign); paramsMap.put("sign", sign);
CallBack callBack=JSONObject.parseObject(sb.toString(), CallBack.class); CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
if(callBack.getStatus().equals("1")) { log.info("callBack=====" + sb.toString());
log.info("callBack" + JSONObject.toJSONString(callBack)); 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<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 -> { list.forEach(i -> {
i.setInsureStatus(1); i.setInsureStatus(1);
i.updateById(); i.updateById();
YgglMainEmp.builder().isInsure(1).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId())); 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())); 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 -> { oldlist.forEach(i -> {
i.setInsureStatus(4); i.setInsureStatus(4);
i.setStatus("2"); i.setStatus("2");
i.updateById(); i.updateById();
YgglMainEmp.builder().isInsure(0).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId())); 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())); 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) {
if(oldlist==null||oldlist.size()==0) {
insurePolicy.setTotalPremium(String.valueOf(Double.valueOf(insurePolicy.getTotalPremium()) + Double.valueOf(callBack.getOrder_import_info().getTotal_money()))); 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.setPolicyFile(callBack.getOrder_import_info().getEndorsement_file());
insurePolicy.setUpdateTime(new Date()); insurePolicy.setUpdateTime(new Date());
insurePolicy.updateById(); 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 写入日志 //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(); Map trueMap = Maps.newHashMap();
trueMap.put("status","1"); 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();
return trueMap; return trueMap;
} }
} }
...@@ -14,12 +14,17 @@ import java.util.Map; ...@@ -14,12 +14,17 @@ import java.util.Map;
import cn.timer.api.bean.insure.InsureLog; import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsureProduct; 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.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.Result;
import cn.timer.api.utils.ResultUtil; import cn.timer.api.utils.ResultUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.common.utils.StringUtils; import com.aliyun.oss.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -33,8 +38,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -33,8 +38,6 @@ import javax.servlet.http.HttpServletResponse;
/** /**
*
*
* @author wgd * @author wgd
* @email 862422848@qq.com * @email 862422848@qq.com
* @date 2022-03-22 09:55:46 * @date 2022-03-22 09:55:46
...@@ -43,61 +46,72 @@ import javax.servlet.http.HttpServletResponse; ...@@ -43,61 +46,72 @@ import javax.servlet.http.HttpServletResponse;
@RestController @RestController
@Transactional @Transactional
@RequestMapping(value = "/insureLog", produces = {"application/json"}) @RequestMapping(value = "/insureLog", produces = {"application/json"})
public class InsureLogController{ public class InsureLogController {
@Autowired @Autowired
private InsureLogMapper insureLogMapper; private InsureLogMapper insureLogMapper;
@GetMapping(value = "/logList") @GetMapping(value = "/logList")
@ApiOperation(value = "12.日志列表", httpMethod = "Get", notes = "日志列表") @ApiOperation(value = "12.日志列表", httpMethod = "Get", notes = "日志列表")
public Result<Object> logList(@RequestParam("policyId") String policyId) { public Result<Object> logList(@RequestParam("policyId") String policyId) {
List<InsureLog> list = insureLogMapper.selectListById(policyId); List<InsureLog> list = insureLogMapper.selectListById(policyId);
if (list.size()>0) { if (list.size() > 0) {
return ResultUtil.data(list); return ResultUtil.data(list);
} }
return ResultUtil.error("暂无日志"); return ResultUtil.error("暂无日志");
} }
@GetMapping(value = "/downUserExcel")
@ApiOperation(value = "12.人员清单", httpMethod = "Get", notes = "人员清单") @GetMapping(value = "/downUserExcel")
public void downUserExcel(@RequestParam("logId") String logId, HttpServletRequest request, HttpServletResponse response) { @ApiOperation(value = "12.人员清单", httpMethod = "Get", notes = "人员清单")
InsureLog insureLog = InsureLog.builder().id(Integer.parseInt(logId)).build().selectById(); public void downUserExcel(@RequestParam("logId") String logId, HttpServletRequest request, HttpServletResponse response) {
if(insureLog==null|| StringUtils.isNullOrEmpty(insureLog.getFileUrl())){ InsureLog insureLog = InsureLog.builder().id(Integer.parseInt(logId)).build().selectById();
return; if (insureLog == null || StringUtils.isNullOrEmpty(insureLog.getFileUrl())) {
} return;
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); }
OutputStream sos = null; DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
BufferedInputStream bis = null; OutputStream sos = null;
try { BufferedInputStream bis = null;
response.setContentType("application/octet-stream"); try {
response.setHeader("content-disposition", "attachment; filename=" + new String((dtf2.format(LocalDateTime.now())+".xlsx").getBytes("UTF8"), "ISO-8859-1")); response.setContentType("application/octet-stream");
response.setCharacterEncoding("UTF-8"); response.setHeader("content-disposition", "attachment; filename=" + new String((dtf2.format(LocalDateTime.now()) + ".xlsx").getBytes("UTF8"), "ISO-8859-1"));
sos = response.getOutputStream(); response.setCharacterEncoding("UTF-8");
String destUrl ="http:"+insureLog.getFileUrl(); sos = response.getOutputStream();
URL url = new URL(destUrl); String destUrl = "http:" + insureLog.getFileUrl();
HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection(); URL url = new URL(destUrl);
//连接指定的网络资源 HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection();
httpUrl.connect(); //连接指定的网络资源
//获取网络输入流 httpUrl.connect();
bis = new BufferedInputStream(httpUrl.getInputStream()); //获取网络输入流
int b; bis = new BufferedInputStream(httpUrl.getInputStream());
while ((b = bis.read()) != -1) { int b;
sos.write(b); while ((b = bis.read()) != -1) {
} sos.write(b);
} catch (MalformedURLException e) { }
e.printStackTrace(); } catch (MalformedURLException e) {
} catch (IOException e) { e.printStackTrace();
e.printStackTrace(); } catch (IOException e) {
} finally { e.printStackTrace();
try { } finally {
sos.close(); try {
} catch (IOException e) { sos.close();
e.printStackTrace(); } catch (IOException e) {
} e.printStackTrace();
try { }
bis.close(); try {
} catch (IOException e) { bis.close();
e.printStackTrace(); } catch (IOException e) {
} e.printStackTrace();
} }
} }
}
@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; package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsureLog; 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.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -19,5 +22,7 @@ import java.util.List; ...@@ -19,5 +22,7 @@ import java.util.List;
public interface InsureLogMapper extends BaseMapper<InsureLog> { public interface InsureLogMapper extends BaseMapper<InsureLog> {
List<InsureLog> selectListById(@Param("policyId")String policyId); List<InsureLog> selectListById(@Param("policyId")String policyId);
List<InsureLog> selectListByIds(@Param("array")Integer[] ids); 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 @@ ...@@ -184,4 +184,18 @@
#{id} #{id}
</foreach> </foreach>
</select> </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> </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