Explorar o código

k3对接出库单bug修复

hu %!s(int64=2) %!d(string=hai) anos
pai
achega
dc5d1920dd

+ 27 - 16
src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java

@@ -12,6 +12,7 @@ import common.data.Row;
 import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
+import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
 
 import javax.swing.text.StyledEditorKit;
@@ -105,16 +106,25 @@ public class stockbill extends Controller {
                 sqlList.add(sqlFactory.getSQL());
 
                 JSONArray detailarray = content.getJSONArray("icstockbilldetails");
-                List<String> itemnos=new ArrayList<>();
+                StringBuffer str = new StringBuffer();
+
                 List<Long> sa_dispatch_itemsids=new ArrayList<>();
-                itemnos.add("0");
                 sa_dispatch_itemsids.add(0l);
                 for (Object object:detailarray) {
                     JSONObject jsonObject = (JSONObject)object;
-                    itemnos.add(jsonObject.getString("fitemno"));
+                    if (str.toString().equals("")) {
+                        str.append("'" +jsonObject.getString("fitemno") + "'");
+                    } else {
+                        str.append(",'" + jsonObject.getString("fitemno") + "'");
+                    }
                     sa_dispatch_itemsids.add(jsonObject.getLong("sainvoicedetailid"));
                 }
-                Rows rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='lsa1986' and itemno in "+itemnos.toString().replace("[", "(").replace("]", ")"));
+                Rows rows;
+                if (!str.toString().equals("")) {
+                     rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='lsa1986' and itemno in "+"(" + str.toString() + ")");
+                } else {
+                     rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='lsa1986' and itemno in('')");
+                }
                 RowsMap itemRowsMap =rows.toRowsMap("itemno");
                 Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid from sa_dispatch_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid inner join sa_dispatch t3 on t1.sa_dispatchid=t3.sa_dispatchid and t1.siteid=t3.siteid  where t3.status in('审核','复核','关闭') and  t1.siteid='lsa1986' and  t1.sa_dispatch_itemsid in "+sa_dispatch_itemsids.toString().replace("[", "(").replace("]", ")"));
                 RowsMap distiptchRowsMap =distiptchRows.toRowsMap("sa_dispatch_itemsid");
@@ -165,18 +175,19 @@ public class stockbill extends Controller {
                 //返利比例
                 String icstockbillrebateaccount = Parameter.get(siteid,"icstockbillrebateaccount"); //经销商销售出库单返利账户
                 String icstockbillrebaterate1 = Parameter.get(siteid,"icstockbillrebaterate"); //销售出库单返利比例
-                BigDecimal icstockbillrebaterate =new BigDecimal(icstockbillrebaterate1);
-                //经销商返利
-                BigDecimal rebateamount = icstockbillrebaterate.multiply(amountTotal);
-                 System.out.println(rebateamount);
-                CashbillEntity entity = new CashbillEntity();
-                entity.setAmount(rebateamount);
-                entity.setOwnerid(st_stockbillid);
-                entity.setOwnertable("st_stockbill");
-                entity.setSource("");
-                entity.setRemarks("销售出库单" + fbillnum + "返利");
-                sqlList.addAll(Accountbalance.createCashbillIncome(this,sys_enterpriseid,Long.valueOf(icstockbillrebateaccount).longValue(),entity,true));
-
+                if(!StringUtils.isBlank(icstockbillrebateaccount) && !StringUtils.isBlank(icstockbillrebaterate1)){
+                    BigDecimal icstockbillrebaterate =new BigDecimal(icstockbillrebaterate1);
+                    //经销商返利
+                    BigDecimal rebateamount = icstockbillrebaterate.multiply(amountTotal);
+                    System.out.println(rebateamount);
+                    CashbillEntity entity = new CashbillEntity();
+                    entity.setAmount(rebateamount);
+                    entity.setOwnerid(st_stockbillid);
+                    entity.setOwnertable("st_stockbill");
+                    entity.setSource("");
+                    entity.setRemarks("销售出库单" + fbillnum + "返利");
+                    sqlList.addAll(Accountbalance.createCashbillIncome(this,sys_enterpriseid,Long.valueOf(icstockbillrebateaccount).longValue(),entity,true));
+                }
                 sqlList.add("update st_stockbill set status='审核',checkby='"+checkby+"',checkdate=CURRENT_TIMESTAMP where st_stockbillid = "+st_stockbillid+" and siteid='lsa1986'");