2024-08-29 17:01:41 +08:00
|
|
|
|
package com.yem.em.task;
|
|
|
|
|
|
|
|
|
|
import com.yem.rf.utils.RFUtils;
|
|
|
|
|
import com.yem.wm.utils.DynamicObjectUtil;
|
|
|
|
|
import kd.bos.context.RequestContext;
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
|
import kd.bos.exception.KDException;
|
|
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
import kd.bos.schedule.executor.AbstractTask;
|
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
2024-09-02 09:33:19 +08:00
|
|
|
|
import java.util.Date;
|
2024-08-29 17:01:41 +08:00
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description:
|
|
|
|
|
* 1.根据《PLM变更单》中的
|
|
|
|
|
* 【PLM工艺变更单号】+【总成编码】+【子项零件编码】+【子件数量】
|
|
|
|
|
* 匹配《BOM》变更单
|
|
|
|
|
* 【更改单号】+【总成编码】+【子项零件编码】+【数量】+【启用停用状态=‘停用’】更新 《PLM变更单》【启用停用状态】【启用停用时间】;
|
|
|
|
|
* <p>
|
|
|
|
|
* 2.根据《PLM变更单》中的
|
|
|
|
|
* 【PLM工艺变更单号】+【替换后总成编码】+【替换后子项零件编码】+【替换子件数量】
|
|
|
|
|
* 匹配《BOM》变更单
|
|
|
|
|
* 【更改单号】+【总成编码】+【子项零件编码】+【数量】+【启用停用状态=‘启用’】更新 《PLM变更单》【替换件启用停用状态】【替换件启用停用时间】;
|
|
|
|
|
*
|
|
|
|
|
* @Date: 2024/8/29 15:08
|
|
|
|
|
* @Created: by ZZSLL
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class MatchingPLMChangeUpdateTaskEdit extends AbstractTask {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
|
|
|
|
DynamicObject[] plms = queryPLMChange();
|
|
|
|
|
DynamicObject[] boms = queryBOMChange();
|
|
|
|
|
|
|
|
|
|
for (DynamicObject plmObj : plms) {
|
|
|
|
|
DynamicObjectCollection plm_entry = plmObj.getDynamicObjectCollection("yem_change_detail");
|
|
|
|
|
for (DynamicObject plm : plm_entry) {
|
|
|
|
|
String plm_billno = plm.getString("billno");//PLM工艺变更单号
|
|
|
|
|
String plm_parent = plm.getString("yem_materiel_parent.number");//总成编码
|
|
|
|
|
String plm_child = plm.getString("yem_materiel_child.number");//子项零件编码
|
|
|
|
|
BigDecimal plm_qty = plm.getBigDecimal("yem_qty_before");//子件数量
|
|
|
|
|
for (DynamicObject bomObj : boms) {
|
|
|
|
|
DynamicObjectCollection bom_entry = bomObj.getDynamicObjectCollection("yem_entryentity");
|
|
|
|
|
for (DynamicObject bom : bom_entry) {
|
|
|
|
|
String bom_billno = bom.getString("yem_changeno");//更改单号
|
|
|
|
|
String bom_parent = bom.getString("yem_parentno.number");//父件编码
|
|
|
|
|
String bom_child = bom.getString("yem_subno");//子项零件编码
|
|
|
|
|
BigDecimal bom_qty = bom.getBigDecimal("yem_qty");//数量
|
|
|
|
|
if (eq(plm_billno, bom_billno) && eq(plm_parent, bom_parent) && eq(plm_child, bom_child) && eq(plm_qty, bom_qty)) {
|
|
|
|
|
String enablesta = bom.getString("yem_enablesta");//启用停用状态
|
|
|
|
|
if ("A".equals(enablesta)) {//启用
|
2024-09-02 09:33:19 +08:00
|
|
|
|
Date starttime = plm.getDate("yem_starttime");
|
|
|
|
|
if (starttime == null) {
|
|
|
|
|
plm.set("yem_starttime", new Date());
|
|
|
|
|
}
|
2024-08-29 17:01:41 +08:00
|
|
|
|
}
|
|
|
|
|
if ("B".equals(enablesta)) {//停用
|
2024-09-02 09:33:19 +08:00
|
|
|
|
Date stoptime = plm.getDate("yem_stoptime");
|
|
|
|
|
if (stoptime == null) {
|
|
|
|
|
plm.set("yem_stoptime", new Date());
|
|
|
|
|
}
|
2024-08-29 17:01:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SaveServiceHelper.save(plms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean eq(Object str1, Object str2) {
|
|
|
|
|
if (str1 instanceof String && str2 instanceof String) {
|
|
|
|
|
return str1.equals(str2);
|
|
|
|
|
}
|
|
|
|
|
if (str1 instanceof BigDecimal && str2 instanceof BigDecimal) {
|
|
|
|
|
return ((BigDecimal) str1).compareTo((BigDecimal) str2) == 0;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DynamicObject[] queryPLMChange() {
|
|
|
|
|
final String formId = "yem_changecompare";
|
|
|
|
|
final String entryId = "yem_change_detail";
|
|
|
|
|
String selectfields = DynamicObjectUtil.getSelectfields(formId);
|
|
|
|
|
selectfields = DynamicObjectUtil.getEntrySelectfields(selectfields, formId, entryId);
|
|
|
|
|
QFilter qFilter = RFUtils.getBaseQFilter();
|
|
|
|
|
return BusinessDataServiceHelper.load(formId, selectfields, qFilter.toArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DynamicObject[] queryBOMChange() {
|
|
|
|
|
final String formId = "yem_em_bomchange";
|
|
|
|
|
final String entryId = "yem_entryentity";
|
|
|
|
|
String selectfields = DynamicObjectUtil.getSelectfields(formId);
|
|
|
|
|
selectfields = DynamicObjectUtil.getEntrySelectfields(selectfields, formId, entryId);
|
|
|
|
|
QFilter qFilter = RFUtils.getBaseQFilter();
|
|
|
|
|
return BusinessDataServiceHelper.load(formId, selectfields, qFilter.toArray());
|
|
|
|
|
}
|
|
|
|
|
}
|