guoweisong пре 2 година
родитељ
комит
702cdf5e5b

+ 13 - 0
src/main/java/com/ydtech/modules/fnc/controller/InsPlyMainController.java

@@ -57,4 +57,17 @@ public class InsPlyMainController {
         }
         }
         return result;
         return result;
     }
     }
+    @ApiOperation(value = "导入保单修改")
+    @PostMapping("/update")
+    public HttpResult<BasePageResult<InsPlyMain>> update(@RequestBody InsPlyMain insPlyMain) {
+
+        HttpResult result = null;
+        try {
+            result = insPlyMainService.updatePly(insPlyMain);
+        } catch (Exception e) {
+            result = HttpResult.error("保单修改失败!" + e.getMessage());
+            e.printStackTrace();
+        }
+        return result;
+    }
 }
 }

+ 1 - 0
src/main/java/com/ydtech/modules/fnc/service/InsPlyMainService.java

@@ -19,6 +19,7 @@ public interface InsPlyMainService extends IService<InsPlyMain> {
     public HttpResult excelImport(MultipartFile file) throws Exception;
     public HttpResult excelImport(MultipartFile file) throws Exception;
 
 
     public HttpResult<BasePageResult<InsPlyMain>> queryPly(InsPlyMainVo insPlyMainVo);
     public HttpResult<BasePageResult<InsPlyMain>> queryPly(InsPlyMainVo insPlyMainVo);
+    public HttpResult updatePly(InsPlyMain insPlyMain) throws Exception;
 
 
 
 
 }
 }

+ 60 - 5
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyMainServiceImpl.java

@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
@@ -86,7 +87,43 @@ public class InsPlyMainServiceImpl extends ServiceImpl<InsPlyMainMapper, InsPlyM
     @Autowired
     @Autowired
     private EsmUserReferrerService esmUserReferrerService;
     private EsmUserReferrerService esmUserReferrerService;
 
 
+    @Transactional
+    @Override
+    public HttpResult updatePly(InsPlyMain insPlyMain) throws Exception {
+        String msg = "修改成功";
+        try {
+            /**
+             * 1.校验必填字段是否为空
+             */
+            isNullCmain(-1, insPlyMain);
+            /**
+             * 2.码值校验:保险公司、协议号、机构代码、业务员工号
+             */
+            checkData(-1, insPlyMain);
+            insPlyMain.setUpdateuser(StpUtil.getLoginId().toString());
+            insPlyMain.setUpdatetime(LocalDateTime.now());
+            this.baseMapper.update(insPlyMain,new LambdaUpdateWrapper<InsPlyMain>().eq(InsPlyMain::getPolicyno,insPlyMain.getPolicyno()));
+
+            //生成保司费用(应收费用)
+            insPlyIncomeMapper.delete(new LambdaUpdateWrapper<InsPlyIncome>().eq(InsPlyIncome::getPolicyno,insPlyMain.getPolicyno()));
+            gene_orderIncome(  insPlyMain);
+            //生成机构费用
+            insDeptFeeService.deleteByPolicyno(insPlyMain.getPolicyno());
+            gene_deptfee( insPlyMain);
+            //生成分销费用
+            insCommissionService.deleteByPolicyno(insPlyMain.getPolicyno());
+            saveRetail(insPlyMain);
+            //个代费用生成
+            insCompanyFeeService.deleteByPolicyno(insPlyMain.getPolicyno());
+            saveInsCompanyFee(insPlyMain);
 
 
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        }
+        return HttpResult.ok(msg, null);
+    }
+    @Override
     public HttpResult<BasePageResult<InsPlyMain>> queryPly(InsPlyMainVo insPlyMainVo) {
     public HttpResult<BasePageResult<InsPlyMain>> queryPly(InsPlyMainVo insPlyMainVo) {
 
 
         try {
         try {
@@ -134,6 +171,13 @@ public class InsPlyMainServiceImpl extends ServiceImpl<InsPlyMainMapper, InsPlyM
                  * 2.码值校验:保险公司、协议号、机构代码、业务员工号
                  * 2.码值校验:保险公司、协议号、机构代码、业务员工号
                  */
                  */
                 checkData(i, excelVo);
                 checkData(i, excelVo);
+                /**
+                 * 3.校验保单是否已导入
+                 */
+                InsPlyMain plyMain=this.baseMapper.selectById(excelVo.getPolicyno());
+                if(plyMain!=null){
+                    throw new DescribeException("保单号:【"+excelVo.getPolicyno()+"】已导入,请核对!");
+                }
                 excelVo.setAllFeeValue(excelVo.getCommissionFeevalue().add(excelVo.getOtherFeevalue()));
                 excelVo.setAllFeeValue(excelVo.getCommissionFeevalue().add(excelVo.getOtherFeevalue()));
                 excelVo.setBatchno(batchno);
                 excelVo.setBatchno(batchno);
                 excelVo.setCreator(StpUtil.getLoginId().toString());
                 excelVo.setCreator(StpUtil.getLoginId().toString());
@@ -423,24 +467,35 @@ public class InsPlyMainServiceImpl extends ServiceImpl<InsPlyMainMapper, InsPlyM
                 ||StringUtils.isNullOrEmpty(excelVo.getUserFeeProportion())
                 ||StringUtils.isNullOrEmpty(excelVo.getUserFeeProportion())
                 ||StringUtils.isNullOrEmpty(excelVo.getUserFeelPremiums())
                 ||StringUtils.isNullOrEmpty(excelVo.getUserFeelPremiums())
         ) {
         ) {
-            throw new DescribeException("第" + (i + 1) + "行 必填字段 不可为空");
+            String msg="";
+            if(i>=0){
+                msg="第" + (i + 1) + "行 必填字段 不可为空";
+            }else
+            {
+                msg="必填字段 不可为空,请核对";
+            }
+            throw new DescribeException(msg);
         }
         }
     }
     }
     private void checkData(int i, InsPlyMain excelVo) {
     private void checkData(int i, InsPlyMain excelVo) {
+        String msg="";
+        if(i<0){
+            msg="第" + (i + 1) + "行";
+        }
         EsmInsCompany esmInsCompany =esmInsCompanyMapper.selectById(excelVo.getCompanyId());
         EsmInsCompany esmInsCompany =esmInsCompanyMapper.selectById(excelVo.getCompanyId());
         if(StringUtils.isNullOrEmpty(esmInsCompany)){
         if(StringUtils.isNullOrEmpty(esmInsCompany)){
-            throw new DescribeException("第" + (i + 1) + "行 保司编码错误,请核对!");
+            throw new DescribeException(msg+" 保司编码错误,请核对!");
         }
         }
         SysDept sysDept=sysDeptMapper.selectById(excelVo.getDeptId());
         SysDept sysDept=sysDeptMapper.selectById(excelVo.getDeptId());
         if(StringUtils.isNullOrEmpty(sysDept)){
         if(StringUtils.isNullOrEmpty(sysDept)){
-            throw new DescribeException("第" + (i + 1) + "行 机构编码错误,请核对!");
+            throw new DescribeException(msg+" 机构编码错误,请核对!");
         }
         }
         SysUser sysUser=sysUserMapper.selectById(excelVo.getUserId());
         SysUser sysUser=sysUserMapper.selectById(excelVo.getUserId());
         if(StringUtils.isNullOrEmpty(sysUser)){
         if(StringUtils.isNullOrEmpty(sysUser)){
-            throw new DescribeException("第" + (i + 1) + "行 人员编码错误,请核对!");
+            throw new DescribeException(msg+" 人员编码错误,请核对!");
         }
         }
         if(!"交强".equals(excelVo.getRiskcode())&&!"商业".equals(excelVo.getRiskcode())){
         if(!"交强".equals(excelVo.getRiskcode())&&!"商业".equals(excelVo.getRiskcode())){
-            throw new DescribeException("第" + (i + 1) + "行 险种错误,只能填写 【交强】、【商业】!");
+            throw new DescribeException(msg+" 险种错误,只能填写 【交强】、【商业】!");
         }
         }
     }
     }
 }
 }

