|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
package org.dromara.mes.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
@ -9,22 +8,22 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.dromara.mes.domain.ProdBaseRouteProcess;
|
|
|
|
|
import org.dromara.mes.domain.*;
|
|
|
|
|
import org.dromara.mes.domain.bo.ProdBaseRouteProcessBo;
|
|
|
|
|
import org.dromara.mes.domain.vo.ProdBaseRouteProcessVo;
|
|
|
|
|
import org.dromara.mes.mapper.ProdBaseRouteMaterialMapper;
|
|
|
|
|
import org.dromara.mes.service.IProdBaseRouteProcessService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.dromara.mes.domain.bo.ProdBaseRouteBo;
|
|
|
|
|
import org.dromara.mes.domain.vo.ProdBaseRouteVo;
|
|
|
|
|
import org.dromara.mes.domain.ProdBaseRoute;
|
|
|
|
|
import org.dromara.mes.mapper.ProdBaseRouteMapper;
|
|
|
|
|
import org.dromara.mes.service.IProdBaseRouteService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 工艺路线Service业务层处理
|
|
|
|
@ -40,6 +39,8 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
|
|
|
|
|
private final IProdBaseRouteProcessService routeProcessService;
|
|
|
|
|
|
|
|
|
|
private final ProdBaseRouteMaterialMapper routeMaterialMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询工艺路线
|
|
|
|
|
*
|
|
|
|
@ -47,13 +48,22 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
* @return 工艺路线
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ProdBaseRouteVo queryById(Long routeId){
|
|
|
|
|
public ProdBaseRouteVo queryById(Long routeId) {
|
|
|
|
|
ProdBaseRouteVo prodBaseRouteVo = routeMapper.selectVoById(routeId);
|
|
|
|
|
// queryList方法查询工艺路线组陈(工艺步骤)
|
|
|
|
|
// queryList方法查询工艺路线组成(工艺步骤)
|
|
|
|
|
ProdBaseRouteProcessBo prodBaseRouteProcessBo = new ProdBaseRouteProcessBo();
|
|
|
|
|
prodBaseRouteProcessBo.setRouteId(routeId);
|
|
|
|
|
List<ProdBaseRouteProcessVo> routeProcessVoList = routeProcessService.queryList(prodBaseRouteProcessBo);
|
|
|
|
|
prodBaseRouteVo.setRouteProcessVoList(routeProcessVoList);
|
|
|
|
|
prodBaseRouteVo.setRouteProcessList(routeProcessVoList);
|
|
|
|
|
|
|
|
|
|
// 关联物料
|
|
|
|
|
MPJLambdaWrapper<ProdBaseRouteMaterial> lqw = JoinWrappers.lambda(ProdBaseRouteMaterial.class);
|
|
|
|
|
lqw.selectAll(ProdBaseRouteMaterial.class)
|
|
|
|
|
.select(BaseMaterialInfo::getMaterialName)
|
|
|
|
|
.leftJoin(BaseMaterialInfo.class, BaseMaterialInfo::getMaterialId, ProdBaseRouteMaterial::getMaterialId)
|
|
|
|
|
.eq(ProdBaseRouteMaterial::getRouteId, routeId);
|
|
|
|
|
List<ProdBaseRouteMaterial> prodBaseRouteMaterialList = routeMaterialMapper.selectList(lqw);
|
|
|
|
|
prodBaseRouteVo.setProdBaseRouteMaterialList(prodBaseRouteMaterialList);
|
|
|
|
|
|
|
|
|
|
return prodBaseRouteVo;
|
|
|
|
|
}
|
|
|
|
@ -87,12 +97,12 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
private MPJLambdaWrapper<ProdBaseRoute> buildQueryWrapper(ProdBaseRouteBo bo) {
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
MPJLambdaWrapper<ProdBaseRoute> lqw = JoinWrappers.lambda(ProdBaseRoute.class)
|
|
|
|
|
.selectAll(ProdBaseRoute.class)
|
|
|
|
|
.eq(bo.getRouteId() != null, ProdBaseRoute::getRouteId, bo.getRouteId())
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getRouteName()), ProdBaseRoute::getRouteName, bo.getRouteName())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getRouteDesc()), ProdBaseRoute::getRouteDesc, bo.getRouteDesc())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ProdBaseRoute::getActiveFlag, bo.getActiveFlag())
|
|
|
|
|
.orderByAsc(ProdBaseRoute::getCreateTime);
|
|
|
|
|
.selectAll(ProdBaseRoute.class)
|
|
|
|
|
.eq(bo.getRouteId() != null, ProdBaseRoute::getRouteId, bo.getRouteId())
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getRouteName()), ProdBaseRoute::getRouteName, bo.getRouteName())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getRouteDesc()), ProdBaseRoute::getRouteDesc, bo.getRouteDesc())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ProdBaseRoute::getActiveFlag, bo.getActiveFlag())
|
|
|
|
|
.orderByAsc(ProdBaseRoute::getCreateTime);
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -111,7 +121,16 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
insertProdBaseRouteProcess(bo);
|
|
|
|
|
boolean flag = routeMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
assert add != null;
|
|
|
|
|
bo.setRouteId(add.getRouteId());
|
|
|
|
|
// 插入关联物料
|
|
|
|
|
List<ProdBaseRouteMaterial> materialList = bo.getProdBaseRouteMaterialList();
|
|
|
|
|
if (materialList != null && !materialList.isEmpty()) {
|
|
|
|
|
for (ProdBaseRouteMaterial material : materialList) {
|
|
|
|
|
material.setRouteId(add.getRouteId());
|
|
|
|
|
routeMaterialMapper.insert(material);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
@ -130,14 +149,44 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
Long routeId = bo.getRouteId();
|
|
|
|
|
routeMapper.deleteProdBaseRouteProcessByRouteId(routeId);
|
|
|
|
|
insertProdBaseRouteProcess(bo);
|
|
|
|
|
// 更新工艺路线关联物料
|
|
|
|
|
List<ProdBaseRouteMaterial> materialList = bo.getProdBaseRouteMaterialList();
|
|
|
|
|
MPJLambdaWrapper<ProdBaseRouteMaterial> lqwMaterial = JoinWrappers.lambda(ProdBaseRouteMaterial.class);
|
|
|
|
|
lqwMaterial.eq(ProdBaseRouteMaterial::getRouteId, bo.getRouteId());
|
|
|
|
|
List<ProdBaseRouteMaterial> dbMaterialList = routeMaterialMapper.selectList(lqwMaterial);
|
|
|
|
|
if (materialList != null && !materialList.isEmpty()) {
|
|
|
|
|
for (ProdBaseRouteMaterial material : materialList) {
|
|
|
|
|
material.setRouteId(bo.getRouteId());
|
|
|
|
|
if (material.getRouteMaterialId() == null) {
|
|
|
|
|
routeMaterialMapper.insert(material);
|
|
|
|
|
} else {
|
|
|
|
|
routeMaterialMapper.updateById(material);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Set<Long> existingIds = materialList.stream()
|
|
|
|
|
.filter(m -> m.getRouteMaterialId() != null)
|
|
|
|
|
.map(ProdBaseRouteMaterial::getRouteMaterialId)
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
List<ProdBaseRouteMaterial> filteredIds = dbMaterialList.stream()
|
|
|
|
|
.filter(field -> !existingIds.contains(field.getRouteMaterialId()))
|
|
|
|
|
.toList();
|
|
|
|
|
for (ProdBaseRouteMaterial material : filteredIds) {
|
|
|
|
|
routeMaterialMapper.deleteById(material.getRouteMaterialId());
|
|
|
|
|
}
|
|
|
|
|
} else if (dbMaterialList != null && !dbMaterialList.isEmpty()) {
|
|
|
|
|
// 如果前端传空,全部删除
|
|
|
|
|
for (ProdBaseRouteMaterial material : dbMaterialList) {
|
|
|
|
|
routeMaterialMapper.deleteById(material.getRouteMaterialId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
return updateResult > 0;
|
|
|
|
|
return updateResult > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存前的数据校验
|
|
|
|
|
*/
|
|
|
|
|
private void validEntityBeforeSave(ProdBaseRoute entity){
|
|
|
|
|
private void validEntityBeforeSave(ProdBaseRoute entity) {
|
|
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -151,7 +200,7 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
@Transactional
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
if(isValid){
|
|
|
|
|
if (isValid) {
|
|
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
}
|
|
|
|
|
routeProcessService.deleteWithValidByIds(ids, isValid);
|
|
|
|
@ -160,31 +209,28 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 插入工艺路线过程
|
|
|
|
|
*
|
|
|
|
|
* @param bo 包含工艺路线信息的业务对象
|
|
|
|
|
*/
|
|
|
|
|
public void insertProdBaseRouteProcess(ProdBaseRouteBo bo)
|
|
|
|
|
{
|
|
|
|
|
public void insertProdBaseRouteProcess(ProdBaseRouteBo bo) {
|
|
|
|
|
// 获取工艺路线中的工艺步骤列表
|
|
|
|
|
List<ProdBaseRouteProcessBo> prodBaseRouteProcessList = bo.getRouteProcessBoList();
|
|
|
|
|
List<ProdBaseRouteProcessBo> prodBaseRouteProcessList = bo.getRouteProcessList();
|
|
|
|
|
// 获取工艺路线ID
|
|
|
|
|
Long routeId = bo.getRouteId();
|
|
|
|
|
|
|
|
|
|
// 如果工艺步骤列表不为空
|
|
|
|
|
if (ObjectUtil.isNotNull(prodBaseRouteProcessList))
|
|
|
|
|
{
|
|
|
|
|
if (ObjectUtil.isNotNull(prodBaseRouteProcessList)) {
|
|
|
|
|
// 创建一个新的工艺步骤列表
|
|
|
|
|
List<ProdBaseRouteProcessBo> list = new ArrayList<ProdBaseRouteProcessBo>();
|
|
|
|
|
// 遍历每一个工艺步骤
|
|
|
|
|
for (ProdBaseRouteProcessBo prodBaseRouteProcess : prodBaseRouteProcessList)
|
|
|
|
|
{
|
|
|
|
|
for (ProdBaseRouteProcessBo prodBaseRouteProcess : prodBaseRouteProcessList) {
|
|
|
|
|
// 设置工艺步骤的工艺路线ID
|
|
|
|
|
prodBaseRouteProcess.setRouteId(routeId);
|
|
|
|
|
// 将工艺步骤添加到新的列表中
|
|
|
|
|
list.add(prodBaseRouteProcess);
|
|
|
|
|
}
|
|
|
|
|
// 如果新的工艺步骤列表不为空
|
|
|
|
|
if (!list.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
|
// 批量插入工艺步骤到数据库
|
|
|
|
|
routeMapper.batchProdBaseRouteProcess(list);
|
|
|
|
|
}
|
|
|
|
@ -193,6 +239,7 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据工艺路线ID查询工位信息
|
|
|
|
|
*
|
|
|
|
|
* @param routeId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -208,8 +255,7 @@ public class ProdBaseRouteServiceImpl implements IProdBaseRouteService {
|
|
|
|
|
* @return 工艺路线
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ProdBaseRouteVo selectProdBaseRouteByRouteId(Long routeId)
|
|
|
|
|
{
|
|
|
|
|
public ProdBaseRouteVo selectProdBaseRouteByRouteId(Long routeId) {
|
|
|
|
|
return routeMapper.selectProdBaseRouteByRouteId(routeId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|