Commit f98534e7 by 翁国栋

运营后台--

保全增员
parent bd909e43
......@@ -40,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.net.URLEncoder;
import java.security.Policy;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -82,6 +83,8 @@ public class InsureContorll {
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";
@Autowired
private YgglMainEmpMapper ygglMainEmpMapper;
......@@ -98,7 +101,7 @@ public class InsureContorll {
* @param sign
* @return
*/
private Map setParams(String sign){
private Map setParams(String sign,String appid,String secret){
/*当前时间戳*/
long timestamp =System.currentTimeMillis()/1000;
log.info("时间戳"+timestamp);
......@@ -114,23 +117,6 @@ public class InsureContorll {
log.info("params参数======"+JSONObject.toJSONString(paramsMap));
return paramsMap;
}
/*保全*/
private Map setParams2(String sign){
/*当前时间戳*/
long timestamp =System.currentTimeMillis()/1000;
log.info("时间戳"+timestamp);
Map paramsMap = Maps.newHashMap();
paramsMap.put("pid",appidq);
paramsMap.put("timestamp",String.valueOf(timestamp/1000));
paramsMap.put("trace_id",appidq+timestamp+ new Random().nextInt((9999 - 100) + 1) + 10);
// paramsMap.put("sign",Md5.md5(appidq+secret+timestamp+sign.trim()));
String value=appidq+secretq+timestamp+sign;
log.info("body参数======"+sign);
paramsMap.put("sign", DigestUtils.md5Hex(value));
log.info("params参数======"+JSONObject.toJSONString(paramsMap));
return paramsMap;
}
@PostMapping(value = "/insured_add")
@ApiOperation(value = "1.投保申请", httpMethod = "Post", notes = "投保申请")
......@@ -277,12 +263,12 @@ public class InsureContorll {
}
/*测试用生产环境不需要*/
synchronized private Map requestAgent(Map bodyMap ){
String data=HttpUtils.sendPost(insuredUrl,setParams(JSONObject.toJSONString(bodyMap)),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("e1")&&dataMap.get("errmsg").toString().equals("出单中")){
if(dataMap.get("errcode").toString().equals("e1")&&(dataMap.get("errmsg").toString().equals("出单中")||dataMap.get("errmsg").toString().equals("系统正在处理中,请稍候再试"))){
try {
Thread.sleep(30000);
return requestAgent(bodyMap);
......@@ -318,44 +304,11 @@ public class InsureContorll {
bodyMap.put("name",file.getName());
bodyMap.put("file",fileBase64);
/*end*/
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap)),bodyMap);
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap),appid,secret),bodyMap);
log.info("请求返回的结果====="+data);
/*文件流base64*/
return ResultUtil.data(message(data));
};
@PostMapping (value = "/file_upload2")
@ApiOperation(value = "3.保全上传文件", httpMethod = "Post", notes = "上传文件")
@ApiOperationSupport(order = 2)
public Result<Object> fileUpload2(@CurrentUser UserBean userBean, @RequestParam(required = true) MultipartFile file) {
if (file == null) {
return ResultUtil.error("上传失败,请选择上传文件");
}
byte[] bytes =null;
try {
bytes=file.getBytes();
} catch (IOException e) {
e.printStackTrace();
log.warn("文件转换Base64异常");
}
String fileBase64= Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap= Maps.newHashMap();
// bodyMap.put("app","mall");
// bodyMap.put("name","劳务公司批增-月单(1).xlsx");
bodyMap.put("file",fileBase64);
/*end*/
String data=HttpUtils.sendPost(uploadUrl2,setParams2(JSONObject.toJSONString(bodyMap)),bodyMap);
log.info("请求返回的结果====="+data);
/*文件流base64*/
return ResultUtil.data(message(data));
};
// @PostMapping(value = "/baoquan")
// @ApiOperation(value = "2.单个添加保全", httpMethod = "Post", notes = "上传文件")
// @ApiOperationSupport(order = 2)
// public Result<Object> baoquan_add(InsuredUser user) {
//return null;
// }
/**
* 设置错误信息
......@@ -370,7 +323,11 @@ public class InsureContorll {
return dataMap.get("errmsg");
}
/**
* 生成投保问文件
* @param ids
* @return
*/
public String creaXSSFWorkbook(String[] ids){
if(ids.length<=0){
return "error";
......@@ -398,7 +355,7 @@ public class InsureContorll {
bodyMap.put("name",localDate+"_"+list.size()+"名人员清单.xlsx");
bodyMap.put("file",fileBase64);
/*end*/
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap)),bodyMap);
String data=HttpUtils.sendPost(uploadUrl,setParams(JSONObject.toJSONString(bodyMap),appid,secret),bodyMap);
Map<String,Object> dataMap = JSONObject.parseObject(data);
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
......@@ -434,4 +391,92 @@ public class InsureContorll {
List<PolicyDto> list = insurePolicyMapper.policyList();
return ResultUtil.data(list);
}
@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){
return ResultUtil.error("保单不存在");
}
return ResultUtil.data(policyDto);
}
@PostMapping(value = "/joinUser")
@ApiOperation(value = "5.增员", httpMethod = "Post", notes = "增员")
@ApiOperationSupport(order = 2)
public Result<Object> policyDetail(@RequestBody InsureDto insureDto) {
InsurePolicy insurePolicy=InsurePolicy.builder().id(Integer.parseInt(insureDto.getId())).build().selectById();
if(insurePolicy==null){
return ResultUtil.error("保单不存在");
}
LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook1(insureDto.getUserIds());
log.info("保全增员文件地址",url);
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
Map bodyMap = Maps.newHashMap();
bodyMap.put("contract_no",insurePolicy.getPolicyNo());
bodyMap.put("order_status","1");
bodyMap.put("callback_plan","");
bodyMap.put("file_url",url);
bodyMap.put("from_source","API");
bodyMap.put("import_review_callback","");
bodyMap.put("import_callback","");
bodyMap.put("third_uuid","BQ_"+insurePolicy.getOrgCode()+"_"+dtf2.format(now));
String data=HttpUtils.sendPost(batchUrl,setParams(JSONObject.toJSONString(bodyMap),appidq,secretq),bodyMap);
log.info("保全增员返回",data);
return ResultUtil.data("");
}
/**
* 生成保全增员文件
* @param ids
* @return
*/
public String creaXSSFWorkbook1(String[] ids){
if(ids.length<=0){
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> ygglMainEmpList=ygglMainEmpMapper.selectListByIds(ids);
List list=Lists.newArrayList();
for (YgglMainEmp y:ygglMainEmpList) {
String[] arr =new String[]{String.valueOf(y.getId()),y.getName(),"身份证",y.getZjNum(),"50万意外/5万医疗/扩展24小时(A类)","","深圳名邦人力资源管理有限公司","无","A类"};
list.add(arr);
}
String[] rowName=new String[]{"ID","name","ID_type","ID_number","Scheme_name","Date_start","Branch","Tricycle_frame_number","benefit_occupation_category"};
XSSFWorkbook xssfWorkbook= ExcelUtils.exportExcel(localDate+"_"+list.size()+"名人员清单.xlsx",rowName,list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64= Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap= Maps.newHashMap();
bodyMap.put("media",fileBase64);
/*end*/
String data=HttpUtils.sendPost(uploadUrl2,setParams(JSONObject.toJSONString(bodyMap),appidq,secretq),bodyMap);
Map<String,Object> dataMap = JSONObject.parseObject(data);
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();
}
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return "suc";
}
}
......@@ -3,6 +3,7 @@ package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.dto.insure.PolicyDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -17,5 +18,6 @@ import java.util.List;
@Repository
public interface InsurePolicyMapper extends BaseMapper<InsurePolicy> {
public List<PolicyDto> policyList();
PolicyDto getPolicyDetail(@Param("id")Integer id);
}
......@@ -19,6 +19,7 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
public class InsureDto {
private String id;
private String orgCode;/*劳动合同*/
private String companyName;/*用工单位实际工作单位*/
private String[] userIds;
......
......@@ -30,5 +30,6 @@ public class PolicyDto {
private String insuredName;
private String benefitBasicPlan;
private String price;
private String orgCode;
}
......@@ -74,4 +74,7 @@ public class YgQueryDto extends Page {
@ApiModelProperty(value = "性别", example = "1")
private Integer sex;
@ApiModelProperty(value="是否已购买保险",example = "0")
private Integer isInsure;
}
......@@ -271,4 +271,22 @@
</select>
<select id="getPolicyDetail" resultType="cn.timer.api.dto.insure.PolicyDto">
SELECT
ip.id as id,
ip.scheme_name as schemeName,
ip.policy_date_start as policyDateStart,
ip.policy_date_end as policyDateEnd,
ip.policy_no as policyNo,
ip.org_code as orgCode,
iu.insured_name as insuredName,
iu.benefit_basic_plan as benefitBasicPlan
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_no = ip.policy_no
WHERE
ip.id = #{id}
LIMIT 1
</select>
</mapper>
......@@ -240,7 +240,8 @@
a.phone phone,
a.job_status jobStatus,
a.head_url headUrl,
a.sex sex
a.sex sex,
a.is_insure isInsure
FROM
yggl_main_emp a
LEFT JOIN zzgl_bmgw_m b ON a.bmgw_id = b.id
......
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