Browse Source

获取用户计划数量除去已转移计划;转移计划同意后重复复制线修改;点到位及设备更新完成率更新改为异步

pra 4 years ago
parent
commit
768225d6a8

+ 1 - 0
.idea/workspace.xml

@@ -72,6 +72,7 @@
     <property name="project.structure.last.edited" value="Modules" />
     <property name="project.structure.proportion" value="0.15" />
     <property name="project.structure.side.proportion" value="0.0" />
+    <property name="dynamic.classpath" value="true" />
   </component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">

+ 1 - 1
src/main/java/com/tofly/dyrq/custom/service/CustomPointService.java

@@ -15,6 +15,6 @@ public interface CustomPointService {
      */
     public Map<String,Long> updatePointOrPathIsover(List<UpdatePoint> updatePoints);
 
-    Boolean percentUpdate(Long childPlanId);
+    void percentUpdate(String childPlanIds);
 
 }

+ 19 - 3
src/main/java/com/tofly/dyrq/custom/service/impl/CustomMaintenanceServiceImpl.java

@@ -25,6 +25,7 @@ import com.tofly.dyrq.entity.*;
 import com.tofly.dyrq.config.FilePathBean;
 import com.tofly.dyrq.service.*;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.MultiValueMap;
@@ -33,6 +34,8 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.stream.Collectors;
 
 @AllArgsConstructor
@@ -178,8 +181,14 @@ public class CustomMaintenanceServiceImpl implements CustomMaintenanceService {
                 }
             });
         });
-        //更新到位比例
-        customPointService.percentUpdate(childPlanId);
+        //异步更新到位比例
+        ExecutorService executorService = Executors.newSingleThreadExecutor();
+        executorService.execute(new Runnable() {
+            @Override
+            public void run() {
+                customPointService.percentUpdate(childPlanId.toString());
+            }
+        });
         return true;
     }
 
@@ -390,7 +399,14 @@ public class CustomMaintenanceServiceImpl implements CustomMaintenanceService {
             });
         });
         //更新到位比例
-        customPointService.percentUpdate(childPlanId);
+        //异步更新到位比例
+        ExecutorService executorService = Executors.newSingleThreadExecutor();
+        executorService.execute(new Runnable() {
+            @Override
+            public void run() {
+                customPointService.percentUpdate(childPlanId.toString());
+            }
+        });
         return true;
     }
 

+ 3 - 1
src/main/java/com/tofly/dyrq/custom/service/impl/CustomPlanServiceImpl.java

