组板履历

main
BKGY_MYT 4 weeks ago
parent 94472a99da
commit fce4ec5909

@ -1,10 +1,13 @@
package com.xisc.pm.api.controller.v1;
import com.google.ortools.Loader;
import com.xisc.pm.api.dto.PmPdRecDTO;
import com.xisc.pm.api.dto.PmProductionPlanReqDTO;
import com.xisc.pm.api.dto.model.*;
import com.xisc.pm.domain.entity.*;
import com.xisc.pm.domain.vo.util.JsonData;
import io.choerodon.core.oauth.CustomUserDetails;
import io.choerodon.core.oauth.DetailsHelper;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
@ -75,6 +78,8 @@ public class SubController {
private static List<PmCmdCont> pmCmdContDOList = new ArrayList<>();
//命令小板表
private static List<PmCmdSmallPlt> pmCmdSmallPltDOList = new ArrayList<>();
//组板履历表
private static List<PmPdRecDTO> pmPdRecs = new ArrayList<>();
// 全局变量,使用 ConcurrentHashMap 和 AtomicInteger 确保线程安全
private final ConcurrentHashMap<String, AtomicInteger> counterMap = new ConcurrentHashMap<>();
@ -351,7 +356,7 @@ public class SubController {
//TransactionStatus transactionStatus = transactionService.begin();
try {
//保存数据
SaveData(p);
SaveData(p,organizationId);
//transactionService.commit(transactionStatus);
} catch (Exception e) {
logger.error("保存事务回滚:" + p.getSlabNo(), e);
@ -2804,8 +2809,7 @@ public class SubController {
//设置保存数据
public void SetSaveDate(SlabInfoDO SInfo, Long organizationId) {
SetPmPdSlab(SInfo,organizationId);//组板板坯表 命令板坯表 命令大板表
SetPmPdPlateCut(organizationId);//大板粗切位置表
SetPmPdSlab(SInfo,organizationId);//组板板坯表 命令板坯表 命令大板表 大板粗切位置表
SetPmPdBlockPos(organizationId);//组合子板位置表
SetPmPdContSum(organizationId);//组板合同总量表 命令参数表
SetPmSmallPltPos(SInfo.getMscLineNo(),organizationId);//组板小板位置表 命令小板表
@ -2827,10 +2831,79 @@ public class SubController {
pmPdSlabDO.setMatDesignKind("S");
pmPdSlabDO.setPdStatusHp("18");
pmPdSlabDO.setPdResp("781"); // TODO 组板责任者 未赋值 操作人id
pmPdSlabDO.setFormPlateMode("A1"); //TODO 组板方式 需要判断
String formplateMode = "";
if(ggcr.getLtActInfoGPreOrder().stream().filter(item -> item.getCombinationFlag() == 1).count() == 0){ //无组合情况 为A
if(ggcr.getLtActInfoGPreOrder().stream().map(element -> element.getWid()).distinct().count() == 1){ //宽度相同为A1
formplateMode = "A1";
}else{//宽度不同为A2
formplateMode = "A2";
}
}else if(ggcr.getLtActInfoGPreOrder().stream().filter(item -> item.getSpecialFlag() == 1).count() == ggcr.getLtActInfoGPreOrder().size()){//全为22组合 为S或G
boolean checkS1 = true;//S1判断标识
boolean checkS3 = true;//S3判断标识
boolean checkS = true;//S判断标识
Integer checkWid1 = ggcr.getLtActInfoGPreOrder().get(0).getLtInfoCombGPreOrder().get(0).getInfoGPreOrder().getWid();//第一组合第一块的宽度
Integer checkWid2 = ggcr.getLtActInfoGPreOrder().get(0).getLtInfoCombGPreOrder().get(1).getInfoGPreOrder().getWid();//第一组合第二块的宽度
Integer checkLen = ggcr.getLtActInfoGPreOrder().get(0).getLtInfoCombGPreOrder().get(0).getInfoGPreOrder().getLen();//第一组合第一块的长度
for(GPreOrder gPreOrder : ggcr.getLtActInfoGPreOrder()){
if(gPreOrder.getLtInfoCombGPreOrder().get(0).getLen() != gPreOrder.getLtInfoCombGPreOrder().get(1).getLen()){ //上下不同长 非S
checkS = false;
break;
}
if(gPreOrder.getLtInfoCombGPreOrder().get(0).getWid() != checkWid1 || gPreOrder.getLtInfoCombGPreOrder().get(1).getWid() != checkWid2){//左右不同宽 非S
checkS = false;
break;
}
for(GComBOrder gComBOrder : gPreOrder.getLtInfoCombGPreOrder()){
if(gComBOrder.getWid() != checkWid1){//宽不全相同 非S1 S3
checkS1 = false;
checkS3 = false;
}
if(gComBOrder.getLen() != checkLen){// 长不全相同 非S1
checkS1 = false;
}
}
}
if(checkS){
if(checkS1){
formplateMode = "S1";
}else if(checkS3){
formplateMode = "S3";
}else{
if(checkWid1 > checkWid2){
formplateMode = "S7";
}else{
formplateMode = "S2";
}
}
}else{
formplateMode = "G";
}
// if(checkS1){
// formplateMode = "S1";
// }else if(checkS3){
// formplateMode = "S3";
// }else if(checkS){
// if(checkWid1 > checkWid2){
// formplateMode = "S7";
// }else{
// formplateMode = "S2";
// }
// }else {
// formplateMode = "G";
// }
}else{
if(ggcr.getLtActInfoGPreOrder().stream().filter(item -> item.getCombinationFlag() == 2).count() > 0){//存在特殊标记为2的情况 一拖多为G1
formplateMode = "G1";
}else{//其余情况均为G
formplateMode = "G";
}
}
pmPdSlabDO.setFormPlateMode(formplateMode);
pmPdSlabDO.setPickModeLenDir(BigDecimal.valueOf(ggcr.getLtActInfoGPreOrder().size()));
BigDecimal widDir = ggcr.getLtActInfoGPreOrder().stream().filter(item -> item.getCombinationFlag() == 0).count() > 0? BigDecimal.ONE: BigDecimal.valueOf(2);
pmPdSlabDO.setPickModeWidDir(widDir); //TODO 取板方式_宽度方向 未赋值
pmPdSlabDO.setPickModeWidDir(widDir);
pmPdSlabDO.setFurType("C");// TODO 加热炉类型 暂时赋值为C
pmPdSlabDO.setAutoManualFlag("M");
pmPdSlabDO.setOrderRemainDiv("1");
@ -3044,7 +3117,8 @@ public class SubController {
pmPdSlabDO.setRollAimLen(BigDecimal.valueOf(ggcr.getCal_Len()));
pmPdSlabDO.setOrderThickAxis(axleGPreOrder.getThk());
pmPdSlabDO.setCombinePlateWidth(BigDecimal.valueOf(axleGPreOrder.getWid()));
pmPdSlabDO.setCombinePlateLen(BigDecimal.valueOf(axleGPreOrder.getLen()));
Integer lenSum = ggcr.getLtActInfoGPreOrder().stream().mapToInt(GPreOrder::getLen).sum();
pmPdSlabDO.setCombinePlateLen(BigDecimal.valueOf(lenSum));
pmPdSlabDO.setRollWtHp(weight);
BigDecimal minThickTolMax = ggcr.getLtActInfoGPreOrder().stream()
@ -3110,34 +3184,90 @@ public class SubController {
SetPmCmdSlab(pmPdSlabDO,resultPmProContProdAttrDO.get(),organizationId);//命令板坯表
SetPmCmdLargePlt(pmPdSlabDO, ggcr,resultPmContMscTechDO1.get(),resultPmProContProdAttrDO.get(),organizationId);//命令大板表
SetPmPdPlateCut(organizationId,formplateMode,SInfo.getMscLineNo().substring(SInfo.getMscLineNo().length()-2));//大板粗切位置表
SetPmPdRecDTO(orderNoList,organizationId,SInfo.getMscLineNo(),ggcr.getVirtualSlabNo());//组板履历表
pmPdSlabDOList.add(pmPdSlabDO);
}
}
//大板粗切位置表
public void SetPmPdPlateCut(Long organizationId) {
public void SetPmPdPlateCut(Long organizationId, String formplateMode, String mscLineNo) {
if(formplateMode.equals("A1") || formplateMode.equals("A2")){
formplateMode = "A";
}else if(formplateMode.equals("S1") || formplateMode.equals("S2")|| formplateMode.equals("S3")|| formplateMode.equals("S7")){
formplateMode = "S";
}else{
formplateMode = "G";
}
String formplateModeFirst = formplateMode;
Integer wid = gltSelGGrpCalRslt.get(0).getLtActInfoGPreOrder().get(0).getWid();
List<PmCutPlaceBt> filteredList = plistPmCutPlaceBtDO.stream()
.filter(p -> p.getPlateThickFrom().compareTo(BigDecimal.valueOf(wid)) < 0
&& p.getPlateThickTo().compareTo(BigDecimal.valueOf(wid)) > 0
&& p.getFormPlateModeFirst().equals(formplateModeFirst)
&& p.getRollLineNo().equals(mscLineNo))
.collect(Collectors.toList());
BigDecimal cutMax = BigDecimal.valueOf(40000);
if(!filteredList.isEmpty()) {
cutMax = filteredList.get(0).getNormalCutLenTo();
}
for (int i = 0; i < gltSelGGrpCalRslt.size(); i++) {// 异宽判断 长度判断 热处理
GGrpCalRslt ggcr = gltSelGGrpCalRslt.get(i);
PmPdPlateCut pmPdPlateCutDO = new PmPdPlateCut();
pmPdPlateCutDO.setPdMatNo(ggcr.getVirtualSlabNo());
//TODO 粗切类型 粗切位置 位置序号 取值待定
pmPdPlateCutDO.setCutType("P"); //粗切类型M:搬送用D:异宽用P命令用H热分切用
//pmPdPlateCutDO.setPositionType();
//pmPdPlateCutDO.setPositionSeq();
pmPdPlateCutDO.setCreatedBy(781L);//TODO 创建人修改人暂时默认781 BKGY
pmPdPlateCutDO.setLastUpdatedBy(781L);
pmPdPlateCutDO.setCreationDate(now);
pmPdPlateCutDO.setLastUpdateDate(now);
pmPdPlateCutDO.setTenantId(organizationId);
// pmPdPlateCutDO.setObjectVersionNumber(1L);
pmPdPlateCutDOList.add(pmPdPlateCutDO);
Integer lastWid = 0;
Integer lastLen = 0;
for(int j = 0; j < ggcr.getLtActInfoGPreOrder().size(); j++){
if(j == 0){
lastWid = ggcr.getLtActInfoGPreOrder().get(j).getWid();
lastLen = ggcr.getLtActInfoGPreOrder().get(j).getLen();
}else{
if(BigDecimal.valueOf(lastLen).compareTo(cutMax) > 0){
SetPmPdPlateCutFM(ggcr.getVirtualSlabNo(), "P", Long.valueOf(j),organizationId);
lastLen = 0;
}else{
if(lastWid != ggcr.getLtActInfoGPreOrder().get(j).getWid()){
SetPmPdPlateCutFM(ggcr.getVirtualSlabNo(), "D", Long.valueOf(j+1),organizationId);
lastLen = 0;
}else{
lastLen += ggcr.getLtActInfoGPreOrder().get(j).getLen();
}
}
lastWid = ggcr.getLtActInfoGPreOrder().get(j).getWid();
}
}
}
}
public void SetPmPdPlateCutFM(String virtualSlabNo, String cutType,Long positionSeq, Long organizationId) {
PmPdPlateCut pmPdPlateCutDOF = new PmPdPlateCut();
pmPdPlateCutDOF.setPdMatNo(virtualSlabNo);
pmPdPlateCutDOF.setCutType(cutType); //粗切类型M:搬送用D:异宽用P命令用H热分切用
pmPdPlateCutDOF.setPositionType("F");
pmPdPlateCutDOF.setPositionSeq(positionSeq);
pmPdPlateCutDOF.setCreatedBy(781L);//TODO 创建人修改人暂时默认781 BKGY
pmPdPlateCutDOF.setLastUpdatedBy(781L);
pmPdPlateCutDOF.setCreationDate(now);
pmPdPlateCutDOF.setLastUpdateDate(now);
pmPdPlateCutDOF.setTenantId(organizationId);
PmPdPlateCut pmPdPlateCutDOM = new PmPdPlateCut();
pmPdPlateCutDOM.setPdMatNo(virtualSlabNo);
pmPdPlateCutDOM.setCutType(cutType); //粗切类型M:搬送用D:异宽用P命令用H热分切用
pmPdPlateCutDOM.setPositionType("M");
pmPdPlateCutDOM.setPositionSeq(positionSeq);
pmPdPlateCutDOM.setCreatedBy(781L);//TODO 创建人修改人暂时默认781 BKGY
pmPdPlateCutDOM.setLastUpdatedBy(781L);
pmPdPlateCutDOM.setCreationDate(now);
pmPdPlateCutDOM.setLastUpdateDate(now);
pmPdPlateCutDOM.setTenantId(organizationId);
pmPdPlateCutDOList.add(pmPdPlateCutDOF);
pmPdPlateCutDOList.add(pmPdPlateCutDOM);
}
//组合子板位置表
public void SetPmPdBlockPos(Long organizationId) {
for (int i = 0; i < gltSelGGrpCalRslt.size(); i++) {
@ -3686,7 +3816,22 @@ public class SubController {
pmCmdSmallPltDOList.add(pmCmdSmallPltDO);
}
public void SaveData(SlabInfoDO p) {
public void SetPmPdRecDTO(List<String> orderNoList, Long organizationId,String mscLineNo,String virtualSlabNo) {
CustomUserDetails userDetails = DetailsHelper.getUserDetails();
for (String orderNo : orderNoList) {
PmPdRecDTO pmPdRecDTO = new PmPdRecDTO();
pmPdRecDTO.setOrderNo(orderNo);
pmPdRecDTO.setEventMaker(userDetails == null ? "": userDetails.getUserId().toString());
pmPdRecDTO.setMscLineNo(mscLineNo);
pmPdRecDTO.setKeyvalue1Desc(PmPdRecDTO.DESC_VIRTUAL_SLAB_NO);
pmPdRecDTO.setKeyvalue1(virtualSlabNo);
pmPdRecDTO.setMatNo(virtualSlabNo);
pmPdRecDTO.setQty(BigDecimal.ZERO);
pmPdRecs.add(pmPdRecDTO);
}
}
public void SaveData(SlabInfoDO p,Long organizationId) {
// subService.batchInsertPmPdSlab(pmPdSlabDOList);
// System.out.println("PmPdSlab表一保存成功");
// subService.batchInsertPmCmdSlab(pmCmdSlabDOList);
@ -3706,7 +3851,7 @@ public class SubController {
// subService.batchInsertPmCmdCont(pmCmdContDOList);
// System.out.println("PmCmdCont 命令参数 保存成功");
subService.SaveData(p,pmPdSlabDOList, pmPdPlateCutDOList, pmPdBlockPosDOList, pmPdContSumDOList, pmSmallPltPosDOList, pmCmdSlabDOList, pmCmdLargePltDOList, pmCmdContDOList, pmCmdSmallPltDOList,plistpmSubHisDO,plistpmSubOrdDO);
subService.SaveData(p,pmPdSlabDOList, pmPdPlateCutDOList, pmPdBlockPosDOList, pmPdContSumDOList, pmSmallPltPosDOList, pmCmdSlabDOList, pmCmdLargePltDOList, pmCmdContDOList, pmCmdSmallPltDOList,plistpmSubHisDO,plistpmSubOrdDO,pmPdRecs,organizationId);
}

@ -62,4 +62,7 @@ public class GPreOrder {
private int CombinationFlag = 0;
//组合信息
private List<GComBOrder> LtInfoCombGPreOrder;
// 特殊组合标识 22 1 1拖多 2(G1只有这一种情况) 3层 3 一定为G
private int specialFlag = 0;
}

@ -1,5 +1,6 @@
package com.xisc.pm.app.service;
import com.xisc.pm.api.dto.PmPdRecDTO;
import com.xisc.pm.api.dto.model.*;
import com.xisc.pm.domain.entity.*;
@ -123,7 +124,7 @@ public interface SubService {
List<PmThickAddvBt> getPmThickAddvBt();
void SaveData(SlabInfoDO p,List<PmPdSlab> pmPdSlabDOList, List<PmPdPlateCut> pmPdPlateCutDOList, List<PmPdBlockPos> pmPdBlockPosDOList, List<PmPdContSum> pmPdContSumDOList, List<PmSmallPltPos> pmSmallPltPosDOList, List<PmCmdSlab> pmCmdSlabDOList, List<PmCmdLargePlt> pmCmdLargePltDOList, List<PmCmdCont> pmCmdContDOList, List<PmCmdSmallPlt> pmCmdSmallPltDOList, List<PmSubHis> plistpmSubHisDO, List<PmSubOrd> plistpmSubOrdDO);
void SaveData(SlabInfoDO p, List<PmPdSlab> pmPdSlabDOList, List<PmPdPlateCut> pmPdPlateCutDOList, List<PmPdBlockPos> pmPdBlockPosDOList, List<PmPdContSum> pmPdContSumDOList, List<PmSmallPltPos> pmSmallPltPosDOList, List<PmCmdSlab> pmCmdSlabDOList, List<PmCmdLargePlt> pmCmdLargePltDOList, List<PmCmdCont> pmCmdContDOList, List<PmCmdSmallPlt> pmCmdSmallPltDOList, List<PmSubHis> plistpmSubHisDO, List<PmSubOrd> plistpmSubOrdDO, List<PmPdRecDTO> pmPdRecDTOList, Long organizationId);
// void SaveData(List<PmPdSlab> pmPdSlabDOList, List<PmPdPlateCut> pmPdPlateCutDOList, List<PmPdBlockPos> pmPdBlockPosDOList, List<PmPdContSum> pmPdContSumDOList, List<PmSmallPltPos> pmSmallPltPosDOList, List<PmCmdSlab> pmCmdSlabDOList, List<PmCmdLargePlt> pmCmdLargePltDOList, List<PmCmdCont> pmCmdContDOList, List<PmCmdSmallPlt> pmCmdSmallPltDOList);
}

@ -1,27 +1,35 @@
package com.xisc.pm.app.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.xisc.pm.api.dto.PmPdRecDTO;
import com.xisc.pm.api.dto.PmPdSlabSplitDTO;
import com.xisc.pm.api.dto.PmProContYieldDTO;
import com.xisc.pm.api.dto.model.*;
import com.xisc.pm.app.service.PmPdRecService;
import com.xisc.pm.app.service.strategy.PdMatTypeStrategyFactory;
import com.xisc.pm.app.service.strategy.pdmattype.PdMatTypeStrategy;
import com.xisc.pm.domain.entity.*;
import com.xisc.pm.domain.repository.*;
import com.xisc.pm.domain.vo.MatStatusModifyVO;
import com.xisc.pm.infra.client.MmEventClient;
import com.xisc.pm.infra.constant.Constants;
import com.xisc.pm.infra.constant.PmPlateConstants;
import com.xisc.pm.infra.enums.PdEventType;
import com.xisc.pm.infra.mapper.SubMapper;
import com.xisc.pm.app.service.SubService;
import com.xisc.pm.infra.util.BeanUtils;
import io.choerodon.core.exception.CommonException;
import io.choerodon.core.oauth.CustomUserDetails;
import io.choerodon.core.oauth.DetailsHelper;
import org.hzero.core.base.BaseConstants;
import org.hzero.core.redis.RedisHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Service
public class SubServiceImpl implements SubService {
@ -68,6 +76,12 @@ public class SubServiceImpl implements SubService {
@Autowired
private MmEventClient mmEventClient;
@Autowired
private RedisHelper redisHelper;
@Autowired
private PmPdRecService pmPdRecService;
// 获取板坯信息
@Override
public List<SlabInfoDO> getSlabInfo(SubParams subParams) {
@ -414,7 +428,7 @@ public class SubServiceImpl implements SubService {
@Override
@Transactional(rollbackFor = Exception.class)
public void SaveData(SlabInfoDO p,List<PmPdSlab> pmPdSlabDOList, List<PmPdPlateCut> pmPdPlateCutDOList, List<PmPdBlockPos> pmPdBlockPosDOList, List<PmPdContSum> pmPdContSumDOList, List<PmSmallPltPos> pmSmallPltPosDOList, List<PmCmdSlab> pmCmdSlabDOList, List<PmCmdLargePlt> pmCmdLargePltDOList, List<PmCmdCont> pmCmdContDOList, List<PmCmdSmallPlt> pmCmdSmallPltDOList, List<PmSubHis> plistpmSubHisDO, List<PmSubOrd> plistpmSubOrdDO) {
public void SaveData(SlabInfoDO p,List<PmPdSlab> pmPdSlabDOList, List<PmPdPlateCut> pmPdPlateCutDOList, List<PmPdBlockPos> pmPdBlockPosDOList, List<PmPdContSum> pmPdContSumDOList, List<PmSmallPltPos> pmSmallPltPosDOList, List<PmCmdSlab> pmCmdSlabDOList, List<PmCmdLargePlt> pmCmdLargePltDOList, List<PmCmdCont> pmCmdContDOList, List<PmCmdSmallPlt> pmCmdSmallPltDOList, List<PmSubHis> plistpmSubHisDO, List<PmSubOrd> plistpmSubOrdDO, List<PmPdRecDTO> pmPdRecDTOList, Long organizationId) {
// 调用mm接口
// 查询MM_SLAB 信息获取板坯信息
@ -433,6 +447,29 @@ public class SubServiceImpl implements SubService {
}
//抛合同事件
String bizId = pmPdRecDTOList.get(0).getKeyvalue1();
String key = String.format(PmPlateConstants.YIELD_EXEC_LOCK_KEY, organizationId.toString() , bizId);
if(redisHelper.hasKey(key)) {
throw new CommonException("pm.pm_pro_cont_043", bizId);
}
PdMatTypeStrategy pdMatTypeStrategy = PdMatTypeStrategyFactory.matchStrategy("S");
try {
// 抛合同组板事件
pmPdRecService.createEvent(organizationId, pmPdRecDTOList
, PdEventType.HP04, Constants.SYSTEM_PD_CODE, pdMatTypeStrategy.pdProgram());
redisHelper.strSet(key, "1", 30L, TimeUnit.SECONDS);
} finally {
// 抛合同组板释放事件
pmPdRecService.createEvent(organizationId, pmPdRecDTOList
, PdEventType.HP05, Constants.SYSTEM_PD_CODE, pdMatTypeStrategy.pdProgram());
redisHelper.delKey(key);
}
//抛合同事件
if(plistpmSubHisDO.size() > 0){
pmSubHisRepository.batchInsertSelective(plistpmSubHisDO);

Loading…
Cancel
Save