|
@@ -92,9 +92,9 @@ public class InstallPlanServiceImpl implements InstallPlanService {
|
|
|
@Override
|
|
|
public int insertSelective(InstallPlan record) {
|
|
|
record.setStatus(1);
|
|
|
- record.setCreateBy(UserUtil.getCurrentUser().getUsername());
|
|
|
+ record.setCreateBy("system");
|
|
|
record.setDateCreate(LocalDateTime.now());
|
|
|
- record.setUpdateBy(UserUtil.getCurrentUser().getUsername());
|
|
|
+ record.setUpdateBy("system");
|
|
|
record.setDateUpdate(LocalDateTime.now());
|
|
|
return installPlanMapper.insertSelective(record);
|
|
|
}
|
|
@@ -102,7 +102,7 @@ public class InstallPlanServiceImpl implements InstallPlanService {
|
|
|
|
|
|
@Override
|
|
|
public int updateByPrimaryKeySelective(InstallPlan record) {
|
|
|
- record.setUpdateBy(UserUtil.getCurrentUser().getUsername());
|
|
|
+ record.setUpdateBy("system");
|
|
|
record.setDateUpdate(LocalDateTime.now());
|
|
|
return installPlanMapper.updateByPrimaryKeySelective(record);
|
|
|
}
|
|
@@ -342,6 +342,208 @@ public class InstallPlanServiceImpl implements InstallPlanService {
|
|
|
log.info("end add InstallPlan");
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void syncPlan(InstallPlanInputDTO installPlanInput) {
|
|
|
+ log.info("begin add InstallPlan : " + JSON.toJSONString(installPlanInput));
|
|
|
+
|
|
|
+ Integer siteId = 1;
|
|
|
+
|
|
|
+ //1、小区
|
|
|
+ if (installPlanInput.getCommunityId() == null) {
|
|
|
+ //Community community = communityService.findByName(siteId, installPlanInput.getCommunityName());
|
|
|
+ Community community = communityService.findByNameV2(siteId,installPlanInput.getProvince(),installPlanInput.getCity(),installPlanInput.getRegion(), installPlanInput.getCommunityName());
|
|
|
+ if (community != null) {
|
|
|
+ installPlanInput.setCommunityId(community.getId());
|
|
|
+ Community TempCommunity = new Community();
|
|
|
+ TempCommunity.setId(community.getId());
|
|
|
+ TempCommunity.setAddress(installPlanInput.getAdrress());
|
|
|
+ communityService.updateByPrimaryKeySelective(TempCommunity);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ //获取小区最大值,然后加1
|
|
|
+ String code="001";
|
|
|
+ List<Community> communities = communityService.getMaxCodeBySiteId(siteId);
|
|
|
+ if(communities.size()==1)
|
|
|
+ {
|
|
|
+ if (communities.get(0) != null) {
|
|
|
+ code =String.format("%03d",Integer.valueOf(communities.get(0).getCode()));
|
|
|
+ }else {
|
|
|
+ code = String.format("%03d",Integer.valueOf("1"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Community newCommunity = new Community();
|
|
|
+ newCommunity.setCode(code);
|
|
|
+ newCommunity.setSiteId(siteId);
|
|
|
+ newCommunity.setName(installPlanInput.getCommunityName());
|
|
|
+ newCommunity.setProvince(installPlanInput.getProvince());
|
|
|
+ newCommunity.setCity(installPlanInput.getCity());
|
|
|
+ newCommunity.setRegion(installPlanInput.getRegion());
|
|
|
+ newCommunity.setAddress(installPlanInput.getAdrress());
|
|
|
+ newCommunity.setCustomerId(installPlanInput.getCustomerId());
|
|
|
+ newCommunity.setStatus(1);
|
|
|
+ communityService.insert(newCommunity);
|
|
|
+ installPlanInput.setCommunityId(newCommunity.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ installPlanInput.setSiteId(siteId);
|
|
|
+ installPlanInput.setEnableDownload(0);
|
|
|
+ this.insertSelective(installPlanInput);
|
|
|
+
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
+ //3、添加批次
|
|
|
+ InstallBatch installBatch = new InstallBatch();
|
|
|
+ installBatch.setSiteId(siteId);
|
|
|
+ installBatch.setBatchName(LocalDate.now().format(df));
|
|
|
+ installBatch.setBatchDate(Integer.valueOf(LocalDate.now().format(df)));
|
|
|
+ installBatch.setRelatedPlanId(installPlanInput.getId());
|
|
|
+ installBatch.setBatchStatus(0);
|
|
|
+ installBatchService.insertSelective(installBatch);
|
|
|
+
|
|
|
+ //4、添加水表设备类型
|
|
|
+ List<InstallPlanDeviceType> installPlanDeviceTypeList = newArrayList();
|
|
|
+ if (installPlanInput.getDeviceTypeIds() != null && installPlanInput.getDeviceTypeIds().size() > 0) {
|
|
|
+ for (Integer deviceTypeId : installPlanInput.getDeviceTypeIds()) {
|
|
|
+ InstallPlanDeviceType planDeviceType = new InstallPlanDeviceType();
|
|
|
+ planDeviceType.setInstallPlanId(installPlanInput.getId());
|
|
|
+ planDeviceType.setDeviceTypeId(deviceTypeId);
|
|
|
+ planDeviceType.setStatus(1);
|
|
|
+ planDeviceType.setCreateBy("admin");
|
|
|
+ planDeviceType.setDateCreate(LocalDateTime.now());
|
|
|
+ planDeviceType.setUpdateBy("admin");
|
|
|
+ planDeviceType.setDateUpdate(LocalDateTime.now());
|
|
|
+ installPlanDeviceTypeList.add(planDeviceType);
|
|
|
+ }
|
|
|
+ installPlanDeviceTypeMapper.batchInsert(installPlanDeviceTypeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //5、添加计划清单列表
|
|
|
+ //楼栋
|
|
|
+ int installPlanBuildingNum = 0;
|
|
|
+ int installPlanUnitNum = 0;
|
|
|
+ if (installPlanInput.getInstallPlanDataList() != null && installPlanInput.getInstallPlanDataList().size() > 0) {
|
|
|
+ List<InstallList> installLists = newArrayList();
|
|
|
+ List<InstallPlanData> installPlanDataList = newArrayList();
|
|
|
+ for (InstallPlanDataDTO installPlanBuilding : installPlanInput.getInstallPlanDataList()) {
|
|
|
+ installPlanBuildingNum++;
|
|
|
+ InstallPlanData InstallPlanDataBuilding = new InstallPlanData();
|
|
|
+ InstallPlanDataBuilding.setId(idWorker.nextId());
|
|
|
+ InstallPlanDataBuilding.setName(installPlanBuilding.getName() + "栋");
|
|
|
+ InstallPlanDataBuilding.setParentId(0L);
|
|
|
+ InstallPlanDataBuilding.setInstallPlanId(installPlanInput.getId());
|
|
|
+ InstallPlanDataBuilding.setType(1);
|
|
|
+ InstallPlanDataBuilding.setStatus(1);
|
|
|
+ installPlanDataList.add(InstallPlanDataBuilding);
|
|
|
+ //单元
|
|
|
+ if (installPlanBuilding.getChildren() != null && installPlanBuilding.getChildren().size() > 0) {
|
|
|
+ for (InstallPlanDataDTO installPlanUnit : installPlanBuilding.getChildren()) {
|
|
|
+
|
|
|
+ //判断是否启动单元
|
|
|
+ String buildingName = "";
|
|
|
+ if (installPlanInput.getEnableUnit() == 1) {
|
|
|
+ installPlanUnitNum++;
|
|
|
+ buildingName = installPlanInput.getCommunityName() + installPlanBuilding.getName() + "栋" + installPlanUnit.getName() + "单元";
|
|
|
+ } else {
|
|
|
+ buildingName = installPlanInput.getCommunityName() + installPlanBuilding.getName() + "栋";
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断建筑是否存在
|
|
|
+ Building building = buildingService.findByName(siteId, buildingName);
|
|
|
+ Integer buildingId = null;
|
|
|
+ if (building != null) {
|
|
|
+ buildingId = building.getId();
|
|
|
+ } else {
|
|
|
+ Building newBuilding = new Building();
|
|
|
+ newBuilding.setSiteId(siteId);
|
|
|
+ newBuilding.setName(buildingName);
|
|
|
+ newBuilding.setProvince(installPlanInput.getProvince());
|
|
|
+ newBuilding.setCity(installPlanInput.getCity());
|
|
|
+ newBuilding.setRegion(installPlanInput.getRegion());
|
|
|
+ newBuilding.setCommunity(installPlanInput.getCommunityId());
|
|
|
+ newBuilding.setAddress(installPlanInput.getAdrress());
|
|
|
+ newBuilding.setStatus(1);
|
|
|
+ buildingService.insert(newBuilding);
|
|
|
+ buildingId = newBuilding.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ InstallPlanData InstallPlanDataUnit = new InstallPlanData();
|
|
|
+ InstallPlanDataUnit.setName(installPlanUnit.getName() != null ? installPlanUnit.getName() + "单元" : "");
|
|
|
+ InstallPlanDataUnit.setId(idWorker.nextId());
|
|
|
+ InstallPlanDataUnit.setParentId(InstallPlanDataBuilding.getId());
|
|
|
+ InstallPlanDataUnit.setInstallPlanId(installPlanInput.getId());
|
|
|
+ InstallPlanDataUnit.setType(2);
|
|
|
+ InstallPlanDataUnit.setStatus(1);
|
|
|
+ installPlanDataList.add(InstallPlanDataUnit);
|
|
|
+
|
|
|
+ //安装楼层
|
|
|
+ if (installPlanUnit.getChildren() != null && installPlanUnit.getChildren().size() > 0) {
|
|
|
+ for (InstallPlanDataDTO installPlanFloor : installPlanUnit.getChildren()) {
|
|
|
+ InstallPlanData InstallPlanDataFloor = new InstallPlanData();
|
|
|
+ InstallPlanDataFloor.setName(installPlanFloor.getName() + "层");
|
|
|
+ InstallPlanDataFloor.setId(idWorker.nextId());
|
|
|
+ InstallPlanDataFloor.setParentId(InstallPlanDataUnit.getId());
|
|
|
+ InstallPlanDataFloor.setInstallPlanId(installPlanInput.getId());
|
|
|
+ InstallPlanDataFloor.setType(3);
|
|
|
+ InstallPlanDataFloor.setStatus(1);
|
|
|
+ installPlanDataList.add(InstallPlanDataFloor);
|
|
|
+ //安装清单
|
|
|
+ if (installPlanFloor.getChildren() != null && installPlanFloor.getChildren().size() > 0) {
|
|
|
+ for (InstallPlanDataDTO installPlanDoor : installPlanFloor.getChildren()) {
|
|
|
+ InstallList installList = new InstallList();
|
|
|
+ installList.setSiteId(siteId);
|
|
|
+ installList.setInstallPlanId(installPlanInput.getId());
|
|
|
+ installList.setInstallPlanDataId(InstallPlanDataFloor.getId());
|
|
|
+ installList.setBuildingId(buildingId);
|
|
|
+ installList.setDoorNo(installPlanDoor.getName());
|
|
|
+ installList.setDeviceTypeId(installPlanInput.getDeviceTypeId());
|
|
|
+ installList.setCustomerId(installPlanInput.getCustomerId());
|
|
|
+ installList.setIsInPlan(1);
|
|
|
+ installList.setIsInstalled(0);
|
|
|
+ installList.setIsAccepted(0);
|
|
|
+ installList.setIntallBatchId(installBatch.getId());
|
|
|
+ try {
|
|
|
+ installList.setFloor(Integer.valueOf(installPlanFloor.getName()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info(installPlanFloor.getName() + "楼层转换错误");
|
|
|
+ }
|
|
|
+ installList.setStatus(1);
|
|
|
+ installList.setCreateBy("admin");
|
|
|
+ installList.setDateCreate(LocalDateTime.now());
|
|
|
+ installList.setUpdateBy("admin");
|
|
|
+ installList.setDateUpdate(LocalDateTime.now());
|
|
|
+
|
|
|
+ installLists.add(installList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ installListMapper.batchInsert(installLists);
|
|
|
+ installPlanDataMapper.batchInsert(installPlanDataList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新数量
|
|
|
+ InstallPlan updateInstallPlan = new InstallPlan();
|
|
|
+ updateInstallPlan.setId(installPlanInput.getId());
|
|
|
+ updateInstallPlan.setBuildingNumber(installPlanBuildingNum);
|
|
|
+ updateInstallPlan.setUnitNumber(installPlanUnitNum);
|
|
|
+ this.updateByPrimaryKeySelective(updateInstallPlan);
|
|
|
+
|
|
|
+
|
|
|
+ //异步生成压缩文件
|
|
|
+ InstallPlanDTO installPlan = installPlanMapper.findById(installPlanInput.getId());
|
|
|
+ asyncInstallPlanDownloadTask.asyncTaskToZip(null, installPlan);
|
|
|
+ log.info("end add InstallPlan");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void addJF(InstallPlanInputDTO installPlanInput) {
|