Compare commits
No commits in common. "6af629d16fc5085424be81cd2def0cbf80ceaf28" and "3eb9de8d7b89c6a0296f0f2a6b1ce0efff940b96" have entirely different histories.
6af629d16f
...
3eb9de8d7b
@ -1,17 +1,14 @@
|
||||
package com.yem.em.task;
|
||||
|
||||
import com.yem.em.utils.AtlasUtils;
|
||||
import com.yem.wm.utils.AttachmentUtil;
|
||||
import com.yem.wm.utils.YEM;
|
||||
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.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.AttachmentServiceHelper;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -48,27 +45,22 @@ public class GenerateReplaceRelationshipTaskEdit extends AbstractTask {
|
||||
for (DynamicObject plm : collection) {
|
||||
String enablesta = plm.getString("yem_enablesta");//替换件停用启用状态
|
||||
String enablestatus_before = plm.getString("yem_enablestatus_before");//停用启用状态
|
||||
String isgenfnish = plm.getString("yem_isgenfnish");
|
||||
String invokstatus = plm.getString("yem_invokstatus");
|
||||
String exchangetype = plm.getString("yem_exchangetype");
|
||||
String invokstatus = plm.getString("yem_invokstatus");//执行状态
|
||||
String invoktime = plm.getString("yem_invoktime");//执行时间
|
||||
if ("B".equals(invokstatus) && YEM.isNotEmpty(invoktime) && YEM.isNotEmpty(exchangetype)) {
|
||||
|
||||
//【替换关系】=【相互替换】【新替换旧】【互不替换】 && 【启用停用状态】=‘停用’ && 【替换件启用停用状态】=‘启用’ && 执行状态 != 已完成
|
||||
if ("A-B-C".contains(exchangetype) && "A".equals(enablesta) && "B".equals(enablestatus_before) && !"B".equals(isgenfnish)) {
|
||||
situation_replace.add(plm);
|
||||
}
|
||||
|
||||
// 【替换关系】=【新增】 && 【替换件启用停用状态】=‘启用’
|
||||
if ("D".equals(exchangetype) && "A".equals(enablesta) && !"B".equals(isgenfnish)) {
|
||||
situation_add.add(plm);
|
||||
}
|
||||
// 【替换关系】=【删除】 && 分录【启用停用状态】=‘停用’
|
||||
if ("E".equals(exchangetype) && "B".equals(enablestatus_before) && !"B".equals(isgenfnish)) {
|
||||
situation_delete.add(plm);
|
||||
}
|
||||
//【替换关系】=【相互替换】【新替换旧】【互不替换】 && 【启用停用状态】=‘停用’ && 【替换件启用停用状态】=‘启用’ && 执行状态 != 已完成
|
||||
if ("A-B-C".contains(exchangetype) && "A".equals(enablesta) && "B".equals(enablestatus_before) && !"B".equals(invokstatus)) {
|
||||
situation_replace.add(plm);
|
||||
}
|
||||
|
||||
// 【替换关系】=【新增】 && 【替换件启用停用状态】=‘启用’
|
||||
if ("D".equals(exchangetype) && "A".equals(enablesta) && !"B".equals(invokstatus)) {
|
||||
situation_add.add(plm);
|
||||
}
|
||||
// 【替换关系】=【删除】 && 分录【启用停用状态】=‘停用’
|
||||
if ("E".equals(exchangetype) && "B".equals(enablestatus_before) && !"B".equals(invokstatus)) {
|
||||
situation_delete.add(plm);
|
||||
}
|
||||
}
|
||||
generateReplaceRelation(plmObj, situation_replace);
|
||||
generateReplaceRelation(plmObj, situation_add);
|
||||
@ -85,7 +77,7 @@ public class GenerateReplaceRelationshipTaskEdit extends AbstractTask {
|
||||
private void generateReplaceRelation(DynamicObject plmObj, DynamicObjectCollection enabled) {
|
||||
DynamicObjectCollection collection = plmObj.getDynamicObjectCollection("yem_change_detail");
|
||||
// 更新是否资源、是否总成
|
||||
for (DynamicObject plm : enabled) {
|
||||
for (DynamicObject plm : collection) {
|
||||
|
||||
String exchangetype = plm.getString("yem_exchangetype");
|
||||
String parentno;
|
||||
@ -106,10 +98,6 @@ public class GenerateReplaceRelationshipTaskEdit extends AbstractTask {
|
||||
plm.set("yem_isresource", true);
|
||||
}
|
||||
logger.info("是否资源:{},{}", parentno, basemodelib != null);
|
||||
|
||||
if (!plm.getBoolean("yem_isassy") && !plm.getBoolean("yem_isresource")) {
|
||||
enabled.remove(plm);
|
||||
}
|
||||
}
|
||||
// 替换关系生成成功之后更新完成时间、状态
|
||||
Map<Long, DynamicObject> successMap = new HashMap<>();
|
||||
@ -134,37 +122,29 @@ public class GenerateReplaceRelationshipTaskEdit extends AbstractTask {
|
||||
successMap.put(entryObject.getLong("id"), bomChange);
|
||||
}
|
||||
}
|
||||
List<Long> list = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<Long, DynamicObject> mapEntry : successMap.entrySet()) {
|
||||
Long bomChangeEntryId = mapEntry.getKey();
|
||||
// DynamicObject bomChangeObj = mapEntry.getValue();
|
||||
// DynamicObjectCollection bomChangeEntry = bomChangeObj.getDynamicObjectCollection("yem_entryentity");
|
||||
// int idx = 0;
|
||||
// for (DynamicObject bom : bomChangeEntry) {
|
||||
// if (bomChangeEntryId == bom.getLong("id")) {
|
||||
// idx = bomChangeEntry.indexOf(bom);
|
||||
// }
|
||||
// }
|
||||
// DynamicObject currentEntry = bomChangeEntry.get(idx);
|
||||
// Date completetime = currentEntry.getDate("yem_completetime");//完成时间
|
||||
DynamicObject bomChangeObj = mapEntry.getValue();
|
||||
DynamicObjectCollection bomChangeEntry = bomChangeObj.getDynamicObjectCollection("yem_entryentity");
|
||||
int idx = 0;
|
||||
for (DynamicObject bom : bomChangeEntry) {
|
||||
if (bomChangeEntryId == bom.getLong("id")) {
|
||||
idx = bomChangeEntry.indexOf(bom);
|
||||
}
|
||||
}
|
||||
DynamicObject currentEntry = bomChangeEntry.get(idx);
|
||||
Date completetime = currentEntry.getDate("yem_completetime");//完成时间
|
||||
for (DynamicObject d : collection) {
|
||||
long id = d.getLong("id");
|
||||
if (bomChangeEntryId == id) {
|
||||
d.set("yem_isgenfnish", "B");
|
||||
}
|
||||
}
|
||||
|
||||
for (DynamicObject d : collection) {
|
||||
long entryId = d.getLong("id");
|
||||
String isgenfnish = d.getString("yem_isgenfnish");
|
||||
if ("B".equals(isgenfnish)) {
|
||||
list.add(entryId);
|
||||
d.set("yem_invokstatus", "B");
|
||||
d.set("yem_invoktime", completetime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SaveServiceHelper.save(new DynamicObject[]{plmObj});
|
||||
// syncImage(plmObj, list);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,79 +196,11 @@ public class GenerateReplaceRelationshipTaskEdit extends AbstractTask {
|
||||
addNew.set("yem_replace", exchangetype);//替换关系
|
||||
addNew.set("yem_enableddate", entry.getDate("yem_starttime"));//启用时间
|
||||
addNew.set("yem_downdate", entry.getDate("yem_stoptime"));//停用时间
|
||||
addNew.set("yem_completetime", entry.getDate("yem_invoktime"));//执行时间
|
||||
addNew.set("yem_completetime", entry.getDate("yem_completetime"));//执行时间
|
||||
addNew.set("yem_remark", "");//备注
|
||||
addNew.set("yem_isass", entry.getBoolean("yem_isassy"));//是否总成
|
||||
addNew.set("yem_isresource", entry.getBoolean("yem_isresource"));//是否资源
|
||||
}
|
||||
return bomchange;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步图片 总成图册明细
|
||||
* @param plmObj
|
||||
* @param list
|
||||
*/
|
||||
private void syncImage(DynamicObject plmObj, List<Long> list) {
|
||||
plmObj = BusinessDataServiceHelper.loadSingle(plmObj.getPkValue(), plmObj.getDynamicObjectType().getName());
|
||||
DynamicObjectCollection detail = plmObj.getDynamicObjectCollection("yem_change_detail");
|
||||
DynamicObjectCollection pictureentry = plmObj.getDynamicObjectCollection("yem_pictureentry");
|
||||
for (Long entryId : list) {
|
||||
for (DynamicObject d : detail) {
|
||||
long id = d.getLong("id");
|
||||
if (id == entryId) {
|
||||
String exchangetype = d.getString("yem_exchangetype");
|
||||
String imageName;
|
||||
if ("D".equals(exchangetype)) {
|
||||
imageName = d.getString("yem_parent_now");
|
||||
} else {
|
||||
imageName = d.getString("yem_textfield");
|
||||
}
|
||||
List<DynamicObject> imageInfo = getImageInfo(pictureentry, imageName);
|
||||
|
||||
for (DynamicObject image : imageInfo) {
|
||||
String picturename = image.getString("yem_picturename");
|
||||
int idx = picturename.lastIndexOf(".");
|
||||
String partno = picturename.substring(0, idx);
|
||||
String pictureid = image.getString("yem_pictureid");
|
||||
String pictureaddress = image.getString("yem_pictureaddress");
|
||||
Date breakpointtime = getBreakPointTime(detail, partno);
|
||||
|
||||
DynamicObject attachment = AttachmentServiceHelper.getAttCreatorByUID(pictureid);
|
||||
String url = attachment.getString("ffileid");
|
||||
// AttachmentUtil.uploadAttachmentPanel("yem_em_assatlasdet", )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<DynamicObject> getImageInfo(DynamicObjectCollection pictureentry, String imageName) {
|
||||
List<DynamicObject> list = new ArrayList<>();
|
||||
for (DynamicObject d : pictureentry) {
|
||||
String picturename = d.getString("yem_picturename");
|
||||
if (StringUtils.containsIgnoreCase(picturename, imageName)) {
|
||||
list.add(d);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private Date getBreakPointTime(DynamicObjectCollection detail, String partno) {
|
||||
for (DynamicObject d : detail) {
|
||||
String exchangetype = d.getString("yem_exchangetype");
|
||||
String detailPartNo;
|
||||
if ("D".equals(exchangetype)) {
|
||||
detailPartNo = d.getString("yem_parent_now");
|
||||
} else {
|
||||
detailPartNo = d.getString("yem_textfield");
|
||||
}
|
||||
|
||||
if (partno.equals(detailPartNo)) {
|
||||
return d.getDate("yem_invoktime");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user