Commit 76da2e74 by 翁国栋

运营后台--

增加日志列表
parent 61640e0e
......@@ -33,7 +33,7 @@ import java.util.Date;
@NoArgsConstructor
@Table(name = "insure_log")
@ApiModel("投保日志")
public class InsureLog extends Model<InsurePolicy> {
public class InsureLog extends Model<InsureLog> {
private static final long serialVersionUID = 1L;
@Id
......@@ -88,6 +88,8 @@ public class InsureLog extends Model<InsurePolicy> {
private Integer policyId;
public String fileUrl;
/**
* 设置:
*/
......@@ -221,4 +223,5 @@ public class InsureLog extends Model<InsurePolicy> {
return type;
}
}
......@@ -39,7 +39,7 @@ import org.springframework.web.multipart.MultipartFile;
* @email 862422848@qq.com
* @date 2022-03-07 17:02:46
*/
@Api(tags = "投保人")
@Api(tags = "8.0保险列表")
@RestController
@Transactional
@RequestMapping(value = "/insureApplicant", produces = {"application/json"})
......
......@@ -68,25 +68,23 @@ public class InsureContorll {
@Value("${BASE_API_URL}")
private String base_api_url;
private static final Logger log = LoggerFactory.getLogger(InsureContorll.class);
/*测试用*/
private static String appid = "1002303100602312445";
/*测试用*/
private static String secret = "acb329868c31d5b3ba03de40dac13dd9";
/*保全测试用*/
private static String appidq = "1000115041006006938";
/*保全测试用*/
private static String secretq = "6ba1bf4aa0bd14368c95ff0b9934a17b";
/*测试用投保上传文件地址*/
private static String uploadUrl = " http://sandbox.portal.unistar-ins.com/service/Home/Index/fileUpload";
/*测试用投保申请地址*/
private static String insuredUrl = "http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy";
/*测试用保全上传文件地址*/
private static String uploadUrl2 = "http://sandbox.portal.unistar-ins.com/fuli/Home/Index/file_upload";
/*测试用保全申请地址*/
private static String batchUrl = "http://sandbox.portal.unistar-ins.com/fuli/Home/WelfareProduct/batch_declare";
@Value("${insure.appid}")
private String appid;
@Value("${insure.secret}")
private String secret;
@Value("${insure.appidq}")
private String appidq;
@Value("${insure.secretq}")
private String secretq;
@Value("${insure.uploadUrl}")
private String uploadUrl;
@Value("${insure.insuredUrl}")
private String insuredUrl;
@Value("${insure.uploadUrlq}")
private String uploadUrl2;
@Value("${insure.batchUrl}")
private String batchUrl;
private static SimpleDateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......@@ -125,9 +123,8 @@ public class InsureContorll {
@PostMapping(value = "/insured_add")
@ApiOperation(value = "1.投保申请", httpMethod = "Post", notes = "投保申请")
@ApiOperationSupport(order = 2)
public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,insureDto.getOrgCode()));
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,insureDto.getOrgCode()).eq(InsurePolicy::getStatus,1));
if(insurePolicy!=null){
return ResultUtil.error("企业已存在");
}
......@@ -152,6 +149,13 @@ public class InsureContorll {
quotations.put("quotation_type", 3);/*报价类型:3-投保申请*/
quotations.put("currency", "5");/*币种:5人民币*/
/* quotations.put("source_type", "");*//*币种:5人民币*//*
quotations.put("cps_email", "");*//*币种:5人民币*//*
quotations.put("cps_tel", "");*//*币种:5人民币*//*
quotations.put("last_serial_number", "");*//*币种:5人民币*//*
quotations.put("from_source", "");*//*币种:5人民币*//*
quotations.put("operator_name", "");*//*币种:5人民币*/
/*企业信息*/
InsureApplicant insureApplicant = InsureApplicant.builder().id(1).build().selectById();
if (insureApplicant == null) {
......@@ -181,7 +185,14 @@ public class InsureContorll {
basicMap.put("product_code_id", insureProduct.getProductCodeId());/*产品代码,选项值:61b85207a9f87da19fb5986 (生产环境) 61b85207a9f87da19fb5986 (沙箱环境)*/
basicMap.put("policy_date_start",insureDto.getPolicyDateStart());
basicMap.put("policy_date_end", insureDto.getPolicyDateEnd());
/* basicMap.put("channel", "");
basicMap.put("fee", "");
basicMap.put("partner_user_rate", "");
basicMap.put("promotion_fee", "");
basicMap.put("agent_id", "");
basicMap.put("policy_insure_notify", "");*/
basicMap.put("promotion_id", 0);
/*basicMap.put("policy_number_last_year", "")*/;
quotations.put("basic", basicMap);
quotations.put("individual_applicant", Maps.newHashMap());
......@@ -208,32 +219,37 @@ public class InsureContorll {
quotations.put("file", Lists.newArrayList());
quotations.put("specifically_agreed_file", Lists.newArrayList());
quotations.put("policy_no", "");
quotations.put("callback_policy", "/callBack/policy/insuredCallBack");
quotations.put("insured", insuredArray);
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();
if (dataMap != null) {
if(!dataMap.get("errcode").toString().equals("suc")){
return ResultUtil.error(dataMap.get("errmsg").toString());
}
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);
batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), List.class);
}
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
Map policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
ArrayList<Map> batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), ArrayList.class);
InsureUser insureUser;
insurePolicy = InsurePolicy.builder().build();
insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insurePolicy.setPolicyNo(policyMap.get("policy_no").toString());
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");
insurePolicy.setStatus("1");
insurePolicy.setPolicyFile(policyMap.get("policy_file").toString());
insurePolicy.setKitUrl(policyMap.get("kit_url").toString());
if(dataMap.get("errcode").toString().equals("suc")) {
insurePolicy.setStatus("1");
}else {
insurePolicy.setStatus("2");
}
insurePolicy.setOrgCode(qyzxEntInfoM.getId());
insurePolicy.setCreateTime(date);
insurePolicy.setUpdateTime(date);
......@@ -241,6 +257,9 @@ public class InsureContorll {
insurePolicy.setTotalPremium(String.valueOf(insureDto.getUserIds().length * price));
insurePolicy.setProductId(insureProduct.getId());
insurePolicy.insert();
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(1)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(dataMap)).requestPath(insuredUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).fileUrl(url).build().insert();
for (YgglMainEmp y : ygglMainEmpList) {
insureUser = InsureUser.builder().build();
insureUser.setUserId(y.getId());
......@@ -248,9 +267,11 @@ public class InsureContorll {
insureUser.setPrice(price.toString());/*前端获取的保费*/
insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price));
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
if(dataMap.get("errcode").toString().equals("suc")) {
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
}
insureUser.setBenefitBasicPlan(insureDto.getBenefitBasicPlan());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
insureUser.setUserId(y.getId());
insureUser.setOrgCode(y.getOrgCode());
insureUser.setBenefitOccupationCategory(insureDto.getBenefitOccupationCategory());
......@@ -258,18 +279,27 @@ public class InsureContorll {
insureUser.setInsuredNo(y.getZjNum());
insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url);
insureUser.setInsureStatus(1);
if(dataMap.get("errcode").toString().equals("suc")) {
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
}else{
insureUser.setInsureStatus(2);
insureUser.setStatus("2");
}
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setStatus("1");
insureUser.setPolicyId(insurePolicy.getId());
insureUser.setApplyType(1);
y.setIsInsure(1);
y.insertOrUpdate();
insureUser.insert();
if(dataMap.get("errcode").toString().equals("suc")) {
y.setIsInsure(1);
y.insertOrUpdate();
}
}
}
return ResultUtil.error("");
return ResultUtil.success(dataMap.get("errmsg").toString());
}
......@@ -277,14 +307,10 @@ public class InsureContorll {
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);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(1)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(insuredUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
return dataMap;
} else {
if (dataMap.get("errcode").toString().equals("e1") && (dataMap.get("errmsg").toString().equals("出单中") || dataMap.get("errmsg").toString().equals("系统正在处理中,请稍候再试"))) {
if (dataMap.get("errcode").toString().equals("e1") && (dataMap.get("errmsg").toString().equals("出单中"))) {
try {
Thread.sleep(30000);
return requestAgent(bodyMap);
......@@ -321,6 +347,7 @@ public class InsureContorll {
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_投保" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
......@@ -335,14 +362,14 @@ public class InsureContorll {
String data = HttpUtils.sendPost(uploadUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
/*创建日志*/
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(4)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
return map.get("url").toString();
url=map.get("url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(4)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
......@@ -355,7 +382,7 @@ public class InsureContorll {
}
}
return "suc";
return url;
}
......@@ -363,7 +390,6 @@ public class InsureContorll {
@PostMapping(value = "/policyListAdmin")
@ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "Post", notes = "保单列表--运营后台端")
@ApiOperationSupport(order = 2)
public Result<Object> policyListAdmin(@RequestBody PolicyDto policyDto) {
Map map = Maps.newHashMap();
List<PolicyDto> list = insurePolicyMapper.policyList(policyDto);
......@@ -374,7 +400,6 @@ public class InsureContorll {
@GetMapping(value = "/policyDetail")
@ApiOperation(value = "5.保单信息", httpMethod = "Get", notes = "保单信息")
@ApiOperationSupport(order = 2)
public Result<Object> policyDetail(@RequestParam("policyId") Integer policyId) {
PolicyDto policyDto = insurePolicyMapper.getPolicyDetail(policyId);
if (policyDto == null) {
......@@ -385,7 +410,6 @@ public class InsureContorll {
@PostMapping(value = "/joinUser")
@ApiOperation(value = "2.增员", httpMethod = "Post", notes = "增员")
@ApiOperationSupport(order = 2)
public Result<Object> joinUser(@RequestBody InsureDto insureDto) throws ParseException {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
......@@ -410,7 +434,7 @@ public class InsureContorll {
Map<String, Object> dataMap = JSONObject.parseObject(responData);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(2)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(responData).requestPath(batchUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).fileUrl(url).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Map<String, Object> data = JSONObject.parseObject(JSONObject.toJSONString(dataMap.get("data")));
Map<String, Object> orderImportInfo = JSONObject.parseObject(JSONObject.toJSONString(data.get("order_import_info")));
......@@ -476,6 +500,7 @@ public class InsureContorll {
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel( localDate + "_补充" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url="";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
......@@ -487,14 +512,14 @@ public class InsureContorll {
/*end*/
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(5)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
return map.get("file_url").toString();
url= map.get("file_url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(5)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
......@@ -506,12 +531,11 @@ public class InsureContorll {
e.printStackTrace();
}
}
return "suc";
return url;
}
@GetMapping(value = "/downPolicyFile")
@ApiOperation(value = "7.下载电子保单", httpMethod = "Get", notes = "下载电子保单")
@ApiOperationSupport(order = 2)
public void downPolicyFile(@RequestParam("policyId") String policyId, HttpServletRequest request, HttpServletResponse response) {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(policyId)).build().selectById();
if(insurePolicy==null|| StringUtils.isNullOrEmpty(insurePolicy.getPolicyFile())){
......@@ -555,7 +579,6 @@ public class InsureContorll {
@PostMapping(value = "/replaceUser")
@ApiOperation(value = "6.保全替换", httpMethod = "Post", notes = "保全替换")
@ApiOperationSupport(order = 2)
public Result<Object> replaceUser(@RequestBody InsureDto insureDto) {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
if (insurePolicy == null) {
......@@ -584,7 +607,7 @@ public class InsureContorll {
Map<String, Object> dataMap = JSONObject.parseObject(responData);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(3)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(responData).requestPath(batchUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).fileUrl(url).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Map<String, Object> data = JSONObject.parseObject(JSONObject.toJSONString(dataMap.get("data")));
Map<String, Object> orderImportInfo = JSONObject.parseObject(JSONObject.toJSONString(data.get("order_import_info")));
......@@ -669,6 +692,7 @@ public class InsureContorll {
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel( localDate + "_替换" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url="";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
......@@ -680,14 +704,15 @@ public class InsureContorll {
/*end*/
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(6)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
return map.get("file_url").toString();
url= map.get("file_url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(6)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
......@@ -699,7 +724,7 @@ public class InsureContorll {
e.printStackTrace();
}
}
return "suc";
return url;
}
/*获取基础计划的价格*/
private Integer getPrice(String plan,String type){
......@@ -760,8 +785,7 @@ public class InsureContorll {
return 0;
}
@PostMapping(value = "/policyTotal")
@ApiOperation(value = "10.保单统计列表", httpMethod = "Post", notes = "保单统计列表")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "11.保单统计列表", httpMethod = "Post", notes = "保单统计列表")
public Result<Object> policyTotal() {
List<PolicyDto> list = insurePolicyMapper.policyTotalList();
return ResultUtil.data(list);
......@@ -769,9 +793,8 @@ public class InsureContorll {
@GetMapping(value = "/isInsured")
@ApiOperation(value = "10.企业是否已投保", httpMethod = "Post", notes = "企业是否已投保")
@ApiOperationSupport(order = 2)
public Result<Object> isInsured(@RequestParam("orgCode")String orgCode) {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,orgCode));
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode,orgCode).eq(InsurePolicy::getStatus,1));
if(insurePolicy!=null){
return ResultUtil.error("该企业已经投过保,保单号为"+insurePolicy.getPolicyNo());
}
......
package cn.timer.api.controller.insure;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsureProduct;
import cn.timer.api.dao.insure.InsureLogMapper;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
......@@ -25,11 +39,65 @@ import org.springframework.web.bind.annotation.RestController;
* @email 862422848@qq.com
* @date 2022-03-22 09:55:46
*/
@Api(tags = "8.0保险列表")
@RestController
@RequestMapping("insurelog")
@Transactional
@RequestMapping(value = "/insureLog", produces = {"application/json"})
public class InsureLogController{
@Autowired
private InsureLogMapper insureLogService;
private InsureLogMapper insureLogMapper;
@GetMapping(value = "/logList")
@ApiOperation(value = "12.日志列表", httpMethod = "Get", notes = "日志列表")
public Result<Object> logList(@RequestParam("policyId") String policyId) {
List<InsureLog> list = insureLogMapper.selectListById(policyId);
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())){
return;
}
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
OutputStream sos = null;
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.setCharacterEncoding("UTF-8");
sos = response.getOutputStream();
String destUrl ="http:"+insureLog.getFileUrl();
URL url = new URL(destUrl);
HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection();
//连接指定的网络资源
httpUrl.connect();
//获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
int b;
while ((b = bis.read()) != -1) {
sos.write(b);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
sos.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......@@ -35,7 +35,6 @@ public class InsureProductController{
@GetMapping(value = "/productList")
@ApiOperation(value = "12.产品列表", httpMethod = "Get", notes = "产品列表")
@ApiOperationSupport(order = 2)
public Result<Object> productList() {
List<InsureProduct> productList = InsureProduct.builder().build().selectList(new QueryWrapper<InsureProduct>().lambda().eq(InsureProduct::getIsDel,0));
if (productList.size()>0) {
......
......@@ -36,7 +36,6 @@ public class InsureUserController{
@PostMapping(value = "/policyList")
@ApiOperation(value = "3.保单列表", httpMethod = "Post", notes = "保单列表")
@ApiOperationSupport(order = 2)
public Result<Object> policyList(@RequestBody PolicyDto policyDto) {
Map map = Maps.newHashMap();
List<PolicyDto> list = insureUserMapper.selectPolicyList(policyDto.getPage(), String.valueOf(policyDto.getId()));
......@@ -45,8 +44,7 @@ public class InsureUserController{
return ResultUtil.data(map);
}
@GetMapping(value = "/userDetial")
@ApiOperation(value = "3.被保人详情", httpMethod = "Post", notes = "保单列表")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "被保人详情", httpMethod = "Post", notes = "保单列表")
public Result<Object> userDetial(@RequestParam("userId") String userId) {
InsureUser user = InsureUser.builder().id(Integer.parseInt(userId)).build().selectById();
return ResultUtil.data(user);
......
......@@ -2,8 +2,11 @@ package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsureLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
*
......@@ -14,5 +17,6 @@ import org.springframework.stereotype.Repository;
@Repository
public interface InsureLogMapper extends BaseMapper<InsureLog> {
List<InsureLog> selectListById(@Param("policyId")String policyId);
}
package cn.timer.api.dto.insure;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import sun.dc.pr.PRError;
import java.util.Date;
/**
* @Description TODO
......
......@@ -18,6 +18,7 @@
<result property="type" column="type"/>
<result property="requestType" column="request_type"/>
<result property="policyId" column="policy_id"/>
<result property="fileUrl" column="file_url"/>
</resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsureLog">
......@@ -170,4 +171,9 @@
</foreach>
</delete>
<select id="selectListById" resultType="cn.timer.api.bean.insure.InsureLog">
select id,return_msg,`type`,create_time from insure_log
where policy_id = #{policyId}
ORDER BY create_time DESC
</select>
</mapper>
......@@ -247,9 +247,8 @@
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_id = ip.id
LEFT JOIN qyzx_ent_info_m qy on qy.id=iu.org_code
LEFT JOIN qyzx_ent_info_m qy on qy.id=ip.org_code
<where>
iu.insure_status = 1
<if test="policy.status!=null and policy.status!=''">
and ip.status = #{policy.status}
</if>
......@@ -307,20 +306,20 @@
<select id="policyTotalList" resultType="cn.timer.api.dto.insure.PolicyDto">
SELECT
ip.id AS id,
ip.scheme_name AS schemeName,
ip.name AS schemeName,
ip.type AS type,
(select count(id) from insure_policy) AS totaPolicy,
(select count(org_code) from insure_policy) AS totalCompany,
count( iu.id ) AS totalUser,
(select sum(total_premium) from insure_policy) as totalPremium,
ip.update_time AS updateTime
ifnull(0,(select sum(total_premium) from insure_policy)) as totalPremium,
ipp.update_time AS updateTime
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_id = ip.id
insure_product ip
LEFT JOIN insure_policy ipp ON ipp.product_id = ip.id
LEFT JOIN insure_user iu ON iu.policy_id = ipp.id
WHERE
iu.insure_status = 1
ip.is_del = 0
GROUP BY
ip.type
ip.id
</select>
</mapper>
......@@ -283,7 +283,7 @@
from insure_user iu
LEFT JOIN yggl_main_emp yme on yme.id=iu.user_id
LEFT JOIN insure_policy ip on ip.id=iu.policy_id
where yme.org_code = 3 AND iu.insure_status=1
where yme.org_code = 3
<if test="id !=null and id !=''">
and ip.id=#{id}
</if>
......@@ -296,7 +296,7 @@
select count(iu.id) from insure_user iu
LEFT JOIN yggl_main_emp yme on yme.id=iu.user_id
LEFT JOIN insure_policy ip on ip.id=iu.policy_id
where yme.org_code = 3 AND iu.insure_status=1
where yme.org_code = 3
<if test="id !=null and id !=''">
and ip.id=#{id}
</if>
......
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