@@ -561,6 +561,7 @@ public class CustomPlanServiceImpl implements CustomPlanService {
                         .getType();
                 List<PlanPointTemp> pointTemps = planPointTempService.list(Wrappers.<PlanPointTemp>lambdaQuery().eq(PlanPointTemp::getChildPlanId, childPlanId));
                 for (PlanPointTemp t : pointTemps) {
+                    Long pointId = t.getId();
                     t.setPlanId(planChild.getMainPlanId());
                     t.setChildPlanId(planChild.getId());
                     t.setUserId(checkTransferPlan.getReplaceUserid());
@@ -570,7 +571,8 @@ public class CustomPlanServiceImpl implements CustomPlanService {
                     transfer_tf_plan_point_tempId++;
                     pointTempList.add(t);
                     if ("1".equals(type)) {
-                        List<TfPlanPathTemp> tfPlanPathTemps = planPathTempService.list(Wrappers.<TfPlanPathTemp>lambdaQuery().eq(TfPlanPathTemp::getChildPlanId, childPlanId));
+                        List<TfPlanPathTemp> tfPlanPathTemps = planPathTempService.list(Wrappers.<TfPlanPathTemp>lambdaQuery()
+                                .eq(TfPlanPathTemp::getChildPlanId, childPlanId).eq(TfPlanPathTemp::getTempId,pointId));
                         for (TfPlanPathTemp ppt : tfPlanPathTemps) {
                             //tempId为Piont_temp的ID
                             ppt.setTempId(t.getId());

+ 20 - 11
src/main/java/com/tofly/dyrq/custom/service/impl/CustomPointServiceImpl.java

@@ -15,11 +15,14 @@ import com.tofly.dyrq.service.PlanPointTempService;
 import com.tofly.dyrq.service.SysDeviceTypeService;
 import com.tofly.dyrq.service.TfPlanPathTempService;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.stream.Collectors;
 
 @Service
@@ -34,8 +37,8 @@ public class CustomPointServiceImpl implements CustomPointService {
     private final SysDeviceTypeService sysDeviceTypeService;
 
     @Override
-    public Map<String,Long> updatePointOrPathIsover(List<UpdatePoint> updatePoints) {
-        Map<String,Long> transfer = new HashMap<>();
+    public Map<String, Long> updatePointOrPathIsover(List<UpdatePoint> updatePoints) {
+        Map<String, Long> transfer = new HashMap<>();
         List<Long> childList = new ArrayList<>();
         HashSet<Long> childIds = new HashSet();
         for (UpdatePoint u : updatePoints) {
@@ -43,7 +46,7 @@ public class CustomPointServiceImpl implements CustomPointService {
                 if ("0".equals(u.getType())) {
                     String pointChildPlanState = customPointMapper.getStateByPointId(u.getTempId());
                     if ("7".equals(pointChildPlanState)) {
-                        transfer.put("pointTempId",u.getTempId());
+                        transfer.put("pointTempId", u.getTempId());
                         continue;
                     }
                     planPointTempService.update(Wrappers.<PlanPointTemp>lambdaUpdate()
@@ -54,7 +57,7 @@ public class CustomPointServiceImpl implements CustomPointService {
                 } else if ("1".equals(u.getType())) {
                     String childPlanState = customPointMapper.getStateByPath(u.getTempId());
                     if ("7".equals(childPlanState)) {
-                        transfer.put("pathTempId",u.getTempId());
+                        transfer.put("pathTempId", u.getTempId());
                         continue;
                     } else {
                         if (!childList.contains(u.getPlanChildId())) {
@@ -71,9 +74,14 @@ public class CustomPointServiceImpl implements CustomPointService {
             childIds.add(u.getPlanChildId());
         }
         //批量更新所有计划点,线完成率
-        for (Long childId :childIds){
-            this.percentUpdate(childId);
-        }
+        ExecutorService executorService = Executors.newSingleThreadExecutor();
+        executorService.execute(new Runnable() {
+            @Override
+            public void run() {
+                String ids = StringUtils.join(childIds, ",");
+                percentUpdate(ids);
+            }
+        });
 //        for (Long cid : childList) {
 //            Double percent = (double) planPathTempService.list(Wrappers.<TfPlanPathTemp>lambdaQuery().eq(TfPlanPathTemp::getChildPlanId, cid).eq(TfPlanPathTemp::getIsover, 1)).size()
 //                    / (double) planPathTempService.list(Wrappers.<TfPlanPathTemp>lambdaQuery().eq(TfPlanPathTemp::getChildPlanId, cid)).size();
@@ -90,7 +98,10 @@ public class CustomPointServiceImpl implements CustomPointService {
     }
 
     @Override
-    public Boolean percentUpdate(Long childPlanId){
+    public void percentUpdate(String childPlanIds) {
+        List<String> list = Arrays.asList(childPlanIds.split(","));
+        for (String sid : list) {
+            Long childPlanId = Long.parseLong(sid);
             Date now = Date8Util.getCurrentDate();
             //查询当天的计划
             Map param1 = new HashMap();
@@ -179,9 +190,7 @@ public class CustomPointServiceImpl implements CustomPointService {
             //更新计划状态 完成进度percent1为1 计划变成完成状态
             planChildService.update(Wrappers.<PlanChild>lambdaUpdate().set(PlanChild::getChildPlanState, "3")
                     .eq(PlanChild::getPercent1, 1).eq(PlanChild::getId, childPlanId));
-            return true;
         }
-
-
+    }
 
 }

+ 2 - 4
src/main/resources/customMapper/CustomPlanMapper.xml

@@ -396,8 +396,8 @@
 
     <!-- 获取用户计划数量 -->
     <select id="getPointNum" resultType="java.util.Map">
-        select a.id planChildId,a.point_num from tf_plan_child a left join tf_plan b on a.main_plan_id=b.id where
-        a.user_id = #{pointNumSearch.userId}
+        <![CDATA[select a.id planChildId,a.point_num from tf_plan_child a left join tf_plan b on a.main_plan_id=b.id where
+        a.user_id = #{pointNumSearch.userId} and a.child_plan_state <> 7  ]]>
         <if test="pointNumSearch.searchTime != null">
             <![CDATA[   and a.child_begin_date <= #{pointNumSearch.searchTime} and #{pointNumSearch.searchTime} <= a.child_end_date  ]]>
         </if>
@@ -559,8 +559,6 @@
             from
             tf_plan_child a left join
             tf_plan_point_temp b on a.id=b.child_plan_id
-            left join tf_plan_path_temp c
-            on b.id = c.temp_id
             left join tf_plan_point_type d
             on b.device_type_id = d.id
             left join tf_plan e on a.main_plan_id=e.id