|
|
@@ -0,0 +1,109 @@
|
|
|
+package com.ydtech.modules.order.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.base.controller.BaseController;
|
|
|
+import com.ydtech.modules.order.entity.po.InsCompanyClause;
|
|
|
+import com.ydtech.modules.order.entity.po.InsCompanyClauseQuoteInfoMap;
|
|
|
+import com.ydtech.modules.order.entity.po.InsCompanyClauseReplace;
|
|
|
+import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
|
|
|
+import com.ydtech.modules.order.entity.vo.InsCompanyClauseQueryVo;
|
|
|
+import com.ydtech.modules.order.entity.vo.InsCompanyClauseSaveVo;
|
|
|
+import com.ydtech.modules.order.entity.vo.InsCompanyClauseVo;
|
|
|
+import com.ydtech.modules.order.service.InsCompanyClauseService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static com.ydtech.core.page.PageRequest.buildPageRequest;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 特约条款
|
|
|
+ */
|
|
|
+@Api(tags = "特约条款")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/clause")
|
|
|
+public class ClauseController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ InsCompanyClauseService insCompanyClauseService;
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/updateClause")
|
|
|
+ @ApiOperation("修改特约")
|
|
|
+ public HttpResult updateClause(@RequestBody InsCompanyClauseSaveVo saveVo){
|
|
|
+
|
|
|
+ return insCompanyClauseService.updateClause(saveVo) ? HttpResult.ok("修改成功") : HttpResult.error("修改失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/getInfoMaps")
|
|
|
+ @ApiOperation("获取对象属性")
|
|
|
+ public HttpResult getInfoMaps(){
|
|
|
+ return HttpResult.ok(insCompanyClauseService.getInfoMaps());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/getClausePage")
|
|
|
+ @ApiOperation("获取保险公司特别约定列表")
|
|
|
+ public HttpResult getClausePage(@RequestBody InsCompanyClauseQueryVo queryVo){
|
|
|
+ Page page = buildPageRequest(queryVo.getPageDto());
|
|
|
+ Page<InsCompanyClauseVo> clausePageByParam = insCompanyClauseService.getClausePageByParam(page, queryVo);
|
|
|
+ return HttpResult.ok(clausePageByParam);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/getClauseByCompanyId")
|
|
|
+ @ApiOperation("根据参数获取保险公司的特别约定")
|
|
|
+ public HttpResult getCertificateInfo(@RequestBody InsCompanyClauseQueryVo queryVo) throws IllegalAccessException {
|
|
|
+ //设置险种信息
|
|
|
+ queryVo.setRiskCodes(ProductsType.getRisks(queryVo.getProductCode()));
|
|
|
+
|
|
|
+ List<InsCompanyClauseVo> byCompnayId = insCompanyClauseService.getClauseByParam(queryVo);
|
|
|
+ byCompnayId.forEach(item->{
|
|
|
+ item.setReplaceContent(item.getClauseContent());
|
|
|
+ if(item.getReplaces().size() > 0){
|
|
|
+ for(int i=0;i<item.getReplaces().size();i++){
|
|
|
+ item.getInfoMap().get(i).setReplaceSymbol(item.getReplaces().get(i).getReplaceSymbol());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ byCompnayId.forEach(item->{
|
|
|
+ item.getInfoMap().forEach(map->{
|
|
|
+ try {
|
|
|
+ String fieldValue = "_";
|
|
|
+ if(!map.getGroupType().equals("none")){
|
|
|
+ fieldValue = getFieldValue(queryVo.getQuoteInfoVo(),map);
|
|
|
+ }
|
|
|
+ String replaceContent = item.getReplaceContent();
|
|
|
+ item.setReplaceContent(replaceContent.replaceFirst(map.getReplaceSymbol(), fieldValue));
|
|
|
+ } catch (NoSuchFieldException | IllegalAccessException e) {
|
|
|
+ throw new SystemException("获取实体对象异常");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return HttpResult.ok(byCompnayId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getFieldValue(Object obj, InsCompanyClauseQuoteInfoMap map) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ Field field = obj.getClass().getDeclaredField(map.getGroupType());
|
|
|
+ field.setAccessible(true);
|
|
|
+ Object o = field.get(obj);
|
|
|
+ Field declaredField = o.getClass().getDeclaredField(map.getMapFiled());
|
|
|
+ declaredField.setAccessible(true);
|
|
|
+ Object o1 = declaredField.get(o);
|
|
|
+ return o1.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|