|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package org.springblade.desk.oem.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
@ -10,11 +11,13 @@ import org.springblade.desk.basic.mapper.CraftAbilityMapper; |
|
|
|
|
import org.springblade.desk.dashboard.mapper.BsProcessSetMapper; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.BsProcessSetEntity; |
|
|
|
|
import org.springblade.desk.oem.pojo.entity.OemProcessEntity; |
|
|
|
|
import org.springblade.desk.oem.pojo.entity.OemStatementCategoryEntity; |
|
|
|
|
import org.springblade.desk.oem.pojo.excel.OemProcessExcel; |
|
|
|
|
import org.springblade.desk.oem.pojo.excel.OemProcessImport; |
|
|
|
|
import org.springblade.desk.oem.pojo.vo.OemProcessVO; |
|
|
|
|
import org.springblade.desk.oem.mapper.OemProcessMapper; |
|
|
|
|
import org.springblade.desk.oem.service.IOemProcessService; |
|
|
|
|
import org.springblade.desk.oem.service.IOemStatementCategoryService; |
|
|
|
|
import org.springblade.scheduling.pojo.entity.CraftAbilityEntity; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
@ -40,6 +43,9 @@ public class OemProcessServiceImpl extends BaseServiceImpl<OemProcessMapper, Oem |
|
|
|
|
@Resource |
|
|
|
|
private BsProcessSetMapper processSetMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private IOemStatementCategoryService oemStatementCategoryService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<OemProcessVO> selectOemProcessPage(IPage<OemProcessVO> page, OemProcessVO mesOemProcess) { |
|
|
|
|
return page.setRecords(baseMapper.selectOemProcessPage(page, mesOemProcess)); |
|
|
|
|
@ -72,35 +78,66 @@ public class OemProcessServiceImpl extends BaseServiceImpl<OemProcessMapper, Oem |
|
|
|
|
Map<String, Long> processSetMap = processSetEntities.stream().collect(Collectors.toMap( |
|
|
|
|
entity -> entity.getCode(), |
|
|
|
|
entity -> entity.getId())); |
|
|
|
|
|
|
|
|
|
//根据工艺能力CODES获取相关工艺能力
|
|
|
|
|
importList.forEach(oemProcessImport -> { |
|
|
|
|
if (StringUtil.isNotBlank(oemProcessImport.getCaCodes())) { |
|
|
|
|
Set<Long> processSetIds = processSetEntities.stream().map(BsProcessSetEntity::getId).collect(Collectors.toSet()); |
|
|
|
|
List<OemProcessEntity> oemProcessEntities = this.list(new LambdaQueryWrapper<OemProcessEntity>().in(OemProcessEntity::getProcessId, processSetIds)); |
|
|
|
|
Map<Long, Long> oemProcessMap = oemProcessEntities.stream().collect(Collectors.toMap( |
|
|
|
|
entity -> entity.getProcessId(), |
|
|
|
|
entity -> entity.getId())); |
|
|
|
|
Set<String> statementCategorySet = importList.stream() |
|
|
|
|
.map(OemProcessImport::getStatementCategory) |
|
|
|
|
.filter(Objects::nonNull) |
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
List<OemStatementCategoryEntity> statementCategories = oemStatementCategoryService.list(new LambdaQueryWrapper<OemStatementCategoryEntity>().in(OemStatementCategoryEntity::getStatementCategory, statementCategorySet)); |
|
|
|
|
Map<String, Long> statementCategoryMap = statementCategories.stream().collect(Collectors.toMap( |
|
|
|
|
entity -> entity.getStatementCategory(), |
|
|
|
|
entity -> entity.getId())); |
|
|
|
|
int rowNum = 2; |
|
|
|
|
for (OemProcessImport oemProcessImport : importList) { |
|
|
|
|
if (StringUtils.isEmpty(oemProcessImport.getPaCode())) { |
|
|
|
|
return R.fail("第" + rowNum + "行,工序为空"); |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isEmpty(oemProcessImport.getCaCodes())){ |
|
|
|
|
return R.fail("第" + rowNum + "行,工艺能力为空"); |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isEmpty(oemProcessImport.getStatementCategory())){ |
|
|
|
|
return R.fail("第" + rowNum + "行,工序大类为空"); |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isEmpty(oemProcessImport.getManualStr())){ |
|
|
|
|
return R.fail("第" + rowNum + "行,是否手动结算为空"); |
|
|
|
|
} |
|
|
|
|
if (!processSetMap.containsKey(oemProcessImport.getPaCode())) { |
|
|
|
|
return R.fail("第" + rowNum + "行,工序不存在"); |
|
|
|
|
} |
|
|
|
|
if(!statementCategoryMap.containsKey(oemProcessImport.getStatementCategory())){ |
|
|
|
|
return R.fail("第" + rowNum + "行,工序大类不存在"); |
|
|
|
|
} |
|
|
|
|
LambdaQueryWrapper<CraftAbilityEntity> craftAbilityEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
Set<String> caCodeSet = Arrays.stream(oemProcessImport.getCaCodes().split(",")) |
|
|
|
|
.collect(Collectors.toCollection(HashSet::new)); |
|
|
|
|
craftAbilityEntityLambdaQueryWrapper.in(CollectionUtils.isNotEmpty(caCodeSet), CraftAbilityEntity::getCaCode, caCodeSet); |
|
|
|
|
List<CraftAbilityEntity> craftAbilityEntities = craftAbilityMapper.selectList(craftAbilityEntityLambdaQueryWrapper); |
|
|
|
|
if(caCodeSet.size() != craftAbilityEntities.size()){ |
|
|
|
|
return R.fail("第" + rowNum + "行,工艺能力不存在"); |
|
|
|
|
} |
|
|
|
|
Long processId = processSetMap.get(oemProcessImport.getPaCode()); |
|
|
|
|
|
|
|
|
|
String caIds = craftAbilityEntities.stream() |
|
|
|
|
.map(entity -> String.valueOf(entity.getId())) |
|
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
|
if (processSetMap.containsKey(oemProcessImport.getPaCode())) { |
|
|
|
|
oemProcessImport.setProcessId(processSetMap.get(oemProcessImport.getPaCode())); |
|
|
|
|
oemProcessImport.setProcessId(processId); |
|
|
|
|
oemProcessImport.setCraftIds(caIds); |
|
|
|
|
oemProcessImport.setManual("否".equals(oemProcessImport.getManualStr()) ? "0" : "1"); |
|
|
|
|
OemProcessEntity oemProcessEntity = new OemProcessEntity(); |
|
|
|
|
BeanUtils.copyProperties(oemProcessImport, oemProcessEntity); |
|
|
|
|
oemProcessEntity.setOemProcessCode(oemProcessImport.getPaCode()); |
|
|
|
|
OemProcessEntity one = this.getOne(Wrappers.<OemProcessEntity>lambdaQuery().eq(OemProcessEntity::getProcessId, oemProcessEntity.getProcessId())); |
|
|
|
|
if (one != null) { |
|
|
|
|
oemProcessEntity.setId(one.getId()); |
|
|
|
|
if(oemProcessMap.containsKey(processId)) { |
|
|
|
|
oemProcessEntity.setId(oemProcessMap.get(processId)); |
|
|
|
|
} |
|
|
|
|
oemProcessEntity.setStatementCategoryId(statementCategoryMap.get(oemProcessImport.getStatementCategory())); |
|
|
|
|
saves.add(oemProcessEntity); |
|
|
|
|
rowNum++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
baseMapper.insertOrUpdate(saves); |
|
|
|
|
return R.success("操作成功"); |
|
|
|
|
return R.status(this.saveOrUpdateBatch(saves)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|