+ 2 - 0
src/main/java/com/ydtech/modules/ins/dao/InsCommissionDao.java

@@ -32,4 +32,6 @@ public interface InsCommissionDao {
     public Integer updateSettleStatus(String orderno, String status);
     public Integer updateSettleStatus(String orderno, String status);
 
 
     Integer delete(String orderno);
     Integer delete(String orderno);
+
+    Integer deleteByPolicyno(String policyno);
 }
 }

+ 2 - 0
src/main/java/com/ydtech/modules/ins/dao/InsCompanyFeeDao.java

@@ -29,4 +29,6 @@ public interface InsCompanyFeeDao {
     List<InsCompanyFeeExcel> selectFeeExcel(String toString, Object[] toArray);
     List<InsCompanyFeeExcel> selectFeeExcel(String toString, Object[] toArray);
 
 
     public Integer delete(InsCompanyFee insCompanyFee);
     public Integer delete(InsCompanyFee insCompanyFee);
+
+    Integer deleteByPolicyno(String policyno);
 }
 }

+ 1 - 0
src/main/java/com/ydtech/modules/ins/dao/InsDeptFeeDao.java

@@ -34,4 +34,5 @@ public interface InsDeptFeeDao {
     public Integer updateSettleStatus(String orderno, String status);
     public Integer updateSettleStatus(String orderno, String status);
 
 
     Integer delete(String orderno);
     Integer delete(String orderno);
+    Integer deleteByPolicyno(String policyno);
 }
 }

+ 8 - 0
src/main/java/com/ydtech/modules/ins/dao/impl/InsCommissionDaoImpl.java

@@ -189,4 +189,12 @@ public class InsCommissionDaoImpl implements InsCommissionDao {
 
 
         return jdbcTemplate.update(sql, orderno);
         return jdbcTemplate.update(sql, orderno);
     }
     }
+    @Override
+    public Integer deleteByPolicyno(String policyno) {
+        String sql = "delete from ins_commission where policyno=? ";
+
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+
+        return jdbcTemplate.update(sql, policyno);
+    }
 }
 }

+ 8 - 0
src/main/java/com/ydtech/modules/ins/dao/impl/InsCompanyFeeDaoImpl.java

@@ -260,5 +260,13 @@ public class InsCompanyFeeDaoImpl implements InsCompanyFeeDao {
 
 
         return jdbcTemplate.update(sql, params);
         return jdbcTemplate.update(sql, params);
     }
     }
+    @Override
+    public Integer deleteByPolicyno(String policyno) {
+        String sql = "delete from ins_companyfee where policyno=? ";
+
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+
+        return jdbcTemplate.update(sql, policyno);
+    }
 
 
 }
 }

+ 8 - 0
src/main/java/com/ydtech/modules/ins/dao/impl/InsDeptFeeDaoImpl.java

@@ -213,4 +213,12 @@ public class InsDeptFeeDaoImpl implements InsDeptFeeDao {
 
 
         return jdbcTemplate.update(sql, orderno);
         return jdbcTemplate.update(sql, orderno);
     }
     }
+    @Override
+    public Integer deleteByPolicyno(String policyno) {
+        String sql = "delete from ins_deptfee where policyno=? ";
+
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+
+        return jdbcTemplate.update(sql, policyno);
+    }
 }
 }