Browse Source

安装BUG

lin 4 years ago
parent
commit
6215c35131

+ 9 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/InstallController.java

@@ -189,6 +189,15 @@ public class InstallController {
     	
     	return new AjaxMessage<>(ResultStatus.OK);
     }
+
+	@DeleteMapping("/batchDelete")
+	@ApiOperation(value = "批量删除水表接口")
+	public AjaxMessage batchInstallDelete(
+			@ApiParam(value = "安装主键,多个英文逗号隔开", required = true) @RequestParam(required = true) List<Integer> installIds
+	) {
+		String msg =  installManagerService.batchInstallDelete(installIds);
+		return new AjaxMessage<>(0,msg,null);
+	}
    
 	@GetMapping("getInstallPage")
 	@ApiOperation(value = "查询已装水表分页")

+ 4 - 1
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/InstallResolverExcelTemplate.java

@@ -251,12 +251,15 @@ public class InstallResolverExcelTemplate extends AbstractResolverExcelTemplate
                             successTime.incrementAndGet();
                         }else {
                             failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.DELETE_AND_DOOR_EXISTED.getMessage());
+                            //remarkCell.setCellValue(ResultStatus.DELETE_AND_DOOR_EXISTED.getMessage());
                         }
                     } catch (ServiceException e){
                         if(e.getStatus() == ResultStatus.DEVICE_NO_IS_EXISTED.getStatus()){
                             failTime.incrementAndGet();
                             remarkCell.setCellValue(e.getMessage());
+                        }else if(e.getStatus() == ResultStatus.DELETE_AND_DOOR_EXISTED.getStatus()){
+                            failTime.incrementAndGet();
+                            remarkCell.setCellValue(ResultStatus.DELETE_AND_DOOR_EXISTED.getMessage());
                         }else {
                             failTime.incrementAndGet();
                         }

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/assistant/InstallManagerService.java

@@ -100,4 +100,5 @@ public interface InstallManagerService {
 	List<Integer> queryFloorList(Integer buildingId);
 
 
+    String batchInstallDelete(List<Integer> installIds);
 }

+ 79 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/InstallManagerServiceImpl.java

@@ -10,6 +10,7 @@ import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.annotation.Resource;
 
@@ -228,6 +229,7 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 	}
 
 	@Override
+    @Deprecated
 	public int importInstallList(InstallListDTO dto, MultipartFile file) {
 		log.info("begin InstallManagerService importInstallList!");
 		Integer siteId = dto.getSiteId();		
@@ -529,6 +531,58 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 		log.info("end InstallManagerService deletelInstallInfo ,result = {}",isSuccess);
 		return isSuccess;
 	}
+	@Transactional
+	public boolean deletelInstallInfoV2(Integer installId ){
+		log.info("begin InstallManagerService deletelInstallInfoV2 ,request dto = {}",installId);
+		boolean isSuccess = false ;
+		InstallListDTO  dto = new InstallListDTO();
+		dto.setId(installId);
+		InstallList install = installListMapper.findById(installId);
+		if(install == null ) {
+			throw new ServiceException(ResultStatus.LACK_NECESSARY_PARAM);
+		}
+		Device deviceTemp = deviceMapper.findByDeviceId(install.getDeviceId());
+		dto.setDeviceId(deviceTemp.getId());
+//		InstallList originalDto =  dtoList.get(0);
+//		dto.setDeviceId(originalDto.getDeviceId());
+		Device device = new Device();
+		device.setId(install.getDeviceId());
+		device.setStatus(0);
+		device.setUpdateBy(UserUtil.getCurrentUser().getUsername());
+		// 2.判断是否计划内安装,计划内安装保留计划删除设备,计划外则删除安装计划以及设备
+		if(install.getIsInPlan() == 1) { // 计划内
+			install.setIsInstalled(0); // 设置为未安装
+			install.setDeviceNo(null); // 清除安装记录
+			install.setDeviceId(null);
+			install.setElectronicNo(null);
+			install.setFileNo(null);
+			install.setFileNo(null);
+			install.setDeviceTypeId(null);
+			install.setImageUrl(null);
+			install.setNewMeterStart(null);
+			install.setOldMeterEnd(null);
+			install.setOldImageUrl(null);
+			install.setInstallTime(null);
+			install.setUpdateBy(UserUtil.getCurrentUser().getUsername());
+			installListMapper.updateByPrimaryKey(install);
+		}
+		else { // 计划外
+			dto.setStatus(0);
+			installListMapper.updateByPrimaryKeySelective(dto);
+		}
+		// 3.删除设备
+		deviceMapper.updateByPrimaryKeySelective(device);
+		// 4.删除设备维度信息
+		deviceDimInfoMapper.delByDeviceId(device.getId(), UserUtil.getCurrentUser().getUsername());
+		// 5.保存操作日志
+		genrateInstallLog(dto, InstallAction.DELETE, "");
+		// 6、删除udip平台集成元
+
+		udipUnitService.deleteUdipUnit(deviceTemp.getUdipId());
+		isSuccess = true;
+		log.info("end InstallManagerService deletelInstallInfoV2 ,result = {}",isSuccess);
+		return isSuccess;
+	}
 
 	@Override
 	@Transactional
@@ -713,8 +767,8 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 		dto.setIsAccepted(0);
 		List<InstallListDTO> installList = installListMapper.queryInstallList(condition);
 		if(installList != null && installList.size() != 0 && StringUtils.isNoneBlank(installList.get(0).getDeviceNo())) {
-			//throw new ServiceException(ResultStatus.DELETE_AND_DOOR_EXISTED);
-			return isSuccess;
+			throw new ServiceException(ResultStatus.DELETE_AND_DOOR_EXISTED);
+			//return isSuccess;
 		}
 		if(installList != null && installList.size() != 0 ) { // 计划内安装
 			dto.setIsInPlan(1); //  1 计划内 0 计划外
@@ -978,6 +1032,29 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 		}
 	}
 
+	@Override
+	public String batchInstallDelete(List<Integer> installIds) {
+		log.info("begin batchInstallDelete installIds = {}",JSON.toJSONString(installIds));
+		AtomicInteger count = new AtomicInteger(0);
+		AtomicInteger failCount = new AtomicInteger(0);
+		if (installIds != null && installIds.size() > 0) {
+			for (Integer installId : installIds) {
+				try {
+					if(deletelInstallInfoV2(installId)){
+						count.incrementAndGet();
+					}else {
+						failCount.incrementAndGet();
+					}
+				}catch (Exception e){
+					failCount.incrementAndGet();
+				}
+
+			}
+		}
+		String msg = "成功"+count.get()+"条 失败"+failCount.get()+"条";
+		return msg;
+	}
+
 	protected String getFilePath() {
         String name = Util.createUUIDId();
         String fullPath = filesPath + "/" + name + ".xlsm";

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/UdipUnitService.java

@@ -117,7 +117,7 @@ public class UdipUnitService {
                     throw new ServiceException(-900, jsonObject.getString("msg"));
                 }
             } catch (IOException e) {
-                throw new ServiceException(-900, "新增集成元错误");
+                throw new ServiceException(-900, "删除集成元错误");
             }
         }
     }

+ 1 - 0
smart-city-platform/src/main/resources/mapper/InstallListMapper.xml

@@ -515,6 +515,7 @@
         <if test="floor != null">
             and n.floor = #{floor}
         </if>
+        order by n.date_create desc
 	</select>
 	<select id="queryPlanBuildingList" resultType="com.bz.smart_city.dto.assistant.PlanBuildingDTO">
 		SELECT