|
@@ -1,14 +1,15 @@
|
|
|
package com.platform.service.sqarepartmanage.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.constant.CommonConstants;
|
|
|
import com.platform.common.exception.BusinessException;
|
|
|
-import com.platform.common.util.BeanConverterUtil;
|
|
|
-import com.platform.common.util.IdGeneratorUtils;
|
|
|
-import com.platform.common.util.StringUtils;
|
|
|
+import com.platform.common.model.UserInfo;
|
|
|
+import com.platform.common.util.*;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
+import com.platform.dao.dto.repair.RepairApplicationFormDTO;
|
|
|
import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
@@ -18,12 +19,15 @@ import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
|
import com.platform.dao.entity.sqarepartmanage.SpareType;
|
|
|
import com.platform.dao.entity.store.SpareStore;
|
|
|
import com.platform.dao.entity.upms.SysDept;
|
|
|
+import com.platform.dao.entity.upms.SysFile;
|
|
|
import com.platform.dao.entity.upms.SysUser;
|
|
|
+import com.platform.dao.enums.SysFileTypeEnum;
|
|
|
import com.platform.dao.mapper.sb.SbModelMapper;
|
|
|
import com.platform.dao.mapper.sb.SbModelSpareBomMapper;
|
|
|
import com.platform.dao.mapper.sqarepartmanage.SparePartInfoMapper;
|
|
|
import com.platform.dao.mapper.sqarepartmanage.SpareTypeMapper;
|
|
|
import com.platform.dao.mapper.store.SpareStoreMapper;
|
|
|
+import com.platform.dao.mapper.upms.SysFileMapper;
|
|
|
import com.platform.dao.util.CustomExcelImportUtil;
|
|
|
import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
|
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
@@ -62,6 +66,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
private final SbModelSpareBomMapper sbModelSpareBomMapper;
|
|
|
private final SpareStoreMapper spareStoreMapper;
|
|
|
private final Environment environment;
|
|
|
+ private final SysFileMapper sysFileMapper;
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
|
|
@@ -232,6 +237,17 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
model.setChildNo(type.getNo());
|
|
|
}
|
|
|
}
|
|
|
+ Weekend<SysFile> weekendFile = new Weekend<>(SysFile.class);
|
|
|
+ weekendFile.weekendCriteria().andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
+ List<SysFile> sysFiles = sysFileMapper.selectByExample(weekendFile);
|
|
|
+ List<SysFile> s = ListUtils.newArrayList();
|
|
|
+ List<SysFile> applicationFileList = ListUtils.newArrayList();
|
|
|
+ sysFiles.forEach(item -> {
|
|
|
+ if (item.getType().equals(SysFileTypeEnum.SPARE_IMGS.getValue())) {
|
|
|
+ applicationFileList.add(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ model.setApplicationFileList(applicationFileList);
|
|
|
return model;
|
|
|
}
|
|
|
|
|
@@ -241,10 +257,16 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
// 设置备件的统一编号
|
|
|
SpareType parentType = spareTypeMapper.selectByPrimaryKey(model.getParentTypeId());
|
|
|
SpareType middleType = spareTypeMapper.selectByPrimaryKey(model.getMiddleTypeId());
|
|
|
- String parentTypeNo = parentType.getNo();
|
|
|
- String middleTypeNo = middleType.getNo();
|
|
|
- model.setParentNo(parentTypeNo);
|
|
|
- model.setMiddleNo(middleTypeNo);
|
|
|
+ String parentTypeNo = "";
|
|
|
+ String middleTypeNo = "";
|
|
|
+ if(parentType !=null){
|
|
|
+ parentTypeNo = parentType.getNo();
|
|
|
+ model.setParentNo(parentTypeNo);
|
|
|
+ }
|
|
|
+ if(middleType != null){
|
|
|
+ middleTypeNo = middleType.getNo();
|
|
|
+ model.setMiddleNo(middleTypeNo);
|
|
|
+ }
|
|
|
String nameNo = model.getNameNo();
|
|
|
String ggNo = model.getGgNo();
|
|
|
String childTypeNo = null;
|
|
@@ -264,12 +286,12 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
|
|
|
+ /* Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
|
|
|
weekend.weekendCriteria().andEqualTo(SparePartInfo::getUniteNo, model.getUniteNo());
|
|
|
int checkInfo = mapper.selectCountByExample(weekend);
|
|
|
if(checkInfo > 0){
|
|
|
throw new BusinessException("编码已存在,请重新设置名称编码或者规格编码," + model.getUniteNo());
|
|
|
- }
|
|
|
+ }*/
|
|
|
model.setId(IdGeneratorUtils.getObjectId());
|
|
|
// 保存二维码
|
|
|
String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/" + IdGeneratorUtils.getObjectId() + "/";
|
|
@@ -278,6 +300,25 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
String codePath = path + model.getId() + ".png";
|
|
|
model.setQrCode(codePath);
|
|
|
CodeFileUtils.uploadFileECode(model.getId(), rootPath, filePath, model.getId() + ".png");
|
|
|
+
|
|
|
+ UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
+ LocalDateTime time = LocalDateTime.now();
|
|
|
+ // 如果由sbId,则要创建bom
|
|
|
+ if(StringUtils.isNotBlank(model.getSbId())){
|
|
|
+ SbModelSpareBom bom = new SbModelSpareBom();
|
|
|
+ bom.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ bom.setSpareId(model.getId());
|
|
|
+ bom.setNum(new BigDecimal(1));
|
|
|
+ bom.setCreatedTime(time);
|
|
|
+ bom.setCreatedUserId(userInfo.getUserId());
|
|
|
+ bom.setPeriod(1);
|
|
|
+ bom.setPeriodType(1);
|
|
|
+ bom.setSbId(model.getSbId());
|
|
|
+ bom.setUpdateTime(time);
|
|
|
+ bom.setUpdateUserId(userInfo.getUserId());
|
|
|
+ sbModelSpareBomMapper.insert(bom);
|
|
|
+ }
|
|
|
+ this.saveFile(model);
|
|
|
return super.saveModelHaveCreateInfo(model);
|
|
|
}
|
|
|
|
|
@@ -317,15 +358,33 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
|
|
|
+ /* Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
|
|
|
weekend.weekendCriteria().andEqualTo(SparePartInfo::getUniteNo, model.getUniteNo());
|
|
|
SparePartInfo checkInfo = mapper.selectOneByExample(weekend);
|
|
|
if(checkInfo != null && !checkInfo.getId().equals(model.getId())){
|
|
|
throw new BusinessException("编码已存在,请重新设置名称编码或者规格编码," + model.getUniteNo());
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ this.saveFile(model);
|
|
|
super.modModelByDTO(model);
|
|
|
}
|
|
|
-
|
|
|
+ private void saveFile(SparePartInfoDTO model) {
|
|
|
+ Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
+ weekend.weekendCriteria().andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
+ sysFileMapper.deleteByExample(weekend);
|
|
|
+ List<SysFile> applicationFileList = model.getApplicationFileList();
|
|
|
+ List<SysFile> list = ListUtils.newArrayList();
|
|
|
+ if (CollectionUtil.isNotEmpty(applicationFileList)) {
|
|
|
+ applicationFileList.forEach(item -> {
|
|
|
+ item.setType(SysFileTypeEnum.SPARE_IMGS.getValue());
|
|
|
+ item.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ item.setTargetId(model.getId());
|
|
|
+ list.add(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ sysFileMapper.insertListforComplex(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 导入备件基础信息
|
|
|
*
|