退货补货修改,采购订单最高限价
This commit is contained in:
		
							parent
							
								
									8dfaf34815
								
							
						
					
					
						commit
						a48c5efa99
					
				|  | @ -1,7 +1,10 @@ | |||
| package tqq9.lc123.cloud.app.plugin.form.im; | ||||
| 
 | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.utils.StringUtils; | ||||
| import kd.bos.entity.datamodel.IDataModel; | ||||
| import kd.bos.entity.operate.result.OperationResult; | ||||
| import kd.bos.form.control.EntryGrid; | ||||
| import kd.bos.form.events.AfterDoOperationEventArgs; | ||||
| import kd.bos.form.plugin.AbstractFormPlugin; | ||||
| import kd.bos.logging.Log; | ||||
|  | @ -23,16 +26,21 @@ public class ReturnStockSyncNoticePlugin extends AbstractFormPlugin implements P | |||
|         this.addItemClickListeners("tbmain"); | ||||
|     } | ||||
| 
 | ||||
| // | ||||
| //    @Override | ||||
| //    public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { | ||||
| //        super.afterDoOperation(afterDoOperationEventArgs); | ||||
| //        String operateKey = afterDoOperationEventArgs.getOperateKey(); | ||||
| //        if(StringUtils.equals("audit",operateKey)){ | ||||
| // | ||||
| //        } | ||||
| //            OperationResult operationResult = afterDoOperationEventArgs.getOperationResult(); | ||||
| //        String message = operationResult.getMessage(); | ||||
| //        System.out.println(111); | ||||
| //    } | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { | ||||
|         super.afterDoOperation(afterDoOperationEventArgs); | ||||
|         String operateKey = afterDoOperationEventArgs.getOperateKey(); | ||||
|         if(StringUtils.equals("audit",operateKey)){ | ||||
|             OperationResult operationResult = afterDoOperationEventArgs.getOperationResult(); | ||||
|             String message = operationResult.getMessage(); | ||||
|             if(StringUtils.equals("补货成功",message)){ | ||||
|                 this.getView().showMessage("补货成功"); | ||||
|             }else if(StringUtils.isNotBlank(message)){ | ||||
|                 StringBuilder stringBuilder = new StringBuilder(); | ||||
|                 stringBuilder.append("补货失败,").append("\n").append(message); | ||||
|                 this.getView().showMessage(stringBuilder.toString()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -111,6 +111,10 @@ public class PurSuggestRptFromPlugin extends AbstractFormPlugin implements Plugi | |||
|                     "id as materialinventoryid,masterid as tqq9_sku ", | ||||
|                     new QFilter[]{}, | ||||
|                     null); | ||||
| 
 | ||||
| //            //商城商品 | ||||
| //            String goodspackagesql = "/*dialect*/select t1.fid id, t1.fk_tqq9_mater tqq9_sku,t1.fcreateorgid tqq9_org,t1.tqq9_purchaser tqq9_purchaser,t1.tqq9_onsale tqq9_onsale" + | ||||
| //                    "from tk_tqq9_goodspackage t1"; | ||||
|             //即时库存表 | ||||
|             String realbalancesql = "/*dialect*/select t1.fmaterialid tqq9_sku,t1.forgid tqq9_org,sum(t1.fqty) tqq9_totalinventory " + | ||||
|                     "from t_im_inv_realbalance t1 group by fmaterialid,forgid"; | ||||
|  | @ -125,6 +129,7 @@ public class PurSuggestRptFromPlugin extends AbstractFormPlugin implements Plugi | |||
|             String purorderbillsql = "/*dialect*/select t2.fmaterialid tqq9_sku,t1.forgid tqq9_org, sum(CASE WHEN t1.fclosestatus='A' then t1.fk_tqq9_purqty ELSE 0 END) tqq9_oninventory\n" + | ||||
|                     "from  t_pm_purorderbill t1,t_pm_purorderbillentry t2 where t1.fid=t2.fid and t1.fbillstatus='C' GROUP BY t2.fmaterialid,t1.forgid"; | ||||
| 
 | ||||
| //            DataSet goodspackagDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), goodspackagesql); | ||||
|             DataSet realbalanceDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), realbalancesql); | ||||
|             DataSet saloutbillDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), saloutbillsql); | ||||
|             DataSet purorderbillDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), purorderbillsql); | ||||
|  |  | |||
|  | @ -3,42 +3,66 @@ package tqq9.lc123.cloud.app.plugin.form.pm; | |||
| import kd.bos.bill.AbstractBillPlugIn; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.dataentity.metadata.IDataEntityProperty; | ||||
| import kd.bos.dataentity.utils.StringUtils; | ||||
| import kd.bos.entity.datamodel.IDataModel; | ||||
| import kd.bos.entity.datamodel.RowDataEntity; | ||||
| import kd.bos.entity.datamodel.events.AfterAddRowEventArgs; | ||||
| import kd.bos.entity.datamodel.events.BeforeAddRowEventArgs; | ||||
| import kd.bos.entity.datamodel.events.ChangeData; | ||||
| import kd.bos.entity.datamodel.events.PropertyChangedArgs; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| 
 | ||||
