Commit 420161b7 authored by suhuiguang's avatar suhuiguang

1.机场特殊需求校验一些已经使用的iotCODE

parent 6da481b5
...@@ -145,6 +145,9 @@ public class CarController extends AbstractBaseController { ...@@ -145,6 +145,9 @@ public class CarController extends AbstractBaseController {
@Autowired @Autowired
FireFightingSystemServiceImpl fireFightingSystemServiceImpl; FireFightingSystemServiceImpl fireFightingSystemServiceImpl;
@Value("${iot.code.prefix.have.used:20210003,20210004,20210005}")
private String haveUsedIotPrefix;
/** /**
* 新增消防车信息 * 新增消防车信息
* *
...@@ -166,21 +169,17 @@ public class CarController extends AbstractBaseController { ...@@ -166,21 +169,17 @@ public class CarController extends AbstractBaseController {
// saveFile(carInstance); 图片视频后期统一处理 // saveFile(carInstance); 图片视频后期统一处理
//验证车辆code唯一性 // 验证车辆code唯一性
if(car.getIotCode()!=null){ String iotCode = car.getIotCode();
if(StringUtils.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())){
Car ar= carMapper.getCarsByIotCode(car.getIotCode()); Car ar= carMapper.getCarsByIotCode(car.getIotCode());
if(ar!=null){ if(ar!=null){
throw new BadRequest("物联编码重复"); throw new BadRequest("物联编码重复");
} }
if(car.getIotCode().startsWith("20210003")||car.getIotCode().startsWith("20210004")||car.getIotCode().startsWith("20210005")){ if(StringUtils.isNotEmpty(haveUsedIotPrefix) && Arrays.stream(haveUsedIotPrefix.split(",")).anyMatch(iotCode::startsWith)){
throw new BadRequest("物联编码航班已占用"); throw new BadRequest("物联编码航班已占用");
} }
} }
car.setQrCode(QRCodeUtil.generateQRCode()); car.setQrCode(QRCodeUtil.generateQRCode());
List<CarProperty> carPropertyList = car.getCarPropertyList(); List<CarProperty> carPropertyList = car.getCarPropertyList();
if (carPropertyList.size() > 0) { if (carPropertyList.size() > 0) {
...@@ -310,14 +309,13 @@ public class CarController extends AbstractBaseController { ...@@ -310,14 +309,13 @@ public class CarController extends AbstractBaseController {
// carInstance = iCarService.saveCar(getUserInfo(), carInstance, carInfo, carpList); // carInstance = iCarService.saveCar(getUserInfo(), carInstance, carInfo, carpList);
// saveFile(carInstance);视频图片文件后期统一处理 // saveFile(carInstance);视频图片文件后期统一处理
String iotCode = car.getIotCode();
if(car.getIotCode()!=null){ if(StringUtil.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())){
Car ar= carMapper.getCarsByIotCodeExcludeCarId(car.getIotCode(),car.getId()); Car ar= carMapper.getCarsByIotCodeExcludeCarId(car.getIotCode(),car.getId());
if(ar!=null){ if(ar != null){
throw new BadRequest("物联编码重复"); throw new BadRequest("物联编码重复");
} }
if(car.getIotCode().startsWith("20210003")||car.getIotCode().startsWith("20210004")||car.getIotCode().startsWith("20210005")){ if(StringUtils.isNotEmpty(haveUsedIotPrefix) && Arrays.stream(haveUsedIotPrefix.split(",")).anyMatch(iotCode::startsWith)){
throw new BadRequest("物联编码航班已占用"); throw new BadRequest("物联编码航班已占用");
} }
} }
...@@ -326,8 +324,6 @@ public class CarController extends AbstractBaseController { ...@@ -326,8 +324,6 @@ public class CarController extends AbstractBaseController {
//用来解绑车辆 //用来解绑车辆
jcsFeign.getUserCar(car.getId(),car.getTeamId()); jcsFeign.getUserCar(car.getId(),car.getTeamId());
Car oldCar = iCarService.getById(car.getId());
Car car1 = iCarService.updateOneById(car); Car car1 = iCarService.updateOneById(car);
CarController controllerProxy = SpringUtils.getBean(CarController.class); CarController controllerProxy = SpringUtils.getBean(CarController.class);
controllerProxy.refreshAllCount(); controllerProxy.refreshAllCount();
......
...@@ -94,9 +94,6 @@ public class EquipmentDetailController extends AbstractBaseController { ...@@ -94,9 +94,6 @@ public class EquipmentDetailController extends AbstractBaseController {
private IExcelService excelService; private IExcelService excelService;
@Autowired @Autowired
private JcsFeign jcsFeign;
@Autowired
private IWarehouseStructureService warehouseStructureService; private IWarehouseStructureService warehouseStructureService;
@Autowired @Autowired
...@@ -114,6 +111,10 @@ public class EquipmentDetailController extends AbstractBaseController { ...@@ -114,6 +111,10 @@ public class EquipmentDetailController extends AbstractBaseController {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Value("${iot.code.prefix.have.used:20210003,20210004,20210005}")
private String haveUsedIotPrefix;
/** /**
* 新增 * 新增
* *
...@@ -252,14 +253,13 @@ public class EquipmentDetailController extends AbstractBaseController { ...@@ -252,14 +253,13 @@ public class EquipmentDetailController extends AbstractBaseController {
throw new BadRequest("设备编码重复"); throw new BadRequest("设备编码重复");
} }
} }
String iot = vo.getIotCode(); String iotCode = vo.getIotCode();
if (StringUtils.isNotEmpty(iot) && StringUtils.isNotEmpty(iot.trim())) { if (StringUtils.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())) {
int iotCode = equipmentSpecificSerivce.count(new QueryWrapper<EquipmentSpecific>().eq("iot_code", vo.getIotCode()).ne("id", vo.getId())); int exists = equipmentSpecificSerivce.count(new QueryWrapper<EquipmentSpecific>().eq("iot_code", iotCode).ne("id", vo.getId()));
if (iotCode > 0) { if (exists > 0) {
throw new BadRequest("设备物联编码重复"); throw new BadRequest("设备物联编码重复");
} }
if(sysCode.startsWith("20210003")||sysCode.startsWith("20210004")||sysCode.startsWith("20210005")){ if(StringUtils.isNotEmpty(haveUsedIotPrefix) && Arrays.stream(haveUsedIotPrefix.split(",")).anyMatch(iotCode::startsWith)){
throw new BadRequest("物联编码航班已占用"); throw new BadRequest("物联编码航班已占用");
} }
} }
......
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -13,6 +9,7 @@ import javax.annotation.Resource; ...@@ -13,6 +9,7 @@ import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -145,6 +142,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements ...@@ -145,6 +142,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
@Autowired @Autowired
private TransactionDefinition transactionDefinition; private TransactionDefinition transactionDefinition;
@Value("${iot.code.prefix.have.used:20210003,20210004,20210005}")
private String haveUsedIotPrefix;
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
...@@ -581,15 +581,15 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements ...@@ -581,15 +581,15 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
throw new RuntimeException(String.format("设备编码[%S]填写重复,请重新输入!",sysCode)); throw new RuntimeException(String.format("设备编码[%S]填写重复,请重新输入!",sysCode));
} }
} }
String iot = equipmentDetailDownloadVOS.getIotCode(); String iotCode = equipmentDetailDownloadVOS.getIotCode();
if (StringUtils.isNotEmpty(iot) && StringUtils.isNotEmpty(iot.trim())) { if (StringUtils.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())) {
Integer iot_code = equipmentSpecificMapper.selectCount(new QueryWrapper<EquipmentSpecific>().eq("iot_code", iot.trim())); Integer exists = equipmentSpecificMapper.selectCount(new QueryWrapper<EquipmentSpecific>().eq("iot_code", iotCode.trim()));
if (iot_code != 0) { if (exists != 0) {
erryy.append(String.format("物联编码[%S]填写重复,请重新输入!",iot)+ ","); erryy.append(String.format("物联编码[%S]填写重复,请重新输入!",iotCode)+ ",");
throw new RuntimeException(String.format("物联编码[%S]填写重复,请重新输入!",iot)); throw new RuntimeException(String.format("物联编码[%S]填写重复,请重新输入!",iotCode));
} }
if(iot.startsWith("20210003")||iot.startsWith("20210004")||iot.startsWith("20210005")){ if(StringUtils.isNotEmpty(haveUsedIotPrefix) && Arrays.stream(haveUsedIotPrefix.split(",")).anyMatch(iotCode::startsWith)){
erryy.append(String.format("物联编码[%S]航班已占用,请重新输入!",iot)+ ","); erryy.append(String.format("物联编码[%S]航班已占用,请重新输入!",iotCode)+ ",");
throw new BadRequest("物联编码航班已占用"); throw new BadRequest("物联编码航班已占用");
} }
} }
...@@ -644,7 +644,6 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements ...@@ -644,7 +644,6 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
equipmentSpecific.setOrgCode(reginParams.getCompany().getOrgCode()); equipmentSpecific.setOrgCode(reginParams.getCompany().getOrgCode());
equipmentSpecific.setEquipmentCode(equipmentDetail.getCode()); equipmentSpecific.setEquipmentCode(equipmentDetail.getCode());
equipmentSpecific.setName(equipmentDetail.getName()); equipmentSpecific.setName(equipmentDetail.getName());
String iotCode = equipmentDetailDownloadVOS.getIotCode();
iotCode = ExcelUtils.replaceAllBlank(iotCode); iotCode = ExcelUtils.replaceAllBlank(iotCode);
equipmentSpecific.setIotCode(iotCode); equipmentSpecific.setIotCode(iotCode);
equipmentSpecific.setCode(equipmentDetailDownloadVOS.getSystemCode()); equipmentSpecific.setCode(equipmentDetailDownloadVOS.getSystemCode());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment