Commit dc0adaec by 翁国栋

运营后台--

一键校验
parent 363ec83e
......@@ -7,6 +7,7 @@ import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.controller.insure.bean.ExcelBean;
import cn.timer.api.controller.insure.enums.InsuranceEnum;
import cn.timer.api.dao.insure.InsureLogMapper;
import cn.timer.api.dao.insure.InsurePolicyMapper;
import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
......@@ -97,6 +98,9 @@ public class InsureContorll {
@Autowired
private InsurePolicyMapper insurePolicyMapper;
@Autowired
private InsureLogMapper insureLogMapper;
/**
* 设置请求参数
......@@ -223,11 +227,13 @@ public class InsureContorll {
quotationsArry.add(quotations);
bodyMap.put("quotations", quotationsArry);
log.info(JSONObject.toJSONString(bodyMap));
Map dataMap = requestAgent(bodyMap);
Map policyMap= Maps.newHashMap();
List<Map> batchMap = Lists.newArrayList();
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map dataMap = JSONObject.parseObject(data, Map.class);
if (dataMap != null) {
if(dataMap.get("errcode").toString().equals("suc")){
if ((dataMap.get("errcode").toString().equals("suc")) || (dataMap.get("errcode").toString().equals("e25"))) {
Map policyMap = Maps.newHashMap();
List<Map> batchMap = Lists.newArrayList();
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
......@@ -237,16 +243,16 @@ public class InsureContorll {
insurePolicy = InsurePolicy.builder().build();
insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
if(dataMap.get("errcode").toString().equals("suc")) {
if (dataMap.get("errcode").toString().equals("suc")) {
insurePolicy.setPolicyNo(policyMap.get("policy_no").toString());
insurePolicy.setPolicyFile(policyMap.get("policy_file").toString());
insurePolicy.setKitUrl(policyMap.get("kit_url").toString());
}
insurePolicy.setType(2);/*年单或者月单*/
insurePolicy.setCurrency("5");
if(dataMap.get("errcode").toString().equals("suc")) {
if (dataMap.get("errcode").toString().equals("suc")) {
insurePolicy.setStatus("1");
}else {
} else {
insurePolicy.setStatus("2");
}
insurePolicy.setOrgCode(qyzxEntInfoM.getId());
......@@ -267,7 +273,7 @@ public class InsureContorll {
insureUser.setPrice(price.toString());/*前端获取的保费*/
insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price));
if(dataMap.get("errcode").toString().equals("suc")) {
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
}
......@@ -279,50 +285,30 @@ public class InsureContorll {
insureUser.setInsuredNo(y.getZjNum());
insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url);
if(dataMap.get("errcode").toString().equals("suc")) {
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
}else{
insureUser.setInsureStatus(2);
} else {
insureUser.setInsureStatus(3);
insureUser.setStatus("2");
}
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setPolicyId(insurePolicy.getId());
insureUser.setApplyType(1);
insureUser.setApplyType(2);//投保类型
insureUser.insert();
if(dataMap.get("errcode").toString().equals("suc")) {
if (dataMap.get("errcode").toString().equals("suc")) {
y.setIsInsure(1);
y.insertOrUpdate();
}
}
return ResultUtil.error("投保成功");
}
return ResultUtil.error(dataMap.get("errmsg").toString());
}
/*测试用生产环境不需要*/
synchronized private Map requestAgent(Map bodyMap) {
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map dataMap = JSONObject.parseObject(data, Map.class);
if (dataMap.get("errcode").toString().equals("suc")) {
return dataMap;
} else {
if (dataMap.get("errcode").toString().equals("e25") && (dataMap.get("errmsg").toString().equals("出单中"))) {
try {
Thread.sleep(30000);
return requestAgent(bodyMap);
} catch (InterruptedException e) {
e.printStackTrace();
return ResultUtil.success(dataMap.get("errmsg").toString());
}
return ResultUtil.error("网络异常");
}
return dataMap;
}
}
/**
* 生成投保问文件
......@@ -801,4 +787,42 @@ public class InsureContorll {
}
return ResultUtil.success();
}
@GetMapping(value = "/verification")
@ApiOperation(value = "一键校验", httpMethod = "Post", notes = "一键校验")
public Result<Object> verification() {
List<InsurePolicy> insurePolicies = InsurePolicy.builder().build().selectList(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getStatus,2));
insurePolicies.forEach(i->{
InsureLog insureLog = InsureLog.builder().build().selectOne(new QueryWrapper<InsureLog>().lambda().eq(InsureLog::getPolicyId,i.getId()).eq(InsureLog::getType,1));
Map bodyMap = JSONObject.parseObject(insureLog.getRequestData(), Map.class);
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret),bodyMap );
log.info("校验结果:{}",data);
Map dataMap = JSONObject.parseObject(data, Map.class);
if (dataMap != null) {
if ((dataMap.get("errcode").toString().equals("suc"))) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
Map policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
i.setPolicyNo(policyMap.get("policy_no").toString());
i.setPolicyFile(policyMap.get("policy_file").toString());
i.setKitUrl(policyMap.get("kit_url").toString());
i.setStatus("1");
i.updateById();
/*批次信息*/
List<Map> batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), List.class);
List<InsureUser> insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getPolicyId,i.getId())
.eq(InsureUser::getType,2));
insureUserList.forEach(user->{
user.setBatchNo(batchMap.get(0).get("batch_no").toString());
user.setPolicyNo(policyMap.get("policy_no").toString());
user.setInsureStatus(1);
user.setStatus("1");
user.updateById();
YgglMainEmp.builder().isInsure(1).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, user.getUserId()));
});
}
}
});
return ResultUtil.success();
};
}
......@@ -18,5 +18,6 @@ import java.util.List;
@Repository
public interface InsureLogMapper extends BaseMapper<InsureLog> {
List<InsureLog> selectListById(@Param("policyId")String policyId);
List<InsureLog> selectListByIds(@Param("array")Integer[] ids);
}
......@@ -176,4 +176,12 @@
where policy_id = #{policyId}
ORDER BY create_time DESC
</select>
<select id="selectListByIds" resultType="cn.timer.api.bean.insure.InsureLog">
select * from insure_log
where type = 1 and policy_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</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