From 3602e4088519be44965118c852593c6376217d4e Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 03 六月 2023 13:46:38 +0800
Subject: [PATCH] jlwms ==> xzjlwms
---
src/main/java/com/zy/common/service/CommonService.java | 258 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 201 insertions(+), 57 deletions(-)
diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index c0d057e..6afcffd 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -59,6 +59,8 @@
private LocDetlService locDetlService;
@Autowired
private SlaveProperties slaveProperties;
+ @Autowired
+ private LocRuleService locRuleService;
/**
* 鐢熸垚宸ヤ綔鍙�
@@ -112,13 +114,147 @@
* @return locNo 妫�绱㈠埌鐨勫簱浣嶅彿
*/
public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto,int times) {
-
- StartupDto startupDto = new StartupDto();
-
// 鐩爣搴撲綅
LocMast locMast = null;
+ //娣疯浇鎵惧簱浣�
+ locMast = getLocNoStep1(matNos, locTypeDto);
+ if (locMast != null) {
+ //鎵惧埌搴撲綅锛岃繑鍥瀌to
+ return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+ }
+
+ //搴撲綅瑙勫垯
+ locMast = getLocNoStep2(matNos, locTypeDto);
+ if (locMast != null) {
+ //鎵惧埌搴撲綅锛岃繑鍥瀌to
+ return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+ }
+
// 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
+ locMast = getLocNoStep3(staDescId, matNos, locTypeDto);
+ if (locMast != null) {
+ //鎵惧埌搴撲綅锛岃繑鍥瀌to
+ return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+ }
+
+ // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
+ locMast = getLocNoStep4(staDescId, locTypeDto);
+ if (locMast != null) {
+ //鎵惧埌搴撲綅锛岃繑鍥瀌to
+ return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+ }
+
+ // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
+ // 寮�濮嬫煡鎵惧簱浣� ==============================>>
+ locMast = getLocNoStep5(locTypeDto, times);
+ if (locMast != null) {
+ //鎵惧埌搴撲綅锛岃繑鍥瀌to
+ return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+ }
+
+ //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
+ throw new CoolException("娌℃湁绌哄簱浣�");
+ }
+
+ /**
+ * 娣疯浇鎵惧簱浣�
+ */
+ private LocMast getLocNoStep1(List<String> matNos, LocTypeDto locTypeDto) {
+ //鍒ゆ柇褰撳墠璐х墿鏄惁涓烘贩杞借揣鐗�
+ String firstMatNos = matNos.get(0);
+ boolean mixed = false;//榛樿涓嶆槸娣疯浇璐х墿
+ for (String matNo : matNos) {
+ if (!firstMatNos.equals(matNo)) {
+ mixed = true;//娣疯浇璐х墿
+ break;
+ }
+ }
+
+ if (!mixed) {
+ return null;//涓嶆槸娣疯浇璐х墿锛岀洿鎺ヨ烦鍑哄綋鍓嶄换鍔�
+ }
+
+ // 鎵炬贩杞藉簱浣嶈鍒�
+ List<LocRule> locRules = locRuleService.findMixed();
+ if (locRules == null || locRules.size() == 0) {
+ return null;//娌℃湁娣疯浇瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
+ }
+
+ for (LocRule locRule : locRules) {
+ if (locRule == null) {
+ continue;
+ }
+
+ List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
+
+ for (LocMast one : locMasts) {
+ LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
+ if (null != locMast0) {
+ // 娴呭簱浣嶇鍚堝昂瀵告娴�
+ if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
+ // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
+ if (locMastService.checkEmptyCount(locMast0, 10)) {
+ return locMast0;//鎵惧埌绌轰綑鐨勬贩杞藉簱浣�
+ }
+ }
+ }
+ }
+
+ }
+
+ if (locRules.get(0).getKeepGo() == 0) {
+ //鎵句笉鍒扮┖搴撲綅锛屼笖绂佹缁х画瀵绘壘鍏朵粬闈炴贩杞藉尯鍩熷簱浣�
+ //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
+ throw new CoolException("娣疯浇鍖哄煙娌℃湁绌哄簱浣�");
+ }
+
+ return null;
+ }
+
+ /**
+ * 搴撲綅瑙勫垯
+ */
+ private LocMast getLocNoStep2(List<String> matNos, LocTypeDto locTypeDto) {
+ LocMast locMast = null;
+ // 搴撳尯閿佸畾
+ List<LocRule> locRules = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0));
+ if (locRules == null || locRules.size() == 0) {
+ return null;//娌℃湁搴撲綅瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
+ }
+
+ for (LocRule locRule : locRules) {
+ if (locRule == null) {
+ continue;
+ }
+
+ List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
+ for (LocMast one : locMasts) {
+ LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
+ if (null != locMast0) {
+ // 娴呭簱浣嶇鍚堝昂瀵告娴�
+ if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
+ // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
+ if (locMastService.checkEmptyCount(locMast0, 10)) {
+ return locMast0;
+ }
+ }
+ }
+ }
+ }
+
+ if (locRules.get(0).getKeepGo() == 0) {
+ //鎵句笉鍒扮┖搴撲綅锛屼笖绂佹缁х画瀵绘壘鍏朵粬闈炴贩杞藉尯鍩熷簱浣�
+ //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
+ throw new CoolException("瑙勫垯鍖哄煙娌℃湁绌哄簱浣�");
+ }
+
+ return locMast;
+ }
+
+ // 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
+ private LocMast getLocNoStep3(Integer staDescId, List<String> matNos, LocTypeDto locTypeDto) {
+ LocMast locMast = null;
if (!Cools.isEmpty(matNos) && matNos.size() == 1 && staDescId == 1) {
//鍏堝垽鏂伐浣滄。锛屾煡鎵句富妗OType=1锛� wrkSts < 10鐨勫伐浣滄槑缁嗭紝鏂欏彿鐩稿悓鐨勬槑缁嗗簱浣�
List<WrkMast> wrkMasts = wrkMastService.selectSameMatnrs(matNos.get(0));
@@ -128,7 +264,6 @@
// 娴呭簱浣嶇鍚堝昂瀵告娴�
if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
locMast = locMast0;
- break;
}
}
}
@@ -148,27 +283,76 @@
}
}
+ return locMast;
+ }
+ // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
+ private LocMast getLocNoStep4(Integer staDescId, LocTypeDto locTypeDto) {
+ LocMast locMast = null;
// 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
if (staDescId == 10) {
- List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("loc_sts", "D"));
- if (locMasts.size() > 0) {
- for (LocMast loc : locMasts) {
- LocMast locMast0 = locMastService.findNearloc(loc.getLocNo());
- if (null != locMast0) {
- // 娴呭簱浣嶇鍚堝昂瀵告娴�
- if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
- locMast = locMast0;
- break;
-
+ //鍏堝垽鏂伐浣滄。锛屾煡鎵句富妗OType=1锛� wrkSts < 10鐨勫伐浣滄槑缁嗭紝鏂欏彿鐩稿悓鐨勬槑缁嗗簱浣�
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("io_type",10));
+ for (WrkMast wrkMast : wrkMasts) {
+ LocMast locMast0 = locMastService.findNearloc(wrkMast.getLocNo());
+ if (null != locMast0) {
+ // 娴呭簱浣嶇鍚堝昂瀵告娴�
+ if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
+ locMast = locMast0;
+ break;
+ }
+ }
+ }
+ if (Cools.isEmpty(locMast)){
+ List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
+ .eq("loc_sts", "D"));
+ if (locMasts.size() > 0) {
+ for (LocMast loc : locMasts) {
+ LocMast locMast0 = locMastService.findNearloc(loc.getLocNo());
+ if (null != locMast0) {
+ // 娴呭簱浣嶇鍚堝昂瀵告娴�
+ if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
+ locMast = locMast0;
+ break;
+ }
}
}
}
}
}
- // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
+ return locMast;
+ }
+
+ // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
+ private LocMast getLocNoStep5(LocTypeDto locTypeDto, int times) {
+ LocMast locMast = null;
+ // 1.褰撴绱㈠簱鎺掍负娴呭簱浣嶆帓鏃讹紝浼樺厛瀵绘壘褰撳墠搴撴帓鐨勬繁搴撲綅鎺�
+ List<LocMast> peakLocs = locMastService.selectAllPeakLoc();
+ for (LocMast peakLoc : peakLocs) {
+ List<String> groupInsideLoc = Utils.getGroupInsideLoc(peakLoc.getLocNo());
+ if (!Cools.isEmpty(groupInsideLoc)) {
+ if (!locMastService.checkAllLocEmpty(groupInsideLoc)) continue;
+ locMast = peakLoc;
+ break;
+ } else {
+ locMast = peakLoc;
+ break;
+ }
+ }
+
+ // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
+ if (Cools.isEmpty(locMast)) {
+ log.error("绯荤粺娌℃湁绌哄簱浣嶏紒锛侊紒 灏哄瑙勬牸锛� {}锛� 杞娆℃暟锛歿}", JSON.toJSONString(locTypeDto), times);
+ }
+
+ return locMast;
+ }
+
+ //杩斿洖dto
+ private StartupDto getLocNoStep6(Integer staDescId, Integer sourceStaNo, LocMast locMast) {
+ StartupDto startupDto = new StartupDto();
+
// 鑾峰彇鐩爣绔�
Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
.eq("type_no", staDescId)
@@ -185,53 +369,13 @@
throw new CoolException("鐩爣绔�" + staDesc.getCrnStn() + "涓嶅彲鐢�");
}
- // 寮�濮嬫煡鎵惧簱浣� ==============================>>
-
- // 1.褰撴绱㈠簱鎺掍负娴呭簱浣嶆帓鏃讹紝浼樺厛瀵绘壘褰撳墠搴撴帓鐨勬繁搴撲綅鎺�
- if (locMast == null) {
- List<LocMast> peakLocs = locMastService.selectAllPeakLoc();
- for (LocMast peakLoc : peakLocs) {
- List<String> groupInsideLoc = Utils.getGroupInsideLoc(peakLoc.getLocNo());
- if (!Cools.isEmpty(groupInsideLoc)){
- if (!locMastService.checkAllLocEmpty(groupInsideLoc)) continue;
- locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
- .eq("loc_no", groupInsideLoc.get(0)));
- break;
- }else {
- locMast=peakLoc;
- break;
- }
- }
- }
-
- // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
- if (Cools.isEmpty(locMast)) {
- List<LocMast> peakLocs = locMastService.selectAllPeakLoc();
- for (LocMast peakLoc : peakLocs) {
- List<String> groupOuterLoc = Utils.getGroupInsideLoc(peakLoc.getLocNo());
- if (!Cools.isEmpty(groupOuterLoc)){
- if (!locMastService.checkAllLocEmpty(groupOuterLoc)) continue;
- locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
- .eq("loc_no", groupOuterLoc.get(0)));
- }else {
- locMast = peakLoc;
- }
-
- }
- if (Cools.isEmpty(locMast)) {
- log.error("绯荤粺娌℃湁绌哄簱浣嶏紒锛侊紒 灏哄瑙勬牸锛� {}锛� 杞娆℃暟锛歿}", JSON.toJSONString(locTypeDto), times);
- throw new CoolException("娌℃湁绌哄簱浣�");
- }
- }
- String locNo = locMast.getLocNo();
-
// 鐢熸垚宸ヤ綔鍙�
int workNo = getWorkNo(0);
// 杩斿洖dto
startupDto.setWorkNo(workNo);
startupDto.setSourceStaNo(sourceStaNo);
startupDto.setStaNo(staNo.getDevNo());
- startupDto.setLocNo(locNo);
+ startupDto.setLocNo(locMast.getLocNo());
return startupDto;
}
--
Gitblit v1.9.1