|
@@ -702,7 +702,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
throw new BusinessException("系统找不到车间名称,请先添加车间, 车间名称" + vo.getPositionName());
|
|
throw new BusinessException("系统找不到车间名称,请先添加车间, 车间名称" + vo.getPositionName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(vo.getProducerName())) { // 生产商匹配
|
|
|
|
|
|
+ /*if (StringUtils.isNotBlank(vo.getProducerName())) { // 生产商匹配
|
|
boolean findProducer = false;
|
|
boolean findProducer = false;
|
|
for (FirmProducer producer : producerList) {
|
|
for (FirmProducer producer : producerList) {
|
|
if (producer.getName().equalsIgnoreCase(vo.getProducerName().trim())) {
|
|
if (producer.getName().equalsIgnoreCase(vo.getProducerName().trim())) {
|
|
@@ -714,7 +714,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
if (!findProducer) {
|
|
if (!findProducer) {
|
|
throw new BusinessException("找不到生产商,请先添加:" + vo.getProducerName());
|
|
throw new BusinessException("找不到生产商,请先添加:" + vo.getProducerName());
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
if (StringUtils.isNotBlank(vo.getSaveUserName())) { // 使用人员
|
|
if (StringUtils.isNotBlank(vo.getSaveUserName())) { // 使用人员
|
|
boolean findSaveUser = false;
|
|
boolean findSaveUser = false;
|
|
for (SysUser user : users) {
|
|
for (SysUser user : users) {
|
|
@@ -2137,8 +2137,8 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
if (vo.getUseType() != 4) {
|
|
if (vo.getUseType() != 4) {
|
|
tempInfo.setIsChild(0);
|
|
tempInfo.setIsChild(0);
|
|
}
|
|
}
|
|
- if (vo.getStatus() == null || vo.getStatus() < 1 || vo.getStatus() > 2) {
|
|
|
|
- throw new BusinessException("第" + i + "行,状态为空,在库请填1,使用中填2;");// 编号为空,复制位号
|
|
|
|
|
|
+ if (vo.getStatus() == null || vo.getStatus() != 1 && vo.getStatus() != 2 && vo.getStatus() != 7) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,状态为空,在库请填1,使用中填2,停用中填7");// 编号为空,复制位号
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(vo.getNo())) {
|
|
if (StringUtils.isBlank(vo.getNo())) {
|
|
tempInfo.setNo(vo.getPositionNo());// 编号为空,复制位号
|
|
tempInfo.setNo(vo.getPositionNo());// 编号为空,复制位号
|
|
@@ -2179,7 +2179,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
throw new BusinessException("系统找不到位置名称,请先在基础配置中添加位置, 位置名称" + vo.getPositionName());
|
|
throw new BusinessException("系统找不到位置名称,请先在基础配置中添加位置, 位置名称" + vo.getPositionName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- tempInfo.setProducerId(vo.getProducerName());
|
|
|
|
|
|
+ // tempInfo.setProducerId(vo.getProducerName());
|
|
/*if(StringUtils.isNotBlank(vo.getProducerName())){ // 生产商匹配
|
|
/*if(StringUtils.isNotBlank(vo.getProducerName())){ // 生产商匹配
|
|
boolean findProducer = false;
|
|
boolean findProducer = false;
|
|
for (FirmProducer producer : producerList) {
|
|
for (FirmProducer producer : producerList) {
|
|
@@ -2246,102 +2246,138 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public String importListByUpdateALl(MultipartFile file) {
|
|
public String importListByUpdateALl(MultipartFile file) {
|
|
-
|
|
|
|
- int addNum = 0;
|
|
|
|
- List<String> modelError = new ArrayList<String>();
|
|
|
|
- List<SbInfo> updateList = new ArrayList<SbInfo>();
|
|
|
|
|
|
+ List<FirmProducer> producerList = firmProducerMapper.selectAll(); // 生产厂商
|
|
|
|
+ List<SbPosition> positionList = sbPositionMapper.selectAll(); // 设备位置
|
|
|
|
+ List<SbType> typeList = sbTypeMapper.selectAll(); // 设备类型集合
|
|
|
|
+ List<SbInfo> addList = new ArrayList<>(); // 待导入集合
|
|
|
|
+ List<SysUser> users = sysUserMapper.selectAll(); // 用户集合
|
|
|
|
+ List<String> addTypeList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
- List<SbInfoVO> items = CustomExcelImportUtil.importListByUpdateALl(file.getInputStream());
|
|
|
|
- //List<ExportSbInfoVO> items = ExcelImportUtil.importExcel(file.getInputStream(), ExportSbInfoVO.class,new ImportParams());
|
|
|
|
- if (!CollectionUtils.isEmpty(items)) {
|
|
|
|
- if (!CollectionUtils.isEmpty(items)) {
|
|
|
|
- List<SbInfoVO> addItems = new ArrayList<SbInfoVO>();
|
|
|
|
- List<SysUser> users = sysUserMapper.selectAll();
|
|
|
|
- List<FirmProducer> producerList = firmProducerMapper.selectAll();
|
|
|
|
- List<SbPosition> positionList = sbPositionMapper.selectAll();
|
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
|
- for (SbInfoVO item : items) {
|
|
|
|
|
|
+ List<ExportSbInfoVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportSbInfoVO.class, 1);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
+ int i = 2;
|
|
|
|
+ for (ExportSbInfoVO vo : list) {
|
|
|
|
+ i++;
|
|
|
|
+ // 如果有检定周期,就是需要检定
|
|
|
|
+ SbInfo tempInfo = BeanConverterUtil.copyObjectProperties(vo, SbInfo.class);
|
|
|
|
+ tempInfo.setSeatNumber(30);// 默认30天提醒
|
|
|
|
|
|
|
|
+ // 对必填字段进行判断
|
|
|
|
+ if (StringUtils.isBlank(vo.getPositionNo())) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,位号为空,位号为必填项目,请填写;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (vo.getIsFinancing() == 1 && StringUtils.isBlank(vo.getFinancingNo())) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,是固定资产,但是资产编号为空,请填写;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(vo.getName())) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,名称为空,请填写;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(vo.getModel())) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,型号为空,请填写;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (vo.getLevel() == null || vo.getLevel() < 1 || vo.getLevel() > 3) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,等级为空,A级请填1,B级填2,C级填3;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (vo.getUseType() == null || vo.getUseType() < 3 || vo.getUseType() > 5) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,自定义类型为空,生产设备请填3,计量设备填4,特种设备填5;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (vo.getUseType() == 4) {
|
|
|
|
+ tempInfo.setIsChild(1);
|
|
|
|
+ } else {
|
|
|
|
+ tempInfo.setIsChild(0);
|
|
|
|
+ }
|
|
|
|
+ if (vo.getStatus() == null || vo.getStatus() < 1 || vo.getStatus() > 2) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,状态为空,在库请填1,使用中填2,停用中填7");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(vo.getNo())) {
|
|
|
|
+ tempInfo.setNo(vo.getPositionNo());// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(vo.getPpNo())) {
|
|
|
|
+ tempInfo.setIsChild(1);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(vo.getFinancingNo())) {
|
|
|
|
+ tempInfo.setIsFinancing(1);
|
|
|
|
+ }
|
|
|
|
+ if (vo.getCheckPeriod() != null) {
|
|
|
|
+ tempInfo.setIsMeasure(1);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(vo.getTypeName())) { // 设备类型匹配
|
|
|
|
+ boolean findSbType = false;
|
|
|
|
+ for (SbType sbType : typeList) {
|
|
|
|
+ if (sbType.getName().equalsIgnoreCase(vo.getTypeName().trim())) {
|
|
|
|
+ tempInfo.setTypeId(sbType.getId());
|
|
|
|
+ findSbType = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!findSbType) {
|
|
|
|
+ addTypeList.add(vo.getTypeName());
|
|
|
|
+ // throw new BusinessException("系统找不到该设备类型名称,请先添加设备类型, 设备类型名称" + vo.getTypeName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(vo.getPositionName())) { // 设备位置匹配
|
|
boolean findPosition = false;
|
|
boolean findPosition = false;
|
|
for (SbPosition position : positionList) {
|
|
for (SbPosition position : positionList) {
|
|
- if (position.getName().equalsIgnoreCase(item.getPositionName())) {
|
|
|
|
- item.setPositionId(position.getId());
|
|
|
|
|
|
+ if (position.getName().equalsIgnoreCase(vo.getPositionName().trim())) {
|
|
|
|
+ tempInfo.setPositionId(position.getId());
|
|
findPosition = true;
|
|
findPosition = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!findPosition) {
|
|
if (!findPosition) {
|
|
- throw new BusinessException("系统找不到车间名称,请先添加车间, 车间名称" + item.getPositionName());
|
|
|
|
|
|
+ throw new BusinessException("系统找不到位置名称,请先在基础配置中添加位置, 位置名称" + vo.getPositionName());
|
|
}
|
|
}
|
|
-
|
|
|
|
- boolean findSaveUser = false;
|
|
|
|
- for (SysUser user : users) {
|
|
|
|
- if (user.getRealName().equalsIgnoreCase(item.getSaveUserName())) {
|
|
|
|
- item.setSaveUser(user.getUserId());
|
|
|
|
- item.setUseUser(user.getUserId());
|
|
|
|
- findSaveUser = true;
|
|
|
|
|
|
+ }
|
|
|
|
+ // tempInfo.setProducerId(vo.getProducerName());
|
|
|
|
+ /*if(StringUtils.isNotBlank(vo.getProducerName())){ // 生产商匹配
|
|
|
|
+ boolean findProducer = false;
|
|
|
|
+ for (FirmProducer producer : producerList) {
|
|
|
|
+ if (producer.getName().equalsIgnoreCase(vo.getProducerName().trim())) {
|
|
|
|
+ tempInfo.setProducerId(producer.getId());
|
|
|
|
+ findProducer = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!findSaveUser) {
|
|
|
|
- throw new BusinessException("找不到使用人员,请先添加, 名称" + item.getSaveUser());
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(item.getRepairUserName())) {
|
|
|
|
- boolean findRepairUser = false;
|
|
|
|
- for (SysUser user : users) {
|
|
|
|
- if (user.getRealName().equalsIgnoreCase(item.getRepairUserName())) {
|
|
|
|
- item.setRepairUser(user.getUserId());
|
|
|
|
- findRepairUser = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!findRepairUser) {
|
|
|
|
- throw new BusinessException("找不到维修人员,请先添加, 名称" + item.getRepairUser());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(item.getRepairUserNameSecond())) {
|
|
|
|
- boolean findRepairUser = false;
|
|
|
|
- for (SysUser user : users) {
|
|
|
|
- if (user.getRealName().equalsIgnoreCase(item.getRepairUserNameSecond())) {
|
|
|
|
- item.setRepairUserSecond(user.getUserId());
|
|
|
|
- findRepairUser = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!findRepairUser) {
|
|
|
|
- throw new BusinessException("找不到第二维修人员,请先添加, 名称" + item.getRepairUser());
|
|
|
|
- }
|
|
|
|
|
|
+ if (!findProducer) {
|
|
|
|
+ throw new BusinessException("找不到生产商,请先添加:" + vo.getProducerName());
|
|
}
|
|
}
|
|
-
|
|
|
|
- List<SbType> typeList = sbTypeMapper.selectAll();
|
|
|
|
- boolean find = false;
|
|
|
|
- for (SbType type : typeList) {
|
|
|
|
- if (type.getName().equalsIgnoreCase(item.getTypeName())) {
|
|
|
|
- item.setTypeId(type.getId());
|
|
|
|
- find = true;
|
|
|
|
|
|
+ }*/
|
|
|
|
+ if (StringUtils.isNotBlank(vo.getSaveUserName())) { // 使用人员
|
|
|
|
+ boolean findSaveUser = false;
|
|
|
|
+ for (SysUser user : users) {
|
|
|
|
+ if (user.getRealName().equalsIgnoreCase(vo.getSaveUserName().trim())) {
|
|
|
|
+ tempInfo.setSaveUser(user.getUserId());
|
|
|
|
+ findSaveUser = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!find) {
|
|
|
|
- throw new BusinessException("找不到设备类型,请先添加:" + item.getTypeName());
|
|
|
|
|
|
+ if (!findSaveUser) {
|
|
|
|
+ throw new BusinessException("找不到使用人员,请先添加, 名称" + vo.getSaveUserName());
|
|
}
|
|
}
|
|
-
|
|
|
|
- boolean findProdcuer = false;
|
|
|
|
- for (FirmProducer producer : producerList) {
|
|
|
|
- if (producer.getName().equalsIgnoreCase(item.getProducerId())) {
|
|
|
|
- item.setProducerId(producer.getId());
|
|
|
|
- findProdcuer = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ // 如果计量设备 且是需要检定
|
|
|
|
+ if (vo.getUseType() == SbUseType.BGCL.getValue() && vo.getIsMeasure() == YesNoEnum.YES.getValue()) {
|
|
|
|
+ if (vo.getCheckDate() == null && vo.getNextCheckDate() == null) {
|
|
|
|
+ throw new BusinessException("上次和下次检定日期,不能全部为空");
|
|
}
|
|
}
|
|
- if (!findProdcuer) {
|
|
|
|
- throw new BusinessException("找不到生产商,请先添加:" + item.getProducerId());
|
|
|
|
|
|
+ if (vo.getCheckPeriod() == null) {
|
|
|
|
+ throw new BusinessException("检定周期不能为空");
|
|
}
|
|
}
|
|
- mapper.updateByPrimaryKeySelective(BeanConverterUtil.copyObjectProperties(item, SbInfo.class));
|
|
|
|
}
|
|
}
|
|
|
|
+ // tempInfo.setId(IdGeneratorUtils.getObjectId());
|
|
|
|
+ tempInfo.setUpdateUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
|
+ tempInfo.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
|
+ tempInfo.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ addList.add(tempInfo);
|
|
|
|
+ mapper.updateByPrimaryKeySelective(tempInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return "总计更新:" + (items.size());
|
|
|
|
|
|
+
|
|
|
|
+ if (CollectionUtil.isNotEmpty(addTypeList)) {
|
|
|
|
+ throw new BusinessException(addTypeList.size() + "个设备类型名称找不到,请先添加:" + addTypeList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return "总计更新:" + (list.size());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw new BusinessException(e.getMessage());
|
|
throw new BusinessException(e.getMessage());
|
|
}
|
|
}
|