guarantee-lsq 3 years ago
parent
commit
14bf752d0a

+ 16 - 0
platform-dao/src/main/java/com/platform/dao/dto/repair/RepairApplicationFormDTO.java

@@ -319,4 +319,20 @@ public class RepairApplicationFormDTO extends BaseDTO implements Serializable {
     private LocalDateTime searchEndTime;
 
     private String searchTime;
+
+    /**
+     * 1 待维修  2 待审核 3 已完成 4 已驳回
+     */
+    private Integer statusSearchType;
+
+    private LocalDateTime repairStartTimeStart;
+
+    private LocalDateTime repairStartTimeEnd;
+
+    /**
+     * 维修人员ID,原有的被用在特殊地方,详见.xml
+     */
+    private String queryRepairUserId;
+
+    private List<Integer> statusList;
 }

+ 7 - 0
platform-dao/src/main/java/com/platform/dao/mapper/repair/RepairApplicationFormMapper.java

@@ -45,4 +45,11 @@ public interface RepairApplicationFormMapper extends MyMapper<RepairApplicationF
      * @return
      */
     List<RepairApplicationFormVO> getCurrentlyList(RepairApplicationFormDTO model);
+
+    /**
+     * 统计累计数据
+     * @param model
+     * @return
+     */
+    RepairApplicationFormVO getWorkplaceRepairSumData(RepairApplicationFormDTO model);
 }

+ 36 - 0
platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml

@@ -92,6 +92,22 @@
             <if test="searchEndTime != null">
                 and application.apply_time <![CDATA[ <= ]]> #{searchEndTime}
             </if>
+            <!-- 新增查询参数 -->
+            <if test="queryRepairUserId != null">
+                and application.repair_user_id = #{queryRepairUserId}
+            </if>
+            <if test="statusList != null and statusList.size > 0">
+                AND application.status in
+                <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="repairStartTimeStart != null">
+                and application.repair_start_time <![CDATA[ > ]]> #{repairStartTimeStart}
+            </if>
+            <if test="repairStartTimeEnd != null">
+                and application.repair_start_time <![CDATA[ < ]]> #{repairStartTimeEnd}
+            </if>
         </where>
     </select>
     <select id="selectById" parameterType="java.lang.Object"
@@ -149,4 +165,24 @@
             </if>
         </where>
     </select>
+    <!-- 近月统计单数和费用 -->
+    <select id="getWorkplaceRepairSumData" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
+            resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
+        select count(1) as tempTotalNum,sum(fee.fee) as tempTotalFee from t_repair_application_form rf
+        join t_repair_fee fee on fee.repair_id = rf.id
+        <where>
+            <if test="repairUserId != null">
+                and rf.repair_user_id = #{repairUserId}
+            </if>
+            <if test="searchStartTime != null">
+                and rf.repair_start_time <![CDATA[>]]> #{searchStartTime}
+            </if>
+            <if test="searchEndTime != null">
+                and rf.repair_start_time <![CDATA[<]]> #{searchEndTime}
+            </if>
+            <if test="type != null">
+                and rf.type = #{type}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 5 - 2
platform-dao/src/main/resources/mapper/repair/RepairFeeMapper.xml

@@ -96,8 +96,11 @@
             <if test="repairUserId != null">
                 and rf.repair_user_id = #{repairUserId}
             </if>
-            <if test="searchTime != null">
-                and rf.repair_start_time like concat('',#{searchTime},'%')
+            <if test="searchStartTime != null">
+                and rf.repair_start_time <![CDATA[ > ]]> #{searchStartTime}
+            </if>
+            <if test="searchEndTime != null">
+                and rf.repair_start_time <![CDATA[ < ]]> #{searchEndTime}
             </if>
         </where>
         group by fee.type

+ 2 - 1
platform-service/src/main/java/com/platform/service/repair/RepairFeeService.java

@@ -8,6 +8,7 @@ import com.platform.dao.vo.report.RepairSbInfoReportFee;
 import com.platform.service.base.IBaseService;
 
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -30,5 +31,5 @@ public interface RepairFeeService extends IBaseService<RepairFee, RepairFeeDTO>
 
     List<RepairSbInfoReportFee> getSbInfoReport(RepairFeeDTO dto, Integer year);
 
-    List<RepairFeeVO> listForWorkplacePie(String userId,String searchTime);
+    List<RepairFeeVO> listForWorkplacePie(String userId, LocalDateTime start,LocalDateTime end);
 }

+ 28 - 2
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -168,6 +168,23 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                 }
             }
         }
