fix:后替代前、通用、不通用,必须停用启用都匹配到才更新完成状态,启用或停用的,停用的匹配到一个就更新完成状态
This commit is contained in:
parent
5f4ebab6a3
commit
f1c315c534
@ -33,14 +33,14 @@ import java.util.*;
|
||||
|
||||
public class MatchingPLMChangeUpdateTaskEdit extends AbstractTask {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(MatchingPLMChangeUpdateTaskEdit.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(MatchingPLMChangeUpdateTaskEdit.class);
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
DynamicObject[] plms = queryPLMChange();
|
||||
DynamicObject[] boms = queryBOMChange();
|
||||
|
||||
List<MatchInfo> matchList = new ArrayList<>();
|
||||
List<MatchResult> matchList = new ArrayList<>();
|
||||
|
||||
for (DynamicObject bomObj : boms) {
|
||||
DynamicObjectCollection bom_entry = bomObj.getDynamicObjectCollection("yem_entryentity");
|
||||
@ -55,10 +55,15 @@ public class MatchingPLMChangeUpdateTaskEdit extends AbstractTask {
|
||||
String exestate = bom.getString("yem_exestate");
|
||||
Date invoktime = plm.getDate("yem_invoktime");//执行时间
|
||||
String invokstatus = plm.getString("yem_invokstatus");//执行状态
|
||||
String exchangetype = plm.getString("yem_exchangetype");//替换标志
|
||||
if (YEM.isNotEmpty(invoktime) && "B".equals(invokstatus)) {
|
||||
//已完成跳过
|
||||
continue;
|
||||
}
|
||||
// 没有替换关系不匹配
|
||||
if (YEM.isEmpty(exchangetype)) {
|
||||
continue;
|
||||
}
|
||||
MatchResult result = isPlmMatchBom(plmObj, bom, plm);
|
||||
exestate = "30".equals(exestate) ? "B" : "A";
|
||||
if (result.isMatched() && result.getDisable()) {
|
||||
@ -82,24 +87,52 @@ public class MatchingPLMChangeUpdateTaskEdit extends AbstractTask {
|
||||
}
|
||||
|
||||
if (result.isMatched() && YEM.isNotEmpty(bom_completetime)) {
|
||||
boolean exist = false;
|
||||
for (MatchResult res : matchList) {
|
||||
Long id = res.getInfo().getId();
|
||||
if (id == plm.getLong("id")) {
|
||||
exist = true;
|
||||
if (result.getEnable()) {
|
||||
res.setEnable(true);
|
||||
}
|
||||
if (result.getDisable()) {
|
||||
res.setDisable(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exist) {
|
||||
MatchInfo info = new MatchInfo(plm.getLong("id"), bom_completetime, exestate, exchangetype);
|
||||
result.setInfo(info);
|
||||
|
||||
MatchInfo info = new MatchInfo(plm.getLong("id"), bom_completetime, exestate);
|
||||
matchList.add(info);
|
||||
|
||||
matchList.add(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (MatchInfo info : matchList) {
|
||||
// 更新执行状态、执行时间
|
||||
for (MatchResult result : matchList) {
|
||||
for (DynamicObject plmObj : plms) {
|
||||
DynamicObjectCollection plm_entry = plmObj.getDynamicObjectCollection("yem_change_detail");
|
||||
for (DynamicObject plm : plm_entry) {
|
||||
MatchInfo info = result.getInfo();
|
||||
if (plm.getLong("id") == info.getId()) {
|
||||
|
||||
// 后替代前、通用、不通用,必须停用启用都匹配到才更新完成状态
|
||||
if (YEM.isNotEmpty(info.getReplace()) && "A-B-C".contains(info.getReplace()) && result.getDisable() && result.getEnable()) {
|
||||
plm.set("yem_invoktime", info.getComplateDate());
|
||||
plm.set("yem_invokstatus", info.getStatus());
|
||||
}
|
||||
|
||||
// 启用或停用的,停用的匹配到一个就更新完成状态
|
||||
if (YEM.isNotEmpty(info.getReplace()) && "D-E".contains(info.getReplace()) && result.isMatched()) {
|
||||
plm.set("yem_invoktime", info.getComplateDate());
|
||||
plm.set("yem_invokstatus", info.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,8 +213,13 @@ public class MatchingPLMChangeUpdateTaskEdit extends AbstractTask {
|
||||
|
||||
|
||||
class MatchResult {
|
||||
// 是否启用匹配到
|
||||
private Boolean enable;
|
||||
|
||||
// 是否停用匹配到
|
||||
private Boolean disable;
|
||||
|
||||
// 匹配信息
|
||||
private MatchInfo info;
|
||||
|
||||
public MatchResult() {
|
||||
@ -224,19 +262,26 @@ class MatchResult {
|
||||
}
|
||||
|
||||
class MatchInfo {
|
||||
// PLM分录ID
|
||||
private Long id;
|
||||
|
||||
// 完成时间
|
||||
private Date complateDate;
|
||||
|
||||
// 启用停用状态
|
||||
private String status;
|
||||
|
||||
// 替换关系
|
||||
private String replace;
|
||||
|
||||
public MatchInfo() {
|
||||
}
|
||||
|
||||
public MatchInfo(Long id, Date complateDate, String status) {
|
||||
public MatchInfo(Long id, Date complateDate, String status, String replace) {
|
||||
this.id = id;
|
||||
this.complateDate = complateDate;
|
||||
this.status = status;
|
||||
this.replace = replace;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
@ -262,4 +307,12 @@ class MatchInfo {
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReplace() {
|
||||
return replace;
|
||||
}
|
||||
|
||||
public void setReplace(String replace) {
|
||||
this.replace = replace;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user