1出库单操作插件逻辑优化;2添加我的报账修改报账状态定时任务
This commit is contained in:
parent
e7020edce3
commit
398eb6700b
|
@ -199,7 +199,7 @@ public class MaterialInventoryUtilsExt {
|
||||||
coef = BigDecimal.valueOf(-1L);
|
coef = BigDecimal.valueOf(-1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用Map来按物料唯一标识分组并累加qty
|
// 使用Map来按物料唯一标识分组并累加qty(与更新库存保持一致的合并逻辑)
|
||||||
Map<String, BigDecimal> materialQtyMap = new HashMap<>();
|
Map<String, BigDecimal> materialQtyMap = new HashMap<>();
|
||||||
Map<String, DynamicObject> materialEntryMap = new HashMap<>();
|
Map<String, DynamicObject> materialEntryMap = new HashMap<>();
|
||||||
Map<String, DynamicObject> materialInvMap = new HashMap<>();
|
Map<String, DynamicObject> materialInvMap = new HashMap<>();
|
||||||
|
@ -212,16 +212,20 @@ public class MaterialInventoryUtilsExt {
|
||||||
String lot = "".equals(entryInfo.getString("lot")) ? " " : entryInfo.getString("lot");
|
String lot = "".equals(entryInfo.getString("lot")) ? " " : entryInfo.getString("lot");
|
||||||
String unitId = entryInfo.getDynamicObject("measureunit") == null ? "" : entryInfo.getDynamicObject("measureunit").getString("id");
|
String unitId = entryInfo.getDynamicObject("measureunit") == null ? "" : entryInfo.getDynamicObject("measureunit").getString("id");
|
||||||
|
|
||||||
// 创建物料的唯一键
|
// 创建物料的唯一键(使用与更新库存一致的格式)
|
||||||
String materialKey = matId + "|" + modelnum + "|" + lot + "|" + unitId;
|
String materialKey = String.format("%1$s_%2$s_%3$s_%4$s", matId, modelnum, lot, unitId);
|
||||||
|
|
||||||
// 累加qty
|
// 累加qty
|
||||||
BigDecimal currentQty = entryInfo.getBigDecimal("qty").multiply(coef);
|
BigDecimal currentQty = entryInfo.getBigDecimal("qty").multiply(coef);
|
||||||
materialQtyMap.merge(materialKey, currentQty, BigDecimal::add);
|
materialQtyMap.merge(materialKey, currentQty, BigDecimal::add);
|
||||||
|
|
||||||
// 保存entryInfo和material信息供后续使用
|
// 保存entryInfo和material信息供后续使用(只保存第一个,因为我们只需要物料信息)
|
||||||
materialEntryMap.put(materialKey, entryInfo);
|
if (!materialEntryMap.containsKey(materialKey)) {
|
||||||
materialInvMap.put(materialKey, material);
|
materialEntryMap.put(materialKey, entryInfo);
|
||||||
|
}
|
||||||
|
if (!materialInvMap.containsKey(materialKey)) {
|
||||||
|
materialInvMap.put(materialKey, material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DynamicObject> matInvList = new ArrayList<>();
|
List<DynamicObject> matInvList = new ArrayList<>();
|
||||||
|
@ -229,7 +233,7 @@ public class MaterialInventoryUtilsExt {
|
||||||
// 第二次循环:处理累加后的qty
|
// 第二次循环:处理累加后的qty
|
||||||
for (Map.Entry<String, BigDecimal> entry : materialQtyMap.entrySet()) {
|
for (Map.Entry<String, BigDecimal> entry : materialQtyMap.entrySet()) {
|
||||||
String materialKey = entry.getKey();
|
String materialKey = entry.getKey();
|
||||||
String[] keys = materialKey.split("\\|");
|
String[] keys = materialKey.split("_");
|
||||||
|
|
||||||
if (keys.length < 4) {
|
if (keys.length < 4) {
|
||||||
log.error("Invalid material key format: " + materialKey);
|
log.error("Invalid material key format: " + materialKey);
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.task;
|
||||||
|
|
||||||
|
import kd.bos.context.RequestContext;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.exception.KDException;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.schedule.executor.AbstractTask;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import zcgj.zcdev.zcdev.pr.utils.OrgCheckUtils;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 我的报账修改报账状态定时任务
|
||||||
|
* 说明:查询我的报账中的单据,存在对公报销单且为审核通过的单据且为冲预付的单据,则修改报账状态为报账完成
|
||||||
|
*/
|
||||||
|
public class ReimbursementStatusTaskPlugin extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
|
QFilter qFilters = new QFilter("bill.number", QCP.equals, "er_publicreimbursebill");
|
||||||
|
qFilters.and(new QFilter("billstatusext", QCP.equals, "审核通过"));
|
||||||
|
DynamicObject[] dhc_myBillLists = BusinessDataServiceHelper.load("dhc_mybilllist",
|
||||||
|
"id,billno,reimbursestatus", new QFilter[]{qFilters});//我的报账
|
||||||
|
|
||||||
|
if (dhc_myBillLists != null && dhc_myBillLists.length > 0) {
|
||||||
|
for (DynamicObject dhc_myBillList : dhc_myBillLists) {
|
||||||
|
String billNo = dhc_myBillList.getString("billno");//对公报销单单据编号
|
||||||
|
QFilter[] qFilter = new QFilter[]{new QFilter("billno", QCP.equals, billNo).and("payamount", QCP.equals, 0)};
|
||||||
|
DynamicObject er_publicReimburseBill = BusinessDataServiceHelper.loadSingle("er_publicreimbursebill",
|
||||||
|
"id,costcompany", qFilter);//对公报销单
|
||||||
|
|
||||||
|
if (er_publicReimburseBill != null) {
|
||||||
|
DynamicObject costCompany = er_publicReimburseBill.getDynamicObject("costcompany");//对公报销单-费用承担公司
|
||||||
|
Long costCompanyId = costCompany.getLong("id");
|
||||||
|
if (OrgCheckUtils.isKS(costCompanyId)) {
|
||||||
|
//当前所在的组织是属于矿山下的
|
||||||
|
dhc_myBillList.set("reimbursestatus", "2");//我的报账-报账状态 变为报账完成
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dhc_myBillLists != null) {
|
||||||
|
SaveServiceHelper.save(dhc_myBillLists);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue