|
@@ -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";
|