diff --git a/lc123/cloud/app/plugin/form/im/OtherOutApplyBillPlugin.java b/lc123/cloud/app/plugin/form/im/OtherOutApplyBillPlugin.java index 20bdc4c..1ddd9ae 100644 --- a/lc123/cloud/app/plugin/form/im/OtherOutApplyBillPlugin.java +++ b/lc123/cloud/app/plugin/form/im/OtherOutApplyBillPlugin.java @@ -131,7 +131,7 @@ public class OtherOutApplyBillPlugin extends AbstractBillPlugIn implements Befor } } //批号带出生产厂商 - if (StringUtils.equals("tqq9_lotnumber", name)||StringUtils.equals("tqq9_dcck", name)||StringUtils.equals("tqq9_materiel", name)) { + if (StringUtils.equals("tqq9_lotnumber", name) || StringUtils.equals("tqq9_dcck", name) || StringUtils.equals("tqq9_materiel", name)) { ChangeData[] changeSet = e.getChangeSet(); int rowIndex = changeSet[0].getRowIndex(); Object tqq9_materiel = model.getValue("tqq9_materiel"); @@ -144,12 +144,12 @@ public class OtherOutApplyBillPlugin extends AbstractBillPlugIn implements Befor if (materiel != null && dcck != null && StringUtils.isNotBlank(lotNumber)) { QFilter materielF = new QFilter("material", QCP.equals, materiel.getDynamicObject("masterid").getLong("id")); QFilter warehouseF = new QFilter("warehouse", QCP.equals, dcck.getLong("id")); - QFilter lotNumberF= new QFilter("lotnum", QCP.equals, lotNumber); - QFilter qtyF= new QFilter("qty", QCP.not_equals2, 0); + QFilter lotNumberF = new QFilter("lotnum", QCP.equals, lotNumber); + QFilter qtyF = new QFilter("qty", QCP.not_equals2, 0); DynamicObject[] objects = BusinessDataServiceHelper.load("im_inv_realbalance", "id,keycol,material,lotnum,producedate,expirydate,tqq9_goods,tqq9_registration,qty" , new QFilter[]{materielF.and(warehouseF).and(lotNumberF).and(qtyF)}); - if (null != objects && objects.length > 0) { + if (null != objects) { if (objects.length == 1) { DynamicObject object = objects[0]; Date producedate = object.getDate("producedate");//生产日期 @@ -187,7 +187,16 @@ public class OtherOutApplyBillPlugin extends AbstractBillPlugIn implements Befor this.getModel().setValue("tqq9_cs", tqq9_cs.toString(), rowIndex); this.getModel().setValue("tqq9_licenseno", tqq9_licenseno.toString(), rowIndex); this.getModel().setValue("tqq9_zczh", tqq9_registration, rowIndex); - }else{ + } else if (objects.length == 0 && StringUtils.equals("tqq9_dcck", name)) { + this.getModel().setValue("tqq9_lotnumber", null, rowIndex); + this.getModel().setValue("tqq9_materiel", null, rowIndex); + this.getModel().setValue("tqq9_producedate", null, rowIndex); + this.getModel().setValue("tqq9_goods", null, rowIndex); + this.getModel().setValue("tqq9_expirydate", null, rowIndex); + this.getModel().setValue("tqq9_cs", null, rowIndex); + this.getModel().setValue("tqq9_licenseno", null, rowIndex); + this.getModel().setValue("tqq9_zczh", null, rowIndex); + } else if (objects.length == 0 && StringUtils.equals("tqq9_lotnumber", name)) { this.getModel().setValue("tqq9_producedate", null, rowIndex); this.getModel().setValue("tqq9_goods", null, rowIndex); this.getModel().setValue("tqq9_expirydate", null, rowIndex); @@ -196,9 +205,7 @@ public class OtherOutApplyBillPlugin extends AbstractBillPlugIn implements Befor this.getModel().setValue("tqq9_zczh", null, rowIndex); } } - - - String sql="/*dialect*/SELECT \n" + + String sql = "/*dialect*/SELECT \n" + " t1.fmaterialid, \n" + " t1.fwarehouseid,\n" + " t1.flotnum,\n" + @@ -215,21 +222,21 @@ public class OtherOutApplyBillPlugin extends AbstractBillPlugIn implements Befor " AND t1.fwarehouseid = t2.f_s_warehouse\n" + " AND t1.flotnum = t2.f_s_lotnum\n" + " WHERE \n" + - " t1.fmaterialid = "+materiel.getDynamicObject("masterid").getString("id")+"\n" + - " AND t1.fwarehouseid = "+dcck.getString("id")+" \n" + - " AND t1.flotnum = '"+lotNumber+"' \n" + + " t1.fmaterialid = " + materiel.getDynamicObject("masterid").getString("id") + "\n" + + " AND t1.fwarehouseid = " + dcck.getString("id") + " \n" + + " AND t1.flotnum = '" + lotNumber + "' \n" + "GROUP BY t1.fmaterialid, t1.fwarehouseid, t1.flotnum;\n"; DataSet materialDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), sql); DataSet copy1 = materialDataSet.copy(); DynamicObjectCollection dynamicObjects = ORM.create().toPlainDynamicObjectCollection(copy1); - if (dynamicObjects.size()>0) { + if (dynamicObjects.size() > 0) { BigDecimal total_qty = dynamicObjects.get(0).getBigDecimal("qty_difference"); this.getModel().setValue("tqq9_pckyamount", total_qty, rowIndex); } - }else if(materiel != null && dcck != null && StringUtils.isBlank(lotNumber)){ + } else if (materiel != null && dcck != null && StringUtils.isBlank(lotNumber)) { - String sql="/*dialect*/SELECT \n" + + String sql = "/*dialect*/SELECT \n" + " t1.fmaterialid, \n" + " t1.fwarehouseid,\n" + " SUM(t1.fqty) - COALESCE(SUM(t2.f_qty), 0) AS qty_difference\n" + @@ -244,19 +251,40 @@ public class OtherOutApplyBillPlugin extends AbstractBillPlugIn implements Befor "ON t1.fmaterialid = t2.f_s_materiel \n" + " AND t1.fwarehouseid = t2.f_s_warehouse\n" + " WHERE \n" + - " t1.fmaterialid = "+materiel.getDynamicObject("masterid").getString("id")+"\n" + - " AND t1.fwarehouseid = "+dcck.getString("id")+" \n" + + " t1.fmaterialid = " + materiel.getDynamicObject("masterid").getString("id") + "\n" + + " AND t1.fwarehouseid = " + dcck.getString("id") + " \n" + "GROUP BY t1.fmaterialid, t1.fwarehouseid;\n"; DataSet materialDataSet = DB.queryDataSet(this.getClass().getName(), DBRoute.of("scm"), sql); DataSet copy1 = materialDataSet.copy(); DynamicObjectCollection dynamicObjects = ORM.create().toPlainDynamicObjectCollection(copy1); - if (dynamicObjects.size()>0) { + if (dynamicObjects.size() > 0) { BigDecimal total_qty = dynamicObjects.get(0).getBigDecimal("qty_difference"); this.getModel().setValue("tqq9_pckyamount", total_qty, rowIndex); } + this.getModel().setValue("tqq9_producedate", null, rowIndex); + this.getModel().setValue("tqq9_goods", null, rowIndex); + this.getModel().setValue("tqq9_expirydate", null, rowIndex); + this.getModel().setValue("tqq9_cs", null, rowIndex); + this.getModel().setValue("tqq9_licenseno", null, rowIndex); + this.getModel().setValue("tqq9_zczh", null, rowIndex); + }else if(dcck == null && StringUtils.equals("tqq9_dcck",name)){ + this.getModel().setValue("tqq9_lotnumber", null, rowIndex); + this.getModel().setValue("tqq9_materiel", null, rowIndex); + this.getModel().setValue("tqq9_producedate", null, rowIndex); + this.getModel().setValue("tqq9_goods", null, rowIndex); + this.getModel().setValue("tqq9_expirydate", null, rowIndex); + this.getModel().setValue("tqq9_cs", null, rowIndex); + this.getModel().setValue("tqq9_licenseno", null, rowIndex); + this.getModel().setValue("tqq9_zczh", null, rowIndex); + }else if(tqq9_materiel == null && StringUtils.equals("tqq9_materiel",name)){ + this.getModel().setValue("tqq9_lotnumber", null, rowIndex); + this.getModel().setValue("tqq9_producedate", null, rowIndex); + this.getModel().setValue("tqq9_goods", null, rowIndex); + this.getModel().setValue("tqq9_expirydate", null, rowIndex); + this.getModel().setValue("tqq9_cs", null, rowIndex); + this.getModel().setValue("tqq9_licenseno", null, rowIndex); + this.getModel().setValue("tqq9_zczh", null, rowIndex); + } } } - -} - } \ No newline at end of file