|
@@ -15,6 +15,7 @@ import com.github.zuihou.business.centralToolMagazine.entity.ToolTask;
|
|
|
import com.github.zuihou.business.centralToolMagazine.service.ToolManagementService;
|
|
|
import com.github.zuihou.business.centralToolMagazine.dao.ToolManagementMapper;
|
|
|
import com.github.zuihou.business.centralToolMagazine.dto.ToolManagementSaveDTO;
|
|
|
+import com.github.zuihou.business.cuttercategories.entity.CutterCategories;
|
|
|
import com.github.zuihou.business.edgeLibrary.dto.ShelvesUpdateDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.PlanProductMapper;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.ToolTaskMapper;
|
|
@@ -26,12 +27,17 @@ import com.github.zuihou.business.productionReadyCenter.dao.CuttingToolMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.*;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.BomProcedureProductionresourceService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.BomProcedureToolService;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.service.MachineCuttingToolService;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.CutterCategoriesService;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourceBizService;
|
|
|
import com.github.zuihou.database.mybatis.auth.DataScope;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.injection.annonation.InjectionResult;
|
|
|
-import com.github.zuihou.tenant.entity.Productionresource;
|
|
|
+
|
|
|
import com.github.zuihou.utils.BeanPlusUtil;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
@@ -90,6 +96,18 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
|
|
|
@Autowired
|
|
|
private DictionaryMapper dictionaryMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CutterCategoriesService cutterCategoriesService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MachineCuttingToolService machineCuttingToolService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductionresourceBizService productionresourceBizService;
|
|
|
+
|
|
|
+ //默认机床刀位数
|
|
|
+ private final int DEVICE_CUTTER_POSITION = 40;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
protected String getRegion() {
|
|
@@ -199,6 +217,7 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
|
|
|
|
|
|
//产品所需所有的类别集合
|
|
|
List<String> toolId=new ArrayList<>();
|
|
|
+ Map<String, List<String>> toolMaps = Maps.newConcurrentMap();
|
|
|
|
|
|
//所有可执行设备资源
|
|
|
List<BomProcedureProductionresource> resourceList=new ArrayList<>();
|
|
@@ -211,12 +230,22 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
|
|
|
List<BomProcedureProductionresource> resourcelist = bomProcedureProductionresourceService.getResourcelist(bomProcedureVersion);
|
|
|
resourceList.addAll(resourcelist);
|
|
|
|
|
|
- List<BBomProcedureTool> toolList = bomProcedureToolService.list(Wraps.<BBomProcedureTool>lbQ().eq(BBomProcedureTool::getProcedureId,vo.getId()));
|
|
|
+ BBomProcedureTool bomProcedureTool = bomProcedureToolService.getOne(Wraps.<BBomProcedureTool>lbQ().eq(BBomProcedureTool::getProcedureId,vo.getId()).last("limit 1"));
|
|
|
+ //List<BBomProcedureTool> toolList = bomProcedureToolService.list(Wraps.<BBomProcedureTool>lbQ().eq(BBomProcedureTool::getProcedureId,vo.getId()));
|
|
|
/*List<String> toolIdList = toolList.stream()
|
|
|
.map(BBomProcedureTool::getCuttingToolCategory)
|
|
|
.collect(Collectors.toList()); */
|
|
|
- List<String> toolIdList = Lists.newArrayList();
|
|
|
+ List<String> toolIdList = null;
|
|
|
+ if (null == bomProcedureTool){
|
|
|
+ toolIdList = Lists.newArrayList();
|
|
|
+ }else{
|
|
|
+ String[] conditions = bomProcedureTool.getCuttingToolCategory().split("_");
|
|
|
+ List<CutterCategories> toolList = cutterCategoriesService.list(new LbqWrapper<CutterCategories>().eq(CutterCategories::getPartsNo, conditions[0]).eq(CutterCategories::getProcedureNo, conditions[1]));
|
|
|
+ toolIdList = toolList.stream().map(obj->obj.getCutterT())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
toolId.addAll(toolIdList);
|
|
|
+ toolMaps.put(vo.getId().toString(), toolId);
|
|
|
});
|
|
|
if(CollectionUtil.isEmpty(toolId)){
|
|
|
log.info("刀具校验:未配置工艺刀具");
|
|
@@ -235,30 +264,43 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
|
|
|
ToolCheckDTO toolCheckDTO=new ToolCheckDTO();
|
|
|
|
|
|
//机床现有刀具集合
|
|
|
- List<Long> realToolId = toolManagementMapper.getToolManagementToolId(vo.getResourceId());
|
|
|
- Integer freeCount = toolManagementMapper.getFreeStorge(vo.getResourceId());
|
|
|
+ //List<Long> realToolId = toolManagementMapper.getToolManagementToolId(vo.getResourceId());
|
|
|
+ //Integer freeCount = toolManagementMapper.getFreeStorge(vo.getResourceId());
|
|
|
+ Productionresource productionresource = productionresourceBizService.getById(vo.getResourceId());
|
|
|
+ List<String> realToolId = null;
|
|
|
+ Integer freeCount = 0;
|
|
|
+ //判断是否机床
|
|
|
+ if(StringUtils.isNotEmpty(productionresource.getModeSpecification())){
|
|
|
+ realToolId = machineCuttingToolService.list(new LbqWrapper<MachineCuttingTool>().eq(MachineCuttingTool::getMachineId, vo.getResourceId())).stream().map(obj->obj.getCuttingToolId()).collect(Collectors.toList());
|
|
|
+ freeCount = DEVICE_CUTTER_POSITION - realToolId.size();
|
|
|
+ }else{
|
|
|
+ realToolId = Lists.newArrayList();
|
|
|
+ }
|
|
|
+
|
|
|
//Integer freeCount=0;
|
|
|
//if(!realToolId.containsAll(toolId)){
|
|
|
//需要的类别
|
|
|
//List<String> toolCategory = cuttingToolMapper.getToolCategory(toolId);
|
|
|
|
|
|
//机床现有的类别
|
|
|
- List<String> realToolCategory = cuttingToolMapper.getToolCategory(realToolId);
|
|
|
+ //List<String> realToolCategory = cuttingToolMapper.getToolCategory(realToolId);
|
|
|
|
|
|
//比较 刀具类别 是否存在
|
|
|
- if(!realToolCategory.containsAll(toolId)){
|
|
|
+ if(freeCount > 0){
|
|
|
+ List<String> finalRealToolId = realToolId;
|
|
|
List<String> differenceCategory = toolId.stream()
|
|
|
- .filter(id -> !realToolCategory.contains(id))
|
|
|
+ .filter(id -> !finalRealToolId.contains(id))
|
|
|
.collect(Collectors.toList());
|
|
|
- List<String> dicName = dictionaryMapper.getDicName(toolId);
|
|
|
+ List<CutterCategories> cutterCategories = cutterCategoriesService.list(new LbqWrapper<CutterCategories>().in(CutterCategories::getCutterT, differenceCategory)).stream().collect(Collectors.toList());
|
|
|
+ //List<String> dicName = dictionaryMapper.getDicName(toolId);
|
|
|
/*List<Long> differenceTool = toolId.stream()
|
|
|
.filter(id -> !realToolId.contains(id))
|
|
|
.collect(Collectors.toList());
|
|
|
List<CuttingTool> cuttingTools = cuttingToolMapper.selectList(Wraps.<CuttingTool>lbQ().in(CuttingTool::getId, differenceTool));*/
|
|
|
//true 机床刀库空闲个数大于缺刀个数
|
|
|
Boolean isFree=freeCount > differenceCategory.size();
|
|
|
- ToolTask findToolTask = toolTaskMapper.selectOne(Wraps.<ToolTask>lbQ().eq(ToolTask::getPlanId, item));
|
|
|
- toolCheckDTO.setIsTask(Objects.isNull(findToolTask)?"否":"是");
|
|
|
+ //ToolTask findToolTask = toolTaskMapper.selectOne(Wraps.<ToolTask>lbQ().eq(ToolTask::getPlanId, item));
|
|
|
+ toolCheckDTO.setIsTask(differenceCategory.size()>0?"是":"否");
|
|
|
toolCheckDTO.setId(vo.getResourceId());
|
|
|
toolCheckDTO.setDeviceName(vo.getName());
|
|
|
toolCheckDTO.setName(bBom.getName());
|
|
@@ -266,7 +308,7 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
|
|
|
toolCheckDTO.setIsFree(isFree);
|
|
|
toolCheckDTO.setHasCuttingToolsFlag(CollectionUtil.isEmpty(differenceCategory) ? "是" : "否" );
|
|
|
toolCheckDTO.setMsg(CollectionUtil.isNotEmpty(differenceCategory) ?
|
|
|
- "缺少:"+dicName.stream().collect(Collectors.joining(","))+(isFree ? ",机床刀库空闲个数大于缺刀个数":""):"");
|
|
|
+ "缺少:"+cutterCategories.stream().map(obj->obj.getCutterName()).collect(Collectors.joining(","))+(isFree ? ",机床刀库空闲个数大于缺刀个数":"") +(" 缺刀总数:"+ differenceCategory.size() +"个"):"校验成功" );
|
|
|
toolCheckDTO.setPlanId(item);
|
|
|
returnList.add(toolCheckDTO);
|
|
|
}
|