diff --git a/lc123/cloud/app/plugin/form/im/ShortageBillPlugin.java b/lc123/cloud/app/plugin/form/im/ShortageBillPlugin.java new file mode 100644 index 0000000..a23323a --- /dev/null +++ b/lc123/cloud/app/plugin/form/im/ShortageBillPlugin.java @@ -0,0 +1,82 @@ +package tqq9.lc123.cloud.app.plugin.form.im; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.EntityMetadataCache; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.orm.ORM; +import kd.bos.servicehelper.BusinessDataServiceHelper; + +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Date; +import java.util.EventObject; + +/** + * 短缺处理表单插件 + */ +public class ShortageBillPlugin extends AbstractBillPlugIn { + + @Override + public void afterBindData(EventObject e) { + super.afterBindData(e); + DynamicObject dataEntity = this.getModel().getDataEntity(true); + DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry"); + for (int i = 0; i < billentries.size(); i++) { + DynamicObject billentry = billentries.get(i); + DynamicObject material = billentry.getDynamicObject("material"); + if(material != null){ + material = BusinessDataServiceHelper.loadSingle(material.getPkValue(), material.getDynamicObjectType().getName()); + boolean enablelot = material.getBoolean("enablelot");//是否启用批号 + boolean enableshelflifemgr = material.getBoolean("enableshelflifemgr");//是否启用保质期 + if(enablelot){ + this.getModel().setValue("lotnumber", "ZZZ", i); + }else{ + this.getModel().setValue("lotnumber", null, i); + } + if(enableshelflifemgr){ + this.getModel().setValue("producedate", new Date(), i); + LocalDate localDate = LocalDate.of(2999, 12, 31); + Date expirydate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); + this.getModel().setValue("expirydate", expirydate, i); + }else{ + this.getModel().setValue("producedate", null, i); + this.getModel().setValue("expirydate", null, i); + } + } + } + + } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + ChangeData[] changeSet = e.getChangeSet(); + int rowIndex = changeSet[0].getRowIndex(); + if("material".equals(name)){ + DynamicObject material = (DynamicObject) this.getModel().getValue("material", rowIndex);//物料库存信息 + if(material != null){ + material = BusinessDataServiceHelper.loadSingle(material.getPkValue(), material.getDynamicObjectType().getName()); + boolean enablelot = material.getBoolean("enablelot");//是否启用批号 + boolean enableshelflifemgr = material.getBoolean("enableshelflifemgr");//是否启用保质期 + if(enablelot){ + this.getModel().setValue("lotnumber", "ZZZ", rowIndex); + }else{ + this.getModel().setValue("lotnumber", null, rowIndex); + } + if(enableshelflifemgr){ + this.getModel().setValue("producedate", new Date(), rowIndex); + LocalDate localDate = LocalDate.of(2999, 12, 31); + Date expirydate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); + this.getModel().setValue("expirydate", expirydate, rowIndex); + }else{ + this.getModel().setValue("producedate", null, rowIndex); + this.getModel().setValue("expirydate", null, rowIndex); + } + } + } + } +} diff --git a/lc123/cloud/app/plugin/utils/FWRestfulUtils.java b/lc123/cloud/app/plugin/utils/FWRestfulUtils.java index a5722cd..a8f552c 100644 --- a/lc123/cloud/app/plugin/utils/FWRestfulUtils.java +++ b/lc123/cloud/app/plugin/utils/FWRestfulUtils.java @@ -194,7 +194,9 @@ public class FWRestfulUtils { //装填参数 List list = new ArrayList<>(); list.add(new BasicNameValuePair("mainData", JSON.toJSONString(mainData))); - list.add(new BasicNameValuePair("detailData", JSON.toJSONString(detailData))); + if (detailData != null && detailData.size() > 0) { + list.add(new BasicNameValuePair("detailData", JSON.toJSONString(detailData))); + } //restful接口url String url = null;