Jelajahi Sumber

安装计划

lin 3 tahun lalu
induk
melakukan
32b0e233e0

+ 3 - 1
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/InstallListMapper.java

@@ -37,5 +37,7 @@ public interface InstallListMapper {
 
     int delete(@Param("ids") List<Integer> ids);
 
-    int deleteByDeviceId(@Param("ids") List<Long> ids);
+    int deleteByDeviceId(@Param("deviceId") List<Long> deviceId);
+
+    Integer findPlanId(@Param("ids")List<Integer> ids);
 }

+ 4 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/InstallPlanMapper.java

@@ -31,4 +31,8 @@ public interface InstallPlanMapper {
     StatisticsDeviceStatusVo totalDeviceStatus(@Param("planId") Integer planId);
 
     InstallDetailDto findDetail(@Param("planId")Integer planId);
+
+    int updatePlanStatus(@Param("planId")Integer planId);
+
+    int updateAcceptStatus(@Param("planId")Integer planId);
 }

+ 7 - 1
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/InstallListMapper.xml

@@ -334,6 +334,12 @@
     device_id=null,
     update_date=now()
     WHERE `status` = 1
-    and device_id in <foreach collection="ids" item="item" open="(" separator="," close=")">#{item}</foreach>
+    and device_id in <foreach collection="deviceId" item="item" open="(" separator="," close=")">#{item}</foreach>
   </update>
+
+  <select id="findPlanId" resultType="java.lang.Integer">
+    select install_plan_id from rmcp_install_list
+    WHERE `status` = 1
+    and id in <foreach collection="ids" item="item" open="(" separator="," close=")">#{item}</foreach> limit 1
+  </select>
 </mapper>

+ 12 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/InstallPlanMapper.xml

@@ -392,4 +392,16 @@
       left join rmcp_area a3 on a3.id = rc.region
     where rip.status = 1 and rip.id = #{planId}
   </select>
+
+  <update id="updatePlanStatus">
+    update rmcp_install_plan  set plan_status = 1 ,update_date = NOW()
+    WHERE id = #{planId}
+    and door_num = (SELECT count(1) FROM rmcp_install_list WHERE install_plan_id =  #{planId} and is_installed = 1)
+  </update>
+
+  <update id="updateAcceptStatus">
+    update rmcp_install_plan set accept_status = 1 ,update_date = NOW()
+    WHERE id = #{planId}
+    and door_num = (SELECT count(1) FROM rmcp_install_list WHERE install_plan_id =  #{planId} and is_accepted = 1)
+  </update>
 </mapper>

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/InstallController.java

@@ -71,7 +71,7 @@ public class InstallController {
     @ApiOperation(value = "下载装表模板", notes = "下载装表模板")
     public void downInstallMeterTemplate(
             @ApiParam(value = "安装计划id", required = true) @RequestParam(required = true) Integer planId,
-            @ApiParam(value = "access_token", required = true) @RequestParam(required = true) String accessToken,
+            @ApiParam(value = "access_token", required = true) @RequestParam(required = true) String access_token,
             HttpServletRequest request, HttpServletResponse response
     ) {
         installPlanService.downInstallMeterTemplate(planId, response);

+ 1 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/model/ExcelData.java

@@ -17,6 +17,7 @@ import static com.google.common.collect.Lists.newArrayList;
  */
 @Data
 public class ExcelData {
+    private Integer planId;
     private ImportFile importFile;
     private InstallPlan installPlan;
     private AtomicInteger successNum = new AtomicInteger(0);

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/excel/resolver/listener/InstallImportListener.java

@@ -33,7 +33,6 @@ public class InstallImportListener extends AnalysisEventListener<InstallMeterDat
     }
     @Override
     public void invoke(InstallMeterData data, AnalysisContext analysisContext) {
-        System.out.println(data);
         if (
                 data.getId() == null ||
                         data.getDoorNo() == null || data.getMeterNo() == null
@@ -57,6 +56,7 @@ public class InstallImportListener extends AnalysisEventListener<InstallMeterDat
     @Override
     public void doAfterAllAnalysed(AnalysisContext analysisContext) {
         log.info("批量导出设备完成 successNum = {},failNum = {}",excelData.getSuccessNum().get(),excelData.getFailNum().get());
+        installListService.updatePlanStatus(excelData.getPlanId());
     }
 
     public List<InstallMeterData> getData(){

+ 8 - 0
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/install/InstallListService.java

@@ -98,4 +98,12 @@ public interface InstallListService{
      * @author linqingwei
      **/
     void allDelete(InstallQueryDto dto);
+
+    /**
+     * @description 更新计划状态
+     * @param planId
+     * @return
+     * @author linqingwei
+     **/
+    void updatePlanStatus(Integer planId);
 }

+ 18 - 2
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/service/install/impl/InstallListServiceImpl.java

@@ -87,6 +87,7 @@ public class InstallListServiceImpl implements InstallListService {
         if (deviceMapper.findByMeterNoUnique(dto.getDeviceId(), dto.getMeterNo()) > 0) {
             throw BusinessException.builder(RmcpErrorEnum.RMCP_METER_NO_UNIQUE_ERROR);
         }
+        InstallList install = installListMapper.findById(dto.getId());
         if (dto.getDeviceId() != null) {
             //更新设备
             Device update = new Device();
@@ -111,7 +112,7 @@ public class InstallListServiceImpl implements InstallListService {
             installList.setDeviceId(dto.getDeviceId());
             this.updateByPrimaryKeySelective(installList);
         }else {
-            InstallList install = installListMapper.findById(dto.getId());
+
             InstallPlan installPlan = installPlanMapper.findById(install.getInstallPlanId());
             Product product = productMapper.findById(installPlan.getProductId());
             Device device = new Device();
@@ -145,6 +146,8 @@ public class InstallListServiceImpl implements InstallListService {
             installList.setDeviceId(device.getId());
             this.updateByPrimaryKeySelective(installList);
         }
+        //更新安装计划状态
+        installPlanMapper.updatePlanStatus(install.getInstallPlanId());
         log.info("end installSave");
     }
 
@@ -276,7 +279,11 @@ public class InstallListServiceImpl implements InstallListService {
         installList.setIsInstalled(1);
         installList.setDeviceId(device.getId());
         this.updateByPrimaryKeySelective(installList);
-        return null;
+
+        excelData.setPlanId(install.getInstallPlanId());
+
+        resultMessage.setStatus(true);
+        return resultMessage;
     }
 
     @Override
@@ -284,6 +291,8 @@ public class InstallListServiceImpl implements InstallListService {
     public void batchAccept(List<Integer> ids) {
         log.info("begin InstallListServiceImpl batchAccept ids = {}",JSON.toJSONString(ids));
         installListMapper.accept(ids);
+        Integer planId = installListMapper.findPlanId(ids);
+        installPlanMapper.updateAcceptStatus(planId);
         log.info("end InstallListServiceImpl batchAccept ");
     }
 
@@ -323,4 +332,11 @@ public class InstallListServiceImpl implements InstallListService {
         }
         log.info("end InstallListServiceImpl allDelete ");
     }
+
+    @Override
+    public void updatePlanStatus(Integer planId) {
+        log.info("begin InstallListServiceImpl updatePlanStatus planId = {}",JSON.toJSONString(planId));
+        installPlanMapper.updatePlanStatus(planId);
+        log.info("end InstallListServiceImpl updatePlanStatus");
+    }
 }