feat: 替换关系审核更新总成图册明细中是否部件是否上级字段

This commit is contained in:
zzs 2025-04-02 14:24:56 +08:00
parent 08e2229c29
commit 4ca9d1426c
3 changed files with 58 additions and 45 deletions

View File

@ -12,6 +12,8 @@ import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.util.List;
import static com.yem.em.task.GenerateReplaceRelationshipTaskEdit.updateIsCompAndIsUp;
/**
* @author zhouc
* @date 2023/11/2 18:14
@ -38,49 +40,7 @@ public class AssAtlasdetAuditOpEdit extends AbstractOperationServicePlugIn {
if (e.getDataEntities() != null && e.getDataEntities().length != 0) {
DynamicObject[] bills = e.getDataEntities();
for (DynamicObject bill : bills) {
String number = bill.getString("number");
QFilter qFilter = new QFilter("enable", QCP.equals, "1");//
qFilter.and(new QFilter("yem_entryentity.yem_partnumber", QCP.equals, number));//
DynamicObject[] yem_em_assatlasdet = BusinessDataServiceHelper.load("yem_em_assatlasdet", "id"
, new QFilter[]{qFilter}, null);
if (yem_em_assatlasdet.length > 0) {
bill.set("yem_issup", true);
for (int i = 0; i < yem_em_assatlasdet.length; i++) {
DynamicObject assatlasdet = yem_em_assatlasdet[i];
//根据id加载所有数据
DynamicObject component = BusinessDataServiceHelper.loadSingle(assatlasdet.getLong("id"), "yem_em_assatlasdet");
DynamicObjectCollection yemEntryentity = component.getDynamicObjectCollection("yem_entryentity");
for (int j = 0; j < yemEntryentity.size(); j++) {
DynamicObject dynamicObject = yemEntryentity.get(j);
String yemPartnumber = dynamicObject.getString("yem_partnumber");
if (yemPartnumber.equals(number)) {
dynamicObject.set("yem_iscomp", true);
dynamicObject.set("yem_compid", bill.getString("id"));
}
}
//保存
SaveServiceHelper.save(new DynamicObject[]{component});
}
}
DynamicObjectCollection yem_entryentity = bill.getDynamicObjectCollection("yem_entryentity");
for (int i = 0; i < yem_entryentity.size(); i++) {
DynamicObject object = yem_entryentity.get(i);
boolean yem_iscomp = object.getBoolean("yem_iscomp");
if (!yem_iscomp) {
String yem_partnumber = object.getString("yem_partnumber");
QFilter qFilter1 = new QFilter("enable", QCP.equals, "1");//
qFilter1.and(new QFilter("number", QCP.equals, yem_partnumber));//
DynamicObject assatlasdet = BusinessDataServiceHelper.loadSingle("yem_em_assatlasdet", "id,yem_issup,number,name"
, new QFilter[]{qFilter1});
if (assatlasdet != null) {
assatlasdet.set("yem_issup", true);
object.set("yem_iscomp", true);
object.set("yem_compid", assatlasdet.getString("id"));
SaveServiceHelper.save(new DynamicObject[]{assatlasdet});
}
}
}
SaveServiceHelper.save(new DynamicObject[]{bill});
updateIsCompAndIsUp(bill);
}
}
}

View File

@ -9,6 +9,7 @@ import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.exception.KDException;
import kd.bos.fileservice.FileServiceFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.AttachmentServiceHelper;
@ -377,4 +378,54 @@ public class GenerateReplaceRelationshipTaskEdit extends AbstractTask {
}
return null;
}
/**
* 更新总成图册明细中的 是否部件 是否有上级
* @param bill 总成图册明细
*/
public static void updateIsCompAndIsUp(DynamicObject bill) {
String number = bill.getString("number");
QFilter qFilter = new QFilter("enable", QCP.equals, "1");//
qFilter.and(new QFilter("yem_entryentity.yem_partnumber", QCP.equals, number));//
DynamicObject[] yem_em_assatlasdet = BusinessDataServiceHelper.load("yem_em_assatlasdet", "id"
, new QFilter[]{qFilter}, null);
if (yem_em_assatlasdet.length > 0) {
bill.set("yem_issup", true);
for (int i = 0; i < yem_em_assatlasdet.length; i++) {
DynamicObject assatlasdet = yem_em_assatlasdet[i];
//根据id加载所有数据
DynamicObject component = BusinessDataServiceHelper.loadSingle(assatlasdet.getLong("id"), "yem_em_assatlasdet");
DynamicObjectCollection yemEntryentity = component.getDynamicObjectCollection("yem_entryentity");
for (int j = 0; j < yemEntryentity.size(); j++) {
DynamicObject dynamicObject = yemEntryentity.get(j);
String yemPartnumber = dynamicObject.getString("yem_partnumber");
if (yemPartnumber.equals(number)) {
dynamicObject.set("yem_iscomp", true);
dynamicObject.set("yem_compid", bill.getString("id"));
}
}
//保存
SaveServiceHelper.save(new DynamicObject[]{component});
}
}
DynamicObjectCollection yem_entryentity = bill.getDynamicObjectCollection("yem_entryentity");
for (int i = 0; i < yem_entryentity.size(); i++) {
DynamicObject object = yem_entryentity.get(i);
boolean yem_iscomp = object.getBoolean("yem_iscomp");
if (!yem_iscomp) {
String yem_partnumber = object.getString("yem_partnumber");
QFilter qFilter1 = new QFilter("enable", QCP.equals, "1");//
qFilter1.and(new QFilter("number", QCP.equals, yem_partnumber));//
DynamicObject assatlasdet = BusinessDataServiceHelper.loadSingle("yem_em_assatlasdet", "id,yem_issup,number,name"
, new QFilter[]{qFilter1});
if (assatlasdet != null) {
assatlasdet.set("yem_issup", true);
object.set("yem_iscomp", true);
object.set("yem_compid", assatlasdet.getString("id"));
SaveServiceHelper.save(new DynamicObject[]{assatlasdet});
}
}
}
SaveServiceHelper.save(new DynamicObject[]{bill});
}
}

View File

@ -18,6 +18,8 @@ import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.math.BigDecimal;
import java.util.*;
import static com.yem.em.task.GenerateReplaceRelationshipTaskEdit.updateIsCompAndIsUp;
/**
* @author zhouc
* @date 2023/10/24 11:33
@ -424,7 +426,7 @@ public class AtlasUtils {
OperationResult Operate = OperationServiceHelper.executeOperate("save", yem_em_assatlasdet.getDynamicObjectType().getName(),
new DynamicObject[]{yem_em_assatlasdet}, OperateOption.create());
if (Operate.isSuccess()) {
updateIsCompAndIsUp(yem_em_assatlasdet);
}
}
}
@ -571,7 +573,7 @@ public class AtlasUtils {
OperationResult Operate = OperationServiceHelper.executeOperate("save", yem_em_assatlasdet.getDynamicObjectType().getName(),
new DynamicObject[]{yem_em_assatlasdet}, OperateOption.create());
if (Operate.isSuccess()) {
updateIsCompAndIsUp(yem_em_assatlasdet);
}
}
}