+        if(record.getStatusSearchType() != null){
+            List<Integer> statusList = new ArrayList<>();
+            if(record.getStatusSearchType() == 1){ // 待维修
+                statusList.add(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
+                statusList.add(RepairApplicationFormStatusEnum.PROCESSING.getValue());
+            }
+            if(record.getStatusSearchType() == 2){ // 待审核
+                statusList.add(RepairApplicationFormStatusEnum.WAIT_SUBMIT.getValue());
+                statusList.add(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
+            }
+            if(record.getStatusSearchType() == 3){ // 已完成
+                statusList.add(RepairApplicationFormStatusEnum.FINISHED.getValue());
+            }
+            if(record.getStatusSearchType() == 4){ // 已驳回
+                statusList.add(RepairApplicationFormStatusEnum.REBACK.getValue());
+            }
+        }
         return new MyVOPage<>(mapper.selectPageList(record));
     }
 
@@ -872,8 +889,17 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             }
         }
         // 统计总和数据
-        vo.setTotalFee(vo.getRepairFee().add(vo.getOutRepairFee()));
-        vo.setTotalNum(vo.getRepairTotalNum().add(vo.getOutRepairTotalNum()));
+        queryDTO.setType(null);
+        queryDTO.setSearchTime(null);
+        int year = LocalDateTime.now().getYear();
+        int month = LocalDateTime.now().getMonthValue();
+        queryDTO.setSearchStartTime(DateUtils.getFirstDayOfMonth(year, month));
+        queryDTO.setSearchEndTime(DateUtils.getLastDayOfMonth(year, month));
+        RepairApplicationFormVO voInfo = mapper.getWorkplaceRepairSumData(queryDTO);
+        if(voInfo != null){
+            vo.setTotalFee(voInfo.getTempTotalFee());
+            vo.setTotalNum(vo.getTotalNum());
+        }
         return vo;
     }
 

+ 7 - 3
platform-service/src/main/java/com/platform/service/repair/impl/RepairFeeServiceImpl.java

@@ -299,12 +299,16 @@ public class RepairFeeServiceImpl extends BaseServiceImpl<RepairFeeMapper, Repai
     }
 
     @Override
-    public List<RepairFeeVO> listForWorkplacePie(String userId,String searchTime) {
+    public List<RepairFeeVO> listForWorkplacePie(String userId,LocalDateTime start,LocalDateTime end) {
         // 查询统计费用类别数据
         RepairFeeDTO queryDTO = new RepairFeeDTO();
-        queryDTO.setSearchTime(searchTime);
+        queryDTO.setSearchStartTime(start);
+        queryDTO.setSearchEndTime(end);
         queryDTO.setRepairUserId(userId);
-        List<RepairFeeVO> list = mapper.listForWorkplacePie(queryDTO) == null ? new ArrayList<>() : mapper.listForWorkplacePie(queryDTO);
+        List<RepairFeeVO> list = mapper.listForWorkplacePie(queryDTO);
+        if(list == null){
+            list = new ArrayList<>();
+        }
         SysConfig sysConfig = sysConfigService.getByCode(SysConfigEnum.REPAIR_FEE_TYPE_MAPS.toString());
         if(sysConfig != null) {
             List<RepairFeeVO> voList = JSONArray.parseArray(sysConfig.getContent(), RepairFeeVO.class);

+ 4 - 2
platform-service/src/main/java/com/platform/service/workplace/impl/IndexServiceImpl.java

@@ -54,13 +54,15 @@ public class IndexServiceImpl implements IndexService {
     public R getWorkplaceLeftPie(String roleCode) {
         String userId = SecurityUtils.getUserInfo().getUserId();
         LocalDateTime now = LocalDateTime.now();
+        int year = now.getYear();
+        int month = now.getDayOfMonth();
         R r = R.success();
         switch (roleCode){
             case CommonConstants.WORKPLACE_REPAIR_NORMAL:
-                r.setData(repairFeeService.listForWorkplacePie(userId, DateUtils.dateToString(now,DateUtils.PATTERN_YMD)));
+                r.setData(repairFeeService.listForWorkplacePie(userId, DateUtils.getFirstDayOfMonth(year, month),DateUtils.getLastDayOfMonth(year, month)));
                 break;
             case CommonConstants.WORKPLACE_REPAIR_MANAGE:
-                r.setData(repairFeeService.listForWorkplacePie(null, DateUtils.dateToString(now,DateUtils.PATTERN_YMD)));
+                r.setData(repairFeeService.listForWorkplacePie(null, DateUtils.getFirstDayOfMonth(year, month),DateUtils.getLastDayOfMonth(year, month)));
                 break;
             case CommonConstants.WORKPLACE_STORE_MANAGE:
                 r.setData(sparePartInfoService.listForWorkplacePie(null,DateUtils.dateToString(now,DateUtils.PATTERN_YMD)));