|
@@ -4,16 +4,22 @@ 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.cache.ConfigCache;
|
|
|
import com.platform.common.constant.CommonConstants;
|
|
|
import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
+import com.platform.dao.dto.check.CheckStandardDTO;
|
|
|
+import com.platform.dao.dto.check.CheckStandardSpareDTO;
|
|
|
import com.platform.dao.dto.repair.RepairApplicationFormDTO;
|
|
|
import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
import com.platform.dao.dto.sb.SbModelSpareBomDTO;
|
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
|
import com.platform.dao.dto.store.InStoreDetailDTO;
|
|
|
+import com.platform.dao.dto.store.SpareStoreDTO;
|
|
|
+import com.platform.dao.entity.check.CheckJob;
|
|
|
+import com.platform.dao.entity.check.CheckStandard;
|
|
|
import com.platform.dao.entity.check.CheckStandardSpare;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
import com.platform.dao.entity.sb.SbModel;
|
|
@@ -25,7 +31,9 @@ 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.enums.*;
|
|
|
+import com.platform.dao.mapper.check.CheckJobMapper;
|
|
|
+import com.platform.dao.mapper.check.CheckStandardSpareMapper;
|
|
|
import com.platform.dao.mapper.sb.SbInfoMapper;
|
|
|
import com.platform.dao.mapper.sb.SbModelMapper;
|
|
|
import com.platform.dao.mapper.sb.SbModelSpareBomMapper;
|
|
@@ -34,12 +42,18 @@ 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.util.MessageTemplateUtil;
|
|
|
+import com.platform.dao.vo.query.check.CheckStandardSpareVO;
|
|
|
import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
|
|
|
+import com.platform.dao.vo.query.store.SpareStoreVO;
|
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
|
+import com.platform.service.check.CheckStandardService;
|
|
|
+import com.platform.service.event.WorkplaceBacklogEvent;
|
|
|
import com.platform.service.sqarepartmanage.SparePartInfoService;
|
|
|
import com.platform.service.sqarepartmanage.SpareTypeService;
|
|
|
import com.platform.service.util.CodeFileUtils;
|
|
|
import com.platform.service.util.SysFileUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
@@ -51,7 +65,9 @@ import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -63,6 +79,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@AllArgsConstructor
|
|
|
@Service("sparePartInfoService")
|
|
|
+@Slf4j
|
|
|
public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMapper, SparePartInfo, SparePartInfoDTO> implements SparePartInfoService {
|
|
|
|
|
|
private final SbInfoMapper sbInfoMapper;
|
|
@@ -72,6 +89,9 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
private final SpareStoreMapper spareStoreMapper;
|
|
|
private final Environment environment;
|
|
|
private final SysFileMapper sysFileMapper;
|
|
|
+ private CheckJobMapper checkJobMapper;
|
|
|
+ private CheckStandardSpareMapper checkStandardSpareMapper;
|
|
|
+ private CheckStandardService checkStandardService;
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
|
|
@@ -80,7 +100,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
WeekendCriteria<SpareStore, Object> weekendCriteriaStore = weekendStore.weekendCriteria();
|
|
|
weekendCriteriaStore.andIn(SpareStore::getSpareId, ids).andGreaterThan(SpareStore::getNum, 0);
|
|
|
List<SpareStore> spareStoreList = spareStoreMapper.selectByExample(weekendStore);
|
|
|
- if(!CollectionUtils.isEmpty(spareStoreList)){
|
|
|
+ if (!CollectionUtils.isEmpty(spareStoreList)) {
|
|
|
throw new BusinessException("该备件仓库有数据,不能删除,请先清空仓库库存");
|
|
|
}
|
|
|
// 删除
|
|
@@ -107,17 +127,122 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
return new MyPage(mapper.selectSpareInfoListBySbId(sbId));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 定时扫描是否过期
|
|
|
+ * 1:增加warnStatus状态
|
|
|
+ * 增加warnStatus的枚举类型
|
|
|
+ * 2:每周定时扫描warnStatus为正常的,判断他的最低库存是否正常,有异常的交给人工来判定。并发送邮件通知
|
|
|
+ * 3:扫描的时候,是扫描总库存,有可能仓库里面的备件不在同一个库存。
|
|
|
+ * <p>
|
|
|
+ * 4:增加预警菜单,查出来所有异常的列表
|
|
|
+ * 5:增加人工干预,可以改变每条的状态。
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void genMinStockWarn() {
|
|
|
+ SparePartInfoDTO record = new SparePartInfoDTO();
|
|
|
+ record.setSearchMinStockWarn(true);
|
|
|
+ // 查找超过最低库存的备件
|
|
|
+ List<SparePartInfoVO> sparePartInfoVOList = mapper.selectPageList(record);
|
|
|
+ List<SparePartInfo> sparePartInfos = new ArrayList<>();
|
|
|
+ for (SparePartInfoVO sparePartInfoVO : sparePartInfoVOList) {
|
|
|
+ SparePartInfo sparePartInfo = new SparePartInfo();
|
|
|
+ sparePartInfo.setId(sparePartInfoVO.getId());
|
|
|
+ sparePartInfo.setWarnStatus(1);
|
|
|
+ sparePartInfos.add(sparePartInfo);
|
|
|
+ mapper.updateByPrimaryKeySelective(sparePartInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(sparePartInfos)) {
|
|
|
+ // 发送邮件通知
|
|
|
+ String email = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SPARE_WARN_EMAIL.name());
|
|
|
+ String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
+ String url = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.URL_SPARE_MIN_STOCK_WARN.name());
|
|
|
+ if (StringUtils.isNotBlank(email)) {
|
|
|
+ // 通过给邮件人员
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(), WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
|
|
|
+ null, MessageTemplateUtil.getSpareMinStockWarnNotice(domain + url, sparePartInfos.size()),
|
|
|
+ null, null, Arrays.asList(email)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定时扫描是否过期
|
|
|
+ * 1:增加warnStatus状态
|
|
|
+ * 增加warnStatus的枚举类型
|
|
|
+ * 2:每周定时扫描warnStatus为正常的,判断他的最低库存是否正常,有异常的交给人工来判定。并发送邮件通知
|
|
|
+ * 3:扫描的时候,是扫描总库存,有可能仓库里面的备件不在同一个库存。
|
|
|
+ * <p>
|
|
|
+ * 4:增加预警菜单,查出来所有异常的列表
|
|
|
+ * 5:增加人工干预,可以改变每条的状态。
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void genCheckStockWarn() {
|
|
|
+
|
|
|
+ // 查询近六个月待执行的任务列表。
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ LocalDate afterSixMonth = DateUtils.plus(now, 6, ChronoUnit.MONTHS);
|
|
|
+ Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
|
+ weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue())
|
|
|
+ .andBetween(CheckJob::getStartTime, now, afterSixMonth);
|
|
|
+ List<CheckJob> checkJobs = checkJobMapper.selectByExample(weekend);
|
|
|
+
|
|
|
+ // 获取未执行的标准id,不能用stream获取id列表,会覆盖重复的标准id(不会重复,因为一个标准对应一个任务。)
|
|
|
+ List<CheckStandardSpareVO> voList = new ArrayList<CheckStandardSpareVO>();
|
|
|
+ if(CollectionUtil.isNotEmpty(checkJobs)){
|
|
|
+ List<String> ids = checkJobs.stream().map(CheckJob::getStandardId).collect(Collectors.toList());
|
|
|
+ ids = ids.stream().filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(ids) && ids.size()>0) {
|
|
|
+ CheckStandardSpareDTO dto = new CheckStandardSpareDTO();
|
|
|
+ dto.setCheckIds(ids);
|
|
|
+ voList = checkStandardSpareMapper.selectSpareWarn(dto);
|
|
|
+
|
|
|
+ // 判断总库存是否大于最近6个月的需求量
|
|
|
+ if(CollectionUtil.isNotEmpty(voList)){
|
|
|
+ for(CheckStandardSpareVO checkStandardSpareVO:voList){
|
|
|
+ if(checkStandardSpareVO.getNum().compareTo(checkStandardSpareVO.getStoreNum())>0){
|
|
|
+ SparePartInfo sparePartInfo = new SparePartInfo();
|
|
|
+ sparePartInfo.setId(checkStandardSpareVO.getId());
|
|
|
+ sparePartInfo.setForecastStatus(1);
|
|
|
+ mapper.updateByPrimaryKeySelective(sparePartInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发送邮件通知
|
|
|
+ String email = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SPARE_WARN_EMAIL.name());
|
|
|
+ String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
+ String url = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.URL_SPARE_CHECK_STOCK_WARN.name());
|
|
|
+ if (StringUtils.isNotBlank(email)) {
|
|
|
+ // 通过给邮件人员
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.CHECK_SPARE_WARN.getValue(), WorkplaceBacklogDetailTypeEnum.CHECK_SPARE_WARN.getValue(),
|
|
|
+ null, MessageTemplateUtil.getSpareCheckStockWarnNotice(domain + url, voList.size()),
|
|
|
+ null, null, Arrays.asList(email)));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String ss = "TYPJ-CC-00002";
|
|
|
+ String newStr = ss.substring(ss.length() - 5);
|
|
|
+ int count = Integer.valueOf(newStr) + 1;
|
|
|
+ String str1 = String.format("%05d", count);
|
|
|
+ System.out.println(str1);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<SparePartInfo> getModelListByDTO(SparePartInfoDTO sparePartInfoDTO) {
|
|
|
- if(sparePartInfoDTO.getTypeId() != null){
|
|
|
+ if (sparePartInfoDTO.getTypeId() != null) {
|
|
|
Weekend<SpareType> weekend = new Weekend<>(SpareType.class);
|
|
|
WeekendCriteria<SpareType, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
weekendCriteria.andEqualTo(SpareType::getParentId, sparePartInfoDTO.getTypeId());
|
|
|
List<SpareType> childList = spareTypeMapper.selectByExample(weekend);
|
|
|
List<String> typeIds = new ArrayList<String>();
|
|
|
typeIds.add(sparePartInfoDTO.getTypeId());
|
|
|
- if(!CollectionUtils.isEmpty(childList)){
|
|
|
- childList.forEach(item->{
|
|
|
+ if (!CollectionUtils.isEmpty(childList)) {
|
|
|
+ childList.forEach(item -> {
|
|
|
typeIds.add(item.getId());
|
|
|
});
|
|
|
}
|
|
@@ -125,21 +250,21 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
}
|
|
|
List<SparePartInfoVO> listVO = mapper.selectPageList(sparePartInfoDTO);
|
|
|
List<SpareType> typeList = spareTypeMapper.selectAll();
|
|
|
- for(SparePartInfoVO vo: listVO){
|
|
|
- for(SpareType type:typeList){
|
|
|
- if(StringUtils.isNotBlank(vo.getTypeId()) && vo.getTypeId().equals(type.getId())){
|
|
|
+ for (SparePartInfoVO vo : listVO) {
|
|
|
+ for (SpareType type : typeList) {
|
|
|
+ if (StringUtils.isNotBlank(vo.getTypeId()) && vo.getTypeId().equals(type.getId())) {
|
|
|
vo.setTypeName(type.getName());
|
|
|
vo.setTypeNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(vo.getParentTypeId()) && vo.getParentTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(vo.getParentTypeId()) && vo.getParentTypeId().equals(type.getId())) {
|
|
|
vo.setParentName(type.getName());
|
|
|
vo.setParentNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(vo.getMiddleTypeId()) && vo.getMiddleTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(vo.getMiddleTypeId()) && vo.getMiddleTypeId().equals(type.getId())) {
|
|
|
vo.setMiddleName(type.getName());
|
|
|
vo.setMiddleNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(vo.getChildTypeId()) && vo.getChildTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(vo.getChildTypeId()) && vo.getChildTypeId().equals(type.getId())) {
|
|
|
vo.setChildName(type.getName());
|
|
|
vo.setChildNo(type.getNo());
|
|
|
}
|
|
@@ -153,15 +278,15 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
@Override
|
|
|
public AbstractPageResultBean<SparePartInfo> selectPageInfo(SparePartInfoDTO record, int pageNum, int pageSize) {
|
|
|
// 选择设备对应的备件bom列表
|
|
|
- if(record.getSbId()!=null){
|
|
|
+ if (record.getSbId() != null) {
|
|
|
SbInfoVO sbInfo = sbInfoMapper.getById(record.getSbId());
|
|
|
List<SparePartInfoVO> partList = mapper.selectSpareInfoList(sbInfo.getModelId());
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
AbstractPageResultBean<SparePartInfo> pageInfo = new MyPage(partList);
|
|
|
return pageInfo;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
List<SpareType> typeList = spareTypeMapper.selectAll();
|
|
|
- if(StringUtils.isNotBlank(record.getTypeName())){
|
|
|
+ if (StringUtils.isNotBlank(record.getTypeName())) {
|
|
|
for (SpareType type : typeList) {
|
|
|
if (type.getName().equals(record.getTypeName())) {
|
|
|
record.setTypeId(type.getId());
|
|
@@ -169,15 +294,15 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(record.getTypeId() != null){
|
|
|
+ if (record.getTypeId() != null) {
|
|
|
Weekend<SpareType> weekend = new Weekend<>(SpareType.class);
|
|
|
WeekendCriteria<SpareType, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
weekendCriteria.andEqualTo(SpareType::getParentId, record.getTypeId());
|
|
|
List<SpareType> childList = spareTypeMapper.selectByExample(weekend);
|
|
|
List<String> typeIds = new ArrayList<String>();
|
|
|
typeIds.add(record.getTypeId());
|
|
|
- if(!CollectionUtils.isEmpty(childList)){
|
|
|
- childList.forEach(item->{
|
|
|
+ if (!CollectionUtils.isEmpty(childList)) {
|
|
|
+ childList.forEach(item -> {
|
|
|
typeIds.add(item.getId());
|
|
|
});
|
|
|
}
|
|
@@ -186,21 +311,21 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<SparePartInfoVO> list = mapper.selectPageList(record);
|
|
|
- for(SparePartInfoVO vo: list){
|
|
|
- for(SpareType type:typeList){
|
|
|
- if(StringUtils.isNotBlank(vo.getTypeId()) && vo.getTypeId().equals(type.getId())){
|
|
|
+ for (SparePartInfoVO vo : list) {
|
|
|
+ for (SpareType type : typeList) {
|
|
|
+ if (StringUtils.isNotBlank(vo.getTypeId()) && vo.getTypeId().equals(type.getId())) {
|
|
|
vo.setTypeName(type.getName());
|
|
|
vo.setTypeNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(vo.getParentTypeId()) && vo.getParentTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(vo.getParentTypeId()) && vo.getParentTypeId().equals(type.getId())) {
|
|
|
vo.setParentName(type.getName());
|
|
|
vo.setParentNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(vo.getMiddleTypeId()) && vo.getMiddleTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(vo.getMiddleTypeId()) && vo.getMiddleTypeId().equals(type.getId())) {
|
|
|
vo.setMiddleName(type.getName());
|
|
|
vo.setMiddleNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(vo.getChildTypeId()) && vo.getChildTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(vo.getChildTypeId()) && vo.getChildTypeId().equals(type.getId())) {
|
|
|
vo.setChildName(type.getName());
|
|
|
vo.setChildNo(type.getNo());
|
|
|
}
|
|
@@ -215,35 +340,35 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
public SparePartInfo getModelById(Object id) {
|
|
|
SparePartInfo model = mapper.selectById(id);
|
|
|
List<String> ids = new ArrayList<String>();
|
|
|
- if(StringUtils.isNotBlank(model.getTypeId()) && !ids.contains(model.getTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getTypeId()) && !ids.contains(model.getTypeId())) {
|
|
|
ids.add(model.getTypeId());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(model.getParentTypeId()) && !ids.contains(model.getParentTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getParentTypeId()) && !ids.contains(model.getParentTypeId())) {
|
|
|
ids.add(model.getParentTypeId());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(model.getMiddleTypeId()) && !ids.contains(model.getMiddleTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getMiddleTypeId()) && !ids.contains(model.getMiddleTypeId())) {
|
|
|
ids.add(model.getMiddleTypeId());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(model.getChildTypeId()) && !ids.contains(model.getChildTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getChildTypeId()) && !ids.contains(model.getChildTypeId())) {
|
|
|
ids.add(model.getChildTypeId());
|
|
|
}
|
|
|
Weekend<SpareType> weekend = new Weekend<>(SpareType.class);
|
|
|
WeekendCriteria<SpareType, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
weekendCriteria.andIn(SpareType::getId, ids);
|
|
|
List<SpareType> typeList = spareTypeMapper.selectByExample(weekend);
|
|
|
- for(SpareType type:typeList){
|
|
|
- if(StringUtils.isNotBlank(model.getTypeId()) && model.getTypeId().equals(type.getId())){
|
|
|
+ for (SpareType type : typeList) {
|
|
|
+ if (StringUtils.isNotBlank(model.getTypeId()) && model.getTypeId().equals(type.getId())) {
|
|
|
model.setTypeName(type.getName());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(model.getParentTypeId()) && model.getParentTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getParentTypeId()) && model.getParentTypeId().equals(type.getId())) {
|
|
|
model.setParentName(type.getName());
|
|
|
model.setParentNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(model.getMiddleTypeId()) && model.getMiddleTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getMiddleTypeId()) && model.getMiddleTypeId().equals(type.getId())) {
|
|
|
model.setMiddleName(type.getName());
|
|
|
model.setMiddleNo(type.getNo());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(model.getChildTypeId()) && model.getChildTypeId().equals(type.getId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getChildTypeId()) && model.getChildTypeId().equals(type.getId())) {
|
|
|
model.setChildName(type.getName());
|
|
|
model.setChildNo(type.getNo());
|
|
|
}
|
|
@@ -277,28 +402,28 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
SpareType middleType = spareTypeMapper.selectByPrimaryKey(model.getMiddleTypeId());
|
|
|
String parentTypeNo = "";
|
|
|
String middleTypeNo = "";
|
|
|
- if(parentType !=null){
|
|
|
+ if (parentType != null) {
|
|
|
parentTypeNo = parentType.getNo();
|
|
|
model.setParentNo(parentTypeNo);
|
|
|
}
|
|
|
- if(middleType != null){
|
|
|
+ if (middleType != null) {
|
|
|
middleTypeNo = middleType.getNo();
|
|
|
model.setMiddleNo(middleTypeNo);
|
|
|
}
|
|
|
String nameNo = model.getNameNo();
|
|
|
String ggNo = model.getGgNo();
|
|
|
String childTypeNo = null;
|
|
|
- if(StringUtils.isNotBlank(model.getChildTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getChildTypeId())) {
|
|
|
SpareType childType = spareTypeMapper.selectByPrimaryKey(model.getChildTypeId());
|
|
|
childTypeNo = childType.getNo();
|
|
|
model.setChildNo(childTypeNo);
|
|
|
model.setTypeId(model.getChildTypeId());
|
|
|
model.setUniteNo(parentTypeNo + "-" + middleTypeNo + "-" + childTypeNo);
|
|
|
- }else{
|
|
|
- if(StringUtils.isNotBlank(model.getMiddleTypeId())){
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isNotBlank(model.getMiddleTypeId())) {
|
|
|
model.setTypeId(model.getMiddleTypeId());
|
|
|
model.setUniteNo(parentTypeNo + "-" + middleTypeNo);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
model.setTypeId(model.getParentTypeId());
|
|
|
model.setUniteNo(parentTypeNo);
|
|
|
}
|
|
@@ -307,10 +432,14 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
|
|
|
weekend.weekendCriteria().andEqualTo(SparePartInfo::getName, model.getName()).andEqualTo(SparePartInfo::getGgxh, model.getGgxh());
|
|
|
int checkInfo = mapper.selectCountByExample(weekend);
|
|
|
- if(checkInfo > 0){
|
|
|
+ if (checkInfo > 0) {
|
|
|
throw new BusinessException("同名称同规格的备件已存在,请重新设置");
|
|
|
}
|
|
|
model.setId(IdGeneratorUtils.getObjectId());
|
|
|
+
|
|
|
+ // 设置编码
|
|
|
+ setSpareNo(model);
|
|
|
+
|
|
|
// 保存二维码
|
|
|
String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/" + IdGeneratorUtils.getObjectId() + "/";
|
|
|
String rootPath = environment.getProperty("upload.root-dir");
|
|
@@ -322,7 +451,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
LocalDateTime time = LocalDateTime.now();
|
|
|
// 如果由sbId,则要创建bom
|
|
|
- if(StringUtils.isNotBlank(model.getSbId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getSbId())) {
|
|
|
SbModelSpareBom bom = new SbModelSpareBom();
|
|
|
bom.setId(IdGeneratorUtils.getObjectId());
|
|
|
bom.setSpareId(model.getId());
|
|
@@ -339,21 +468,21 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
this.saveFile(model);
|
|
|
|
|
|
// 如果初始化数量有了,就需要更新库存
|
|
|
- if(model.getInitStock() == null){
|
|
|
+ if (model.getInitStock() == null) {
|
|
|
model.setInitStock(new BigDecimal(0));
|
|
|
}
|
|
|
- if(model.getInitStock() != null){
|
|
|
+ if (model.getInitStock() != null) {
|
|
|
SpareStore spareStore = new SpareStore();
|
|
|
spareStore.setSpareId(model.getId());
|
|
|
spareStore.setId(IdGeneratorUtils.getObjectId());
|
|
|
- if(StringUtils.isBlank(model.getStoreId())){
|
|
|
+ if (StringUtils.isBlank(model.getStoreId())) {
|
|
|
throw new BusinessException("请设置库位信息");
|
|
|
}
|
|
|
spareStore.setStoreId(model.getStoreId());
|
|
|
BigDecimal price = model.getInitialValue();
|
|
|
spareStore.setPrice(model.getInitialValue());
|
|
|
- spareStore.setNum(model.getInitStock() );
|
|
|
- spareStore.setInitNum(model.getInitStock() );
|
|
|
+ spareStore.setNum(model.getInitStock());
|
|
|
+ spareStore.setInitNum(model.getInitStock());
|
|
|
spareStore.setInitPrice(model.getInitialValue());
|
|
|
spareStore.setInitPurchasePrice(model.getInitialValue());
|
|
|
spareStore.setCreatedTime(time);
|
|
@@ -365,8 +494,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
|
|
|
// 插入设备关联
|
|
|
List<SbModelSpareBomDTO> detailList = model.getDetailList();
|
|
|
- if(!CollectionUtils.isEmpty(detailList)){
|
|
|
- for(SbModelSpareBomDTO detail:detailList) {
|
|
|
+ if (!CollectionUtils.isEmpty(detailList)) {
|
|
|
+ for (SbModelSpareBomDTO detail : detailList) {
|
|
|
detail.setSpareId(model.getId());
|
|
|
detail.setId(IdGeneratorUtils.getObjectId());
|
|
|
}
|
|
@@ -375,6 +504,54 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
return super.saveModelHaveCreateInfo(model);
|
|
|
}
|
|
|
|
|
|
+ public void setSpareNo(SparePartInfoDTO model) {
|
|
|
+ String prefix = "";
|
|
|
+ SpareType spareType = spareTypeMapper.selectByPrimaryKey(model.getTypeId());
|
|
|
+ if (StringUtils.isNotBlank(spareType.getParentId())) {
|
|
|
+ SpareType spareType1 = spareTypeMapper.selectByPrimaryKey(spareType.getParentId());
|
|
|
+ prefix += spareType1.getNo() + "-";
|
|
|
+ }
|
|
|
+ prefix += spareType.getNo() + "-";
|
|
|
+ String selectMaxNo = mapper.selectMaxNo(model.getTypeId());
|
|
|
+ if (StringUtils.isBlank(selectMaxNo)) {
|
|
|
+ model.setNo(prefix + "00001");
|
|
|
+ } else {
|
|
|
+ String newStr = selectMaxNo.substring(selectMaxNo.length() - 5).replaceFirst("^0*", "");
|
|
|
+ int count = Integer.valueOf(newStr) + 1;
|
|
|
+ String str1 = String.format("%05d", count);
|
|
|
+ model.setNo(prefix + str1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateSpareNo(SparePartInfo model) {
|
|
|
+ String prefix = "";
|
|
|
+ SpareType spareType = spareTypeMapper.selectByPrimaryKey(model.getTypeId());
|
|
|
+ if(spareType == null){
|
|
|
+ throw new BusinessException("备件类别不存在:type_id=" + model.getTypeId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(spareType.getParentId())) {
|
|
|
+ SpareType spareType1 = spareTypeMapper.selectByPrimaryKey(spareType.getParentId());
|
|
|
+ prefix += spareType1.getNo() + "-";
|
|
|
+ }
|
|
|
+ prefix += spareType.getNo() + "-";
|
|
|
+ String selectMaxNo = mapper.selectMaxNo(model.getTypeId());
|
|
|
+ if (StringUtils.isBlank(selectMaxNo)) {
|
|
|
+ model.setNo(prefix + "00001");
|
|
|
+ } else {
|
|
|
+ log.info("selectMaxNo: " + selectMaxNo);
|
|
|
+ String newStr = selectMaxNo.substring(selectMaxNo.length() - 5).replaceFirst("^0*", "");
|
|
|
+ int count = Integer.valueOf(newStr) + 1;
|
|
|
+ String str1 = String.format("%05d", count);
|
|
|
+ model.setNo(prefix + str1);
|
|
|
+ }
|
|
|
+ SparePartInfo sparePartInfo = new SparePartInfo();
|
|
|
+ sparePartInfo.setId(model.getId());
|
|
|
+ sparePartInfo.setNo(model.getNo());
|
|
|
+ mapper.updateByPrimaryKeySelective(sparePartInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void modModelByDTO(SparePartInfoDTO model) {
|
|
|
UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
@@ -384,29 +561,29 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
SpareType middleType = spareTypeMapper.selectByPrimaryKey(model.getMiddleTypeId());
|
|
|
String parentTypeNo = "";
|
|
|
String middleTypeNo = "";
|
|
|
- if(parentType !=null){
|
|
|
+ if (parentType != null) {
|
|
|
parentTypeNo = parentType.getNo();
|
|
|
model.setParentNo(parentTypeNo);
|
|
|
}
|
|
|
- if(middleType != null){
|
|
|
+ if (middleType != null) {
|
|
|
middleTypeNo = middleType.getNo();
|
|
|
model.setMiddleNo(middleTypeNo);
|
|
|
}
|
|
|
String nameNo = model.getNameNo();
|
|
|
String ggNo = model.getGgNo();
|
|
|
String childTypeNo = null;
|
|
|
- if(StringUtils.isNotBlank(model.getChildTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(model.getChildTypeId())) {
|
|
|
SpareType childType = spareTypeMapper.selectByPrimaryKey(model.getChildTypeId());
|
|
|
childTypeNo = childType.getNo();
|
|
|
model.setChildNo(childTypeNo);
|
|
|
model.setTypeId(model.getChildTypeId());
|
|
|
model.setUniteNo(parentTypeNo + "-" + middleTypeNo + "-" + childTypeNo + "-" + nameNo + "-" + ggNo);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
model.setTypeId(model.getMiddleTypeId());
|
|
|
- if(StringUtils.isNotBlank(middleTypeNo)){
|
|
|
+ if (StringUtils.isNotBlank(middleTypeNo)) {
|
|
|
model.setTypeId(model.getMiddleTypeId());
|
|
|
model.setUniteNo(parentTypeNo + "-" + middleTypeNo);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
model.setTypeId(model.getParentTypeId());
|
|
|
model.setUniteNo(parentTypeNo);
|
|
|
}
|
|
@@ -415,7 +592,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
Weekend<SparePartInfo> weekend = new Weekend<>(SparePartInfo.class);
|
|
|
weekend.weekendCriteria().andEqualTo(SparePartInfo::getName, model.getName()).andEqualTo(SparePartInfo::getGgxh, model.getGgxh());
|
|
|
int count = mapper.selectCountByExample(weekend);
|
|
|
- if(count > 1){
|
|
|
+ if (count > 1) {
|
|
|
throw new BusinessException("同名称同规格的备件已存在,请重新设置名称或者规格");
|
|
|
}
|
|
|
|
|
@@ -428,46 +605,48 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
Weekend<SbModelSpareBom> detailWeekend = new Weekend<>(SbModelSpareBom.class);
|
|
|
List<String> ids = detailList.stream().map(SbModelSpareBomDTO::getId).collect(Collectors.toList());
|
|
|
ids = ids.stream().filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(ids) && ids.size()>0) {
|
|
|
+ if (!CollectionUtils.isEmpty(ids) && ids.size() > 0) {
|
|
|
detailWeekend.weekendCriteria().andNotIn(SbModelSpareBom::getId, ids);
|
|
|
sbModelSpareBomMapper.deleteByExample(detailWeekend);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 全部刪除:说明id为空,全部删除了
|
|
|
detailWeekend.weekendCriteria().andEqualTo(SbModelSpareBom::getSpareId, model.getId());
|
|
|
sbModelSpareBomMapper.deleteByExample(detailWeekend);
|
|
|
}
|
|
|
// 新增与更新
|
|
|
- if(!CollectionUtils.isEmpty(detailList)){
|
|
|
- for(SbModelSpareBomDTO detail:detailList) {
|
|
|
- if(StringUtils.isBlank(detail.getId())){
|
|
|
+ if (!CollectionUtils.isEmpty(detailList)) {
|
|
|
+ for (SbModelSpareBomDTO detail : detailList) {
|
|
|
+ if (StringUtils.isBlank(detail.getId())) {
|
|
|
detail.setSpareId(model.getId());
|
|
|
detail.setId(IdGeneratorUtils.getObjectId());
|
|
|
addList.add(detail);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
updateList.add(detail);
|
|
|
}
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addList)){
|
|
|
+ if (!CollectionUtils.isEmpty(addList)) {
|
|
|
sbModelSpareBomMapper.insertListforComplex(BeanConverterUtil.copyListProperties(addList, SbModelSpareBom.class));
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(updateList)){
|
|
|
+ if (!CollectionUtils.isEmpty(updateList)) {
|
|
|
sbModelSpareBomMapper.updateBatchAll(BeanConverterUtil.copyListProperties(updateList, SbModelSpareBom.class));
|
|
|
}
|
|
|
}
|
|
|
this.saveFile(model);
|
|
|
super.modModelByDTO(model);
|
|
|
}
|
|
|
+
|
|
|
private void saveFile(SparePartInfoDTO model) {
|
|
|
if (CollectionUtil.isNotEmpty(model.getApplicationFileList())) {
|
|
|
Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.SPARE_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
sysFileMapper.deleteByExample(weekend);
|
|
|
- List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(), SysFileTypeEnum.SPARE_IMGS.getValue());
|
|
|
+ List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(), SysFileTypeEnum.SPARE_IMGS.getValue());
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
sysFileMapper.insertListforComplex(list);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 导入备件基础信息
|
|
|
*
|
|
@@ -496,29 +675,29 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
List<SbModel> addSbModelItems = new ArrayList<SbModel>();
|
|
|
for (SparePartInfoVO item : items) {
|
|
|
System.out.println("正在处理:" + item.getName() + ",编号" + item.getNo());
|
|
|
- boolean isExist = false;
|
|
|
+ boolean isExist = false;
|
|
|
for (SparePartInfo old : vos) {
|
|
|
// System.out.println("正在对比:" + old.getName() + ", 规格" + old.getGgxh() + ", 原厂编号" + old.getInitNo());
|
|
|
- if(item.getGgxh() == null){
|
|
|
- if(old.getName().equals(item.getName()) && old.getGgxh() == null){
|
|
|
+ if (item.getGgxh() == null) {
|
|
|
+ if (old.getName().equals(item.getName()) && old.getGgxh() == null) {
|
|
|
isExist = true;
|
|
|
item.setId(old.getId());
|
|
|
item.setNo(old.getNo());
|
|
|
item.setInitNo(old.getInitNo());
|
|
|
- if(!modelExist.contains(item.getName() + ",规格" + item.getGgxh())){
|
|
|
+ if (!modelExist.contains(item.getName() + ",规格" + item.getGgxh())) {
|
|
|
modelExist.add(item.getName() + ",规格" + item.getGgxh());
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- if(old.getGgxh() == null){
|
|
|
+ } else {
|
|
|
+ if (old.getGgxh() == null) {
|
|
|
|
|
|
- }else{
|
|
|
- if(old.getName().equals(item.getName()) && old.getGgxh().equals(item.getGgxh())){
|
|
|
+ } else {
|
|
|
+ if (old.getName().equals(item.getName()) && old.getGgxh().equals(item.getGgxh())) {
|
|
|
isExist = true;
|
|
|
item.setId(old.getId());
|
|
|
item.setNo(old.getNo());
|
|
|
item.setInitNo(old.getInitNo());
|
|
|
- if(!modelExist.contains(item.getName() + ",规格" + item.getGgxh())){
|
|
|
+ if (!modelExist.contains(item.getName() + ",规格" + item.getGgxh())) {
|
|
|
modelExist.add(item.getName() + ",规格" + item.getGgxh());
|
|
|
}
|
|
|
}
|
|
@@ -527,54 +706,54 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
}
|
|
|
// 如果已经存在,则跳过去下一个,不行,需要获取id,因为要入库。需要备件信息
|
|
|
System.out.println("处理到这");
|
|
|
- if(isExist){
|
|
|
+ if (isExist) {
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 新增的,需要设置id和类别
|
|
|
item.setId(IdGeneratorUtils.getObjectId());
|
|
|
// 设置类型转换
|
|
|
for (SpareType type : typeList) {
|
|
|
- if(type.getName().equals(item.getParentName())){
|
|
|
+ if (type.getName().equals(item.getParentName())) {
|
|
|
item.setParentTypeId(type.getId());
|
|
|
item.setParentNo(type.getNo());
|
|
|
}
|
|
|
- if(type.getName().equals(item.getMiddleName())){
|
|
|
+ if (type.getName().equals(item.getMiddleName())) {
|
|
|
item.setMiddleTypeId(type.getId());
|
|
|
item.setMiddleNo(type.getNo());
|
|
|
}
|
|
|
- if(type.getName().equals(item.getChildName())){
|
|
|
+ if (type.getName().equals(item.getChildName())) {
|
|
|
item.setChildTypeId(type.getId());
|
|
|
item.setChildNo(type.getNo());
|
|
|
}
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(item.getChildTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(item.getChildTypeId())) {
|
|
|
item.setTypeId(item.getChildTypeId());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
item.setTypeId(item.getMiddleTypeId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 设置型号bom
|
|
|
boolean findModel = false;
|
|
|
- if(StringUtils.isNotBlank(item.getSbModel())){
|
|
|
+ if (StringUtils.isNotBlank(item.getSbModel())) {
|
|
|
SbModelSpareBom bom = new SbModelSpareBom();
|
|
|
bom.setSpareId(item.getId());
|
|
|
for (SbModel model : modelList) {
|
|
|
- if(model.getModel().equals(item.getSbModel())){
|
|
|
+ if (model.getModel().equals(item.getSbModel())) {
|
|
|
findModel = true;
|
|
|
// 判断该model是否已经有bom,如果有,则不导入,需要验证后重新导入。
|
|
|
boolean withBoms = false;
|
|
|
for (String modelIdWithBom : modelIdsWithBom) {
|
|
|
- if(model.getId().equals(modelIdWithBom)){
|
|
|
+ if (model.getId().equals(modelIdWithBom)) {
|
|
|
withBoms = true;
|
|
|
- if(!modelWarn.contains(item.getSbName() + ",型号" + item.getSbModel())){
|
|
|
+ if (!modelWarn.contains(item.getSbName() + ",型号" + item.getSbModel())) {
|
|
|
modelWarn.add(item.getSbName() + ",型号" + item.getSbModel());
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(withBoms){
|
|
|
+ if (withBoms) {
|
|
|
break;
|
|
|
}
|
|
|
bom.setId(IdGeneratorUtils.getObjectId());
|
|
@@ -587,8 +766,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(!findModel){
|
|
|
- if(!modelError.contains(item.getSbName() + ",型号" + item.getSbModel())){
|
|
|
+ if (!findModel) {
|
|
|
+ if (!modelError.contains(item.getSbName() + ",型号" + item.getSbModel())) {
|
|
|
modelError.add(item.getSbName() + ",型号" + item.getSbModel());
|
|
|
}
|
|
|
SbModel model = new SbModel();
|
|
@@ -610,12 +789,12 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
model.setId(IdGeneratorUtils.getObjectId());
|
|
|
boolean withModelBoms = false;
|
|
|
for (SbModel modelIs : addSbModelItems) {
|
|
|
- if(modelIs.getName().equals(model.getName()) && modelIs.getModel().equals(model.getModel())){
|
|
|
+ if (modelIs.getName().equals(model.getName()) && modelIs.getModel().equals(model.getModel())) {
|
|
|
withModelBoms = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(!withModelBoms){
|
|
|
+ if (!withModelBoms) {
|
|
|
addSbModelItems.add(model);
|
|
|
}
|
|
|
bom.setId(IdGeneratorUtils.getObjectId());
|
|
@@ -626,7 +805,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
bom.setUpdateTime(now);
|
|
|
bom.setUpdateUserId("1");
|
|
|
bomList.add(bom);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
bomList.add(bom);
|
|
|
}
|
|
|
}
|
|
@@ -646,29 +825,29 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
spareStore.setUpdateTime(now);
|
|
|
spareStore.setUpdateUserId("1");
|
|
|
spareStoreList.add(spareStore);
|
|
|
- if(!isExist) {
|
|
|
+ if (!isExist) {
|
|
|
addItems.add(item);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(modelWarn.size()>0){
|
|
|
+ if (modelWarn.size() > 0) {
|
|
|
System.out.println("如下型号已经存在bom,该备件没有导入,后期可以自行导入: " + modelWarn.toString());
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addItems)){
|
|
|
- addItemsReal = BeanConverterUtil.copyListProperties(addItems,SparePartInfo.class);
|
|
|
+ if (!CollectionUtils.isEmpty(addItems)) {
|
|
|
+ addItemsReal = BeanConverterUtil.copyListProperties(addItems, SparePartInfo.class);
|
|
|
mapper.insertListforComplex(addItemsReal);
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addSbModelItems)){
|
|
|
+ if (!CollectionUtils.isEmpty(addSbModelItems)) {
|
|
|
sbModelMapper.insertListforComplex(addSbModelItems);
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(bomList)){
|
|
|
+ if (!CollectionUtils.isEmpty(bomList)) {
|
|
|
sbModelSpareBomMapper.insertListforComplex(bomList);
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(spareStoreList)){
|
|
|
+ if (!CollectionUtils.isEmpty(spareStoreList)) {
|
|
|
spareStoreMapper.insertListforComplex(spareStoreList);
|
|
|
}
|
|
|
}
|
|
|
- return "总计新增导入:"+ (addItems.size()) + "已存在未导入数量:" + modelExist.size() + ",找不到如下型号,已经添加:" + modelError.toString();
|
|
|
+ return "总计新增导入:" + (addItems.size()) + "已存在未导入数量:" + modelExist.size() + ",找不到如下型号,已经添加:" + modelError.toString();
|
|
|
} catch (Exception e) {
|
|
|
throw new BusinessException(e.getMessage());
|
|
|
}
|
|
@@ -700,22 +879,22 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
item.setId(IdGeneratorUtils.getObjectId());
|
|
|
// 设置类型转换
|
|
|
for (SpareType type : typeList) {
|
|
|
- if(type.getName().equals(item.getParentName())){
|
|
|
+ if (type.getName().equals(item.getParentName())) {
|
|
|
item.setParentTypeId(type.getId());
|
|
|
item.setParentNo(type.getNo());
|
|
|
}
|
|
|
- if(type.getName().equals(item.getMiddleName())){
|
|
|
+ if (type.getName().equals(item.getMiddleName())) {
|
|
|
item.setMiddleTypeId(type.getId());
|
|
|
item.setMiddleNo(type.getNo());
|
|
|
}
|
|
|
- if(type.getName().equals(item.getChildName())){
|
|
|
+ if (type.getName().equals(item.getChildName())) {
|
|
|
item.setChildTypeId(type.getId());
|
|
|
item.setChildNo(type.getNo());
|
|
|
}
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(item.getChildTypeId())){
|
|
|
+ if (StringUtils.isNotBlank(item.getChildTypeId())) {
|
|
|
item.setTypeId(item.getChildTypeId());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
item.setTypeId(item.getMiddleTypeId());
|
|
|
}
|
|
|
|
|
@@ -801,8 +980,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
addItems.add(item);
|
|
|
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addItems)){
|
|
|
- addItemsReal = BeanConverterUtil.copyListProperties(addItems,SparePartInfo.class);
|
|
|
+ if (!CollectionUtils.isEmpty(addItems)) {
|
|
|
+ addItemsReal = BeanConverterUtil.copyListProperties(addItems, SparePartInfo.class);
|
|
|
mapper.insertListforComplex(addItemsReal);
|
|
|
}
|
|
|
/* if(!CollectionUtils.isEmpty(addSbModelItems)){
|
|
@@ -811,11 +990,11 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
if(!CollectionUtils.isEmpty(bomList)){
|
|
|
sbModelSpareBomMapper.insertListforComplex(bomList);
|
|
|
}*/
|
|
|
- if(!CollectionUtils.isEmpty(spareStoreList)){
|
|
|
+ if (!CollectionUtils.isEmpty(spareStoreList)) {
|
|
|
spareStoreMapper.insertListforComplex(spareStoreList);
|
|
|
}
|
|
|
}
|
|
|
- return "总计新增导入:"+ (addItems.size()) ;
|
|
|
+ return "总计新增导入:" + (addItems.size());
|
|
|
} catch (Exception e) {
|
|
|
throw new BusinessException(e.getMessage());
|
|
|
}
|
|
@@ -827,35 +1006,36 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
List<SparePartInfoVO> addItems = new ArrayList<SparePartInfoVO>();
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
try {
|
|
|
- List<SparePartInfoVO> items = CustomExcelImportUtil.importSparePartInfoListForUpdate(now, file.getInputStream());
|
|
|
+ List<SparePartInfoVO> items = CustomExcelImportUtil.importSparePartInfoListForUpdate(file.getInputStream());
|
|
|
if (!CollectionUtils.isEmpty(items)) {
|
|
|
List<SpareType> typeList = spareTypeMapper.selectAll();
|
|
|
for (SparePartInfoVO item : items) {
|
|
|
// 设置类型转换
|
|
|
for (SpareType type : typeList) {
|
|
|
- if(type.getName().equals(item.getParentName())){
|
|
|
+ if (type.getName().equals(item.getTypeName())) {
|
|
|
item.setParentTypeId(type.getId());
|
|
|
item.setParentNo(type.getNo());
|
|
|
item.setTypeId(type.getId());
|
|
|
}
|
|
|
- if(type.getName().equals(item.getMiddleName()) && StringUtils.isNotBlank(type.getParentId()) && type.getParentId().equals(item.getParentTypeId())){
|
|
|
+ /*if (type.getName().equals(item.getMiddleName()) && StringUtils.isNotBlank(type.getParentId()) && type.getParentId().equals(item.getParentTypeId())) {
|
|
|
item.setMiddleTypeId(type.getId());
|
|
|
item.setMiddleNo(type.getNo());
|
|
|
item.setTypeId(type.getId());
|
|
|
}
|
|
|
- if(type.getName().equals(item.getChildName()) && StringUtils.isNotBlank(type.getParentId()) && type.getParentId().equals(item.getMiddleTypeId())){
|
|
|
+ if (type.getName().equals(item.getChildName()) && StringUtils.isNotBlank(type.getParentId()) && type.getParentId().equals(item.getMiddleTypeId())) {
|
|
|
item.setChildTypeId(type.getId());
|
|
|
item.setChildNo(type.getNo());
|
|
|
item.setTypeId(type.getId());
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
+ mapper.updateByPrimaryKeySelective(BeanConverterUtil.copyObjectProperties(item, SparePartInfo.class));
|
|
|
addItems.add(item);
|
|
|
}
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addItems)){
|
|
|
- mapper.updateBatch(addItems);
|
|
|
+ if (!CollectionUtils.isEmpty(addItems)) {
|
|
|
+ // mapper.updateBatch(addItems);
|
|
|
}
|
|
|
- return "总计修改:"+ addItems.size();
|
|
|
+ return "总计修改:" + addItems.size();
|
|
|
} catch (Exception e) {
|
|
|
throw new BusinessException(e.getMessage());
|
|
|
}
|
|
@@ -867,11 +1047,11 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
WeekendCriteria<SpareStore, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
weekendCriteria.andIn(SpareStore::getSpareId, ids);
|
|
|
List<SpareStore> list = spareStoreMapper.selectByExample(weekend);
|
|
|
- list.forEach(item->{
|
|
|
+ list.forEach(item -> {
|
|
|
item.setSpareId(spareId);
|
|
|
});
|
|
|
List<SpareStore> newlist = new ArrayList<SpareStore>();
|
|
|
- for(SpareStore spareStore:list){
|
|
|
+ for (SpareStore spareStore : list) {
|
|
|
SpareStore spare = new SpareStore();
|
|
|
spare.setId(spareStore.getId());
|
|
|
spare.setSpareId(spareId);
|
|
@@ -883,11 +1063,11 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
WeekendCriteria<SbModelSpareBom, Object> weekendCriteria2 = weekend2.weekendCriteria();
|
|
|
weekendCriteria2.andIn(SbModelSpareBom::getSpareId, ids);
|
|
|
List<SbModelSpareBom> sbModelSpareBomList = sbModelSpareBomMapper.selectByExample(weekend2);
|
|
|
- sbModelSpareBomList.forEach(item->{
|
|
|
+ sbModelSpareBomList.forEach(item -> {
|
|
|
item.setSpareId(spareId);
|
|
|
});
|
|
|
List<SbModelSpareBom> newSbModelSpareBomList = new ArrayList<SbModelSpareBom>();
|
|
|
- for(SbModelSpareBom spareStore:sbModelSpareBomList){
|
|
|
+ for (SbModelSpareBom spareStore : sbModelSpareBomList) {
|
|
|
SbModelSpareBom spare = new SbModelSpareBom();
|
|
|
spare.setId(spareStore.getId());
|
|
|
spare.setSpareId(spareId);
|
|
@@ -897,6 +1077,17 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
this.batchDelete(ids);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateSpareWarnStatus(String id, Integer type, Integer warnStatus) {
|
|
|
+ SparePartInfo sparePartInfo = mapper.selectById(id);
|
|
|
+ if (type == 1) {
|
|
|
+ sparePartInfo.setWarnStatus(warnStatus);
|
|
|
+ } else {
|
|
|
+ sparePartInfo.setForecastStatus(warnStatus);
|
|
|
+ }
|
|
|
+ mapper.updateByPrimaryKey(sparePartInfo);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void updateQrCode(SparePartInfoDTO model) {
|
|
|
SparePartInfo sbInfo = new SparePartInfo();
|