Преглед изворни кода

Merge remote-tracking branch 'origin/test'

y пре 2 година
родитељ
комит
50ddd3beeb

+ 24 - 35
src/main/java/com/ydtech/modules/ins/model/guoren/CarPriceReq.java

@@ -9,11 +9,14 @@ import com.ydtech.modules.ins.model.vo.CarInfoVo;
 import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
 import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
 import com.ydtech.modules.ins.model.vo.KindInfoVo;
 import com.ydtech.modules.ins.model.vo.KindInfoVo;
 import com.ydtech.modules.ins.model.vo.RiskInfoVo;
 import com.ydtech.modules.ins.model.vo.RiskInfoVo;
+import com.ydtech.modules.order.entity.api.guoren.constants.ClauseTypeSystem;
+import com.ydtech.modules.order.entity.api.guoren.constants.FuelType;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.utils.StringUtils;
 import com.ydtech.utils.StringUtils;
 import lombok.Data;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
 
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 @NoArgsConstructor
 @NoArgsConstructor
@@ -95,7 +98,6 @@ public class CarPriceReq {
         BcDTO.PrpTitemCarDTO prpTitemCar = new BcDTO.PrpTitemCarDTO();
         BcDTO.PrpTitemCarDTO prpTitemCar = new BcDTO.PrpTitemCarDTO();
         prpTitemCar.setFrameNo(carInfo.getFrameNo());
         prpTitemCar.setFrameNo(carInfo.getFrameNo());
         prpTitemCar.setLicenseNo(carInfo.getLicenseNo());
         prpTitemCar.setLicenseNo(carInfo.getLicenseNo());
-        prpTitemCar.setNewEnergyFlag("0");
         //类比排量
         //类比排量
         prpTitemCar.setExhaustScalelb(vinQ.getExHaustScale());
         prpTitemCar.setExhaustScalelb(vinQ.getExHaustScale());
         //排量
         //排量
@@ -114,10 +116,22 @@ public class CarPriceReq {
         prpTitemCar.setLoanVehicleFlag("0");
         prpTitemCar.setLoanVehicleFlag("0");
         prpTitemCar.setChgOwnerFlag(carInfo.isTransferFlag() ? "1" : "0");
         prpTitemCar.setChgOwnerFlag(carInfo.isTransferFlag() ? "1" : "0");
         prpTitemCar.setProductType("0101");
         prpTitemCar.setProductType("0101");
-        prpTitemCar.setClauseTypeSystem("04");
+
+        // 新能源车
+        if(FuelType.getEnergy().contains(vinQ.getFuelType())){
+            prpTitemCar.setClauseTypeSystem(ClauseTypeSystem.CTS_05.getCode());
+            prpTitemCar.setTermsSystem(ClauseTypeSystem.CTS_05.getCode());
+            prpTitemCar.setNewEnergyFlag("1");
+        }else {
+            prpTitemCar.setClauseTypeSystem(ClauseTypeSystem.CTS_04.getCode());
+            prpTitemCar.setTermsSystem(ClauseTypeSystem.CTS_04.getCode());
+            prpTitemCar.setNewEnergyFlag("0");
+        }
+
         prpTitemCar.setEngineNo(carInfo.getEngineNo());
         prpTitemCar.setEngineNo(carInfo.getEngineNo());
         prpTitemCar.setBrandName(vinQ.getBrandNameBC());
         prpTitemCar.setBrandName(vinQ.getBrandNameBC());
         prpTitemCar.setCertifiCateDate(carInfo.getIssueDate());
         prpTitemCar.setCertifiCateDate(carInfo.getIssueDate());
+
         //使用性质  8A	家庭自用
         //使用性质  8A	家庭自用
         prpTitemCar.setUseNatureCode("8A");
         prpTitemCar.setUseNatureCode("8A");
         //初登日期
         //初登日期
@@ -125,7 +139,8 @@ public class CarPriceReq {
         //核定载客数
         //核定载客数
         prpTitemCar.setSeatCount(carInfo.getSeatCount());
         prpTitemCar.setSeatCount(carInfo.getSeatCount());
         prpTitemCar.setFuelType("0");
         prpTitemCar.setFuelType("0");
-        prpTitemCar.setTermsSystem("04");
+
+
         prpTitemCar.setTonCountlb(vinQ.getTonCount());
         prpTitemCar.setTonCountlb(vinQ.getTonCount());
 //        prpTitemCar.setTonCountlb("0");
 //        prpTitemCar.setTonCountlb("0");
         prpTitemCar.setVinClick("0");
         prpTitemCar.setVinClick("0");
@@ -160,14 +175,11 @@ public class CarPriceReq {
 
 
         //保费计算折扣    0是第一次计算保费,1是价费联动,2是批折扣,默认0
         //保费计算折扣    0是第一次计算保费,1是价费联动,2是批折扣,默认0
         bc.setFeeandDiscountFlag("0");
         bc.setFeeandDiscountFlag("0");
-
         //险种信息  0500-车险 摩托车、拖拉机的商业险-0521
         //险种信息  0500-车险 摩托车、拖拉机的商业险-0521
         bc.setRiskCode("0500");
         bc.setRiskCode("0500");
-
         //是否涉及农险业务  默认0
         //是否涉及农险业务  默认0
         bc.setAgriFlagBC("0");
         bc.setAgriFlagBC("0");
 
 
-
         BasePartVoDTO basePartVo = new BasePartVoDTO();
         BasePartVoDTO basePartVo = new BasePartVoDTO();
         basePartVo.setEditType("EditType_ProposalInput");
         basePartVo.setEditType("EditType_ProposalInput");
         basePartVo.setInputType("34");
         basePartVo.setInputType("34");
@@ -176,7 +188,6 @@ public class CarPriceReq {
 //        basePartVo.setLoginRiskCode("0500");
 //        basePartVo.setLoginRiskCode("0500");
         basePartVo.setUserCode(channelInfo.getAgentCode());
         basePartVo.setUserCode(channelInfo.getAgentCode());
 
 
-
         req.setBi(new BiDTO());
         req.setBi(new BiDTO());
         req.setCi(new CiDTO());
         req.setCi(new CiDTO());
 
 
@@ -274,6 +285,9 @@ public class CarPriceReq {
             @JsonProperty(value = "chgOwnerDate")
             @JsonProperty(value = "chgOwnerDate")
             @JSONField(name = "chgOwnerDate")
             @JSONField(name = "chgOwnerDate")
             private String chgOwnerDate;
             private String chgOwnerDate;
+            /**
+             * 条款体系
+             */
             @JsonProperty(value = "clauseTypeSystem")
             @JsonProperty(value = "clauseTypeSystem")
             @JSONField(name = "clauseTypeSystem")
             @JSONField(name = "clauseTypeSystem")
             private String clauseTypeSystem;
             private String clauseTypeSystem;
@@ -307,6 +321,9 @@ public class CarPriceReq {
             @JsonProperty(value = "fuelType")
             @JsonProperty(value = "fuelType")
             @JSONField(name = "fuelType")
             @JSONField(name = "fuelType")
             private String fuelType;
             private String fuelType;
+            /**
+             * 商业险体系
+             */
             @JsonProperty(value = "termsSystem")
             @JsonProperty(value = "termsSystem")
             @JSONField(name = "termsSystem")
             @JSONField(name = "termsSystem")
             private String termsSystem;
             private String termsSystem;
@@ -480,32 +497,4 @@ public class CarPriceReq {
     public static class CiDTO {
     public static class CiDTO {
     }
     }
 
 
-
-//    private static BcDTO.PrpTmainDTO buildPrpTmain(){
-//        BcDTO.PrpTmainDTO tmain = new BcDTO.PrpTmainDTO();
-//        tmain.setUnitmainTenanceType2Name();
-//        "unitmainTenanceType2Name":"直通网销",
-//                "channeltypeone":"60",
-//                "argueSolution":"1",
-//                "handler1Name":"徐丽",
-//                "channeltypetwo":"0201",
-//                "agentName":"徐丽",
-//                "unitMaintenanceName":"南京测试标准件",
-//                "businessNature":"0",
-//                "activityPlan":"IXX",
-//                "signDate":"2022-06-17",
-//                "handlerCode":"S0300042",
-//                "channeltypeoneName":"行销",
-//                "unitMaintenanceCode":"0315G022105203121",
-//                "unitmainTenanceType1":"G",
-//                "unitmainTenanceType2":"06",
-//                "channeltypetwoName":"行销传统",
-//                "handler1Code":"S0300042",
-//                "comName":"江苏南京溧水支公司个客综合",
-//                "comCode":"031514A3",
-//                "operateDate":"2022-06-17",
-//                "startDate":"2022-06-18",
-//                "eProposalFlag":"1",
-//                "business":"2020-06-18"
-//    }
 }
 }

+ 6 - 48
src/main/java/com/ydtech/modules/ins/model/guoren/VinQueryReq.java

@@ -1,9 +1,7 @@
 package com.ydtech.modules.ins.model.guoren;
 package com.ydtech.modules.ins.model.guoren;
 
 
 import com.alibaba.fastjson.annotation.JSONField;
 import com.alibaba.fastjson.annotation.JSONField;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonProperty;
-import com.ydtech.modules.ins.model.ya.CarModel_Req;
 import lombok.Data;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
 
 
@@ -50,52 +48,12 @@ public class VinQueryReq {
     @JSONField(name = "userCode")
     @JSONField(name = "userCode")
     private String userCode;
     private String userCode;
 
 
-
-    /**
-     * 构造VIN请求参数
-     *
-     * @author: lig
-     * @date: 2023年08月14日 0014
-     */
-    @JsonIgnore
-    public static VinQueryReq buildParam(CarModel_Req carModelReq, ChannelInfoResp channelInfo) {
-
-        VinQueryReq vinReq = new VinQueryReq();
-        vinReq.setFrameNo(carModelReq.getFrameNo());
-        vinReq.setEngineNo(carModelReq.getEngineNo());
-        vinReq.setLicenseNo(carModelReq.getLicenseNo());
-
-
-        vinReq.setComCode(channelInfo.getData().get(0).getPrptmain().getComCode());
-        vinReq.setUserCode(channelInfo.getData().get(0).getPrptmain().getHandlerCode());
-//        vinReq.setComCode("160700A8");
-//        vinReq.setUserCode("S1600104");
-
-
-        return vinReq;
-
+    public VinQueryReq(VinQueryReq vinQueryReq, ChannelInfoDto channelInfo) {
+        this.frameNo = vinQueryReq.getFrameNo();
+        this.engineNo = vinQueryReq.getEngineNo();
+        this.licenseNo = vinQueryReq.getLicenseNo();
+        this.comCode = channelInfo.getComCode();
+        this.userCode = channelInfo.getHandlerCode();
     }
     }
 
 
-    /**
-     * 构造VIN请求参数
-     *
-     * @author: lig
-     * @date: 2023年08月14日 0014
-     */
-    @JsonIgnore
-    public static VinQueryReq buildParam2(VinQueryReq vinQueryReq, ChannelInfoDto channelInfo) {
-
-        VinQueryReq vinReq = new VinQueryReq();
-        vinReq.setFrameNo(vinQueryReq.getFrameNo());
-        vinReq.setEngineNo(vinQueryReq.getEngineNo());
-        vinReq.setLicenseNo(vinQueryReq.getLicenseNo());
-
-
-        vinReq.setComCode(channelInfo.getComCode());
-        vinReq.setUserCode(channelInfo.getHandlerCode());
-
-
-        return vinReq;
-
-    }
 }
 }

+ 22 - 0
src/main/java/com/ydtech/modules/order/entity/api/guoren/constants/ClauseTypeSystem.java

@@ -0,0 +1,22 @@
+package com.ydtech.modules.order.entity.api.guoren.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @description: 条款体系  商业险体系
+ * @author: wenks
+ * @date: 2024/1/23 11:00
+ **/
+@AllArgsConstructor
+@Getter
+public enum ClauseTypeSystem {
+
+    CTS_04("04", "默认"),
+    CTS_05("05", "新能源");
+
+    private final String code;
+
+    private final String desc;
+
+}

+ 36 - 0
src/main/java/com/ydtech/modules/order/entity/api/guoren/constants/FuelType.java

@@ -0,0 +1,36 @@
+package com.ydtech.modules.order.entity.api.guoren.constants;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @description: 能源类型
+ * @author: wenks
+ * @date: 2024/1/23 11:00
+ **/
+@AllArgsConstructor
+@Getter
+public enum FuelType {
+
+    FT_0("0", "燃油"),
+    FT_1("1", "纯电动"),
+    FT_2("2", "燃料电池"),
+    FT_3("3", "插电式混合动力"),
+    FT_4("4", "其他混合动力"),
+    FT_9("9", "其他");
+
+    private final String code;
+
+    private final String desc;
+
+    private static final String[] ENERGY = new String[]{FT_1.code, FT_2.code, FT_3.code};
+
+    public static List<String> getEnergy() {
+        return Arrays.asList(ENERGY);
+    }
+
+}

+ 37 - 0
src/main/java/com/ydtech/modules/order/entity/api/guoren/constants/UseNatureCode.java

@@ -0,0 +1,37 @@
+package com.ydtech.modules.order.entity.api.guoren.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+
+
+/**
+ * @version
+ * @description: TODO
+ * @author: wenks
+ * @date: 2024/1/23 11:19
+ **/
+@AllArgsConstructor
+@Getter
+public enum UseNatureCode {
+
+    UNC_8A("8A",	"家庭自用"),
+    UNC_8B("8B",	"非营业企业"),
+    UNC_8D("8D",	"非营业个人"),
+    UNC_8E("8E",	"非营业党政机关"),
+    UNC_8F("8F",	"非营业事业团体"),
+    UNC_9B("9B",	"营业城市公交"),
+    UNC_9C("9C",	"营业公路客运"),
+    UNC_9D("9D",	"营业货运"),
+    UNC_9E("9E",	"营业旅游客运"),
+    UNC_9F("9F",	"营业出租 预约 出租客运"),
+    UNC_9G("9G",	"营业租赁"),
+    UNC_9H("9H",	"危化品运输"),
+    UNC_7A("7A", " 兼用型"),
+    UNC_7B("7B",	"运输型");
+
+    private final String code;
+
+    private final String desc;
+
+}

+ 35 - 0
src/main/java/com/ydtech/modules/order/entity/api/guoren/constants/UseNatureCodeMapping.java

@@ -0,0 +1,35 @@
+package com.ydtech.modules.order.entity.api.guoren.constants;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+
+/**
+ * @description: 使用性质映射
+ * @author: wenks
+ * @date: 2024/1/23 11:22
+ **/
+@AllArgsConstructor
+@Getter
+public enum UseNatureCodeMapping {
+
+    UM_01("01", "营业出租租赁", UseNatureCode.UNC_9F.getCode()),
+    UM_02("02", "营业城市公交", UseNatureCode.UNC_9B.getCode()),
+    UM_03("03", "营业公路客运", UseNatureCode.UNC_9C.getCode()),
+    UM_04("04", "营业货运", UseNatureCode.UNC_9D.getCode()),
+
+    UM_05("05", "家庭自用", UseNatureCode.UNC_8A.getCode()),
+    UM_06("06", "非营业机关", UseNatureCode.UNC_8E.getCode()),
+    UM_07("07", "非营业企业", UseNatureCode.UNC_8B.getCode()),
+    UM_08("08", "非营业货运", UseNatureCode.UNC_8D.getCode());
+
+    private final String code;
+
+    private final String desc;
+
+    private final String useNatureCode;
+
+    public static final String TITLE = "UM_";
+
+}

+ 2 - 2
src/main/java/com/ydtech/modules/order/service/impl/GuorenOrderApiServiceImpl.java

@@ -887,7 +887,7 @@ public class GuorenOrderApiServiceImpl implements GuorenOrderApiService {
      * @date: 2023年08月18日 0018
      * @date: 2023年08月18日 0018
      */
      */
     public VinQueryResp.DataDTO vinQuery(VinQueryReq vinQueryReq, ChannelInfoDto channelInfo) {
     public VinQueryResp.DataDTO vinQuery(VinQueryReq vinQueryReq, ChannelInfoDto channelInfo) {
-        VinQueryReq req = VinQueryReq.buildParam2(vinQueryReq, channelInfo);
+        VinQueryReq req = new VinQueryReq(vinQueryReq, channelInfo);
         VinQueryResp resp = guorenRequestApiComponent.request(req, PlatformInterfaceCode.API_IIRBT00009,
         VinQueryResp resp = guorenRequestApiComponent.request(req, PlatformInterfaceCode.API_IIRBT00009,
                 VinQueryResp.class);
                 VinQueryResp.class);
         if (resp.getResultCode() == 1) {
         if (resp.getResultCode() == 1) {
@@ -902,7 +902,7 @@ public class GuorenOrderApiServiceImpl implements GuorenOrderApiService {
      */
      */
     public CarPriceResp.DataDTO carPriceQuery(BaseQuoteInfoVo yaQuoteInfoVo, VinQueryResp.DataDTO vinQ,
     public CarPriceResp.DataDTO carPriceQuery(BaseQuoteInfoVo yaQuoteInfoVo, VinQueryResp.DataDTO vinQ,
                                               ChannelInfoDto channelInfo) {
                                               ChannelInfoDto channelInfo) {
-        //构造请求参数
+
         CarPriceReq req = CarPriceReq.buildCarPriceParam(yaQuoteInfoVo, vinQ, channelInfo);
         CarPriceReq req = CarPriceReq.buildCarPriceParam(yaQuoteInfoVo, vinQ, channelInfo);
         JSONObject request = guorenRequestApiComponent.request(req, PlatformInterfaceCode.API_IIRBT00003);
         JSONObject request = guorenRequestApiComponent.request(req, PlatformInterfaceCode.API_IIRBT00003);
         Object cars = request.get("cars");
         Object cars = request.get("cars");

+ 2 - 0
src/main/java/com/ydtech/modules/report/model/vo/StatisticsReportReqVo.java

@@ -44,5 +44,7 @@ public class StatisticsReportReqVo {
     private String drilType;
     private String drilType;
     @ApiModelProperty(value = "机构下钻需要截取机构位数  2总部下钻  4一级机构下钻 6二级机构下钻  8三级机构下钻  11四级机构下钻  0五级机构下钻")
     @ApiModelProperty(value = "机构下钻需要截取机构位数  2总部下钻  4一级机构下钻 6二级机构下钻  8三级机构下钻  11四级机构下钻  0五级机构下钻")
     private String drilFlag;
     private String drilFlag;
+    @ApiModelProperty(value = "是否返回上层  1 返回上层 0非返回上层")
+    private String isReturnBack;
 
 
 }
 }

+ 181 - 44
src/main/java/com/ydtech/modules/report/service/impl/ReportServiceImpl.java

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageHelper;
 import com.ydtech.aop.exception.DescribeException;
 import com.ydtech.aop.exception.DescribeException;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageResult;
 import com.ydtech.core.page.PageResult;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.SysDeptMapper;
 import com.ydtech.modules.admin.dao.SysDeptMapper;
 import com.ydtech.modules.admin.dao.SysUserMapper;
 import com.ydtech.modules.admin.dao.SysUserMapper;
 import com.ydtech.modules.admin.model.SysDept;
 import com.ydtech.modules.admin.model.SysDept;
@@ -943,6 +944,15 @@ public class ReportServiceImpl implements ReportService {
         Page<OrderVolumeAndCostStatisticsResVo> orderVolumeAndCostStatisticsResVoPage = reportInsurancePolicyMapper.queryOrderAndCostData(page,
         Page<OrderVolumeAndCostStatisticsResVo> orderVolumeAndCostStatisticsResVoPage = reportInsurancePolicyMapper.queryOrderAndCostData(page,
                 reqVo);
                 reqVo);
         orderVolumeAndCostStatisticsResVoPage.getRecords().stream().forEach(item->{
         orderVolumeAndCostStatisticsResVoPage.getRecords().stream().forEach(item->{
+            String riskName="";
+            if("ALL".equals(reqVo.getRiskCode())){
+                riskName="全部";
+            }else if("BZ".equals(reqVo.getRiskCode())){
+                riskName="交强";
+            }else if("BUS".equals(reqVo.getRiskCode())){
+                riskName="商业";
+            }
+            item.setRiskName(riskName);
             item.setInstitutionId(reqVo.getDeptId());
             item.setInstitutionId(reqVo.getDeptId());
             SysDept sysDept1=sysDeptService.getById(reqVo.getDeptId());
             SysDept sysDept1=sysDeptService.getById(reqVo.getDeptId());
             item.setInstitution(sysDept1.getName());
             item.setInstitution(sysDept1.getName());
@@ -975,35 +985,103 @@ public class ReportServiceImpl implements ReportService {
     public BasePageResult<OrderVolumeAndCostStatisticsResVo> drilQueryOrderAndCostData(StatisticsReportReqVo reqVo){
     public BasePageResult<OrderVolumeAndCostStatisticsResVo> drilQueryOrderAndCostData(StatisticsReportReqVo reqVo){
         com.baomidou.mybatisplus.extension.plugins.pagination.Page<InsOrders> page = new Page<>(reqVo.getPageNum(), reqVo.getPageSize());
         com.baomidou.mybatisplus.extension.plugins.pagination.Page<InsOrders> page = new Page<>(reqVo.getPageNum(), reqVo.getPageSize());
         page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
         page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
-        if(StringUtils.isNotEmpty(reqVo.getTeamCode())){
-            //如果团队不为空,则为团队下钻  查询到业务员
-            reqVo.setDrilType("1");
-        }else{
-            //如果团队为空,则为机构下钻,查询下一级机构
-            reqVo.setDrilType("0");
-            SysDept sysDept=sysDeptService.getById(reqVo.getDeptId());
-            String flag="";
-            if(StringUtils.isNotEmpty(sysDept.getComlevel())){
-                switch (sysDept.getComlevel()){
-                    case "1":
-                        flag="4"; break;
-                    case "2":
-                        flag="6"; break;
-                    case "3":
-                        flag="8"; break;
-                    case "4":
-                        flag="11"; break;
-                    case "5":
-                        flag="0"; break;
+        //返回上层时 调整查询条件
+        if(StringUtils.isNotEmpty(reqVo.getIsReturnBack())&&"1".equals(reqVo.getIsReturnBack())){
+            if(StringUtils.isNotEmpty(reqVo.getTeamCode())){
+                //团队不为空时,直接置为上一级  清空团队
+                reqVo.setTeamCode("");
+                reqVo.setDrilType("3");
+                //如果是机构找上层时
+                SysDept sysDept=sysDeptService.getById(reqVo.getDeptId());
+                reqVo.setDeptId(sysDept.getId());
+                //如果团队为空,则为机构下钻,查询下一级机构
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept.getComlevel())){
+                    switch (sysDept.getComlevel()){
+                        case "1":
+                            flag="2"; break;
+                        case "2":
+                            flag="4"; break;
+                        case "3":
+                            flag="6"; break;
+                        case "4":
+                            flag="8"; break;
+                        case "5":
+                            flag="11"; break;
+                    }
+                }else{
+                    flag="1";
+                }
+                reqVo.setDrilFlag(flag);
+            }else{
+                reqVo.setDrilType("3");
+                //如果是机构找上层时
+                SysDept sysDept=sysDeptService.getById(reqVo.getDeptId());
+                SysDept sysDept1=sysDeptService.getById(sysDept.getParentId());
+                if(sysDept1==null){
+                    throw new SystemException("已经到最上层,不能继续返回!");
+                }
+                reqVo.setDeptId(sysDept1.getId());
+                //如果团队为空,则为机构下钻,查询下一级机构
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept1.getComlevel())){
+                    switch (sysDept1.getComlevel()){
+                        case "1":
+                            flag="2"; break;
+                        case "2":
+                            flag="4"; break;
+                        case "3":
+                            flag="6"; break;
+                        case "4":
+                            flag="8"; break;
+                        case "5":
+                            flag="11"; break;
+                    }
+                }else{
+                    flag="1";
                 }
                 }
+                reqVo.setDrilFlag(flag);
+            }
+        }else{
+            if(StringUtils.isNotEmpty(reqVo.getTeamCode())){
+                //如果团队不为空,则为团队下钻  查询到业务员
+                reqVo.setDrilType("1");
             }else{
             }else{
-                flag="2";
+                //如果团队为空,则为机构下钻,查询下一级机构
+                reqVo.setDrilType("0");
+                SysDept sysDept=sysDeptService.getById(reqVo.getDeptId());
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept.getComlevel())){
+                    switch (sysDept.getComlevel()){
+                        case "1":
+                            flag="4"; break;
+                        case "2":
+                            flag="6"; break;
+                        case "3":
+                            flag="8"; break;
+                        case "4":
+                            flag="11"; break;
+                        case "5":
+                            flag="0"; break;
+                    }
+                }else{
+                    flag="2";
+                }
+                reqVo.setDrilFlag(flag);
             }
             }
-            reqVo.setDrilFlag(flag);
         }
         }
         Page<OrderVolumeAndCostStatisticsResVo> orderVolumeAndCostStatisticsResVoPage = reportInsurancePolicyMapper.queryOrderAndCostData(page,
         Page<OrderVolumeAndCostStatisticsResVo> orderVolumeAndCostStatisticsResVoPage = reportInsurancePolicyMapper.queryOrderAndCostData(page,
                 reqVo);
                 reqVo);
         orderVolumeAndCostStatisticsResVoPage.getRecords().stream().forEach(item->{
         orderVolumeAndCostStatisticsResVoPage.getRecords().stream().forEach(item->{
+            String riskName="";
+            if("ALL".equals(reqVo.getRiskCode())){
+                riskName="全部";
+            }else if("BZ".equals(reqVo.getRiskCode())){
+                riskName="交强";
+            }else if("BUS".equals(reqVo.getRiskCode())){
+                riskName="商业";
+            }
+            item.setRiskName(riskName);
             //如果返回业务员时
             //如果返回业务员时
             if(StringUtils.isNotEmpty(item.getUsername())){
             if(StringUtils.isNotEmpty(item.getUsername())){
                 SysDept sysDept1=sysDeptService.getById(reqVo.getDeptId());
                 SysDept sysDept1=sysDeptService.getById(reqVo.getDeptId());
@@ -1063,31 +1141,90 @@ public class ReportServiceImpl implements ReportService {
 
 
     @Override
     @Override
     public String exportDrilOrderAndCostData(StatisticsReportReqVo reqDto) {
     public String exportDrilOrderAndCostData(StatisticsReportReqVo reqDto) {
-        if(StringUtils.isNotEmpty(reqDto.getTeamCode())){
-            //如果团队不为空,则为团队下钻  查询到业务员
-            reqDto.setDrilType("1");
-        }else{
-            //如果团队为空,则为机构下钻,查询下一级机构
-            reqDto.setDrilType("0");
-            SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
-            String flag="";
-            if(StringUtils.isNotEmpty(sysDept.getComlevel())){
-                switch (sysDept.getComlevel()){
-                    case "1":
-                        flag="4"; break;
-                    case "2":
-                        flag="6"; break;
-                    case "3":
-                        flag="8"; break;
-                    case "4":
-                        flag="11"; break;
-                    case "5":
-                        flag="0"; break;
+        //返回上层时 调整查询条件
+        if(StringUtils.isNotEmpty(reqDto.getIsReturnBack())&&"1".equals(reqDto.getIsReturnBack())){
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())){
+                //团队不为空时,直接置为上一级  清空团队
+                reqDto.setTeamCode("");
+                reqDto.setDrilType("3");
+                //如果是机构找上层时
+                SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+                reqDto.setDeptId(sysDept.getId());
+                //如果团队为空,则为机构下钻,查询下一级机构
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept.getComlevel())){
+                    switch (sysDept.getComlevel()){
+                        case "1":
+                            flag="2"; break;
+                        case "2":
+                            flag="4"; break;
+                        case "3":
+                            flag="6"; break;
+                        case "4":
+                            flag="8"; break;
+                        case "5":
+                            flag="11"; break;
+                    }
+                }else{
+                    flag="1";
+                }
+                reqDto.setDrilFlag(flag);
+            }else{
+                reqDto.setDrilType("3");
+                //如果是机构找上层时
+                SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+                SysDept sysDept1=sysDeptService.getById(sysDept.getParentId());
+                if(sysDept1==null){
+                    throw new SystemException("已经到最上层,不能继续返回!");
+                }
+                reqDto.setDeptId(sysDept1.getId());
+                //如果团队为空,则为机构下钻,查询下一级机构
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept1.getComlevel())){
+                    switch (sysDept1.getComlevel()){
+                        case "1":
+                            flag="2"; break;
+                        case "2":
+                            flag="4"; break;
+                        case "3":
+                            flag="6"; break;
+                        case "4":
+                            flag="8"; break;
+                        case "5":
+                            flag="11"; break;
+                    }
+                }else{
+                    flag="1";
                 }
                 }
+                reqDto.setDrilFlag(flag);
+            }
+        }else{
+            if(StringUtils.isNotEmpty(reqDto.getTeamCode())){
+                //如果团队不为空,则为团队下钻  查询到业务员
+                reqDto.setDrilType("1");
             }else{
             }else{
-                flag="2";
+                //如果团队为空,则为机构下钻,查询下一级机构
+                reqDto.setDrilType("0");
+                SysDept sysDept=sysDeptService.getById(reqDto.getDeptId());
+                String flag="";
+                if(StringUtils.isNotEmpty(sysDept.getComlevel())){
+                    switch (sysDept.getComlevel()){
+                        case "1":
+                            flag="4"; break;
+                        case "2":
+                            flag="6"; break;
+                        case "3":
+                            flag="8"; break;
+                        case "4":
+                            flag="11"; break;
+                        case "5":
+                            flag="0"; break;
+                    }
+                }else{
+                    flag="2";
+                }
+                reqDto.setDrilFlag(flag);
             }
             }
-            reqDto.setDrilFlag(flag);
         }
         }
         List<OrderVolumeAndCostStatisticsResVo> orderVolumeAndCostStatisticsResVoPage = reportInsurancePolicyMapper.queryOrderAndCostData(reqDto);
         List<OrderVolumeAndCostStatisticsResVo> orderVolumeAndCostStatisticsResVoPage = reportInsurancePolicyMapper.queryOrderAndCostData(reqDto);
         orderVolumeAndCostStatisticsResVoPage.stream().forEach(item->{
         orderVolumeAndCostStatisticsResVoPage.stream().forEach(item->{

+ 175 - 44
src/main/resources/mapper/modules/report/ReportInsurancePolicyMapper.xml

@@ -62,8 +62,20 @@
                     </otherwise>
                     </otherwise>
                 </choose>
                 </choose>
             </if>
             </if>
+            <!--团队返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                p.deptid,
+            </if>
+            <!--机构返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                substr(p.deptid,1,#{reportReqVo.drilFlag}) institutionId,
+            </if>
+        </if>
+        <if test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
+            <if test="reportReqVo.riskCode!='ALL'.toString()">
+                p.`risk_name` risk_name,
+            </if>
         </if>
         </if>
-        p.`risk_name` risk_name,
         count(distinct policyno) policy_count,
         count(distinct policyno) policy_count,
         SUM(p.`sumpremium`) sumpremium,
         SUM(p.`sumpremium`) sumpremium,
         SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
         SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
@@ -92,6 +104,15 @@
                     </otherwise>
                     </otherwise>
                 </choose>
                 </choose>
             </if>
             </if>
+
+            <!--团队返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                and p.deptid = #{reportReqVo.deptId}
+            </if>
+            <!--机构返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                and substr(p.deptid,1,#{reportReqVo.drilFlag})  = #{reportReqVo.deptId}
+            </if>
         </if>
         </if>
         <!--非下钻查询时拼接-->
         <!--非下钻查询时拼接-->
         <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
         <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
@@ -123,27 +144,71 @@
         <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
         <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
             and p.inside_pay_time  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
             and p.inside_pay_time  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
         </if>
         </if>
-        GROUP BY p.`risk_name`
-        <!--下钻查询时拼接-->
-        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
-            <!--按团队下钻时-->
-            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
-                ,p.`username`,p.userid order by p.`username`,p.`risk_name`
-            </if>
-            <!--按机构下钻时-->
-            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
-                <choose>
-                    <!--下钻的是五级机构时,下钻到团队-->
-                    <when test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '0'.toString()">
-                        ,p.deptid  order by p.deptid,p.`risk_name`
-                    </when>
-                    <!--下钻的非五级机构时,下钻到下级机构-->
-                    <otherwise>
-                        ,substr(p.deptid,1,#{reportReqVo.drilFlag}) order by    substr(p.deptid,1,#{reportReqVo.drilFlag}),p.`risk_name`
-                    </otherwise>
-                </choose>
-            </if>
-        </if>
+
+        <choose>
+            <when test="reportReqVo.riskCode != null and reportReqVo.riskCode!='ALL'.toString()">
+                GROUP BY p.`risk_name`
+                <!--下钻查询时拼接-->
+                <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+                    <!--按团队下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                        ,p.`username`,p.userid order by p.`username`,p.`risk_name`
+                    </if>
+                    <!--按机构下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                        <choose>
+                            <!--下钻的是五级机构时,下钻到团队-->
+                            <when test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '0'.toString()">
+                                ,p.deptid  order by p.deptid,p.`risk_name`
+                            </when>
+                            <!--下钻的非五级机构时,下钻到下级机构-->
+                            <otherwise>
+                                ,substr(p.deptid,1,#{reportReqVo.drilFlag}) order by    substr(p.deptid,1,#{reportReqVo.drilFlag}),p.`risk_name`
+                            </otherwise>
+                        </choose>
+                    </if>
+                    <!--团队返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                        ,p.deptid order by p.deptid
+                    </if>
+                    <!--机构返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                        ,substr(p.deptid,1,#{reportReqVo.drilFlag})   order by substr(p.deptid,1,#{reportReqVo.drilFlag})
+                    </if>
+                </if>
+            </when>
+            <otherwise>
+                <!--下钻查询时拼接-->
+                <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+                    <!--按团队下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                        group by p.`username`,p.userid order by p.`username`
+                    </if>
+                    <!--按机构下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                        <choose>
+                            <!--下钻的是五级机构时,下钻到团队-->
+                            <when test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '0'.toString()">
+                                group by  p.deptid  order by p.deptid
+                            </when>
+                            <!--下钻的非五级机构时,下钻到下级机构-->
+                            <otherwise>
+                                group by  substr(p.deptid,1,#{reportReqVo.drilFlag}) order by    substr(p.deptid,1,#{reportReqVo.drilFlag})
+                            </otherwise>
+                        </choose>
+                    </if>
+                    <!--团队返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                        group by p.deptid order by p.deptid
+                    </if>
+                    <!--机构返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                        group by substr(p.deptid,1,#{reportReqVo.drilFlag})   order by substr(p.deptid,1,#{reportReqVo.drilFlag})
+                    </if>
+                </if>
+            </otherwise>
+        </choose>
+
     </select>
     </select>
 
 
     <resultMap id="OrderAndCostDataMap" type="com.ydtech.modules.report.model.vo.OrderVolumeAndCostStatisticsResVo">
     <resultMap id="OrderAndCostDataMap" type="com.ydtech.modules.report.model.vo.OrderVolumeAndCostStatisticsResVo">
@@ -161,6 +226,7 @@
         select
         select
         count(1)
         count(1)
         from (
         from (
+
         SELECT
         SELECT
         <!--下钻查询时拼接-->
         <!--下钻查询时拼接-->
         <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
         <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
@@ -181,8 +247,20 @@
                     </otherwise>
                     </otherwise>
                 </choose>
                 </choose>
             </if>
             </if>
+            <!--团队返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                p.deptid,
+            </if>
+            <!--机构返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                substr(p.deptid,1,#{reportReqVo.drilFlag}) institutionId,
+            </if>
+        </if>
+        <if test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
+            <if test="reportReqVo.riskCode!='ALL'.toString()">
+                p.`risk_name` risk_name,
+            </if>
         </if>
         </if>
-        p.`risk_name` risk_name,
         count(distinct policyno) policy_count,
         count(distinct policyno) policy_count,
         SUM(p.`sumpremium`) sumpremium,
         SUM(p.`sumpremium`) sumpremium,
         SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
         SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
@@ -211,6 +289,15 @@
                     </otherwise>
                     </otherwise>
                 </choose>
                 </choose>
             </if>
             </if>
+
+            <!--团队返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                and p.deptid = #{reportReqVo.deptId}
+            </if>
+            <!--机构返回上层时-->
+            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                and substr(p.deptid,1,#{reportReqVo.drilFlag})  = #{reportReqVo.deptId}
+            </if>
         </if>
         </if>
         <!--非下钻查询时拼接-->
         <!--非下钻查询时拼接-->
         <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
         <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
@@ -242,27 +329,71 @@
         <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
         <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
             and p.inside_pay_time  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
             and p.inside_pay_time  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
         </if>
         </if>
-        GROUP BY p.`risk_name`
-        <!--下钻查询时拼接-->
-        <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
-            <!--按团队下钻时-->
-            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
-                ,p.`username`,p.userid order by p.`username`,p.`risk_name`
-            </if>
-            <!--按机构下钻时-->
-            <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
-                <choose>
-                    <!--下钻的是五级机构时,下钻到团队-->
-                    <when test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '0'.toString()">
-                        ,p.deptid  order by p.deptid,p.`risk_name`
-                    </when>
-                    <!--下钻的非五级机构时,下钻到下级机构-->
-                    <otherwise>
-                        ,substr(p.deptid,1,#{reportReqVo.drilFlag}) order by    substr(p.deptid,1,#{reportReqVo.drilFlag}),p.`risk_name`
-                    </otherwise>
-                </choose>
-            </if>
-        </if>
+
+        <choose>
+            <when test="reportReqVo.riskCode != null and reportReqVo.riskCode!='ALL'.toString()">
+                GROUP BY p.`risk_name`
+                <!--下钻查询时拼接-->
+                <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+                    <!--按团队下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                        ,p.`username`,p.userid order by p.`username`,p.`risk_name`
+                    </if>
+                    <!--按机构下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                        <choose>
+                            <!--下钻的是五级机构时,下钻到团队-->
+                            <when test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '0'.toString()">
+                                ,p.deptid  order by p.deptid,p.`risk_name`
+                            </when>
+                            <!--下钻的非五级机构时,下钻到下级机构-->
+                            <otherwise>
+                                ,substr(p.deptid,1,#{reportReqVo.drilFlag}) order by    substr(p.deptid,1,#{reportReqVo.drilFlag}),p.`risk_name`
+                            </otherwise>
+                        </choose>
+                    </if>
+                    <!--团队返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                        ,p.deptid order by p.deptid
+                    </if>
+                    <!--机构返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                        ,substr(p.deptid,1,#{reportReqVo.drilFlag})   order by substr(p.deptid,1,#{reportReqVo.drilFlag})
+                    </if>
+                </if>
+            </when>
+            <otherwise>
+                <!--下钻查询时拼接-->
+                <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
+                    <!--按团队下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
+                        group by p.`username`,p.userid order by p.`username`
+                    </if>
+                    <!--按机构下钻时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
+                        <choose>
+                            <!--下钻的是五级机构时,下钻到团队-->
+                            <when test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '0'.toString()">
+                                group by  p.deptid  order by p.deptid
+                            </when>
+                            <!--下钻的非五级机构时,下钻到下级机构-->
+                            <otherwise>
+                                group by  substr(p.deptid,1,#{reportReqVo.drilFlag}) order by    substr(p.deptid,1,#{reportReqVo.drilFlag})
+                            </otherwise>
+                        </choose>
+                    </if>
+                    <!--团队返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
+                        group by p.deptid order by p.deptid
+                    </if>
+                    <!--机构返回上层时-->
+                    <if test="reportReqVo.drilType != null and reportReqVo.drilType == '3'.toString()">
+                        group by substr(p.deptid,1,#{reportReqVo.drilFlag})   order by substr(p.deptid,1,#{reportReqVo.drilFlag})
+                    </if>
+                </if>
+            </otherwise>
+        </choose>
+
         ) as s
         ) as s
     </select>
     </select>