InsureApplicantController.java 4.35 KB
Newer Older
翁国栋 committed
1 2 3 4 5 6 7 8
package cn.timer.api.controller.insure;

import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.Random;

import cn.timer.api.bean.insure.InsureApplicant;
9
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
翁国栋 committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dao.insure.InsureApplicantMapper;
import cn.timer.api.dto.insure.InsureDto;
import cn.timer.api.utils.HttpUtils;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import com.alibaba.druid.util.Base64;
import com.alibaba.fastjson.JSONObject;
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 io.swagger.models.auth.In;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;


/**
 * 投保人
 *
 * @author wgd
 * @email 862422848@qq.com
 * @date 2022-03-07 17:02:46
 */
翁国栋 committed
43
@Api(tags = "8.0保险列表")
翁国栋 committed
44 45 46 47 48 49 50
@RestController
@Transactional
@RequestMapping(value = "/insureApplicant", produces = {"application/json"})
public class InsureApplicantController {

    @PostMapping("/insureApplicationSetting")
    @ApiOperation(value = "设置投保人", httpMethod = "POST", notes = "投保申请")
翁国栋 committed
51
    private Result<Object> insureApplicationSetting(@RequestBody InsureApplicant params) {
52
        InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode,params.getOrgCode()));
翁国栋 committed
53 54 55
        params.setId(insureApplicant.getId());
        params.updateById();
        return ResultUtil.data(params);
翁国栋 committed
56 57 58
    }


59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    @GetMapping("/getApplicantAdmin")
    @ApiOperation(value = "获取投保人--运营后台", httpMethod = "GET", notes = "获取投保人")
    private Result<Object> getApplicant(@RequestParam("orgCode") Integer orgCode) {
        InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode,orgCode));
        if(insureApplicant==null){
            QyzxEntInfoM qyzxEntInfoM=QyzxEntInfoM.builder().id(orgCode).build().selectById();
            insureApplicant = getInsureApplicant(qyzxEntInfoM);
            insureApplicant.setOrgCode(orgCode);
            insureApplicant.insert();
        }
        return ResultUtil.data(insureApplicant);
    }

    private InsureApplicant getInsureApplicant(QyzxEntInfoM qyzxEntInfoM) {
        InsureApplicant insureApplicant;
        insureApplicant=new InsureApplicant();
        insureApplicant.setApplicantEName(qyzxEntInfoM.getName());
        insureApplicant.setApplicantEAddress(qyzxEntInfoM.getWorkAddress());
        insureApplicant.setApplicantEContacts(qyzxEntInfoM.getOperName());/*这里为避免联系人为空,默认使用法人*/
        insureApplicant.setApplicantEPhone(qyzxEntInfoM.getPhone());/*这里为避免联系人为空,默认使用法人*/
        insureApplicant.setApplicantType("2");
        insureApplicant.setApplicantENoType("3646");
        insureApplicant.setApplicantENo(qyzxEntInfoM.getCreditCode());
        insureApplicant.setApplicantProvinceCity("21721");
        return insureApplicant;
    }

翁国栋 committed
86
    @GetMapping("/getApplicant")
87 88 89
    @ApiOperation(value = "获取投保人--8小时", httpMethod = "GET", notes = "获取投保人")
    private Result<Object> getApplicant(@CurrentUser UserBean userBean) {
        InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode,userBean.getOrgCode()));
翁国栋 committed
90
        if(insureApplicant==null){
91 92 93 94
            QyzxEntInfoM qyzxEntInfoM=QyzxEntInfoM.builder().id(userBean.getOrgCode()).build().selectById();
            insureApplicant = getInsureApplicant(qyzxEntInfoM);
            insureApplicant.setOrgCode(userBean.getOrgCode());
            insureApplicant.insert();
翁国栋 committed
95 96 97 98 99
        }
        return ResultUtil.data(insureApplicant);
    }

}