Sfoglia il codice sorgente

报表清单出单量及费用统计

cuixinpeng 2 anni fa
parent
commit
2a5f41975b

+ 6 - 2
src/main/java/com/ydtech/modules/report/service/impl/ReportServiceImpl.java

@@ -949,11 +949,15 @@ public class ReportServiceImpl implements ReportService {
             if(StringUtils.isNotEmpty(reqVo.getTeamCode())){
                 item.setDeptId(reqVo.getTeamCode());
                 SysDept sysDept2=sysDeptService.getById(reqVo.getTeamCode());
-                item.setDeptname(sysDept2.getName());
+                if(sysDept2!=null){
+                    item.setDeptname(sysDept2.getName());
+                }
             }
             if(StringUtils.isNotEmpty(reqVo.getUserId())){
                 SysUser sysUser=sysUserService.getById(reqVo.getUserId());
-                item.setUsername(sysUser.getName());
+                if(sysUser!=null){
+                    item.setUsername(sysUser.getName());
+                }
             }
         });
 

+ 86 - 20
src/main/resources/mapper/modules/report/ReportInsurancePolicyMapper.xml

@@ -40,24 +40,22 @@
         <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
     </resultMap>
 
-    <resultMap id="OrderAndCostDataMap" type="com.ydtech.modules.report.model.vo.OrderVolumeAndCostStatisticsResVo">
-        <result property="institution" column="institution" jdbcType="VARCHAR"/>
-        <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
-        <result property="username" column="username" jdbcType="VARCHAR"/>
-        <result property="riskName" column="risk_name" jdbcType="VARCHAR"/>
-        <result property="policyCount" column="policy_count" jdbcType="DECIMAL"/>
-        <result property="sumPremium" column="sumremium" jdbcType="DECIMAL"/>
-        <result property="sumCostsPremiums" column="sum_costs_premiums" jdbcType="DECIMAL"/>
-        <result property="superviseCostsPremiums" column="supervise_costs_premiums" jdbcType="DECIMAL"/>
-        <result property="otherCostsPremiums" column="other_costs_premiums" jdbcType="DECIMAL"/>
-    </resultMap>
-
     <select id="queryOrderAndCostData"  resultMap="OrderAndCostDataMap">
 
         SELECT
         ''institution,
-        ''deptname,
-        ''username,
+        <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+            p.deptname,
+        </if>
+        <if test="reportReqVo.teamCode == null || reportReqVo.teamCode == ''">
+            ''deptname,
+        </if>
+        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+            p.username,
+        </if>
+        <if test="reportReqVo.userId == null || reportReqVo.userId == ''">
+            ''username,
+        </if>
         p.`risk_name` risk_name,
         count(1) policy_count,
         SUM(p.`sumpremium`) sumpremium,
@@ -67,30 +65,98 @@
         FROM
         report_insurance_policy p WHERE 1=1
         <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
-            and p.deptid like "${reportReqVo.deptId}%"
+            and p.deptid like #{reportReqVo.deptId}"%"
+        </if>
+        <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+            and p.deptid = #{reportReqVo.teamCode}
+        </if>
+        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+            and p.userid = #{reportReqVo.userId}
+        </if>
+        <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
+            and p.company_id = #{reportReqVo.insCompany}
+        </if>
+        <if test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
+            <if test="reportReqVo.riskCode!='ALL'.toString()">
+                and p.risk_code = #{reportReqVo.riskCode}
+            </if>
+        </if>
+        <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
+            and p.inside_pay_time  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
         </if>
         GROUP BY p.`risk_name`
+        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+            ,p.username
+        </if>
+        <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+            ,p.deptname
+        </if>
     </select>
+
+    <resultMap id="OrderAndCostDataMap" type="com.ydtech.modules.report.model.vo.OrderVolumeAndCostStatisticsResVo">
+        <result property="institution" column="institution" jdbcType="VARCHAR"/>
+        <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
+        <result property="username" column="username" jdbcType="VARCHAR"/>
+        <result property="riskName" column="risk_name" jdbcType="VARCHAR"/>
+        <result property="policyCount" column="policy_count" jdbcType="DECIMAL"/>
+        <result property="sumPremium" column="sumremium" jdbcType="DECIMAL"/>
+        <result property="sumCostsPremiums" column="sum_costs_premiums" jdbcType="DECIMAL"/>
+        <result property="superviseCostsPremiums" column="supervise_costs_premiums" jdbcType="DECIMAL"/>
+        <result property="otherCostsPremiums" column="other_costs_premiums" jdbcType="DECIMAL"/>
+    </resultMap>
     <select id="queryOrderAndCostDataCount" resultType="Long">
         select
         count(1)
         from (
         SELECT
         ''institution,
-        ''deptname,
-        ''username,
-        p.`risk_name`,
+        <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+            p.deptname,
+        </if>
+        <if test="reportReqVo.teamCode == null || reportReqVo.teamCode == ''">
+            ''deptname,
+        </if>
+        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+            p.username,
+        </if>
+        <if test="reportReqVo.userId == null || reportReqVo.userId == ''">
+            ''username,
+        </if>
+        p.`risk_name` risk_name,
         count(1) policy_count,
-        SUM(p.`sumpremium`) sumprmium,
+        SUM(p.`sumpremium`) sumpremium,
         SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
         SUM(p.`other_costs_premiums`) other_costs_premiums,
         SUM(p.`sum_costs_premiums`) sum_costs_premiums
         FROM
         report_insurance_policy p WHERE 1=1
         <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
-            and p.deptid like "${reportReqVo.deptId}%"
+            and p.deptid like #{reportReqVo.deptId}"%"
+        </if>
+        <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+            and p.deptid = #{reportReqVo.teamCode}
+        </if>
+        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+            and p.userid = #{reportReqVo.userId}
+        </if>
+        <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
+            and p.company_id = #{reportReqVo.insCompany}
+        </if>
+        <if test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
+            <if test="reportReqVo.riskCode!='ALL'.toString()">
+                and p.risk_code = #{reportReqVo.riskCode}
+            </if>
+        </if>
+        <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
+            and p.inside_pay_time  between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
         </if>
         GROUP BY p.`risk_name`
+        <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
+            ,p.username
+        </if>
+        <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
+            ,p.deptname
+        </if>
         ) as s
     </select>
 </mapper>