| /** | ||||
|  * 采购订单 | ||||
|  *      值改变事件:现返、货返金额分摊;付款比例不超过100% | ||||
|  * 值改变事件:现返、货返金额分摊;付款比例不超过100% | ||||
|  */ | ||||
| public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn { | ||||
| 
 | ||||
|     private final static Log logger = LogFactory.getLog(PuroderBillShareRefundPlugin.class); | ||||
|     private final static String ENTRYENTITY = "billentry"; | ||||
| 
 | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterAddRow(AfterAddRowEventArgs e) { | ||||
|         super.afterAddRow(e); | ||||
|         if (StringUtils.equals(e.getEntryProp().getName(), ENTRYENTITY)) { | ||||
|             BigDecimal tqq9_discountamount = (BigDecimal) this.getModel().getValue("tqq9_discountamount"); | ||||
|             if (tqq9_discountamount.compareTo(BigDecimal.ZERO) > 0) { | ||||
|                 RowDataEntity[] rowDataEntities = e.getRowDataEntities(); | ||||
|                 for (RowDataEntity rowDataEntity : rowDataEntities) { | ||||
|                     int rowIndex = rowDataEntity.getRowIndex(); | ||||
|                     this.getModel().setValue("discounttype","C",rowIndex); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void propertyChanged(PropertyChangedArgs e) { | ||||
|         super.propertyChanged(e); | ||||
|         String name = e.getProperty().getName(); | ||||
|         DynamicObject dataEntity = this.getModel().getDataEntity(true); | ||||
|         if("tqq9_hsxfsyje".equals(name)){ | ||||
|         if ("tqq9_hsxfsyje".equals(name)) { | ||||
|             //含税现返使用金额 | ||||
|             BigDecimal tqq9_hsxfsyje = dataEntity.getBigDecimal(name);//单头含税现返使用金额 | ||||
|             if(tqq9_hsxfsyje.compareTo(BigDecimal.ZERO) > 0){ | ||||
|             if (tqq9_hsxfsyje.compareTo(BigDecimal.ZERO) > 0) { | ||||
|                 BigDecimal totalallamount = dataEntity.getBigDecimal("totalallamount");//单头价税合计 | ||||
|                 DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry"); | ||||
|                 if(billentries != null && billentries.size() > 0){ | ||||
|                 if (billentries != null && billentries.size() > 0) { | ||||
|                     BigDecimal remainRefundAmt = tqq9_hsxfsyje;//拆分后剩余的金额 | ||||
|                     for (int i = 0; i <= billentries.size() - 1; i++) { | ||||
|                         DynamicObject billentry = billentries.get(i); | ||||
|                         if(i == billentries.size() - 1){ | ||||
|                         if (i == billentries.size() - 1) { | ||||
|                             //如果是最后一行 | ||||
|                             this.getModel().setValue("tqq9_xfamount", remainRefundAmt, i);//明细现返使用金额 | ||||
|                         }else{ | ||||
|                         } else { | ||||
|                             //如果不是最后一行 | ||||
|                             BigDecimal amountandtax = billentry.getBigDecimal("amountandtax");//明细价税合计 | ||||
|                             BigDecimal tqq9_xfamount = tqq9_hsxfsyje.multiply(amountandtax).divide(totalallamount, 2, RoundingMode.HALF_UP);//分录行含税金额比例 | ||||
|  | @ -50,20 +74,20 @@ public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn { | |||
|             } | ||||
|             this.getView().updateView("billentry"); | ||||
|         } | ||||
|         if("tqq9_hshfsyje".equals(name)){ | ||||
|         if ("tqq9_hshfsyje".equals(name)) { | ||||
|             //含税货返使用金额 | ||||
|             BigDecimal tqq9_hshfsyje = dataEntity.getBigDecimal(name);//单头含税现返使用金额 | ||||
|             if(tqq9_hshfsyje.compareTo(BigDecimal.ZERO) > 0){ | ||||
|             if (tqq9_hshfsyje.compareTo(BigDecimal.ZERO) > 0) { | ||||
|                 BigDecimal totalallamount = dataEntity.getBigDecimal("totalallamount");//单头价税合计 | ||||
|                 DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry"); | ||||
|                 if(billentries != null && billentries.size() > 0){ | ||||
|                 if (billentries != null && billentries.size() > 0) { | ||||
|                     BigDecimal remainRefundAmt = tqq9_hshfsyje;//拆分后剩余的金额 | ||||
|                     for (int i = 0; i <= billentries.size() - 1; i++) { | ||||
|                         DynamicObject billentry = billentries.get(i); | ||||
|                         if(i == billentries.size() - 1){ | ||||
|                         if (i == billentries.size() - 1) { | ||||
|                             //如果是最后一行 | ||||
|                             this.getModel().setValue("tqq9_hfamount", remainRefundAmt, i);//明细货返使用金额 | ||||
|                         }else{ | ||||
|                         } else { | ||||
|                             //如果不是最后一行 | ||||
|                             BigDecimal amountandtax = billentry.getBigDecimal("amountandtax");//明细价税合计 | ||||
|                             BigDecimal tqq9_hfamount = tqq9_hshfsyje.multiply(amountandtax).divide(totalallamount, 2, RoundingMode.HALF_UP);//分录行含税金额比例 | ||||
|  | @ -75,20 +99,20 @@ public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn { | |||
|             } | ||||
|             this.getView().updateView("billentry"); | ||||
|         } | ||||
|         if("tqq9_discountamount".equals(name)){ | ||||
|         if ("tqq9_discountamount".equals(name)) { | ||||
|             //优惠金额 | ||||
|             BigDecimal tqq9_discountamount = dataEntity.getBigDecimal(name);//单头优惠金额 | ||||
|             if(tqq9_discountamount.compareTo(BigDecimal.ZERO) > 0){ | ||||
|             if (tqq9_discountamount.compareTo(BigDecimal.ZERO) > 0) { | ||||
|                 BigDecimal totalallamount = dataEntity.getBigDecimal("totalallamount");//单头价税合计 | ||||
|                 DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry"); | ||||
|                 if(billentries != null && billentries.size() > 0){ | ||||
|                 if (billentries != null && billentries.size() > 0) { | ||||
|                     BigDecimal remainRefundAmt = tqq9_discountamount;//拆分后剩余的金额 | ||||
|                     for (int i = 0; i <= billentries.size() - 1; i++) { | ||||
|                         DynamicObject billentry = billentries.get(i); | ||||
|                         if(i == billentries.size() - 1){ | ||||
|                         if (i == billentries.size() - 1) { | ||||
|                             //如果是最后一行 | ||||
|                             this.getModel().setValue("tqq9_disamount", remainRefundAmt, i);//明细优惠金额 | ||||
|                         }else{ | ||||
|                         } else { | ||||
|                             //如果不是最后一行 | ||||
|                             BigDecimal amountandtax = billentry.getBigDecimal("amountandtax");//明细价税合计 | ||||
|                             BigDecimal tqq9_disamount = tqq9_discountamount.multiply(amountandtax).divide(totalallamount, 2, RoundingMode.HALF_UP);//分录行含税金额比例 | ||||
|  | @ -108,11 +132,115 @@ public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn { | |||
|             BigDecimal zero = BigDecimal.ZERO; | ||||
|             for (DynamicObject entry : entries) { | ||||
|                 BigDecimal payrate = entry.getBigDecimal("payrate"); | ||||
|                 zero=zero.add(payrate); | ||||
|                 zero = zero.add(payrate); | ||||
|             } | ||||
|             if (zero.compareTo(new BigDecimal(100)) > 0) { | ||||
|                 this.getView().showErrorNotification("付款计划付款比例总计大于100%,请修改"); | ||||
|             } | ||||
|         } | ||||
|         if (StringUtils.equals("tqq9_amount", name)) { | ||||
|             //单头金额下推 | ||||
|             BigDecimal tqq9_hsxfsyje = dataEntity.getBigDecimal("tqq9_hsxfsyje");//单头含税现返使用金额 | ||||
|             BigDecimal tqq9_hshfsyje = dataEntity.getBigDecimal("tqq9_hshfsyje");//单头含税货返使用金额 | ||||
|             BigDecimal tqq9_discountamount = dataEntity.getBigDecimal("tqq9_discountamount");//单头优惠金额 | ||||
|             BigDecimal totalallamount = dataEntity.getBigDecimal("totalallamount");//单头价税合计 | ||||
|             DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry"); | ||||
|             BigDecimal remainRefundAmt_xf = tqq9_hsxfsyje;//拆分后剩余的金额-现返 | ||||
|             BigDecimal remainRefundAmt_hf = tqq9_hshfsyje;//拆分后剩余的金额-货返 | ||||
|             BigDecimal remainRefundAmt_yh = tqq9_discountamount;//拆分后剩余的金额-优惠 | ||||
|             if (billentries != null && billentries.size() > 0) { | ||||
|                 for (int i = 0; i <= billentries.size() - 1; i++) { | ||||
|                     DynamicObject billentry = billentries.get(i); | ||||
|                     if (tqq9_hsxfsyje.compareTo(BigDecimal.ZERO) > 0) { | ||||
|                         if (i == billentries.size() - 1) { | ||||
|                             //如果是最后一行 | ||||
|                             this.getModel().setValue("tqq9_xfamount", remainRefundAmt_xf, i);//明细现返使用金额 | ||||
|                         } else { | ||||
|                             //如果不是最后一行 | ||||
|                             BigDecimal amountandtax = billentry.getBigDecimal("amountandtax");//明细价税合计 | ||||
|                             BigDecimal tqq9_xfamount = tqq9_hsxfsyje.multiply(amountandtax).divide(totalallamount.add(amountandtax), 2, RoundingMode.HALF_UP);//分录行含税金额比例 | ||||
|                             this.getModel().setValue("tqq9_xfamount", tqq9_xfamount, i);//明细现返使用金额 | ||||
|                             remainRefundAmt_xf = remainRefundAmt_xf.subtract(tqq9_xfamount); | ||||
|                         } | ||||
|                     } | ||||
|                     if (tqq9_hshfsyje.compareTo(BigDecimal.ZERO) > 0) { | ||||
| 
 | ||||
|                         if (i == billentries.size() - 1) { | ||||
|                             //如果是最后一行 | ||||
|                             this.getModel().setValue("tqq9_hfamount", remainRefundAmt_hf, i);//明细货返使用金额 | ||||
|                         } else { | ||||
|                             //如果不是最后一行 | ||||
|                             BigDecimal amountandtax = billentry.getBigDecimal("amountandtax");//明细价税合计 | ||||
|                             BigDecimal tqq9_hfamount = tqq9_hshfsyje.multiply(amountandtax).divide(totalallamount.add(amountandtax), 2, RoundingMode.HALF_UP);//分录行含税金额比例 | ||||
|                             this.getModel().setValue("tqq9_hfamount", tqq9_hfamount, i);//明细货返使用金额 | ||||
|                             remainRefundAmt_hf = remainRefundAmt_hf.subtract(tqq9_hfamount); | ||||
|                         } | ||||
|                     } | ||||
|                     if (tqq9_discountamount.compareTo(BigDecimal.ZERO) > 0) { | ||||
|                         if (i == billentries.size() - 1) { | ||||
|                             //如果是最后一行 | ||||
|                             this.getModel().setValue("tqq9_disamount", remainRefundAmt_yh, i);//明细优惠金额 | ||||
|                             this.getModel().setValue("discountamount", remainRefundAmt_yh, i);//明细折扣额 | ||||
|                         } else { | ||||
|                             //如果不是最后一行 | ||||
|                             BigDecimal amountandtax = billentry.getBigDecimal("amountandtax");//明细价税合计 | ||||
|                             BigDecimal tqq9_disamount = tqq9_discountamount.multiply(amountandtax).divide(totalallamount.add(amountandtax), 2, RoundingMode.HALF_UP);//分录行含税金额比例 | ||||
|                             this.getModel().setValue("tqq9_disamount", tqq9_disamount, i);//明细优惠金额 | ||||
|                             this.getModel().setValue("discountamount", tqq9_disamount, i);// | ||||
|                             remainRefundAmt_yh = remainRefundAmt_yh.subtract(tqq9_disamount); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             this.getView().updateView("billentry"); | ||||
|         } | ||||
|         if(StringUtils.equals("material",name)){ | ||||
|             ChangeData changeData = e.getChangeSet()[0]; | ||||
|             int rowIndex = changeData.getRowIndex(); | ||||
|             DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection(ENTRYENTITY); | ||||
|             DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex); | ||||
|             DynamicObject material = dynamicObject.getDynamicObject("material"); | ||||
|             DynamicObject masterid = material.getDynamicObject("masterid"); | ||||
|             DynamicObject bd_material = BusinessDataServiceHelper.loadSingle(masterid.getLong("id"), "bd_material"); | ||||
| 
 | ||||
|             DynamicObject org = dataEntity.getDynamicObject("org"); | ||||
|             //上海 | ||||
|             if(StringUtils.equals("Org-00001",org.getString("number"))){ | ||||
|                 BigDecimal tqq9_maxprice_sh = bd_material.getBigDecimal("tqq9_maxprice_sh"); | ||||
|                 if(tqq9_maxprice_sh.compareTo(BigDecimal.ZERO)>0){ | ||||
|                     getModel().setValue("priceandtax",tqq9_maxprice_sh,rowIndex); | ||||
|                     getModel().setValue("tqq9_zgcgxj",tqq9_maxprice_sh,rowIndex); | ||||
|                 } | ||||
| 
 | ||||
|             //北京 | ||||
|             }else if(StringUtils.equals("Org-00002",org.getString("number"))){ | ||||
|                 BigDecimal tqq9_maxprice_bj = bd_material.getBigDecimal("tqq9_maxprice_bj"); | ||||
|                 if(tqq9_maxprice_bj.compareTo(BigDecimal.ZERO)>0) { | ||||
|                     getModel().setValue("priceandtax", tqq9_maxprice_bj, rowIndex); | ||||
|                     getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_bj, rowIndex); | ||||
|                 } | ||||
|             //广州 | ||||
|             } else if(StringUtils.equals("Org-00003",org.getString("number"))){ | ||||
|                 BigDecimal tqq9_maxprice_gz = bd_material.getBigDecimal("tqq9_maxprice_gz"); | ||||
|                 if(tqq9_maxprice_gz.compareTo(BigDecimal.ZERO)>0) { | ||||
|                     getModel().setValue("priceandtax", tqq9_maxprice_gz, rowIndex); | ||||
|                     getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_gz, rowIndex); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|         if(StringUtils.equals("priceandtax",name)){ | ||||
|             ChangeData changeData = e.getChangeSet()[0]; | ||||
|             int rowIndex = changeData.getRowIndex(); | ||||
|             DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection(ENTRYENTITY); | ||||
|             BigDecimal oldValue = (BigDecimal)changeData.getOldValue(); | ||||
|             BigDecimal tqq9_zgcgxj = (BigDecimal)getModel().getValue("tqq9_zgcgxj"); | ||||
|             if (oldValue.compareTo(tqq9_zgcgxj)>0&&tqq9_zgcgxj.compareTo(BigDecimal.ZERO)>0) { | ||||
|                 getModel().setValue("priceandtax",0); | ||||
|                 this.getView().showErrorNotification("物料明细分录行"+rowIndex+1+"含税单价超过最高采购限价,请修改"); | ||||
|             } | ||||
| 
 | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -1,39 +1,28 @@ | |||
| package tqq9.lc123.cloud.app.plugin.operate.im; | ||||
| 
 | ||||
| import kd.bos.data.BusinessDataReader; | ||||
| import kd.bos.dataentity.OperateOption; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.dataentity.metadata.IDataEntityType; | ||||
| import kd.bos.dataentity.resource.ResManager; | ||||
| import kd.bos.dataentity.utils.StringUtils; | ||||
| import kd.bos.entity.EntityMetadataCache; | ||||
| import kd.bos.entity.MainEntityType; | ||||
| import kd.bos.entity.botp.plugin.args.AfterCreateTargetEventArgs; | ||||
| import kd.bos.entity.botp.runtime.ConvertOperationResult; | ||||
| import kd.bos.entity.botp.runtime.PushArgs; | ||||
| import kd.bos.entity.botp.runtime.SourceBillReport; | ||||
| import kd.bos.entity.datamodel.IRefrencedataProvider; | ||||
| import kd.bos.entity.datamodel.ListSelectedRow; | ||||
| import kd.bos.entity.operate.result.IOperateInfo; | ||||
| import kd.bos.entity.operate.result.OperationResult; | ||||
| import kd.bos.entity.plugin.AbstractOperationServicePlugIn; | ||||
| import kd.bos.entity.plugin.args.AfterOperationArgs; | ||||
| import kd.bos.exception.KDBizException; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.orm.query.QCP; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.bos.servicehelper.botp.ConvertServiceHelper; | ||||
| import kd.bos.servicehelper.operation.SaveServiceHelper; | ||||
| import kd.bos.servicehelper.operation.OperationServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import org.hsqldb.Server; | ||||
| import tqq9.lc123.cloud.app.api.utils.Constants; | ||||
| import tqq9.lc123.cloud.app.plugin.utils.BotpParamUtils; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.*; | ||||
| 
 | ||||
| /** | ||||
|  * 采购退货申请单(采购退补货)下推红字采购入库单审核后,根据来源的采购订单生成收货通知单 | ||||
|  | @ -41,10 +30,11 @@ import java.util.Map; | |||
| public class ReturnStockSyncNotifierPlugin extends AbstractOperationServicePlugIn implements Plugin { | ||||
|     private final static Log logger = LogFactory.getLog(ReturnStockSyncNotifierPlugin.class); | ||||
| 
 | ||||
|     private static String PURORDER="pm_purorderbill"; | ||||
|     private static String RECEIPTNOTICE="pm_receiptnotice"; | ||||
|     private static String PURORDER_ENTRY="billentry"; | ||||
|     private static String RULE="2279256940385159168"; | ||||
|     private static String PURORDER = "pm_purorderbill"; | ||||
|     private static String RECEIPTNOTICE = "pm_receiptnotice"; | ||||
|     private static String PURORDER_ENTRY = "billentry"; | ||||
|     private static String RULE = "2279256940385159168";//单据转换规则id | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterExecuteOperationTransaction(AfterOperationArgs e) { | ||||
|         super.afterExecuteOperationTransaction(e); | ||||
|  | @ -53,14 +43,17 @@ public class ReturnStockSyncNotifierPlugin extends AbstractOperationServicePlugI | |||
|             DynamicObject biztype = dataEntity.getDynamicObject("biztype");//业务类型 | ||||
|             String number = biztype.getString("number"); | ||||
|             //业务类型为物料类采购退补货 | ||||
|             if("1102".equals(number)){ | ||||
|             if ("1102".equals(number)) { | ||||
|                 String billno = dataEntity.getString("billno");//采购入库单单据编号 | ||||
|                 //采购入库单 | ||||
|                 DynamicObject im_purinbill = BusinessDataServiceHelper.loadSingle("im_purinbill", new QFilter[]{new QFilter("billno", QCP.equals, billno)}); | ||||
|                 DynamicObjectCollection billentry = im_purinbill.getDynamicObjectCollection("billentry"); | ||||
|                 Map<String, String> param=new HashMap<>(); | ||||
|                 HashMap<Long, Long> entitypkMap=new HashMap<>(); | ||||
|                 Map<String, String> param = new HashMap<>(); | ||||
|                 HashMap<Long, Long> entitypkMap = new HashMap<>(); | ||||
|                 OperationResult operationResult1 = this.getOperationResult(); | ||||
|                 OperateOption option = this.getOption(); | ||||
|                 Boolean isSuccess = true; | ||||
|                 StringBuilder errorMsg = new StringBuilder(); | ||||
|                 for (DynamicObject entry : billentry) { | ||||
|                     String mainbillnumber = entry.getString("mainbillnumber");//核心单据编号 | ||||
|                     String mainbillentryid = entry.getString("mainbillentryid");//核心单据行id | ||||
|  | @ -70,26 +63,58 @@ public class ReturnStockSyncNotifierPlugin extends AbstractOperationServicePlugI | |||
|                     DynamicObjectCollection billentry1 = pm_purorderbill.getDynamicObjectCollection("billentry"); | ||||
|                     for (DynamicObject entry1 : billentry1) { | ||||
|                         String id = entry1.getString("id"); | ||||
|                         if(StringUtils.equals(id,mainbillentryid)){ | ||||
|                             entitypkMap.put(pm_purorderbill.getLong("id"),entry1.getLong("id")); | ||||
|                             param.put(id,qty); | ||||
|                         if (StringUtils.equals(id, mainbillentryid)) { | ||||
|                             entitypkMap.put(pm_purorderbill.getLong("id"), entry1.getLong("id")); | ||||
|                             param.put(id, qty); | ||||
|                         } | ||||
|                     } | ||||
|                     PushArgs pushArgs = BotpParamUtils.getPushArgs(PURORDER,RECEIPTNOTICE,PURORDER_ENTRY,param,entitypkMap,RULE); | ||||
|                     PushArgs pushArgs = BotpParamUtils.getPushArgs(PURORDER, RECEIPTNOTICE, PURORDER_ENTRY, param, entitypkMap, RULE); | ||||
|                     ConvertOperationResult pushResult = ConvertServiceHelper.pushAndSave(pushArgs); | ||||
|                     if (!pushResult.isSuccess()) { | ||||
|                         // 错误摘要 | ||||
|                         String errMessage = pushResult.getMessage(); | ||||
|                         throw new KDBizException("下推失败,请从订单手动下推补货"); | ||||
|                     }else{ | ||||
|                         operationResult1.setMessage("补货成功"); | ||||
|                         List<SourceBillReport> billReports = pushResult.getBillReports(); | ||||
|                         for (SourceBillReport billReport : billReports) { | ||||
|                             String billNo = billReport.getBillNo(); | ||||
|                             isSuccess = false; | ||||
|                             String billMessage = billReport.getFailMessage(); | ||||
|                             errorMsg.append("收货通知单:"+billNo+"下推失败 ").append(billMessage).append("\n"); | ||||
|                         } | ||||
|                     } else { | ||||
|                         Set<Object> targetBillIds = pushResult.getTargetBillIds(); | ||||
|                         DynamicObject[] load = new DynamicObject[targetBillIds.size()]; | ||||
|                         Iterator<Object> iterator = targetBillIds.iterator(); | ||||
|                         for (int i = 0; iterator.hasNext(); i++) { | ||||
|                             DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(RECEIPTNOTICE, new QFilter[]{new QFilter("id", QCP.equals, iterator.next())}); | ||||
|                             load[i]=dynamicObject; | ||||
| 
 | ||||
|                         } | ||||
|                         OperationResult sumbitResult = OperationServiceHelper.executeOperate(Constants.TYPE_SUBMIT, RECEIPTNOTICE, load, option); | ||||
|                         List<IOperateInfo> allErrorOrValidateInfo = sumbitResult.getAllErrorOrValidateInfo(); | ||||
|                         for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) { | ||||
|                             isSuccess = false; | ||||
|                             String message = iOperateInfo.getMessage(); | ||||
|                             errorMsg.append("收货通知单提交失败:").append(message).append("\n"); | ||||
|                         } | ||||
|                         OperationResult auditResult = OperationServiceHelper.executeOperate(Constants.TYPE_AUDIT, RECEIPTNOTICE, load, option); | ||||
|                         List<IOperateInfo> allErrorOrValidateInfo1 = auditResult.getAllErrorOrValidateInfo(); | ||||
|                         for (IOperateInfo iOperateInfo : allErrorOrValidateInfo1) { | ||||
|                             String message = iOperateInfo.getMessage(); | ||||
|                             errorMsg.append("收货通知单审核失败:").append(message).append("\n"); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 operationResult1.setMessage(errorMsg.toString()); | ||||
|                 if (isSuccess){ | ||||
|                     operationResult1.setMessage("补货成功"); | ||||
|                 }else{ | ||||
|                     operationResult1.setMessage(errorMsg.toString()); | ||||
|                 } | ||||
|                 operationResult1.setShowMessage(false); | ||||
| 
 | ||||
| 
 | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  | @ -5,33 +5,25 @@ import kd.bos.dataentity.entity.DynamicObject; | |||
| import kd.bos.exception.KDException; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.message.api.EmailInfo; | ||||
| import kd.bos.message.service.handler.EmailHandler; | ||||
| 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 kd.bos.workflow.engine.msg.info.MessageAttachment; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import tqq9.lc123.cloud.app.plugin.operate.sys.ValiddaysSavePlugin; | ||||
| import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; | ||||
| import tqq9.lc123.cloud.app.plugin.utils.DateDifferenceCalculator; | ||||
| import tqq9.lc123.cloud.app.plugin.utils.EmailUtils; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import static kd.bos.mvc.form.TitleField.number; | ||||
| 
 | ||||
| /** | ||||
|  * 供应商、注册证证照时间到期时间计算并发送预警邮件 | ||||
|  */ | ||||
| public class DaysRemaining extends AbstractTask implements Plugin { | ||||
|     private final static Log logger = LogFactory.getLog(DaysRemaining.class); | ||||
| public class DaysRemainingTask extends AbstractTask implements Plugin { | ||||
|     private final static Log logger = LogFactory.getLog(DaysRemainingTask.class); | ||||
| 
 | ||||
|     @Override | ||||
|     public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException { | ||||
		Loading…
	
		Reference in New Issue