Commit 4f3e8e64 by 翁国栋 Committed by 284718418@qq.com

更新保险方案为

parent 8b676502
package cn.timer.api.bean.insure;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 投保方案
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-09-23 11:53:23
*/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "insure_plan")
@ApiModel("投保方案")
public class InsurePlan extends Model<InsurePlan> {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
/**
* 名称
*/
private String name;
/**
* id,由保司提供
*/
private String planId;
/**
* 类型
*/
private String type;
/**
* 创建时间
*/
private Date createTime;
/**
* 逻辑删除标记0.未删除 1.删除
*/
private Integer deleteFlag;
/**
* 类型名称
*/
private String typeName;
}
package cn.timer.api.bean.insure;
import cn.timer.api.bean.insure.InsureProduct;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 投保方案中间表
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-09-26 10:06:39
*/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "insure_product_plan")
@ApiModel("保险方案")
public class InsureProductPlan extends Model<InsureProductPlan> {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
/**
* 方案json
*/
private String planJson;
/**
* 单价
*/
private Double price;
/**
* insure_product的id
*/
private Integer productId;
/**
* 创建时间
*/
private Date createTime;
/**
* 是否删除 1已删除 0未删除
*/
private Integer deleteFlag;
/**
* 方案组合后的名字
*/
private String name;
}
......@@ -56,7 +56,7 @@ public class InsureUser extends Model<InsureUser> {
* 批次核算保费
*/
@ApiModelProperty(value = "批次核算保费")
private String price;
private Double price;
/**
* 姓名
*/
......@@ -71,7 +71,7 @@ public class InsureUser extends Model<InsureUser> {
* 保单批次保费
*/
@ApiModelProperty(value = "保单批次保费")
private String premium;
private Double premium;
/**
* 被保险人联系电话
*/
......@@ -172,4 +172,17 @@ public class InsureUser extends Model<InsureUser> {
@TableField(exist = false)
@ApiModelProperty(value="原被保人",example="原被保人")
private InsureUser originaUser;
@ApiModelProperty(value="insure_product_plan表的Id")
private Integer productPlanId;
@Transient
@TableField(exist = false)
@ApiModelProperty(value="方案集合",example="方案集合")
private List planIds;
@Transient
@TableField(exist = false)
@ApiModelProperty(value="产品名称",example="产品名称")
private String productName;
}
package cn.timer.api.controller.insure;
import cn.timer.api.bean.insure.InsurePlan;
import cn.timer.api.bean.insure.InsureProduct;
import cn.timer.api.bean.insure.InsureProductPlan;
import cn.timer.api.dao.insure.InsurePlanMapper;
import cn.timer.api.dao.insure.InsureProductPlanMapper;
import cn.timer.api.dto.insure.ProductDto;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 投保方案
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-09-23 11:53:23
*/
@Api(tags = "8.0保险列表")
@RestController
@Transactional
@RequestMapping(value = "/insurePlan", produces = {"application/json"})
public class InsurePlanController {
@Autowired
private InsurePlanMapper insurePlanMapper;
@Autowired
private InsureProductPlanMapper insureProductPlanMapper;
@GetMapping(value = "/planList")
@ApiOperation(value = "方案列表", httpMethod = "GET", notes = "方案列表")
public Result<Object> planList() {
List<InsurePlan> list = insurePlanMapper.getList();
Map<String, List<InsurePlan>> map = list.stream().collect(Collectors.groupingBy(InsurePlan::getType));
return ResultUtil.data(map);
}
@GetMapping(value = "/getPlanListbyProduct")
@ApiOperation(value = "产品方案列表", httpMethod = "GET", notes = "产品方案列表")
public Result<Object> getPlanListbyProduct(@RequestParam("productId") Integer productId) {
List<ProductDto> list = insureProductPlanMapper.getListByProductId(productId);
return ResultUtil.data(list);
}
@PostMapping(value = "/savePlan")
@ApiOperation(value = "保存方案", httpMethod = "POST", notes = "保存方案")
public Result<Object> savePlan(@RequestBody ProductDto productDto) {
InsureProduct insureProduct = InsureProduct.builder().id(productDto.getProductId()).build().selectById();
InsureProductPlan insureProductPlan = InsureProductPlan.builder().productId(insureProduct.getId())
.createTime(new Date()).name(productDto.getPlanName()).price(productDto.getPrice()).planJson(productDto.getPlanJson().toString()).build();
if (insureProductPlan.insert()) {
return ResultUtil.data("保存成功");
}
return ResultUtil.error("保存失败");
}
;
}
package cn.timer.api.controller.insure;
import java.util.Date;
import java.util.List;
import java.util.Map;
import cn.timer.api.bean.insure.InsureProduct;
import cn.timer.api.dao.insure.InsureProductMapper;
import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.dto.insure.ProductDto;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -29,17 +31,26 @@ import org.springframework.web.bind.annotation.*;
@RestController
@Transactional
@RequestMapping(value = "/insureProduct", produces = {"application/json"})
public class InsureProductController{
@Autowired
private InsureProductMapper insureProductMapper;
public class InsureProductController {
@Autowired
private InsureProductMapper insureProductMapper;
@GetMapping(value = "/productList")
@ApiOperation(value = "12.产品列表", httpMethod = "GET", notes = "产品列表")
public Result<Object> productList() {
List<InsureProduct> productList = InsureProduct.builder().build().selectList(new QueryWrapper<InsureProduct>().lambda().eq(InsureProduct::getIsDel,0));
if (productList.size()>0) {
return ResultUtil.data(productList);
}
return ResultUtil.error("暂无产品");
}
@GetMapping(value = "/productList")
@ApiOperation(value = "12.产品列表", httpMethod = "GET", notes = "产品列表")
public Result<Object> productList() {
List<InsureProduct> productList = InsureProduct.builder().build().selectList(new QueryWrapper<InsureProduct>().lambda().eq(InsureProduct::getIsDel, 0));
return ResultUtil.data(productList);
}
@PostMapping(value = "/saveProduct")
@ApiOperation(value = "保存产品", httpMethod = "POST", notes = "保存产品")
public Result<Object> saveProduct(@RequestBody InsureProduct insureProduct) {
insureProduct.setCreateTime(new Date());
if (insureProduct.insert()) {
return ResultUtil.data("添加产品成功");
}
return ResultUtil.error("添加产品失败");
}
;
}
......@@ -12,6 +12,7 @@ import java.util.Optional;
import java.util.stream.Collectors;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureProductPlan;
import cn.timer.api.bean.insure.InsureUser;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
......@@ -69,6 +70,9 @@ public class InsureUserController{
@ApiOperation(value = "被保人详情", httpMethod = "POST", notes = "保单列表")
public Result<Object> userDetial(@RequestParam("userId") String userId) {
InsureUser user = InsureUser.builder().id(Integer.parseInt(userId)).build().selectById();
InsureProductPlan insureProductPlan = InsureProductPlan.builder().id(user.getProductPlanId()).build().selectById();
user.setPlanIds(JSON.parseArray(insureProductPlan.getPlanJson(), String.class));
user.setProductName(insureProductPlan.getName());
return ResultUtil.data(user);
}
......
......@@ -4,7 +4,7 @@ import cn.timer.api.utils.ExcelUtils;
/**
* @Description TODO
* @Author wgd
* @Author wgd 2022/09/26 废弃枚举类
* @Date 2022/3/24 17:20
*/
public enum PlanEnum {
......@@ -20,6 +20,7 @@ public enum PlanEnum {
B_100(40,"100万意外/10万医疗/扩展24小时(B类)","B类","36972","63120"),
C_50(60,"50万意外/5万医疗/扩展24小时(C类)","C类","36969","63121"),
C_80(75,"80万意外/10万医疗/扩展24小时(C类)","C类","36970","63121");
private Integer price;
private String name;
private String type;
......
package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsurePlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 投保方案
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-09-23 11:53:23
*/
@Repository
public interface InsurePlanMapper extends BaseMapper<InsurePlan> {
List<InsurePlan> getList();
List<InsurePlan> findPlanByIds(@Param("list")List ids);
}
package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsurePlan;
import cn.timer.api.bean.insure.InsureProduct;
import cn.timer.api.bean.insure.InsureProductPlan;
import cn.timer.api.dto.insure.ProductDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 投保方案中间表
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-09-26 10:06:39
*/
@Repository
public interface InsureProductPlanMapper extends BaseMapper<InsureProductPlan> {
List<ProductDto> getListByProductId(@Param("productId") Integer productId);
}
......@@ -27,7 +27,9 @@ public class InsureDto {
private Integer type;/*类型 1是新增 3是替换*/
private String productId;
private List<PlansDto> plans;
private String benefitBasicPlan;/*方案名称*/
// private String benefitBasicPlan;/*方案名称*/
/*原为方案名称,2022/09/26改为使用insure_product_plan表的id*/
private Integer benefitBasicPlan;
private String benefitOccupationCategory;
private String tricycleFrameNumber;
private String[] oldIds;
......
......@@ -11,8 +11,11 @@ import lombok.Data;
public class PlansDto{
private int index;
private String[] userIds;
private String benefitBasicPlan;/*方案名称*/
/*方案名称*/
// private String benefitBasicPlan;
/*原为方案名称,2022/09/26改为使用insure_product_plan表的id*/
private Integer benefitBasicPlan;
private String benefitOccupationCategory;
private String tricycleFrameNumber;
private Integer price;
private Double price;
}
......@@ -48,4 +48,5 @@ public class PolicyDto {
private String userName;
private String companyName;
private boolean isAll = false;
private Integer productPlanId;
}
package cn.timer.api.dto.insure;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.Data;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Description TODO
* @Author wgd
* @Date 2022/9/26 9:45
*/
@Data
public class ProductDto {
private Integer id;
private Integer productId;
private String planName;
private String planJson;
private double price;
private Date createTime;
private List plans;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.timer.api.dao.insure.InsurePlanMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="cn.timer.api.bean.insure.InsurePlan" id="insurePlanMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="planId" column="plan_id"/>
<result property="type" column="type"/>
<result property="createTime" column="create_time"/>
<result property="deleteFlag" column="delete_flag"/>
<result property="typeName" column="type_name"/>
</resultMap>
<select id="getList" resultType="cn.timer.api.bean.insure.InsurePlan">
select * from insure_plan where delete_flag = 0
</select>
<select id="findPlanByIds" resultType="cn.timer.api.bean.insure.InsurePlan">
select * from insure_plan WHERE id in
<foreach item="item" index="index" collection="list" open="("
separator="," close=")">#{item}</foreach>
</select>
</mapper>
......@@ -238,7 +238,7 @@
ip.id AS id,
ip.policy_no AS policyNo,
ip.create_time as createTime,
ip.scheme_name AS schemeName,
ipp.name AS schemeName,
qy.`name` as `name`,
count( iu.id ) AS totalUser,
ip.policy_date_start as policyDateStart,
......@@ -252,6 +252,7 @@
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_id = ip.id
LEFT JOIN qyzx_ent_info_m qy on qy.id=ip.org_code
LEFT JOIN insure_product_plan ipp ON iu.product_plan_id = ipp.id
<where>
<if test="policy.productId!=null and policy.productId!=''">
and ip.product_id = #{policy.productId}
......@@ -263,7 +264,7 @@
and ip.org_code = #{policy.orgCode}
</if>
<if test="policy.benefitBasicPlan!=null and policy.benefitBasicPlan!=''">
and iu.benefit_basic_plan = #{policy.benefitBasicPlan}
and iu.product_plan_id = #{policy.benefitBasicPlan}
</if>
<if test="policy.policyDateStart!=null and policy.policyDateStart!=''">
and ip.policy_date_start <![CDATA[ >= ]]> #{policy.policyDateStart}
......@@ -319,11 +320,15 @@
iu.insured_name as insuredName,
iu.benefit_basic_plan as benefitBasicPlan,
iu.benefit_occupation_category as benefitOccupationCategory,
iu.product_plan_id as productPlanId,
ip.policy_pay_type as policyPayType,
ip.product_id as productId
ip.product_id as productId,
iu.product_plan_id as productPlanId,
ipp.name as name
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_id = ip.id
left join insure_product_plan ipp on ipp.id=iu.product_plan_id
WHERE
ip.id = #{id}
LIMIT 1
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.timer.api.dao.insure.InsureProductPlanMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="cn.timer.api.bean.insure.InsureProductPlan" id="insureProductPlanMap">
<result property="id" column="id"/>
<result property="planJson" column="plan_json"/>
<result property="price" column="price"/>
<result property="productId" column="product_id"/>
<result property="createTime" column="create_time"/>
<result property="deleteFlag" column="delete_flag"/>
<result property="name" column="name"/>
</resultMap>
<select id="getListByProductId" resultType="cn.timer.api.dto.insure.ProductDto">
select ipp.id as id,
ipp.price as price,
ipp.plan_json as planJson,
ipp.`name` as planName,
ipp.create_time as createTime
from insure_product_plan ipp
LEFT JOIN insure_product ip on ip.id = ipp.product_id
WHERE ip.id = #{productId}
</select>
</mapper>
......@@ -32,6 +32,8 @@
<result property="applyType" column="apply_type"/>
<result property="reason" column="reason"/>
<result property="createTime" column="create_time"/>
<result property="productPlanId" column="product_plan_id"/>
</resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsureUser">
......@@ -303,7 +305,7 @@
and ip.id=#{policyDto.id}
</if>
<if test="policyDto.planId !=null and policyDto.planId !=''">
and iu.benefit_basic_plan = #{policyDto.planId}
and iu.product_plan_id = #{policyDto.planId}
</if>
<if test="policyDto.categoryId !=null and policyDto.categoryId !=''">
and iu.benefit_occupation_category = #{policyDto.categoryId}
......@@ -429,13 +431,16 @@
</select>
<select id="selectPlansListById" resultType="cn.timer.api.dto.insure.InsureUserDto">
SELECT policy_id as policyId,
benefit_basic_plan as benefitBasicPlan,
benefit_occupation_category as benefitOccupationCategory,
count(id) as totalUser
FROM insure_user
SELECT iu.policy_id as policyId,
iu.benefit_basic_plan as benefitBasicPlan,
iu.benefit_occupation_category as benefitOccupationCategory,/*废弃*/
count(iu.id) as totalUser,
iu.product_plan_id as productPlanId,
ipp.name as name
FROM insure_user iu
left join insure_product_plan ipp on ipp.id=iu.product_plan_id
WHERE policy_id = #{policyId}
group by benefit_basic_plan, benefit_occupation_category
group by benefit_occupation_category
</select>
<update id="updateInsure">
......
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