Jelajahi Sumber

接口调整,员工概况 近一周人流量统计

yangbq 3 bulan lalu
induk
melakukan
ac52a81c5c

+ 34 - 22
project-zcustom/src/main/java/com/project/zcustom/service/employee/impl/PlatEmployeeTypeFlowServiceImpl.java

@@ -1,16 +1,16 @@
 package com.project.zcustom.service.employee.impl;
 
-import com.project.zcustom.domain.employee.PlatEmployeeTypeFlow;
-import com.project.zcustom.mapper.employee.PlatEmployeeTypeFlowMapper;
-import com.project.zcustom.service.employee.IPlatEmployeeTypeFlowService;
-import com.project.common.core.domain.search.PageParamVo;
-import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.project.common.core.domain.search.PageParamVo;
 import com.project.common.utils.StringUtils;
+import com.project.zcustom.domain.employee.PlatEmployeeTypeFlow;
+import com.project.zcustom.mapper.employee.PlatEmployeeTypeFlowMapper;
+import com.project.zcustom.service.employee.IPlatEmployeeTypeFlowService;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
@@ -159,35 +159,47 @@ public class PlatEmployeeTypeFlowServiceImpl extends ServiceImpl<PlatEmployeeTyp
 
     /**
      * 处理人流量数据
+     * 员工概况 近一周人流量统计
      * @param appOrg
      * @param mapField
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public void handleEmployeeFlow(String appOrg,Map<String, Object> mapField){
         // 先删除 employeeTypeFlow 数据
         LambdaQueryWrapper<PlatEmployeeTypeFlow> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(PlatEmployeeTypeFlow::getAppOrg, appOrg);
         baseMapper.reallyDeleteByWrapper(queryWrapper);
-        List<String> firstList = Arrays.asList("dayBeforeIns", "dayBeforeLoan", "dayBeforeAsso", "dayBeforePro","dayBeforeVis");// 前一天的数据
-        List<String> secondList = Arrays.asList("twoDaysIns", "twoDaysLoan", "twoDaysAsso", "twoDaysPro","twoDaysVis"); // 前两天的数据
-        List<String> thirdList = Arrays.asList("firstThreeDaysIns", "firstThreeDaysLoan", "firstThreeDaysAsso", "firstThreeDaysPro","firstThreeDaysVis");// 前三天的数据
-        List<String> fourList = Arrays.asList("firstFourDaysIns", "firstFourDaysLoan", "firstFourDaysAsso", "firstFourDaysPro","firstFourDaysVis");// 前四天的数据
-        List<String> fiveList = Arrays.asList("firstFiveDaysIns", "firstFiveDaysLoan", "firstFiveDaysAsso", "firstFiveDaysPro","firstFiveDaysVis");// 前五天的数据
-        List<String> sixList = Arrays.asList("firstSixDaysIns", "firstSixDaysLoan", "firstSixDaysAsso", "firstSixDaysPro","firstSixDaysVis");// 前六天的数据
-        List<String> sevenList = Arrays.asList("firstSevenDaysIns", "firstSevenDaysLoan", "firstSevenDaysAsso", "firstSevenDaysPro","firstSevenDaysVis");// 前七天的数据
-        List<List<String>> weekList = Arrays.asList(firstList, secondList, thirdList, fourList, fiveList, sixList, sevenList);
+        // 当天(today)
+        List<String> todayList = Arrays.asList("todayIns", "todayLoan", "todayAsso", "todayPro","todayVis");
+        // 前一天(dayBefore)
+        List<String> beforeList = Arrays.asList("dayBeforeIns", "dayBeforeLoan", "dayBeforeAsso", "dayBeforePro","dayBeforeVis");
+        // 前两天(firstTwoDays)
+        List<String> twodList = Arrays.asList("firstTwoDaysIns", "firstTwoDaysLoan", "firstTwoDaysAsso", "firstTwoDaysPro","firstTwoDaysVis");
+        // 前三天(firstThreeDays)
+        List<String> thirdList = Arrays.asList("firstThreeDaysIns", "firstThreeDaysLoan", "firstThreeDaysAsso", "firstThreeDaysPro","firstThreeDaysVis");
+        // 前四天(firstFourDays)
+        List<String> fourList = Arrays.asList("firstFourDaysIns", "firstFourDaysLoan", "firstFourDaysAsso", "firstFourDaysPro","firstFourDaysVis");
+        // 前五天(firstFiveDays)
+        List<String> fiveList = Arrays.asList("firstFiveDaysIns", "firstFiveDaysLoan", "firstFiveDaysAsso", "firstFiveDaysPro","firstFiveDaysVis");
+        // 前六天(firstSixDays)
+        List<String> sixList = Arrays.asList("firstSixDaysIns", "firstSixDaysLoan", "firstSixDaysAsso", "firstSixDaysPro","firstSixDaysVis");
+
+        List<String> weekList = Arrays.asList("today","dayBefore","firstTwoDays","firstThreeDays","firstFourDays","firstFiveDays","firstSixDays");
+        List<List<String>> week2List = Arrays.asList(todayList, beforeList, twodList, thirdList, fourList, fiveList, sixList);
         List<PlatEmployeeTypeFlow> addList = new ArrayList<>();
         for (int i = 0; i < weekList.size(); i++){
-            List<String> list = weekList.get(i);
+            List<String> list = week2List.get(i);
             PlatEmployeeTypeFlow platEmployeeTypeFlow = new PlatEmployeeTypeFlow();
             platEmployeeTypeFlow.setAppOrg(appOrg);
             platEmployeeTypeFlow.setTimeSign(i+1);
-            StringUtils.setFieldValue(platEmployeeTypeFlow, mapField, list, 0, PlatEmployeeTypeFlow::setInsideNum, Long.class);
-            StringUtils.setFieldValue(platEmployeeTypeFlow, mapField, list, 1, PlatEmployeeTypeFlow::setLoanNum, Long.class);
-            StringUtils.setFieldValue(platEmployeeTypeFlow, mapField, list, 2, PlatEmployeeTypeFlow::setAssociationNum, Long.class);
-            StringUtils.setFieldValue(platEmployeeTypeFlow, mapField, list, 3, PlatEmployeeTypeFlow::setPropertyNum, Long.class);
-            StringUtils.setFieldValue(platEmployeeTypeFlow, mapField, list, 4, PlatEmployeeTypeFlow::setVisitNum, Long.class);
+            String key = weekList.get(i);
+            Map<String, Object> mapJson = StringUtils.getListToMap(mapField.get(key).toString());
+            StringUtils.setFieldValue(platEmployeeTypeFlow, mapJson, list, 0, PlatEmployeeTypeFlow::setInsideNum, Long.class);
+            StringUtils.setFieldValue(platEmployeeTypeFlow, mapJson, list, 1, PlatEmployeeTypeFlow::setLoanNum, Long.class);
+            StringUtils.setFieldValue(platEmployeeTypeFlow, mapJson, list, 2, PlatEmployeeTypeFlow::setAssociationNum, Long.class);
+            StringUtils.setFieldValue(platEmployeeTypeFlow, mapJson, list, 3, PlatEmployeeTypeFlow::setPropertyNum, Long.class);
+            StringUtils.setFieldValue(platEmployeeTypeFlow, mapJson, list, 4, PlatEmployeeTypeFlow::setVisitNum, Long.class);
             addList.add(platEmployeeTypeFlow);
         }
         this.saveBatch(addList);