Explorar o código

去除其他系统的自动任务或同步接口

hu hai 5 meses
pai
achega
e4dac37ef5
Modificáronse 44 ficheiros con 0 adicións e 4321 borrados
  1. 0 2
      src/custom/restcontroller/webmanage/cucuAbutment/stockbill/SQL/数据操作日志新增.sql
  2. 0 2
      src/custom/restcontroller/webmanage/cucuAbutment/stockbill/SQL/销售出库单新增.sql
  3. 0 13
      src/custom/restcontroller/webmanage/cucuAbutment/stockbill/SQL/销售出库单明细新增.sql
  4. 0 438
      src/custom/restcontroller/webmanage/cucuAbutment/stockbill/stockbill.java
  5. 0 80
      src/custom/restcontroller/webmanage/lsak3/aftersalesmag/aftersalesmag.java
  6. 0 23
      src/custom/restcontroller/webmanage/lsak3/agents/SQL/企业修改.sql
  7. 0 28
      src/custom/restcontroller/webmanage/lsak3/agents/SQL/企业新增.sql
  8. 0 15
      src/custom/restcontroller/webmanage/lsak3/agents/SQL/经销商修改.sql
  9. 0 21
      src/custom/restcontroller/webmanage/lsak3/agents/SQL/经销商新增.sql
  10. 0 23
      src/custom/restcontroller/webmanage/lsak3/agents/SQL/联系人信息新增.sql
  11. 0 230
      src/custom/restcontroller/webmanage/lsak3/agents/agents.java
  12. 0 1
      src/custom/restcontroller/webmanage/lsak3/cashbill/SQL/收支凭证反审核.sql
  13. 0 4
      src/custom/restcontroller/webmanage/lsak3/cashbill/SQL/收支凭证新增.sql
  14. 0 11
      src/custom/restcontroller/webmanage/lsak3/cashbill/SQL/营销账户余额新增.sql
  15. 0 385
      src/custom/restcontroller/webmanage/lsak3/cashbill/cashbill.java
  16. 0 77
      src/custom/restcontroller/webmanage/lsak3/dispatch/dispatch.java
  17. 0 9
      src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案-扩展新增.sql
  18. 0 21
      src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案-扩展更新.sql
  19. 0 10
      src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案新增.sql
  20. 0 54
      src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案更新.sql
  21. 0 8
      src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案领域新增.sql
  22. 0 345
      src/custom/restcontroller/webmanage/lsak3/item/item.java
  23. 0 2
      src/custom/restcontroller/webmanage/lsak3/itemPrice/SQL/商品价格新增.sql
  24. 0 7
      src/custom/restcontroller/webmanage/lsak3/itemPrice/SQL/商品价格更新.sql
  25. 0 81
      src/custom/restcontroller/webmanage/lsak3/itemPrice/itemPrice.java
  26. 0 71
      src/custom/restcontroller/webmanage/lsak3/order/order.java
  27. 0 2
      src/custom/restcontroller/webmanage/lsak3/stockbill/SQL/数据操作日志新增.sql
  28. 0 2
      src/custom/restcontroller/webmanage/lsak3/stockbill/SQL/销售出库单新增.sql
  29. 0 13
      src/custom/restcontroller/webmanage/lsak3/stockbill/SQL/销售出库单明细新增.sql
  30. 0 453
      src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java
  31. 0 135
      src/custom/service/AftersalesmagAutoRecheckService.java
  32. 0 306
      src/custom/service/AutoDockItemService.java
  33. 0 37
      src/custom/service/AutoQueryBoclnfosForJH_HY.java
  34. 0 37
      src/custom/service/AutoQueryBoclnfosForJH_NB.java
  35. 0 37
      src/custom/service/AutoQueryBoclnfosForJH_TZ.java
  36. 0 46
      src/custom/service/AutoQueryBoclnfosForNH_HY.java
  37. 0 46
      src/custom/service/AutoQueryBoclnfosForNH_NB.java
  38. 0 46
      src/custom/service/AutoQueryBoclnfosForNH_TZ.java
  39. 0 38
      src/custom/service/AutoQueryBoclnfosForZH_HY.java
  40. 0 38
      src/custom/service/AutoQueryBoclnfosForZH_NB.java
  41. 0 38
      src/custom/service/AutoQueryBoclnfosForZH_TZ.java
  42. 0 502
      src/custom/service/DispatchAutoCloseService.java
  43. 0 286
      src/custom/service/StockAutoDockAftersalesmagService.java
  44. 0 298
      src/custom/service/StockAutoDockDispatchService.java

+ 0 - 2
src/custom/restcontroller/webmanage/cucuAbutment/stockbill/SQL/数据操作日志新增.sql

@@ -1,2 +0,0 @@
-insert into sys_contrllog (siteid, sys_contrllogid,ownertable,ownerid,action, remarks,actionuserid,actionby)
-values ($siteid$, $sys_contrllogid$,$ownertable$,$ownerid$, $action$, $remarks$,$actionuserid$, $actionby$);

+ 0 - 2
src/custom/restcontroller/webmanage/cucuAbutment/stockbill/SQL/销售出库单新增.sql

@@ -1,2 +0,0 @@
-insert into st_stockbill (siteid, st_stockbillid,createby, createdate, billno,billdate,changeby, changedate,checkby,checkdate,sys_enterpriseid, rb,type,remarks)
-values ($siteid$, $st_stockbillid$,$createby$, $createdate$, $billno$,$billdate$, $changeby$, $changedate$,$checkby$,$checkdate$,$sys_enterpriseid$,$rb$,$type$,$remarks$);

+ 0 - 13
src/custom/restcontroller/webmanage/cucuAbutment/stockbill/SQL/销售出库单明细新增.sql

@@ -1,13 +0,0 @@
-insert into st_stockbill_items (siteid, st_stockbill_itemsid,st_stockbillid, sa_dispatch_itemsid, rowno, itemid, qty,amount,remarks,price,sa_orderitemsid,sa_orderid)
-select $siteid$,
-       $st_stockbill_itemsid$,
-       $st_stockbillid$,
-       $sa_dispatch_itemsid$,
-       $rowno$,
-       $itemid$,
-       $qty$,
-       $amount$,
-       $remarks$,
-       $price$,
-       $sa_orderitemsid$,
-       $sa_orderid$

+ 0 - 438
src/custom/restcontroller/webmanage/cucuAbutment/stockbill/stockbill.java

@@ -1,438 +0,0 @@
-package restcontroller.webmanage.cucuAbutment.stockbill;
-
-import beans.accountbalance.Accountbalance;
-import beans.accountbalance.CashbillEntity;
-import beans.datacontrllog.DataContrlLog;
-import beans.parameter.Parameter;
-import beans.remind.Remind;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import restcontroller.R;
-import restcontroller.webmanage.executorService.Executor;
-import service.AftersalesmagAutoRecheckService;
-
-import javax.swing.text.StyledEditorKit;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-public class stockbill extends Controller {
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public stockbill(JSONObject content) throws YosException {
-        super(content);
-    }
-
-    private static Logger logger = Logger.getLogger(stockbill.class);
-
-    /**
-     * 更新YOS销售出库单
-     *
-     * @return
-     * @throws YosException
-     */
-    @API(title = "更新YOS销售出库单", apiversion = R.ID20231115095103.v1.class, accesstoken = false)
-    public String updateIcstockbill() throws YosException {
-        String msg = "";
-        int code = 1;
-        ArrayList<String> sqlList = new ArrayList<>();
-        // 单据编号
-        String fbillnum = content.getString("fbillnum");
-        try {
-            // 经销商编号
-            String fagentnum = content.getString("fagentnum");
-            long sys_enterpriseid = 0;
-            if (dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='CCYOSG' and  agentnum='" + fagentnum + "'").isNotEmpty()) {
-                sys_enterpriseid = dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='CCYOSG' and  agentnum='" + fagentnum + "'").get(0).getLong("sys_enterpriseid");
-            } else {
-                msg = "yos中不存在【" + fagentnum + "】经销商";
-                return getErrReturnObject().setErrMsg(msg).toString();
-            }
-            // 单据日期
-            String fdate = content.getString("fdate");
-            // 会计期间
-            //  String fperiod = content.getString("fperiod");
-            // 红蓝字
-            String frb = content.getString("frb");
-            // 表头仓库
-            // String fstockno = content.getString("fstockno");
-            // 单据类型明细
-            //String ftypemx = content.getString("ftypemx");
-            // 单据状态
-            String fstatus = content.getString("fstatus");
-            // 制单人
-            String createby = content.getString("createby");
-            // 制单日期
-            String createdate = content.getString("createdate");
-            // 审核人
-            String checkby = content.getString("checkby");
-            // 审核日期
-            String checkdate = content.getString("checkdate");
-            // 备注
-            String fnotes = content.getString("fnotes");
-            siteid = "CCYOSG";
-
-            Long sa_cashbillid = 0L;
-
-            Rows stockbillRows = dbConnect.runSqlQuery("select * from st_stockbill where siteid='CCYOSG' and status='审核' and billno='" + fbillnum + "'");
-            Long st_stockbillid = 0L;
-            if (stockbillRows.isEmpty() && "审核".equals(fstatus)) {
-                /**
-                 * DRP不存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需新增该销售出库单
-                 */
-                SQLFactory sqlFactory = new SQLFactory(this, "销售出库单新增");
-                st_stockbillid = createTableID("st_stockbill");
-                sqlFactory.addParameter("siteid", "CCYOSG");
-                sqlFactory.addParameter("st_stockbillid", st_stockbillid);
-                sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                sqlFactory.addParameter("billno", fbillnum);
-                sqlFactory.addParameter("type", "销售出库");
-                sqlFactory.addParameter("rb", frb.equals("蓝") ? 1 : 0);
-                sqlFactory.addParameter("billdate", fdate);
-                sqlFactory.addParameter("createby", createby);
-                sqlFactory.addParameter("createdate", getDate(createdate));
-                sqlFactory.addParameter("changeby", createby);
-                sqlFactory.addParameter("changedate", getDate(createdate));
-                sqlFactory.addParameter("checkby", checkby);
-                sqlFactory.addParameter("checkdate", getDate(checkdate));
-                sqlFactory.addParameter("remarks", fnotes);
-                sqlList.add(sqlFactory.getSQL());
-
-                JSONArray detailarray = content.getJSONArray("icstockbilldetails");
-                StringBuffer str = new StringBuffer();
-
-                List<Long> sa_dispatch_itemsids = new ArrayList<>();
-                sa_dispatch_itemsids.add(0l);
-                for (Object object : detailarray) {
-                    JSONObject jsonObject = (JSONObject) object;
-                    if (str.toString().equals("")) {
-                        str.append("'" + jsonObject.getString("fitemno") + "'");
-                    } else {
-                        str.append(",'" + jsonObject.getString("fitemno") + "'");
-                    }
-                    sa_dispatch_itemsids.add(jsonObject.getLong("sainvoicedetailid"));
-                }
-                Rows rows;
-                if (!str.toString().equals("")) {
-                    rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='CCYOSG' and itemno in " + "(" + str.toString() + ")");
-                } else {
-                    rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='CCYOSG' and itemno in('')");
-                }
-                RowsMap itemRowsMap = rows.toRowsMap("itemno");
-                Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid,t1.sa_orderitemsid,t2.sa_orderid,t3.sys_enterpriseid,t4.sonum,t5.itemno,t5.itemname 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 left join sa_order t4 on t2.sa_orderid=t4.sa_orderid and t2.siteid=t4.siteid left join plm_item t5 on t1.itemid=t5.itemid and t1.siteid=t5.siteid where t3.status in('审核','复核','关闭') and  t1.siteid='CCYOSG' and  t1.sa_dispatch_itemsid in " + sa_dispatch_itemsids.toString().replace("[", "(").replace("]", ")"));
-                RowsMap distiptchRowsMap = distiptchRows.toRowsMap("sa_dispatch_itemsid");
-
-                Rows aftersalesmagRows = dbConnect.runSqlQuery("select t1.price,t1.sa_aftersalesmag_itemsid,t1.sa_orderitemsid,t2.sa_orderid from sa_aftersalesmag_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid  where  t1.siteid='CCYOSG' and  t1.sa_aftersalesmag_itemsid in " + sa_dispatch_itemsids.toString().replace("[", "(").replace("]", ")"));
-                RowsMap aftersalesmagRowsMap = aftersalesmagRows.toRowsMap("sa_aftersalesmag_itemsid");
-                BigDecimal amountTotal = BigDecimal.ZERO;
-                for (Object object : detailarray) {
-                    JSONObject jsonObject = (JSONObject) object;
-                    String frownum = jsonObject.getString("frownum");
-                    String fitemno = jsonObject.getString("fitemno");
-                    System.err.println(frownum + ":" + fitemno);
-                    BigDecimal fqty = new BigDecimal(jsonObject.getString("fqty"));
-                    fqty = fqty.compareTo(BigDecimal.ZERO) < 0 ? fqty.negate() : fqty;
-                    //String fdetailstockno = jsonObject.getString("fstockno");
-                    long sainvoicedetailid = jsonObject.getLong("sainvoicedetailid");
-                    //String fbatchno = jsonObject.getString("fbatchno");
-                    String fdetailnotes = jsonObject.getString("fnotes");
-                    SQLFactory sqlFactorydetail = new SQLFactory(this, "销售出库单明细新增");
-                    sqlFactorydetail.addParameter("siteid", "CCYOSG");
-                    sqlFactorydetail.addParameter("st_stockbill_itemsid", createTableID("st_stockbill_items"));
-                    sqlFactorydetail.addParameter("st_stockbillid", st_stockbillid);
-                    sqlFactorydetail.addParameter("rowno", frownum);
-                    sqlFactorydetail.addParameter("sa_dispatch_itemsid", sainvoicedetailid);
-                    sqlFactorydetail.addParameter("remarks", fnotes);
-                    if (itemRowsMap.containsKey(fitemno) && itemRowsMap.get(fitemno).isNotEmpty()) {
-                        sqlFactorydetail.addParameter("itemid", itemRowsMap.get(fitemno).get(0).getLong("itemid"));
-                    } else {
-                        sqlFactorydetail.addParameter("itemid", 0);
-                    }
-                    sqlFactorydetail.addParameter("remarks", fdetailnotes);
-                    sqlFactorydetail.addParameter("qty", fqty);
-
-                    if (frb.equals("蓝")) {
-                        if (distiptchRowsMap.containsKey(String.valueOf(sainvoicedetailid)) && distiptchRowsMap.get(sainvoicedetailid).isNotEmpty()) {
-                            sqlFactorydetail.addParameter("price", distiptchRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price"));
-                            amountTotal = amountTotal.add(fqty.multiply(distiptchRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-                            sqlFactorydetail.addParameter("amount", fqty.multiply(distiptchRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-                            sqlFactorydetail.addParameter("sa_orderitemsid", distiptchRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderitemsid"));
-                            sqlFactorydetail.addParameter("sa_orderid", distiptchRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderid"));
-                            System.out.println(amountTotal);
-//                            //您的订单【XXX】商品【XXX】工厂已发货,出库单号【XXX】
-//                            String message = "您的订单【" + distiptchRowsMap.get(sainvoicedetailid).get(0).getString("sonum") + "】商品【" + distiptchRowsMap.get(sainvoicedetailid).get(0).getString("itemname") + "】工厂已发货,出库单号【" + fbillnum + "】!";
-//                            sendMsg(message, st_stockbillid, distiptchRowsMap.get(sainvoicedetailid).get(0).getLong("sys_enterpriseid"));
-                        } else {
-                            sqlFactorydetail.addParameter("price", 0);
-                            sqlFactorydetail.addParameter("amount", 0);
-                            sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-                            sqlFactorydetail.addParameter("sa_orderid", 0);
-                        }
-
-//                        /**
-//                         * 更新发货单数量
-//                         */
-//                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)+" + fqty + " where siteid='CCYOSG' and sa_dispatch_itemsid=" + sainvoicedetailid);
-                    } else {
-                        if (aftersalesmagRowsMap.containsKey(String.valueOf(sainvoicedetailid)) && aftersalesmagRowsMap.get(sainvoicedetailid).isNotEmpty()) {
-                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).toJsonObject().toString());
-                            sqlFactorydetail.addParameter("price", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price"));
-                            sqlFactorydetail.addParameter("amount", fqty.multiply(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderitemsid"));
-                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderid"));
-                            sqlFactorydetail.addParameter("sa_orderitemsid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderitemsid"));
-                            sqlFactorydetail.addParameter("sa_orderid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderid"));
-                        } else {
-                            sqlFactorydetail.addParameter("price", 0);
-                            sqlFactorydetail.addParameter("amount", 0);
-                            sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-                            sqlFactorydetail.addParameter("sa_orderid", 0);
-                        }
-                    }
-
-                    sqlList.add(sqlFactorydetail.getSQL());
-                }
-//                if (frb.equals("蓝")) {
-//                    BigDecimal billamount = BigDecimal.ZERO;
-//                    //返利比例
-//                    String icstockbillrebateaccount = Parameter.get(siteid, "icstockbillrebateaccount"); //经销商销售出库单返利账户
-//                    String icstockbillrebaterate1 = Parameter.get(siteid, "icstockbillrebaterate"); //销售出库单返利比例
-//                    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 + "返利");
-//                        JSONObject cashbillIncome = Accountbalance.createCashbillIncome(this, sys_enterpriseid, Long.valueOf(icstockbillrebateaccount).longValue(), entity, true, false);
-//                        sqlList.addAll(cashbillIncome.getJSONArray("sqlList").toJavaList(String.class));
-//                        sa_cashbillid = cashbillIncome.getLong("sa_cashbillid");
-//                    }
-//
-//
-//                }
-
-                sqlList.add("update st_stockbill set status='审核',checkby='" + checkby + "',checkdate=CURRENT_TIMESTAMP where st_stockbillid = " + st_stockbillid + " and siteid='CCYOSG'");
-
-            } else if (!stockbillRows.isEmpty() && "审核".equals(fstatus)) {
-                /**
-                 * DRP存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需将当前销售出库单先反审核,修改内容后再进行审核
-                 */
-                //销售出库单反审核逻辑待添加
-//                if (frb.equals("蓝")) {
-//                    BigDecimal billamount = BigDecimal.ZERO;
-//                    Rows stockbilldetails = dbConnect.runSqlQuery("select * from st_stockbill_items where st_stockbillid ='"
-//                            + stockbillRows.get(0).getLong("st_stockbillid") + "' and  siteid='" + siteid + "'");
-//                    for (Row row : stockbilldetails) {
-//                        billamount = billamount.add(row.getBigDecimal("amount").abs().negate());
-//                    }
-//
-//                    //返利比例
-//                    String icstockbillrebateaccount = Parameter.get(siteid, "icstockbillrebateaccount"); //经销商销售出库单返利账户
-//                    String icstockbillrebaterate1 = Parameter.get(siteid, "icstockbillrebaterate"); //销售出库单返利比例
-//                    BigDecimal icstockbillrebaterate = new BigDecimal(icstockbillrebaterate1);
-//                    //经销商返利
-//                    BigDecimal rebateamount = icstockbillrebaterate.multiply(billamount);
-//
-//                    CashbillEntity entity = new CashbillEntity();
-//                    entity.setAmount(rebateamount);
-//                    entity.setOwnerid(stockbillRows.get(0).getLong("st_stockbillid"));
-//                    entity.setOwnertable("st_stockbill");
-//                    entity.setSource("");
-//                    entity.setRemarks("销售出库单" + fbillnum + "反返利");
-//                    JSONObject cashbillIncome = Accountbalance.createCashbillIncome(this, sys_enterpriseid, Long.valueOf(icstockbillrebateaccount).longValue(), entity, true, false);
-//                    sqlList.addAll(cashbillIncome.getJSONArray("sqlList").toJavaList(String.class));
-//                    sa_cashbillid = cashbillIncome.getLong("sa_cashbillid");
-//                    /**
-//                     * 更新发货单数量
-//                     */
-//                    Rows stockbilldetailrows = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and t1.siteid='CCYOSG' group by t1.sa_dispatch_itemsid");
-//                    for (Row row : stockbilldetailrows) {
-//                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-" + row.getBigDecimal("qty") + " where siteid='CCYOSG' and sa_dispatch_itemsid=" + row.getLong("sa_dispatch_itemsid"));
-//                        sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='CCYOSG' and sa_dispatchid=" + row.getLong("sa_dispatchid"));
-//                    }
-//                }
-
-                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='CCYOSG'");
-
-                msg = "DRP单据状态为审核,现已反审核,下次同步时进行审核操作";
-                code = 0;
-            } else if (!stockbillRows.isEmpty() && ("新建".equals(fstatus))) {
-                /**
-                 * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入销售出库单先反审核
-                 */
-                //销售出库单反审核逻辑待添加
-//                if (frb.equals("蓝")) {
-//                    BigDecimal billamount = BigDecimal.ZERO;
-//                    Rows stockbilldetails = dbConnect.runSqlQuery("select * from st_stockbill_items where st_stockbillid ='"
-//                            + stockbillRows.get(0).getLong("st_stockbillid") + "' and  siteid='" + siteid + "'");
-//                    for (Row row : stockbilldetails) {
-//                        billamount = billamount.add(row.getBigDecimal("amount").abs().negate());
-//                    }
-//
-//                    //返利比例
-//                    String icstockbillrebateaccount = Parameter.get(siteid, "icstockbillrebateaccount"); //经销商销售出库单返利账户
-//                    String icstockbillrebaterate1 = Parameter.get(siteid, "icstockbillrebaterate"); //销售出库单返利比例
-//                    BigDecimal icstockbillrebaterate = new BigDecimal(icstockbillrebaterate1);
-//                    //经销商返利
-//                    BigDecimal rebateamount = icstockbillrebaterate.multiply(billamount);
-//
-//                    CashbillEntity entity = new CashbillEntity();
-//                    entity.setAmount(rebateamount);
-//                    entity.setOwnerid(stockbillRows.get(0).getLong("st_stockbillid"));
-//                    entity.setOwnertable("st_stockbill");
-//                    entity.setSource("");
-//                    entity.setRemarks("销售出库单" + fbillnum + "反返利");
-//                    JSONObject cashbillIncome = Accountbalance.createCashbillIncome(this, sys_enterpriseid, Long.valueOf(icstockbillrebateaccount).longValue(), entity, true, false);
-//                    sqlList.addAll(cashbillIncome.getJSONArray("sqlList").toJavaList(String.class));
-//                    sa_cashbillid = cashbillIncome.getLong("sa_cashbillid");
-//                    /**
-//                     * 更新发货单数量
-//                     */
-//                    Rows stockbilldetailrows = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and t1.siteid='CCYOSG' group by t1.sa_dispatch_itemsid");
-//                    for (Row row : stockbilldetailrows) {
-//                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-" + row.getBigDecimal("qty") + " where siteid='CCYOSG' and sa_dispatch_itemsid=" + row.getLong("sa_dispatch_itemsid"));
-//                        sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='CCYOSG' and sa_dispatchid=" + row.getLong("sa_dispatchid"));
-//                    }
-//
-//
-//                }
-
-                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='CCYOSG'");
-
-            }
-
-            dbConnect.runSqlUpdate(sqlList);
-
-
-            if (stockbillRows.isEmpty() && "审核".equals(fstatus)) {
-                ArrayList<Long> userIdList = dbConnect.runSqlQuery("select userid from sys_enterprise_hr where siteid='" + siteid + "' and sys_enterpriseid=" + sys_enterpriseid).toArrayList("userid", new ArrayList<>());
-                Executor.sendEml(this, "stocck_check", st_stockbillid, siteid, userIdList);
-            }
-
-            Rows stockbillrows = dbConnect.runSqlQuery("select st_stockbillid,status,rb from st_stockbill where billno='" + fbillnum + "' and siteid='CCYOSG'");
-//            if (frb.equals("蓝")) {
-//                //查询可关闭的发货单
-//                Rows dispatchrows = dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='CCYOSG')) group by sa_dispatchid)t where t.sumqty=t.sumoutwarehouseqty");
-//                Rows undispatchrows = dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='CCYOSG')) group by sa_dispatchid)t where t.sumqty!=t.sumoutwarehouseqty");
-//                ArrayList<String> sqldispatch = new ArrayList<>();
-//                for (Row row : dispatchrows) {
-//                    sqldispatch.add("update sa_dispatch set status='关闭',closedate=current_time,closeby='admin' where sa_dispatchid='" + row.getLong("sa_dispatchid") + "' and siteid='CCYOSG'");
-//                    SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-//                    sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-//                    sqlFactory.addParameter("ownertable", "sa_dispatch");
-//                    sqlFactory.addParameter("ownerid", row.getLong("sa_dispatchid"));
-//                    sqlFactory.addParameter("action", "自动关闭");
-//                    sqlFactory.addParameter("remarks", "发货单自动关闭成功");
-//                    sqlFactory.addParameter("actionuserid", "1");
-//                    sqlFactory.addParameter("actionby", "admin");
-//                    sqlFactory.addParameter("siteid", "CCYOSG");
-//                    sqldispatch.add(sqlFactory.getSQL());
-//                }
-//                for (Row row : undispatchrows) {
-//                    sqldispatch.add("update sa_dispatch set status='复核',closedate=null,closeby='' where sa_dispatchid='" + row.getLong("sa_dispatchid") + "' and siteid='CCYOSG'");
-//                    sqldispatch.add("delete from sys_contrllog where ownertable='sa_dispatch' and action='自动关闭' and ownerid='" + row.getLong("sa_dispatchid") + "' and siteid='CCYOSG'");
-//                }
-//
-//                dbConnect.runSqlUpdate(sqldispatch);
-//
-//                //查询可关闭的订单
-//                //订单出库总数量
-//                Rows orderinstockrows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.siteid,sum(ifnull(t2.outwarehouseqty,0)) sumoutwarehouseqty from sa_orderitems t1 left join sa_dispatch_items t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where  t1.sa_orderid in(select t3.sa_orderid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t2.sa_orderitemsid=t3.sa_orderitemsid and t2.siteid=t3.siteid  where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='CCYOSG')   group by t1.sa_orderid,t1.siteid");
-//                //订单总数量
-//                Rows ordersumrows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.siteid,sum(qty) sumqty from sa_orderitems t1  where  t1.sa_orderid in(select t3.sa_orderid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t2.sa_orderitemsid=t3.sa_orderitemsid and t2.siteid=t3.siteid  where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='CCYOSG')   group by t1.sa_orderid,t1.siteid");
-//                RowsMap orderinstockRowsMap = orderinstockrows.toRowsMap("sa_orderid");
-//
-//
-//                ArrayList<String> sqlorder = new ArrayList<>();
-//                for (Row row : ordersumrows) {
-//                    if (orderinstockRowsMap.containsKey(row.getString("sa_orderid"))) {
-//                        if (orderinstockRowsMap.get(row.getString("sa_orderid")).get(0).getBigDecimal("sumoutwarehouseqty").compareTo(row.getBigDecimal("sumqty")) == 0) {
-//                            sqlorder.add("update sa_order set status='关闭',closedate=current_time,closeby='admin' where sa_orderid='" + row.getLong("sa_orderid") + "' and siteid='CCYOSG'");
-//                            SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-//                            sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-//                            sqlFactory.addParameter("ownertable", "sa_order");
-//                            sqlFactory.addParameter("ownerid", row.getLong("sa_orderid"));
-//                            sqlFactory.addParameter("action", "自动关闭");
-//                            sqlFactory.addParameter("remarks", "订单自动关闭成功");
-//                            sqlFactory.addParameter("actionuserid", "1");
-//                            sqlFactory.addParameter("actionby", "admin");
-//                            sqlFactory.addParameter("siteid", "CCYOSG");
-//                            sqlorder.add(sqlFactory.getSQL());
-//                        } else {
-//                            sqlorder.add("update sa_order set status='审核',closedate=null,closeby='' where sa_orderid='" + row.getLong("sa_orderid") + "' and siteid='CCYOSG'");
-//                            sqlorder.add("delete from sys_contrllog  where ownertable='sa_order' and action='自动关闭'  and  ownerid='" + row.getLong("sa_orderid") + "' and siteid='CCYOSG'");
-//                        }
-//                    } else {
-//                        sqlorder.add("update sa_order set status='审核',closedate=null,closeby='' where sa_orderid='" + row.getLong("sa_orderid") + "' and siteid='CCYOSG'");
-//                        sqlorder.add("delete from sys_contrllog  where ownertable='sa_order' and action='自动关闭'  and  ownerid='" + row.getLong("sa_orderid") + "' and siteid='CCYOSG'");
-//                    }
-//
-//                }
-//                dbConnect.runSqlUpdate(sqlorder);
-//
-//            }
-
-            /**
-             * 如单据为新建状态,则,先把单据强行删除掉
-             */
-            dbConnect.runSqlUpdate("delete from st_stockbill where status='新建'");
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            msg = e.getMessage();
-            if (msg == null) {
-                msg = "";
-            }
-            code = 0;
-            dbConnect.runSqlUpdate("delete from st_stockbill_items where  st_stockbillid in(select st_stockbillid from st_stockbill where siteid='CCYOSG' and billno='" + fbillnum + "')");
-            dbConnect.runSqlUpdate("delete from st_stockbill where  billno='" + fbillnum + "' and siteid='CCYOSG'");
-
-        }
-        JSONObject returnObject = new JSONObject();
-        returnObject.put("msg", msg);
-        returnObject.put("code", code);
-        return returnObject.toString();
-    }
-
-    public String getDate(String date) {
-        try {
-            Date a = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date);
-            return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(a);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public void sendMsg(String content, Long st_stockbillid, Long sys_enterpriseid) throws YosException {
-
-        ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid).toArrayList("userid", new ArrayList<>());
-        Remind remind = new Remind(this);
-        remind.setTitle("销售出库单消息");
-        remind.setContent(content);
-        remind.setType("应用");
-        remind.setObjectid(st_stockbillid);
-        remind.setObjectname("st_stockbill");
-        remind.setTouserid(userList);
-        remind.sendByDialogMsg().createSys_message();
-    }
-}

+ 0 - 80
src/custom/restcontroller/webmanage/lsak3/aftersalesmag/aftersalesmag.java

@@ -1,80 +0,0 @@
-package restcontroller.webmanage.lsak3.aftersalesmag;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import restcontroller.R;
-
-import java.util.ArrayList;
-
-public class aftersalesmag extends Controller {
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public aftersalesmag(JSONObject content) throws YosException {
-        super(content);
-    }
-    /**
-     * 获取DRP返退单
-     *
-     * @return
-     */
-    @API(title = "获取DRP返退单", apiversion = R.ID20230715093903.v1.class,accesstoken = false)
-    public String getAftersalesmag() throws YosException{
-        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sa_aftersalesmagid salereturnbillid,t1.billno fbillnum,t1.createby,ifnull(t1.billdate,CURRENT_DATE) fdate,t2.agentnum fagentnum,t1.reason fnotes from sa_aftersalesmag t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa'");
-        if(rows.isEmpty()) {
-            JSONArray array = new JSONArray();
-            return array.toString();
-        }else{
-            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_aftersalesmagid,t2.k3outcode fk3outcode,t1.sa_aftersalesmag_itemsid salereturnbilldeid,t2.itemno fitemno,t1.qty fqty,t1.price fprice,t1.reason fnotes,t4.billno fsaleissuebillno, t3.rowno fsaleissuebillentryid from sa_aftersalesmag_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join st_stockbill_items t3 on t1.st_stockbill_itemsid=t3.st_stockbill_itemsid and t1.siteid=t3.siteid left join st_stockbill t4 on t3.st_stockbillid=t4.st_stockbillid and t3.siteid=t4.siteid where t1.sa_aftersalesmagid in" + rows.toJsonArray("salereturnbillid").toJSONString().replace("[", "(").replace("]", ")")  + " and t1.siteid='lsa'");
-            RowsMap rowsMap =detailRows.toRowsMap("sa_aftersalesmagid");
-            for (Row row : rows) {
-                String salereturnbillid = row.getString("salereturnbillid");
-                if(rowsMap.containsKey(salereturnbillid)){
-                    row.put("salereturnbilldetil", rowsMap.get(salereturnbillid));
-                }else{
-                    row.put("salereturnbilldetil", new JSONArray());
-                }
-
-            }
-        }
-
-
-        return rows.toJsonArray().toString();
-    }
-
-    /**
-     * 获取DRP返退单返回成功消息
-     *
-     * @return
-     */
-    @API(title = "获取DRP返退单返回成功消息", apiversion = R.ID20230715094003.v1.class,accesstoken = false)
-    public String getAftersalesmagFeedBack() throws YosException{
-        JSONArray idsarray = content.getJSONArray("ids");
-        ArrayList<String> sqllist = new ArrayList<>();
-        for (Object object:idsarray) {
-            String id = (String) object;
-            sqllist.add("update sa_aftersalesmag set updatek3flag='1' where siteid='lsa' and  sa_aftersalesmagid=" + id);
-        }
-
-        int count =dbConnect.runSqlUpdate(sqllist);
-        JSONObject returnObject =new JSONObject();
-        if (count>0) {
-            returnObject.put("msg", "");
-            returnObject.put("code", 1);
-        } else {
-            returnObject.put("msg", "true");
-            returnObject.put("code", 0);
-        }
-        return returnObject.toString();
-
-    }
-
-}

+ 0 - 23
src/custom/restcontroller/webmanage/lsak3/agents/SQL/企业修改.sql

@@ -1,23 +0,0 @@
-update sys_enterprise
-set changeuserid=$changeuserid$,
-    changeby=$username$,
-    changedate=$changedate$,
-    enterprisename=$enterprisename$,
-    address=$address$,
-    contact=$contact$,
-    phonenumber=$phonenumber$,
-    taxno=$taxno$,
-    province=$province$,
-    city=$city$,
-    county=$county$,
-    limitreturnday=$limitreturnday$,
-    freefreightamount=$freefreightamount$,
-    latitude = $latitude$,
-    longitude = $longitude$,
-    invoicingpoint=$invoicingpoint$,
-    saleclassauth=$saleclassauth$,
-    abbreviation=$abbreviation$,
-    grade = $grade$,
-    isorder=$isorder$
-where siteid = $siteid$
-  and sys_enterpriseid = $sys_enterpriseid$

+ 0 - 28
src/custom/restcontroller/webmanage/lsak3/agents/SQL/企业新增.sql

@@ -1,28 +0,0 @@
-insert into sys_enterprise(siteid, sys_enterpriseid, createby, createdate, createuserid, authuserid, changeuserid,
-                           changeby, changedate, city, county, address, phonenumber, province, contact, enterprisename,
-                           taxno,limitreturnday,freefreightamount,latitude,longitude,invoicingpoint,saleclassauth,grade,isorder)
-select $siteid$,
-       $sys_enterpriseid$,
-       $username$,
-       $createdate$,
-       $changeuserid$,
-       $changeuserid$,
-       $changeuserid$,
-       $username$,
-       $createdate$,
-       $city$,
-       $county$,
-       $address$,
-       $phonenumber$,
-       $province$,
-       $contact$,
-       $enterprisename$,
-       $taxno$,
-       $limitreturnday$,
-       $freefreightamount$,
-       $latitude$,
-       $longitude$,
-       $invoicingpoint$,
-       $saleclassauth$,
-       $grade$,
-       $isorder$

+ 0 - 15
src/custom/restcontroller/webmanage/lsak3/agents/SQL/经销商修改.sql

@@ -1,15 +0,0 @@
-update sa_agents
-set changeuserid=$changeuserid$,
-    changeby=$username$,
-    changedate=now(),
-    parentid=$parentid$,
-    signdate=$signdate$,
-    type=$type$,
-    isservice = $isservice$,
-    priceadjustment=$priceadjustment$,
-    status=$status$,
-    remarks=$remarks$,
-    description=$description$,
-    k3outcode=$k3outcode$
-where siteid = $siteid$
-  and sa_agentsid = $sa_agentsid$

+ 0 - 21
src/custom/restcontroller/webmanage/lsak3/agents/SQL/经销商新增.sql

@@ -1,21 +0,0 @@
-insert into sa_agents(siteid, sa_agentsid, sys_enterpriseid, createby, createdate, changeuserid,
-                      changeby, changedate, agentnum, type, parentid,
-                      signdate, status, isservice,priceadjustment,remarks,description,k3outcode)
-select $siteid$,
-       $sa_agentsid$,
-       $sys_enterpriseid$,
-       $createby$,
-       $createdate$,
-       $changeuserid$,
-       $changeby$,
-       $changedate$,
-       $agentnum$,
-       $type$,
-       $parentid$,
-       $signdate$,
-       $status$,
-       $isservice$,
-       $priceadjustment$,
-       $remarks$,
-       $description$,
-       $k3outcode$

+ 0 - 23
src/custom/restcontroller/webmanage/lsak3/agents/SQL/联系人信息新增.sql

@@ -1,23 +0,0 @@
-insert into sys_enterprise_contacts(siteid, contactsid, sys_enterpriseid, name, sex, depname,position,
-                      isleader, birthday, phonenumber, email, province,city,county,remarks,address,workaddress,
-                      changeuserid,createuserid,isdefault)
-select $siteid$,
-       $contactsid$,
-       $sys_enterpriseid$,
-       $name$,
-       $sex$,
-       $depname$,
-       $position$,
-       $isleader$,
-       $birthday$,
-       $phonenumber$,
-       $email$,
-       $province$,
-       $city$,
-       $county$,
-       $remarks$,
-       $address$,
-       $workaddress$,
-       $userid$,
-       $userid$,
-       $isdefault$

+ 0 - 230
src/custom/restcontroller/webmanage/lsak3/agents/agents.java

@@ -1,230 +0,0 @@
-package restcontroller.webmanage.lsak3.agents;
-
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.Rows;
-import common.data.SQLFactory;
-import org.apache.commons.lang.StringUtils;
-import restcontroller.R;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-
-public class agents extends Controller {
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public agents(JSONObject content) throws YosException {
-        super(content);
-    }
-    /**
-     * 更新YOS经销商档案
-     *
-     * @return
-     */
-    @API(title = "更新YOS经销商档案", apiversion = R.ID20230715095103.v1.class,accesstoken = false)
-    public String updateAgent() throws  YosException {
-        String msg = "";
-        int code = 1;
-        ArrayList<String> sqllist = new ArrayList<>();
-        try {
-            // k3内码
-            String fagentid = content.getString("fagentid");
-            // 经销商编号
-            String fagentnum = content.getString("fagentnum");
-            // k3外码
-            String foutagentnum = content.getString("foutagentnum");
-            // 是否删除
-            String isdelete = content.getString("isdelete");
-            // 经销商名称
-            String fagentname = content.getString("fagentname");
-            // 简称
-            String fagentshortname = content.getString("fagentshortname");
-            // 法人
-            String fictitiousperson = content.getString("fictitiousperson");
-            // 传真
-            String fax = content.getString("fax");
-            // 手机号
-            String fmobilephone = content.getString("fmobilephone");
-            // 行政区类别
-            String fgrade = content.getString("fgrade");
-            // 省
-            String fprovince = content.getString("fprovince");
-            // 市
-            String fcity = content.getString("fcity");
-            // 县
-            String fcounty = content.getString("fcounty");
-
-            // 收货人
-            String fcontact = content.getString("fcontact");
-            //收货人电话
-            String fconphonenumber = content.getString("fconphonenumber");
-            // 收货地址
-            String faddress = content.getString("faddress");
-            // 是否启用
-            String fisused = content.getString("fisused");
-            // 启用时间
-            String fuseddate = content.getStringValue("fuseddate");
-
-            // 创建人
-            String createby = content.getString("createby");
-            // 创建日期
-            String createdate = content.getString("createdate");
-
-            // 修改人
-            String changeby = content.getString("changeby");
-            // 修改日期
-            String changedate = content.getStringValue("changedate");
-
-
-            Rows agentsRows = dbConnect.runSqlQuery("select * from sa_agents where siteid='lsa' and agentnum ='"+fagentnum+"'");
-            SQLFactory sqlFactory;
-            if(agentsRows.isEmpty()){
-                SQLFactory sqlFactory1 = new SQLFactory(this, "企业新增");
-                 long sys_enterpriseid=createTableID("sys_enterprise");
-                sqlFactory1.addParameter("sys_enterpriseid",sys_enterpriseid);
-                sqlFactory1.addParameter("siteid","lsa");
-                sqlFactory1.addParameter("enterprisename",fagentname);
-                sqlFactory1.addParameter("abbreviation",fagentshortname);
-                sqlFactory1.addParameter("username", createby);
-                sqlFactory1.addParameter("createdate", getDate(createdate));
-                sqlFactory1.addParameter("changeuserid", 1);
-                sqlFactory1.addParameter("address", faddress);
-                sqlFactory1.addParameter("contact", fictitiousperson);
-                sqlFactory1.addParameter("phonenumber", fmobilephone);
-                sqlFactory1.addParameter("province", fprovince);
-                sqlFactory1.addParameter("city",fcity);
-                sqlFactory1.addParameter("county", fcounty);
-                sqlFactory1.addParameter("taxno", "");
-                sqlFactory1.addParameter("limitreturnday", 15);
-                sqlFactory1.addParameter("freefreightamount",0);
-                sqlFactory1.addParameter("latitude", "");
-                sqlFactory1.addParameter("longitude", "");
-
-                sqlFactory1.addParameter("isorder", 1);
-                //开票节点(1:订单审核:2:发货)
-                sqlFactory1.addParameter("invoicingpoint", 2);
-                //是否需要经营授权,默认1
-                sqlFactory1.addParameter("saleclassauth", 1);
-                sqlFactory1.addParameter("grade", 1);
-                sqllist.add(sqlFactory1.getSQL());
-
-
-                SQLFactory sqlFactory2 = new SQLFactory(this, "联系人信息新增");
-                long contactsid =createTableID("sys_enterprise_contacts");
-                sqlFactory2.addParameter("siteid", "lsa");
-                sqlFactory2.addParameter("contactsid", contactsid);
-                sqlFactory2.addParameter("sys_enterpriseid", sys_enterpriseid);
-                sqlFactory2.addParameter("name", fcontact);
-                sqlFactory2.addParameter("sex", "");
-                sqlFactory2.addParameter("depname", "");
-                sqlFactory2.addParameter("position", "");
-                sqlFactory2.addParameter("isleader", 1);
-                sqlFactory2.addParameter("birthday",  "null");
-                sqlFactory2.addParameter("phonenumber", fconphonenumber);
-                sqlFactory2.addParameter("email", "");
-                sqlFactory2.addParameter("province", fprovince);
-                sqlFactory2.addParameter("city", fcity);
-                sqlFactory2.addParameter("county", fcounty);
-                sqlFactory2.addParameter("remarks", "");
-                sqlFactory2.addParameter("address", faddress);
-                sqlFactory2.addParameter("workaddress", 1);
-                sqlFactory2.addParameter("userid", 1);
-                sqlFactory2.addParameter("isdefault", 1);
-                sqllist.add("update sys_enterprise_contacts set isdefault=0 where contactsid !=" + contactsid + " and sys_enterpriseid=" + sys_enterpriseid);
-                sqllist.add(sqlFactory2.getSQL());
-
-
-                sqlFactory = new SQLFactory(this, "经销商新增");
-                sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                sqlFactory.addParameter("sa_agentsid", createTableID("sa_agents"));
-            }else {
-                SQLFactory sqlFactory1 = new SQLFactory(this, "企业修改");
-                sqlFactory1.addParameter("sys_enterpriseid",agentsRows.get(0).getLong("sys_enterpriseid"));
-                sqlFactory1.addParameter("siteid","lsa");
-                sqlFactory1.addParameter("enterprisename",fagentname);
-                sqlFactory1.addParameter("abbreviation",fagentshortname);
-                sqlFactory1.addParameter("username", changeby);
-                sqlFactory1.addParameter("changedate", getDate(changedate));
-                sqlFactory1.addParameter("changeuserid", 1);
-                sqlFactory1.addParameter("address", faddress);
-                sqlFactory1.addParameter("contact", fictitiousperson);
-                sqlFactory1.addParameter("phonenumber", fmobilephone);
-                sqlFactory1.addParameter("province", fprovince);
-                sqlFactory1.addParameter("city",fcity);
-                sqlFactory1.addParameter("county", fcounty);
-                sqlFactory1.addParameter("taxno", "");
-                sqlFactory1.addParameter("limitreturnday", 15);
-                sqlFactory1.addParameter("freefreightamount",0);
-                sqlFactory1.addParameter("latitude", "");
-                sqlFactory1.addParameter("longitude", "");
-
-                sqlFactory1.addParameter("isorder", 1);
-                //开票节点(1:订单审核:2:发货)
-                sqlFactory1.addParameter("invoicingpoint", 2);
-                //是否需要经营授权,默认1
-                sqlFactory1.addParameter("saleclassauth",1);
-                sqlFactory1.addParameter("grade", 1);
-                sqllist.add(sqlFactory1.getSQL());
-
-                sqlFactory = new SQLFactory(this, "经销商修改");
-                sqlFactory.addParameter("sys_enterpriseid", agentsRows.get(0).getLong("sys_enterpriseid"));
-                sqlFactory.addParameter("sa_agentsid",agentsRows.get(0).getLong("sa_agentsid"));
-            }
-            sqlFactory.addParameter("siteid","lsa");
-            sqlFactory.addParameter("agentnum",fagentnum);
-            sqlFactory.addParameter("createby",createby);
-            sqlFactory.addParameter("username",changeby);
-
-            sqlFactory.addParameter("createdate",getDate(createdate));
-            sqlFactory.addParameter("changeby",changeby);
-            sqlFactory.addParameter("changedate",getDate(changedate));
-            sqlFactory.addParameter("changeuserid", 1);
-            sqlFactory.addParameter("type", "普通经销商");
-            sqlFactory.addParameter("k3outcode", foutagentnum);
-            sqlFactory.addParameter("parentid",0);
-            sqlFactory.addParameter("signdate", StringUtils.isBlank(fuseddate)?"null":getDate(fuseddate));
-            sqlFactory.addParameter("isservice", 0);
-            sqlFactory.addParameter("priceadjustment",0);
-            if(fisused.equals("0")){
-                sqlFactory.addParameter("status","禁用");
-            }else {
-                sqlFactory.addParameter("status","启用");
-            }
-            if ("1".equals(isdelete)) {
-                sqlFactory.addParameter("remarks", "K3已删除");
-                sqlFactory.addParameter("status","禁用");
-            } else {
-                sqlFactory.addParameter("remarks", "");
-            }
-            sqlFactory.addParameter("description", "K3");
-
-            sqllist.add(sqlFactory.getSQL());
-        } catch (Exception e) {
-            e.printStackTrace();
-            msg = e.getMessage();
-            code = 0;
-        }
-        dbConnect.runSqlUpdate(sqllist);
-        JSONObject returnObject =new JSONObject();
-        returnObject.put("msg", msg);
-        returnObject.put("code", code);
-        return returnObject.toString();
-    }
-
-
-    public String getDate(String date) {
-        try {
-            Date a = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date);
-            return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(a);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-}

+ 0 - 1
src/custom/restcontroller/webmanage/lsak3/cashbill/SQL/收支凭证反审核.sql

@@ -1 +0,0 @@
-update sa_cashbill set status='新建',checkby='',checkdate=null,balance=$balance$,updatek3flag=$updatek3flag$ where sa_cashbillid = $sa_cashbillid$ and siteid=$siteid$

+ 0 - 4
src/custom/restcontroller/webmanage/lsak3/cashbill/SQL/收支凭证新增.sql

@@ -1,4 +0,0 @@
-insert into sa_cashbill (siteid, sa_cashbillid, createuserid,createby, createdate, billno,billdate,changeuserid,changeby, changedate,checkby,checkdate,
-                                sys_enterpriseid, sa_accountclassid,type,remarks,amount,status,source,sourcenote,ownertable,ownerid,balance,sa_cashbillid_rebate,class,subclass,period,updatek3flag,description)
-values ($siteid$, $sa_cashbillid$,$userid$,$createby$, $createdate$, $billno$,$billdate$,$userid$, $changeby$, $changedate$,$checkby$,$checkdate$,$sys_enterpriseid$,$sa_accountclassid$,$type$,$remarks$,
-        $amount$,$status$,$source$,$sourcenote$,$ownertable$,$ownerid$,$balance$,$sa_cashbillid_rebate$,$class$,$subclass$,current_date,$updatek3flag$,$description$);

+ 0 - 11
src/custom/restcontroller/webmanage/lsak3/cashbill/SQL/营销账户余额新增.sql

@@ -1,11 +0,0 @@
-insert into sa_accountbalance (siteid, sa_accountbalanceid, sys_enterpriseid, sa_accountclassid, balance, creditquota,
-                               changeuserid, changeby, changedate)
-select $siteid$,
-       $sa_accountbalanceid$,
-       $sys_enterpriseid$,
-       $sa_accountclassid$,
-       $balance$,
-       0,
-       $userid$,
-       $username$,
-       CURRENT_TIME where not exists(select *from sa_accountbalance where siteid=$siteid$ and sys_enterpriseid=$sys_enterpriseid$ and sa_accountclassid=$sa_accountclassid$)

+ 0 - 385
src/custom/restcontroller/webmanage/lsak3/cashbill/cashbill.java

@@ -1,385 +0,0 @@
-package restcontroller.webmanage.lsak3.cashbill;
-
-import beans.accountbalance.Accountbalance;
-import beans.datacontrllog.DataContrlLog;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.sun.org.apache.bcel.internal.generic.NEW;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.annotation.CACHEING;
-import common.data.Row;
-import common.data.Rows;
-import common.data.SQLFactory;
-import restcontroller.R;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-
-public class cashbill extends Controller {
-
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public cashbill(JSONObject content) throws YosException {
-        super(content);
-    }
-
-    @API(title = "k3新增更新收入凭证", apiversion = R.ID20230714164803.v1.class,accesstoken = false)
-    public String updatecashbill() throws YosException {
-
-        String msg = "";
-        int code = 1;
-
-        ArrayList<String> sqlList = new ArrayList<>();
-        // 单据编号
-        String billno = content.getString("fbillnum");
-
-        try {
-            // 单据日期
-            String billdate = content.getString("fdate");
-            // 金额
-            BigDecimal amount =content.getBigDecimal("famount");
-            // 经销商编号
-            String agentnum = content.getString("fagentnum");
-            long sys_enterpriseid=0;
-            if(dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='"+agentnum+"'").isNotEmpty()){
-                sys_enterpriseid=dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='"+agentnum+"'").get(0).getLong("sys_enterpriseid");
-            }else{
-                msg ="yos中不存在【"+agentnum+"】经销商";
-                return  getErrReturnObject().setErrMsg(msg).toString();
-            }
-            // 单据类型
-            String type = content.getString("ftype");
-            // 单据类型明细
-            String typemx = content.getString("ftypemx");
-            // 账户编号
-            long sa_accountclassid=0;
-            String faccclsnum = content.getString("faccclsnum");
-            if(dbConnect.runSqlQuery("select sa_accountclassid from sa_accountclass where siteid='lsa' and  accountno='"+faccclsnum+"'").isNotEmpty()){
-                sa_accountclassid=dbConnect.runSqlQuery("select sa_accountclassid from sa_accountclass where siteid='lsa' and  accountno='"+faccclsnum+"'").get(0).getLong("sa_accountclassid");
-            }else{
-                msg ="yos中不存在【"+faccclsnum+"】的账户";
-                return  getErrReturnObject().setErrMsg(msg).toString();
-            }
-
-            // 单据状态
-            String status = content.getString("fstatus");
-            // 制单人
-            String createby = content.getString("createby");
-            // 制单日期
-            String createdate = content.getString("createdate");
-            // 审核人
-            String checkby = content.getString("checkby");
-            // 审核日期
-            String checkdate = content.getString("checkdate");
-            // 备注
-            String remarks = content.getString("fnotes");
-
-            // 是否删除
-            String isdelete = content.getString("isdelete");
-
-            if (type.equals("收入")) {
-                Rows cashbillRows= dbConnect.runSqlQuery("select * from sa_cashbill where billno='"+billno+"' and type=1 and status='审核' and description='K3'");
-
-                if (cashbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(status)) {
-                    /**
-                     * DRP不存在收入凭证,且中间表状态为审核且不在删除状态时,DRP中需新增该收入凭证
-                     */
-                    long sa_cashbillid =createTableID("sa_cashbill");
-                    SQLFactory sqlFactory = new SQLFactory(this, "收支凭证新增");
-                    sqlFactory.addParameter("billno", billno);
-                    sqlFactory.addParameter("billdate", getDate(billdate));
-                    sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                    sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
-                    sqlFactory.addParameter("type", 1);
-                    sqlFactory.addParameter("siteid", "lsa");
-                    sqlFactory.addParameter("remarks", "k3费用"+remarks);
-                    sqlFactory.addParameter("amount", amount);
-                    sqlFactory.addParameter("subclass", typemx);
-                    sqlFactory.addParameter("class", typemx);
-                    sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
-                    sqlFactory.addParameter("createby", createby);
-                    sqlFactory.addParameter("createdate", getDate(createdate));
-                    sqlFactory.addParameter("changeby", createby);
-                    sqlFactory.addParameter("changedate", getDate(createdate));
-                    sqlFactory.addParameter("ownertable", "");
-                    sqlFactory.addParameter("ownerid", 0);
-                    sqlFactory.addParameter("source", "");
-                    sqlFactory.addParameter("sourcenote", "");
-                    sqlFactory.addParameter("period", "");
-                    sqlFactory.addParameter("checkby",checkby);
-                    sqlFactory.addParameter("checkdate", getDate(checkdate));
-                    sqlFactory.addParameter("status", "审核");
-                    sqlFactory.addParameter("sa_cashbillid_rebate", "null");
-                    sqlFactory.addParameter("userid", 1);
-                    sqlFactory.addParameter("description", "k3");
-
-
-
-                    // 审核逻辑判断
-                    BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
-                    Rows rowsaccountbalance = dbConnect.runSqlQuery(
-                            "select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='"
-                                    + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-
-                    if (rowsaccountbalance.isEmpty()) {
-                        SQLFactory accountbalanceaddSqlFactory = new SQLFactory(new Accountbalance(), "营销账户余额新增");
-                        accountbalanceaddSqlFactory.addParameter("sa_accountbalanceid", createTableID("sa_accountbalance"));
-                        accountbalanceaddSqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                        accountbalanceaddSqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
-                        accountbalanceaddSqlFactory.addParameter("siteid", "lsa");
-                        accountbalanceaddSqlFactory.addParameter("balance", amount);
-                        accountbalanceaddSqlFactory.addParameter("userid", 1);
-                        accountbalanceaddSqlFactory.addParameter("username", "admin");
-                        balance = amount;
-                        sqlList.add(accountbalanceaddSqlFactory.getSQL());
-                    } else {
-                        BigDecimal newbalance = amount.add(rowsaccountbalance.get(0).getBigDecimal("balance"));
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance
-                                + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid
-                                + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        balance = newbalance;
-                    }
-                    sqlFactory.addParameter("balance", balance);
-                    sqlFactory.addParameter("updatek3flag", "");
-                    sqlList.add(sqlFactory.getSQL());
-
-                } else if (!cashbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(status)) {
-                    /**
-                     * DRP存在收入凭证,且中间表状态为审核且不在删除状态时,DRP中需将当前收入凭证先反审核,修改内容后再进行审核
-                     */
-                    long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
-
-                    BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
-                    if (!rows.isEmpty()) {
-                         sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
-                         sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
-                        balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "收入凭证反审核成功").getSQL());
-                    }
-
-                    SQLFactory sqlFactoryupdate = new SQLFactory(this, "收支凭证反审核");
-                    sqlFactoryupdate.addParameter("siteid", "lsa");
-                    sqlFactoryupdate.addParameter("sa_cashbillid", sa_cashbillid);
-                    sqlFactoryupdate.addParameter("balance", balance);
-                    sqlFactoryupdate.addParameter("updatek3flag", 2);
-                    sqlList.add(sqlFactoryupdate.getSQL());
-
-                    msg = "DRP单据状态为审核,现已反审核,下次同步时进行审核操作";
-                    code = 0;
-
-                }
-                else if (!cashbillRows.isEmpty() && ("1".equals(isdelete) || "新建".equals(status))) {
-                    /**
-                     * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入凭证先反审核
-                     */
-                    long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
-
-                    BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
-                    if (!rows.isEmpty()) {
-                        sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
-                        sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
-                        balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "收入凭证反审核成功").getSQL());
-                    }
-
-                    SQLFactory sqlFactoryupdate = new SQLFactory(this, "收支凭证反审核");
-                    sqlFactoryupdate.addParameter("siteid", "lsa");
-                    sqlFactoryupdate.addParameter("sa_cashbillid", sa_cashbillid);
-                    sqlFactoryupdate.addParameter("balance", balance);
-                    sqlFactoryupdate.addParameter("updatek3flag", 2);
-                    sqlList.add(sqlFactoryupdate.getSQL());
-
-                }
-            } else if (type.equals("支出")) {
-                Rows cashbillRows= dbConnect.runSqlQuery("select * from sa_cashbill where billno='"+billno+"' and type=0 and status='审核' and description='K3'");
-
-                if (cashbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(status)) {
-                    /**
-                     * DRP不存在收入凭证,且中间表状态为审核且不在删除状态时,DRP中需新增该支出凭证
-                     */
-                    long sa_cashbillid =createTableID("sa_cashbill");
-                    SQLFactory sqlFactory = new SQLFactory(this, "收支凭证新增");
-                    sqlFactory.addParameter("billno", billno);
-                    sqlFactory.addParameter("billdate", getDate(billdate));
-                    sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                    sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
-                    sqlFactory.addParameter("type", 0);
-                    sqlFactory.addParameter("siteid", "lsa");
-                    sqlFactory.addParameter("remarks", "k3费用"+remarks);
-                    sqlFactory.addParameter("amount", amount);
-                    sqlFactory.addParameter("subclass", typemx);
-                    sqlFactory.addParameter("class", typemx);
-                    sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
-                    sqlFactory.addParameter("createby", createby);
-                    sqlFactory.addParameter("createdate", getDate(createdate));
-                    sqlFactory.addParameter("changeby", createby);
-                    sqlFactory.addParameter("changedate", getDate(createdate));
-                    sqlFactory.addParameter("ownertable", "");
-                    sqlFactory.addParameter("ownerid", 0);
-                    sqlFactory.addParameter("source", "");
-                    sqlFactory.addParameter("sourcenote", "");
-                    sqlFactory.addParameter("period", "");
-                    sqlFactory.addParameter("checkby",checkby);
-                    sqlFactory.addParameter("checkdate", getDate(checkdate));
-                    sqlFactory.addParameter("status", "审核");
-                    sqlFactory.addParameter("sa_cashbillid_rebate", "null");
-                    sqlFactory.addParameter("userid", 1);
-                    sqlFactory.addParameter("description", "k3");
-
-                    // 审核逻辑判断
-                    BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
-                    Rows rowsaccountbalance = dbConnect.runSqlQuery(
-                            "select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='"
-                                    + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                    if(rowsaccountbalance.isEmpty()){
-                        JSONObject returnObject=new JSONObject();
-                        returnObject.put("msg", "账户不存在,支出凭证无法审核");
-                        returnObject.put("code", 0);
-                        return returnObject.toString();
-                    }
-                    BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(amount);
-                    sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                    balance = newbalance;
-                    sqlFactory.addParameter("balance", balance);
-                    sqlFactory.addParameter("updatek3flag", "");
-                    sqlList.add(sqlFactory.getSQL());
-                } else if (!cashbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(status)) {
-                     System.out.println("5555555555555555");
-                    /**
-                     * DRP存在收入凭证,且中间表状态为审核且不在删除状态时,DRP中需将当前收入凭证先反审核,修改内容后再进行审核
-                     */
-                    long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
-
-                    BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
-                    if (!rows.isEmpty()) {
-                        sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
-                        sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").add(rows.get(0).getBigDecimal("amount"));
-                        balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "支出凭证反审核成功").getSQL());
-                    }
-
-                    SQLFactory sqlFactoryupdate = new SQLFactory(this, "收支凭证反审核");
-                    sqlFactoryupdate.addParameter("siteid", "lsa");
-                    sqlFactoryupdate.addParameter("sa_cashbillid", sa_cashbillid);
-                    sqlFactoryupdate.addParameter("balance", balance);
-                    sqlFactoryupdate.addParameter("updatek3flag", 2);
-                    sqlList.add(sqlFactoryupdate.getSQL());
-
-                    msg = "DRP单据状态为审核,现已反审核,下次同步时进行审核操作";
-                    code = 0;
-
-                } else if (!cashbillRows.isEmpty() && ("1".equals(isdelete) || "新建".equals(status))) {
-                    /**
-                     * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入凭证先反审核
-                     */
-                    long sa_cashbillid= cashbillRows.get(0).getLong("sa_cashbillid");
-                    Rows rows = dbConnect.runSqlQuery("select sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and  siteid='lsa'");
-
-                    BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
-                    if (!rows.isEmpty()) {
-                        sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
-                        sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
-                        Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").add(rows.get(0).getBigDecimal("amount"));
-                        balance = newbalance;
-                        sqlList.add("update sa_accountbalance set balance='" + newbalance + "',changedate=CURRENT_TIME,changeby ='" + checkby + "',changeuserid='1' where sys_enterpriseid ='" + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='lsa'");
-                        sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "支出凭证反审核成功").getSQL());
-                    }
-
-                    SQLFactory sqlFactoryupdate = new SQLFactory(this, "收支凭证反审核");
-                    sqlFactoryupdate.addParameter("siteid", "lsa");
-                    sqlFactoryupdate.addParameter("sa_cashbillid", sa_cashbillid);
-                    sqlFactoryupdate.addParameter("balance", balance);
-                    sqlFactoryupdate.addParameter("updatek3flag", 2);
-                    sqlList.add(sqlFactoryupdate.getSQL());
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            msg = e.getMessage();
-            code = 0;
-        }
-        /**
-         * 把所有新建状态的单据删除
-         */
-         dbConnect.runSqlUpdate(sqlList);
-         dbConnect.runSqlUpdate("delete from sa_cashbill where status='新建'and description='K3'");
-         JSONObject returnObject=new JSONObject();
-        returnObject.put("msg", msg);
-        returnObject.put("code", code);
-        return returnObject.toString();
-    }
-
-    /**
-     * 获取DRP收入凭证
-     *
-     * @return
-     */
-    @API(title = "k3获取收入凭证", apiversion = R.ID20230714164903.v1.class,accesstoken = false)
-    public String getcashbill() throws YosException{
-
-        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.billno fbillnum,t1.sa_cashbillid ficashbillid,t1.createby,ifnull(t1.period,CURRENT_DATE) fdate,t3.accountno faccclsnum,t2.agentnum fagentnum,t1.amount famount,t1.remarks fnotes,t1.updatek3flag fupdatek3flag from sa_cashbill t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t2.siteid=t2.siteid left join sa_accountclass t3 on t1.sa_accountclassid=t3.sa_accountclassid and t1.siteid=t3.siteid where t3.accountno!='03' and (updatek3flag='0' or updatek3flag='2') and t1.type=1 and ifnull(t1.amount,0)!=0  and t1.status='审核' and ifnull(t1.description,'')!='K3' and t1.siteid='lsa' and t1.createby !='LSA总0001'");
-        if (rows.isEmpty()) {
-            JSONArray array = new JSONArray();
-            return array.toString();
-        }
-        return rows.toJsonArray().toString();
-    }
-
-    /**
-     * 获取DRP收入凭证返回成功消息
-     *
-     * @return
-     */
-    @API(title = "k3获取DRP收入凭证返回成功消息", apiversion = R.ID20230714165003.v1.class,accesstoken = false)
-    public String getcashbillFeedBack() throws YosException{
-        JSONArray idsarray = content.getJSONArray("ids");
-        ArrayList<String> sqllist = new ArrayList<>();
-        for (Object object:idsarray) {
-            String id = (String) object;
-            sqllist.add("update sa_cashbill set updatek3flag='1' where sa_cashbillid=" + id);
-        }
-
-
-        int count =dbConnect.runSqlUpdate(sqllist);
-        JSONObject returnObject =new JSONObject();
-        if (count>0) {
-            returnObject.put("msg", "");
-            returnObject.put("code", 1);
-        } else {
-            returnObject.put("msg", "true");
-            returnObject.put("code", 0);
-        }
-        return returnObject.toString();
-    }
-
-    public String getDate(String date) {
-        try {
-            Date a = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date);
-            return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(a);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-}

+ 0 - 77
src/custom/restcontroller/webmanage/lsak3/dispatch/dispatch.java

@@ -1,77 +0,0 @@
-package restcontroller.webmanage.lsak3.dispatch;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.Rows;
-import common.data.Row;
-import common.data.RowsMap;
-import restcontroller.R;
-
-import java.util.ArrayList;
-
-public class dispatch extends Controller {
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public dispatch(JSONObject content) throws YosException {
-        super(content);
-    }
-    /**
-     * 获取DRP发货单
-     *
-     * @return
-     */
-    @API(title = "获取DRP发货单", apiversion = R.ID20230715091603.v1.class,accesstoken = false)
-    public String getDispatch() throws YosException{
-        Rows rows = dbConnect.runSqlQuery("select t3.sonum fsonum,t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.billno finvonum,t1.sa_dispatchid sainvoiceid,t1.createby,t1.trantype ftrantype,ifnull(t1.billdate,CURRENT_DATE) fdate,t2.agentnum fagentnum,t1.remarks fnotes from sa_dispatch t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sa_order t3 on  t3.sa_orderid=t1.sa_orderid and t3.siteid=t1.siteid  where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001'  and t1.siteid='lsa'");
-        if(rows.isEmpty()) {
-            JSONArray array = new JSONArray();
-            return array.toString();
-        }else{
-            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_dispatchid ,t1.sa_dispatch_itemsid sainvoicedetailid,t2.itemno fitemno,t2.k3outcode fk3outcode,t1.qty fqty,t3.price fprice,t1.remarks fnotes,t3.spec customproperties,t2.spec flong,t4.sa_accountclassinfos from sa_dispatch_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t1.sa_orderitemsid=t3.sa_orderitemsid and t1.siteid=t3.siteid left join (SELECT  sa_orderid,t1.siteid,if(ifnull(replace(replace(replace(JSON_EXTRACT (t1.sa_accountclassinfos, '$**.accountname' ),'[',''),']',''),'\"',''),'')='',t2.accountname,replace(replace(replace(JSON_EXTRACT (t1.sa_accountclassinfos, '$**.accountname' ),'[',''),']',''),'\"','')) as sa_accountclassinfos FROM sa_order t1 left join sa_accountclass t2  on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid) t4 on t3.sa_orderid=t4.sa_orderid and t3.siteid=t4.siteid where t1.sa_dispatchid in" + rows.toJsonArray("sainvoiceid").toJSONString().replace("[", "(").replace("]", ")") + "  and t1.siteid='lsa'");
-            RowsMap rowsMap =detailRows.toRowsMap("sa_dispatchid");
-            for (Row row : rows) {
-                String sainvoiceid = row.getString("sainvoiceid");
-                if(rowsMap.containsKey(sainvoiceid)){
-                    row.put("sainvoicedetail", rowsMap.get(sainvoiceid));
-                }
-
-            }
-        }
-
-
-        return rows.toJsonArray().toString();
-    }
-
-    /**
-     * 获取DRP发货单返回成功消息
-     *
-     * @return
-     */
-    @API(title = "获取DRP发货单返回成功消息", apiversion = R.ID20230715091703.v1.class,accesstoken = false)
-    public String getDispatchFeedBack() throws YosException{
-        JSONArray idsarray = content.getJSONArray("ids");
-        ArrayList<String> sqllist = new ArrayList<>();
-        for (Object object:idsarray) {
-            String id = (String) object;
-            sqllist.add("update sa_dispatch set updatek3flag='1' where siteid='lsa' and  sa_dispatchid=" + id);
-        }
-
-        int count =dbConnect.runSqlUpdate(sqllist);
-        JSONObject returnObject =new JSONObject();
-        if (count>0) {
-            returnObject.put("msg", "");
-            returnObject.put("code", 1);
-        } else {
-            returnObject.put("msg", "true");
-            returnObject.put("code", 0);
-        }
-        return returnObject.toString();
-
-    }
-}

+ 0 - 9
src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案-扩展新增.sql

@@ -1,9 +0,0 @@
-insert into plm_itemextend (plm_itemextendid, siteid, changeuserid, changeby, changedate, itemid, material, pressure,
-                            caliber, butterflyplatedrive, connection, valveplatematerial, bodymaterial, actuatortype,
-                            actuatorbrand, isbutterfly, erpitemno, erpitemname, specalnote, prodline, device)
-values ($plm_itemextendid$, $siteid$, $userid$, $username$, current_time, $itemid$, $material$, $pressure$, $caliber$,
-        $butterflyplatedrive$, $connection$, $valveplatematerial$, $bodymaterial$, $actuatortype$, $actuatorbrand$,
-        $isbutterfly$,
-        $erpitemno$, $erpitemname$, $specalnote$, $prodline$, $device$);
-
-

+ 0 - 21
src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案-扩展更新.sql

@@ -1,21 +0,0 @@
-UPDATE plm_itemextend
-SET changeuserid=$userid$,
-    changedate = current_time,
-    changeby=$username$,
-    material=$material$,
-    pressure=$pressure$,
-    caliber=$caliber$,
-    butterflyplatedrive = $butterflyplatedrive$,
-    connection = $connection$,
-    valveplatematerial= $valveplatematerial$,
-    bodymaterial = $bodymaterial$,
-    actuatortype = $actuatortype$,
-    actuatorbrand = $actuatorbrand$,
-    isbutterfly = $isbutterfly$,
-    erpitemno = $erpitemno$,
-    erpitemname = $erpitemname$,
-    specalnote = $specalnote$,
-    prodline = $prodline$,
-    device = $device$
-WHERE itemid = $itemid$
-  and siteid = $siteid$

+ 0 - 10
src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案新增.sql

@@ -1,10 +0,0 @@
-insert into plm_item (siteid, itemid, createby, createdate, changeuserid, changeby, changedate, itemno, unitid,
-                      isauxunit, unitgroupid, itemname, isonsale, status, model, spec, orderminqty, orderaddqty,
-                      orderminqty_auxunit, orderaddqty_auxunit, remarks, barcode, skucontrol, batchcontrol, grossweight,
-                      weight, height, width, length, delivery, istool, marketprice, standards, stockstatus2,
-                      stockstatus1, warrantyday, iswuliao, isservice,color,packageqty,ismodule,iswoodproducts,sa_customschemeid,cheek,delistingstatus,financeclasstype,stockno,volume,marketingcategory,k3outcode,widthschemeid,lengthschemeid,description,pricingmetod)
-values ($siteid$, $itemid$, $username$, CURRENT_TIME, $userid$, $username$, CURRENT_TIME, $itemno$, $unitid$,
-        $isauxunit$, $unitgroupid$, $itemname$, 0, '新建', $model$, $spec$, $orderminqty$, $orderaddqty$,
-        $orderminqty_auxunit$, $orderaddqty_auxunit$, $remarks$, $barcode$, $skucontrol$, $batchcontrol$, $grossweight$,
-        $weight$, $height$, $width$, $length$, $delivery$, $istool$, $marketprice$, $standards$,
-        $stockstatus2$, $stockstatus1$, $warrantyday$, $iswuliao$, $isservice$,$color$,$packageqty$,$ismodule$,$iswoodproducts$,$sa_customschemeid$,$cheek$,$delistingstatus$,$financeclasstype$,$stockno$,$volume$,$marketingcategory$,$k3outcode$,$widthschemeid$,$lengthschemeid$,$description$,$pricingmetod$)

+ 0 - 54
src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案更新.sql

@@ -1,54 +0,0 @@
-UPDATE plm_item
-SET changeuserid=$userid$,
-    changedate = current_time,
-    itemno=$itemno$,
-    unitid=$unitid$,
-    isauxunit=$isauxunit$,
-    unitgroupid=$unitgroupid$,
-    itemname=$itemname$,
-    isonsale=$isonsale$,
-    `status`=$status$,
-    model = $model$,
-    spec=$spec$,
-    orderminqty=$orderminqty$,
-    orderaddqty=$orderaddqty$,
-    orderminqty_auxunit= $orderminqty_auxunit$,
-    orderaddqty_auxunit= $orderaddqty_auxunit$,
-    remarks = $remarks$,
-    barcode = $barcode$,
-    skucontrol = $skucontrol$,
-    batchcontrol = $batchcontrol$,
-    grossweight = $grossweight$,
-    weight = $weight$,
-    height = $height$,
-    width = $width$,
-    length = $length$,
-    delivery = $delivery$,
-    istool = $istool$,
-    marketprice = $marketprice$,
-    standards = $standards$,
-    stockstatus2 = $stockstatus2$,
-    stockstatus1 = $stockstatus1$,
-    warrantyday = $warrantyday$,
-    iswuliao = $iswuliao$,
-    ismodule = $ismodule$,
-    color = $color$,
-    cheek=$cheek$,
-    delistingstatus=$delistingstatus$,
-    packageqty = $packageqty$,
-    iswoodproducts=$iswoodproducts$,
-    isservice = $isservice$,
-    sa_customschemeid=$sa_customschemeid$,
-    financeclasstype=$financeclasstype$,
-    stockno=$stockno$,
-    volume=$volume$,
-    widthschemeid=$widthschemeid$,
-    lengthschemeid=$lengthschemeid$,
-    iscustomsize=$iscustomsize$,
-    customprice=$customprice$,
-    pricingmetod=$pricingmetod$,
-    k3outcode=$k3outcode$
-WHERE itemid = $itemid$
-  and siteid = $siteid$
-
-

+ 0 - 8
src/custom/restcontroller/webmanage/lsak3/item/SQL/货品档案领域新增.sql

@@ -1,8 +0,0 @@
-INSERT INTO plm_item_tradefield (plm_item_tradefieldid, siteid, changeuserid, itemid, tradefield)
-SELECT $plm_item_tradefieldid$, $siteid$, $userid$, $itemid$, $tradefield$
-FROM dual
-WHERE not exists(SELECT 1
-                 FROM plm_item_tradefield
-                 WHERE siteid = $siteid$
-                   AND itemid = $itemid$
-                   AND tradefield = $tradefield$)

+ 0 - 345
src/custom/restcontroller/webmanage/lsak3/item/item.java

@@ -1,345 +0,0 @@
-package restcontroller.webmanage.lsak3.item;
-
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.InsertSQL;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
-import org.apache.log4j.Logger;
-import restcontroller.R;
-import restcontroller.webmanage.sale.item.Item;
-
-import java.util.ArrayList;
-
-public class item extends Controller {
-    private static Logger logger = Logger.getLogger(item.class);
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public item(JSONObject content) throws YosException {
-        super(content);
-    }
-    /**
-     * 更新YOS商品档案
-     *
-     * @return
-     */
-    @API(title = "更新YOS商品档案", apiversion = R.ID20230715111203.v1.class,accesstoken = false)
-    public String updateItem() throws YosException{
-        String msg = "";
-        int code = 1;
-        ArrayList<String> sqllist = new ArrayList<>();
-        //单位
-        Rows unitRows = dbConnect.runSqlQuery("SELECT unitid,unitname from  plm_unit WHERE siteid = 'lsa'");
-        RowsMap unitRowsMap = unitRows.toRowsMap("unitname");
-        try {
-            // 商品编号
-            String fitemno = content.getString("fitemno");
-            // k3内码
-            String fitemid = content.getString("fitemid");
-            // k3外码
-            String foutitemno = content.getString("foutitemno");
-            // 是否删除
-            String isdelete = content.getString("isdelete");
-            // 商品名称
-            String fitemname = content.getString("fitemname");
-            // 规格尺寸
-            String fspec = content.getString("fspec");
-            // 型号
-            String fmodel = content.getString("fmodel");
-            // 包装数量
-            String fpackingqty = content.getString("fpackingqty");
-            if("0".equals(fpackingqty)||"null".equals(fpackingqty)||fpackingqty==null) {
-                fpackingqty="1";
-            }
-            // 保修期
-            String fwarrantyday = content.getString("fwarrantyday");
-            if("0".equals(fwarrantyday)||"null".equals(fwarrantyday)||fwarrantyday==null) {
-                fwarrantyday="0";
-            }
-            // 存货类别
-            String fitemclsnum = content.getString("fitemclsnum");
-            // 存货名称
-            String fitemclsname = content.getString("fitemclsname");
-            // 单位编码
-            String funitid = content.getString("funitid");
-            // 单位名称
-            String funitname = content.getString("funitname");
-            // 净重
-            String fnetweight = content.getString("fnetweight");
-            // 毛重
-            String fgrossweight = content.getString("fgrossweight");
-            // 是否启用
-            String fisused = content.getString("fisused");
-            // 营销类别
-            String fsaleclsnum = content.getString("fsaleclsnum");
-            // 营销类别 编号
-            String fsaleclsname = content.getString("fsaleclsname");
-
-            // 创建人
-            String createby = content.getString("createby");
-            // 创建日期
-            String createdate = content.getStringValue("createdate");
-
-            // 审核人
-            String checkby = content.getString("checkby");
-            // 审核日期
-            String checkdate = content.getStringValue("checkdate");
-            // 修改人
-            String changeby = content.getString("changeby");
-            // 修改日期
-            String changedate = content.getStringValue("changedate");
-
-            //长度
-            String fdzprice = content.getString("fdzprice");
-            //长度
-            String flong = content.getString("flong");
-            //颜色
-            String fcolour = content.getString("fcolour");
-            //版型
-            String fbx = content.getString("fbx");
-            //边框
-            String fbk = content.getString("fbk");
-            //是否定制尺寸
-            String fisdz = content.getString("fisdz");
-            //功率
-            String fgl = content.getString("fgl");
-
-            Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='lsa' and itemno='"+fitemno+"'");
-            SQLFactory sqlFactory;
-            if(itemRows.isEmpty()){
-                long itemid = createTableID("plm_item");
-                sqlFactory = new SQLFactory(this,"货品档案新增");
-                sqlFactory.addParameter("itemid",itemid);
-                sqlFactory.addParameter("sa_customschemeid", 0);
-                // 货品档案扩展属性字段表
-
-                SQLFactory sqlFactory1 = new SQLFactory(this, "货品档案-扩展新增");
-                sqlFactory1.addParameter("siteid", "lsa");
-                sqlFactory1.addParameter("userid", 1);
-                sqlFactory1.addParameter("username", createby);
-                sqlFactory1.addParameter("plm_itemextendid", createTableID("plm_itemextend"));
-                sqlFactory1.addParameter("itemid", itemid);
-                sqlFactory1.addParameter("material",fbx);
-                sqlFactory1.addParameter("pressure", "");
-                sqlFactory1.addParameter("caliber", "");
-                sqlFactory1.addParameter("butterflyplatedrive", "");
-                sqlFactory1.addParameter("connection", "");
-                sqlFactory1.addParameter("valveplatematerial", "");
-                sqlFactory1.addParameter("bodymaterial", "");
-                sqlFactory1.addParameter("actuatortype", "");
-                sqlFactory1.addParameter("actuatorbrand", "");
-                sqlFactory1.addParameter("isbutterfly", 0);
-                sqlFactory1.addParameter("erpitemno", fitemno);
-                sqlFactory1.addParameter("erpitemname",fitemname);
-                sqlFactory1.addParameter("specalnote","");
-                sqlFactory1.addParameter("prodline", "");
-                sqlFactory1.addParameter("device", "");
-
-                SQLFactory sqlFactorytradefield = new SQLFactory(this,"货品档案领域新增");
-                sqlFactorytradefield.addParameter("siteid", "lsa");
-                sqlFactorytradefield.addParameter("plm_item_tradefieldid", createTableID("plm_item_tradefield"));
-                sqlFactorytradefield.addParameter("userid", 1);
-                sqlFactorytradefield.addParameter("itemid", itemid);
-                sqlFactorytradefield.addParameter("tradefield", "建材家居");
-                sqllist.add(sqlFactorytradefield.getSQL());
-
-                sqllist.add(sqlFactory1.getSQL());
-            }else {
-                long itemid = itemRows.get(0).getLong("itemid");
-                sqlFactory = new SQLFactory(this,"货品档案更新");
-                sqlFactory.addParameter("itemid",itemid);
-                Rows customitemRows = dbConnect.runSqlQuery("select widthschemeid,lengthschemeid,spec,color,material,cheek,t1.status,t1.isonsale,t1.sa_customschemeid from plm_item t1 left join plm_itemextend t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.itemid="+itemid);
-                if(!customitemRows.isEmpty()){
-                    if(customitemRows.get(0).getString("spec").equals(flong) && customitemRows.get(0).getString("color").equals(fcolour)
-                            && customitemRows.get(0).getString("material").equals(fbx) && customitemRows.get(0).getString("cheek").equals(fbk)){
-                        sqlFactory.addParameter("status",customitemRows.get(0).getString("status"));
-                        sqlFactory.addParameter("isonsale",customitemRows.get(0).getString("isonsale"));
-                    }else {
-                        sqlFactory.addParameter("status",customitemRows.get(0).getString("status"));
-                        sqlFactory.addParameter("isonsale",customitemRows.get(0).getString("isonsale"));
-                        Rows rowscount = dbConnect.runSqlQuery("select count(1) count from sa_itemgroupmx where sa_itemgroupid in(select t1.sa_itemgroupid from sa_itemgroupmx t1 inner join sa_itemgroup t2 on t1.sa_itemgroupid=t2.sa_itemgroupid and t1.siteid=t2.siteid  where itemid="+itemid+")");
-                        if(rowscount.isNotEmpty()){
-                            if(rowscount.get(0).getInteger("count")>1){
-                                logger.info("new:"+flong+":"+fcolour+":"+fbx+":"+fbk);
-                                logger.info("old:"+customitemRows.get(0).getString("spec")+":"+customitemRows.get(0).getString("color")+":"+customitemRows.get(0).getString("material")+":"+customitemRows.get(0).getString("cheek"));
-                                if(customitemRows.get(0).getBoolean("isonsale")){
-                                    InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_contrllog");
-                                    insertSQL.setValue("sys_contrllogid", this.createTableID("sys_contrllog"));
-                                    insertSQL.setValue("ownertable", "plm_item");
-                                    insertSQL.setValue("ownerid", itemid);
-                                    insertSQL.setValue("action", "商品自动下架");
-                                    insertSQL.setValue("remarks", "商品自动下架成功");
-                                    insertSQL.setValue("actionuserid",1);
-                                    insertSQL.setValue("actionby","admin");
-                                    insertSQL.setValue("siteid", "lsa");
-                                    insertSQL.setDateValue("actiondate");
-                                    sqllist.add(insertSQL.getSQL());
-                                }
-                                sqlFactory.addParameter("status","审核");
-                                sqlFactory.addParameter("isonsale",0);
-                                sqllist.add("delete from sa_itemgroupmx where itemid=" + itemid + " and siteid='lsa'");
-                            }
-                        }
-
-                    }
-                }
-                sqlFactory.addParameter("sa_customschemeid", itemRows.get(0).getLong("sa_customschemeid"));
-                Rows itemextendRows= dbConnect.runSqlQuery("select * from plm_itemextend where siteid='lsa' and itemid="+itemid);
-                SQLFactory sqlFactory1;
-                if(itemextendRows.isEmpty()){
-                    sqlFactory1 = new SQLFactory(this, "货品档案-扩展新增");
-                    sqlFactory1.addParameter("plm_itemextendid", createTableID("plm_itemextend"));
-                }else {
-                    sqlFactory1 = new SQLFactory(this, "货品档案-扩展更新");
-                    sqlFactory1.addParameter("plm_itemextendid",itemextendRows.get(0).getLong("plm_itemextendid"));
-                }
-                sqlFactory1.addParameter("siteid", "lsa");
-                sqlFactory1.addParameter("userid", 1);
-                sqlFactory1.addParameter("username", createby);
-                sqlFactory1.addParameter("itemid", itemid);
-                sqlFactory1.addParameter("material", fbx);
-                sqlFactory1.addParameter("pressure", "");
-                sqlFactory1.addParameter("caliber", "");
-                sqlFactory1.addParameter("butterflyplatedrive", "");
-                sqlFactory1.addParameter("connection", "");
-                sqlFactory1.addParameter("valveplatematerial", "");
-                sqlFactory1.addParameter("bodymaterial", "");
-                sqlFactory1.addParameter("actuatortype", "");
-                sqlFactory1.addParameter("actuatorbrand", "");
-                sqlFactory1.addParameter("isbutterfly", 0);
-                sqlFactory1.addParameter("erpitemno",fitemno);
-                sqlFactory1.addParameter("erpitemname", fitemname);
-                sqlFactory1.addParameter("specalnote","");
-                sqlFactory1.addParameter("prodline", "");
-                sqlFactory1.addParameter("device", "");
-                sqllist.add(sqlFactory1.getSQL());
-
-            }
-            sqlFactory.addParameter("siteid", "lsa");
-            sqlFactory.addParameter("username",checkby);
-            sqlFactory.addParameter("userid", 1);
-            sqlFactory.addParameter("itemno", fitemno);
-            if(unitRowsMap.containsKey(funitname)){
-                sqlFactory.addParameter("unitid", unitRowsMap.get(funitname).get(0).getLong("unitid"));
-            }else {
-                long unitid=createTableID("plm_unit");
-                InsertSQL insertSQL = SQLFactory.createInsertSQL(new Controller(new JSONObject()), "plm_unit");
-                insertSQL.setValue("siteid", "lsa");
-                insertSQL.setValue("unitid", unitid);
-                insertSQL.setValue("unitname", funitname);
-                dbConnect.runSqlUpdate(insertSQL.getSQL());
-                sqlFactory.addParameter("unitid",unitid);
-
-            }
-            sqlFactory.addParameter("isauxunit", 0);
-            sqlFactory.addParameter("unitgroupid","null");
-
-            sqlFactory.addParameter("itemname", fitemname);
-            sqlFactory.addParameter("model", fmodel);
-            sqlFactory.addParameter("spec", flong);
-            // 订单起订量
-            sqlFactory.addParameter("orderminqty", 1);
-            // 订单增量
-            sqlFactory.addParameter("orderaddqty", 1);
-            // 订单起订量控制单位(0:主单位;1:辅助单位)
-            sqlFactory.addParameter("orderminqty_auxunit", 0);
-            // 订单增量控制单位(0:主单位;1:辅助单位)
-            sqlFactory.addParameter("orderaddqty_auxunit", 0);
-            // 说明
-            sqlFactory.addParameter("remarks", "");
-            // 商品条形码
-            sqlFactory.addParameter("barcode", "");
-            // 是否单品管理
-            sqlFactory.addParameter("skucontrol",0);
-            // 是否批次管理
-            sqlFactory.addParameter("batchcontrol",0);
-            // 毛重(g)
-            sqlFactory.addParameter("grossweight", fgrossweight);
-            // 净重(g)
-            sqlFactory.addParameter("weight", fnetweight);
-            // 高度(mm)
-            sqlFactory.addParameter("height", 0);
-            // 宽度(mm)
-            sqlFactory.addParameter("width", 0);
-            // 长度(mm)
-            sqlFactory.addParameter("length", 0);
-            // 交期
-            sqlFactory.addParameter("delivery", 1);
-            // 牌价
-            sqlFactory.addParameter("marketprice", 0);
-            // 是否工具
-            sqlFactory.addParameter("istool", 0);
-            // 产品标准
-            sqlFactory.addParameter("standards",fspec);
-            // 库存缺货标准
-            sqlFactory.addParameter("stockstatus2", 1);
-            // 库存充足标准
-            sqlFactory.addParameter("stockstatus1", 1);
-            // 保修期(年)
-            sqlFactory.addParameter("warrantyday", fwarrantyday);
-            // 是否营销物料
-            sqlFactory.addParameter("iswuliao",0);
-            // 是否服务物料
-            sqlFactory.addParameter("isservice", 0);
-
-            sqlFactory.addParameter("color", fcolour);
-            sqlFactory.addParameter("cheek", fbk);
-            sqlFactory.addParameter("iscustomsize", fisdz);
-
-            sqlFactory.addParameter("delistingstatus","");
-            sqlFactory.addParameter("marketingcategory","");
-            sqlFactory.addParameter("customprice",0);
-
-
-            sqlFactory.addParameter("ismodule", 0);
-            sqlFactory.addParameter("packageqty", fpackingqty);
-            sqlFactory.addParameter("iswoodproducts", 0);
-
-            sqlFactory.addParameter("financeclasstype","");
-            sqlFactory.addParameter("stockno","");
-            sqlFactory.addParameter("volume", 0);
-            sqlFactory.addParameter("k3outcode", foutitemno);
-
-            if(fisdz.equals("1")){
-                if(!itemRows.isEmpty()){
-                    sqlFactory.addParameter("widthschemeid",itemRows.get(0).getLong("widthschemeid"));
-                    sqlFactory.addParameter("lengthschemeid", itemRows.get(0).getLong("lengthschemeid"));
-                }else{
-                    sqlFactory.addParameter("widthschemeid",1);
-                    sqlFactory.addParameter("lengthschemeid", 1);
-                }
-
-                sqlFactory.addParameter("pricingmetod", 1);
-
-            }else{
-                sqlFactory.addParameter("widthschemeid",0);
-                sqlFactory.addParameter("lengthschemeid", 0);
-                sqlFactory.addParameter("pricingmetod", 2);
-
-            }
-            if ("1".equals(isdelete)) {
-                sqlFactory.addParameter("remarks", "K3已删除");
-            } else {
-                sqlFactory.addParameter("remarks", "");
-            }
-            sqlFactory.addParameter("description", "K3");
-            sqllist.add(sqlFactory.getSQL());
-        } catch (Exception e) {
-            e.printStackTrace();
-            msg = e.getMessage();
-            code = 0;
-        }
-        dbConnect.runSqlUpdate(sqllist);
-
-        JSONObject returnObject=new JSONObject();
-        returnObject.put("msg", msg);
-        returnObject.put("code", code);
-        return returnObject.toString();
-    }
-}

+ 0 - 2
src/custom/restcontroller/webmanage/lsak3/itemPrice/SQL/商品价格新增.sql

@@ -1,2 +0,0 @@
-insert into sa_itemprice(siteid, sa_itempriceid, itemid, itemno, pricegrade, changeuserid, price,description)
-values ($siteid$, $sa_itempriceid$, $itemid$, $itemno$, $pricegrade$, $userid$, $price$,$description$)

+ 0 - 7
src/custom/restcontroller/webmanage/lsak3/itemPrice/SQL/商品价格更新.sql

@@ -1,7 +0,0 @@
-UPDATE sa_itemprice
-SET price=$price$,
-    changeuserid=$userid$,
-    description=$description$
-WHERE itemid = $itemid$
-  and pricegrade = $pricegrade$
-  and siteid = $siteid$

+ 0 - 81
src/custom/restcontroller/webmanage/lsak3/itemPrice/itemPrice.java

@@ -1,81 +0,0 @@
-package restcontroller.webmanage.lsak3.itemPrice;
-
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.Rows;
-import common.data.SQLFactory;
-import restcontroller.R;
-
-import java.util.ArrayList;
-
-public class itemPrice extends Controller {
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public itemPrice(JSONObject content) throws YosException {
-        super(content);
-    }
-    /**
-     * 更新商品价格
-     *
-     * @return
-     */
-    @API(title = "更新商品价格", apiversion = R.ID20230715144203.v1.class,accesstoken = false)
-    public String updateItem_Price() throws YosException{
-        String msg = "";
-        int code = 1;
-        ArrayList<String> sqllist = new ArrayList<>();
-        try {
-            // 商品编号
-            String fitemno = content.getString("fitemno");
-            // 价格等级
-            String fpricegrade = content.getString("fpricegrade");
-            // 是否删除
-            String isdelete = content.getString("isdelete");
-            // 价格等级
-            String fprice = content.getString("fprice");
-
-
-            Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='lsa' and itemno='"+fitemno+"'");
-            if(itemRows.isEmpty()){
-                code=0;
-                msg="商品不存在,无法新增商品价格";
-            }else{
-                Rows itempriceRows = dbConnect.runSqlQuery("select * from sa_itemprice where siteid='lsa' and pricegrade='" + fpricegrade + "' and itemid="+itemRows.get(0).getLong("itemid"));
-                SQLFactory sqlFactory;
-                if(itempriceRows.isEmpty()){
-                    sqlFactory = new SQLFactory(this,"商品价格新增");
-                    sqlFactory.addParameter("sa_itempriceid", createTableID("sa_itemprice"));
-                }else{
-                    sqlFactory = new SQLFactory(this,"商品价格更新");
-                    sqlFactory.addParameter("sa_itempriceid", itempriceRows.get(0).getLong("sa_itempriceid"));
-                }
-                sqlFactory.addParameter("itemno",fitemno);
-                sqlFactory.addParameter("siteid", "lsa");
-                sqlFactory.addParameter("itemid", itemRows.get(0).getLong("itemid"));
-                sqlFactory.addParameter("userid", 1);
-                sqlFactory.addParameter("pricegrade", fpricegrade);
-                if ("1".equals(isdelete)) {
-                    sqlFactory.addParameter("price", 0);
-                } else {
-                    sqlFactory.addParameter("price", fprice);
-                }
-                sqlFactory.addParameter("description", "K3");
-                sqllist.add(sqlFactory.getSQL());
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            msg = e.getMessage();
-            code = 0;
-        }
-        dbConnect.runSqlUpdate(sqllist);
-        JSONObject returnObject =new JSONObject();
-        returnObject.put("msg", msg);
-        returnObject.put("code", code);
-        return returnObject.toString();
-    }
-}

+ 0 - 71
src/custom/restcontroller/webmanage/lsak3/order/order.java

@@ -1,71 +0,0 @@
-package restcontroller.webmanage.lsak3.order;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.Row;
-import common.data.Rows;
-import restcontroller.R;
-
-import java.util.ArrayList;
-
-public class order extends Controller {
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public order(JSONObject content) throws YosException {
-        super(content);
-    }
-
-    /**
-     * 获取DRP订单
-     *
-     * @return
-     */
-    @API(title = "k3获取销售订单", apiversion = R.ID20230715090203.v1.class,accesstoken = false)
-    public String getSaorder() throws  YosException{
-
-        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sonum fsonum,t1.sa_orderid saorderid,t1.createby,t1.billdate fdate,t2.agentnum fagentnum,t1.remarks fnotes from sa_order t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid  where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa'");
-        for (Row row : rows) {
-            String sa_orderid = row.getString("sa_orderid");
-            Rows detailRows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.sa_orderitemsid saorderdetailid,convert(t1.defaultamount,char) as ftaxamount,t2.itemno fitemno,t1.qty fqty,t1.price frateprice,t1.defaultprice fprice,t1.amount famount,t1.remarks fnotes,t1.customproperties,t2.spec flong from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid where sa_orderid='" + sa_orderid + "'  and t1.siteid='lsa'");
-            row.put("saorderdetail", detailRows.toJsonArray());
-        }
-        if(rows.isEmpty()) {
-            JSONArray array = new JSONArray();
-            return array.toString();
-        }
-        return rows.toJsonArray().toString();
-    }
-
-    /**
-     * 获取DRP订单返回成功消息
-     *
-     * @return
-     */
-    @API(title = "获取DRP订单返回成功消息", apiversion = R.ID20230715090703.v1.class,accesstoken = false)
-    public String getSaorderFeedBack() throws  YosException{
-        JSONArray idsarray = content.getJSONArray("ids");
-        ArrayList<String> sqllist = new ArrayList<>();
-        for (Object object:idsarray) {
-            String id = (String) object;
-            sqllist.add("update sa_order set updatek3flag='1' where siteid='lsa' and  sa_orderid=" + id);
-        }
-
-
-        int count =dbConnect.runSqlUpdate(sqllist);
-        JSONObject returnObject =new JSONObject();
-        if (count>0) {
-            returnObject.put("msg", "");
-            returnObject.put("code", 1);
-        } else {
-            returnObject.put("msg", "true");
-            returnObject.put("code", 0);
-        }
-        return returnObject.toString();
-    }
-}

+ 0 - 2
src/custom/restcontroller/webmanage/lsak3/stockbill/SQL/数据操作日志新增.sql

@@ -1,2 +0,0 @@
-insert into sys_contrllog (siteid, sys_contrllogid,ownertable,ownerid,action, remarks,actionuserid,actionby)
-values ($siteid$, $sys_contrllogid$,$ownertable$,$ownerid$, $action$, $remarks$,$actionuserid$, $actionby$);

+ 0 - 2
src/custom/restcontroller/webmanage/lsak3/stockbill/SQL/销售出库单新增.sql

@@ -1,2 +0,0 @@
-insert into st_stockbill (siteid, st_stockbillid,createby, createdate, billno,billdate,changeby, changedate,checkby,checkdate,sys_enterpriseid, rb,type,remarks)
-values ($siteid$, $st_stockbillid$,$createby$, $createdate$, $billno$,$billdate$, $changeby$, $changedate$,$checkby$,$checkdate$,$sys_enterpriseid$,$rb$,$type$,$remarks$);

+ 0 - 13
src/custom/restcontroller/webmanage/lsak3/stockbill/SQL/销售出库单明细新增.sql

@@ -1,13 +0,0 @@
-insert into st_stockbill_items (siteid, st_stockbill_itemsid,st_stockbillid, sa_dispatch_itemsid, rowno, itemid, qty,amount,remarks,price,sa_orderitemsid,sa_orderid)
-select $siteid$,
-       $st_stockbill_itemsid$,
-       $st_stockbillid$,
-       $sa_dispatch_itemsid$,
-       $rowno$,
-       $itemid$,
-       $qty$,
-       $amount$,
-       $remarks$,
-       $price$,
-       $sa_orderitemsid$,
-       $sa_orderid$

+ 0 - 453
src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java

@@ -1,453 +0,0 @@
-package restcontroller.webmanage.lsak3.stockbill;
-
-import beans.accountbalance.Accountbalance;
-import beans.accountbalance.CashbillEntity;
-import beans.datacontrllog.DataContrlLog;
-import beans.parameter.Parameter;
-import beans.remind.Remind;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.YosException;
-import common.annotation.API;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import restcontroller.R;
-import restcontroller.webmanage.executorService.Executor;
-import restcontroller.webmanage.sale.order.OrderItemsHelper;
-import service.AftersalesmagAutoRecheckService;
-
-import javax.swing.text.StyledEditorKit;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-public class stockbill extends Controller {
-    /**
-     * 构造函数
-     *
-     * @param content
-     */
-    public stockbill(JSONObject content) throws YosException {
-        super(content);
-    }
-
-    private static Logger logger = Logger.getLogger(stockbill.class);
-
-    /**
-     * 更新YOS销售出库单
-     *
-     * @return
-     * @throws YosException
-     */
-    @API(title = "更新YOS销售出库单", apiversion = R.ID20230717144803.v1.class, accesstoken = false)
-    public String updateIcstockbill() throws YosException {
-        String msg = "";
-        int code = 1;
-        ArrayList<String> sqlList = new ArrayList<>();
-        // 单据编号
-        String fbillnum = content.getString("fbillnum");
-        try {
-            // 经销商编号
-            String fagentnum = content.getString("fagentnum");
-            long sys_enterpriseid = 0;
-            if (dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='" + fagentnum + "'").isNotEmpty()) {
-                sys_enterpriseid = dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='lsa' and  agentnum='" + fagentnum + "'").get(0).getLong("sys_enterpriseid");
-            } else {
-                msg = "yos中不存在【" + fagentnum + "】经销商";
-                return getErrReturnObject().setErrMsg(msg).toString();
-            }
-            // 单据日期
-            String fdate = content.getString("fdate");
-            // 会计期间
-            //  String fperiod = content.getString("fperiod");
-            // 红蓝字
-            String frb = content.getString("frb");
-            // 表头仓库
-            // String fstockno = content.getString("fstockno");
-            // 单据类型明细
-            //String ftypemx = content.getString("ftypemx");
-            // 单据状态
-            String fstatus = content.getString("fstatus");
-            // 制单人
-            String createby = content.getString("createby");
-            // 制单日期
-            String createdate = content.getString("createdate");
-            // 审核人
-            String checkby = content.getString("checkby");
-            // 审核日期
-            String checkdate = content.getString("checkdate");
-            // 备注
-            String fnotes = content.getString("fnotes");
-            // 是否删除
-            String isdelete = content.getString("isdelete");
-
-            siteid = "lsa";
-
-            Long sa_cashbillid = 0L;
-
-            Rows stockbillRows = dbConnect.runSqlQuery("select * from st_stockbill where siteid='lsa' and status='审核' and billno='" + fbillnum + "'");
-            Long st_stockbillid = 0L;
-            if (stockbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(fstatus)) {
-                /**
-                 * DRP不存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需新增该销售出库单
-                 */
-                SQLFactory sqlFactory = new SQLFactory(this, "销售出库单新增");
-                st_stockbillid = createTableID("st_stockbill");
-                sqlFactory.addParameter("siteid", "lsa");
-                sqlFactory.addParameter("st_stockbillid", st_stockbillid);
-                sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                sqlFactory.addParameter("billno", fbillnum);
-                sqlFactory.addParameter("type", "销售出库");
-                sqlFactory.addParameter("rb", frb.equals("蓝") ? 1 : 0);
-                sqlFactory.addParameter("billdate", fdate);
-                sqlFactory.addParameter("createby", createby);
-                sqlFactory.addParameter("createdate", getDate(createdate));
-                sqlFactory.addParameter("changeby", createby);
-                sqlFactory.addParameter("changedate", getDate(createdate));
-                sqlFactory.addParameter("checkby", checkby);
-                sqlFactory.addParameter("checkdate", getDate(checkdate));
-                sqlFactory.addParameter("remarks", fnotes);
-                sqlList.add(sqlFactory.getSQL());
-
-                JSONArray detailarray = content.getJSONArray("icstockbilldetails");
-                StringBuffer str = new StringBuffer();
-
-                List<Long> sa_dispatch_itemsids = new ArrayList<>();
-                sa_dispatch_itemsids.add(0l);
-                for (Object object : detailarray) {
-                    JSONObject jsonObject = (JSONObject) object;
-                    if (str.toString().equals("")) {
-                        str.append("'" + jsonObject.getString("fitemno") + "'");
-                    } else {
-                        str.append(",'" + jsonObject.getString("fitemno") + "'");
-                    }
-                    sa_dispatch_itemsids.add(jsonObject.getLong("sainvoicedetailid"));
-                }
-                Rows rows;
-                if (!str.toString().equals("")) {
-                    rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='lsa' and itemno in " + "(" + str.toString() + ")");
-                } else {
-                    rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='lsa' and itemno in('')");
-                }
-                RowsMap itemRowsMap = rows.toRowsMap("itemno");
-                Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid,t1.sa_orderitemsid,t2.sa_orderid,t3.sys_enterpriseid,t4.sonum,t5.itemno,t5.itemname 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 left join sa_order t4 on t2.sa_orderid=t4.sa_orderid and t2.siteid=t4.siteid left join plm_item t5 on t1.itemid=t5.itemid and t1.siteid=t5.siteid where t3.status in('审核','复核','关闭') and  t1.siteid='lsa' and  t1.sa_dispatch_itemsid in " + sa_dispatch_itemsids.toString().replace("[", "(").replace("]", ")"));
-                RowsMap distiptchRowsMap = distiptchRows.toRowsMap("sa_dispatch_itemsid");
-
-                Rows aftersalesmagRows = dbConnect.runSqlQuery("select t1.price,t1.sa_aftersalesmag_itemsid,t1.sa_orderitemsid,t2.sa_orderid from sa_aftersalesmag_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid  where  t1.siteid='lsa' and  t1.sa_aftersalesmag_itemsid in " + sa_dispatch_itemsids.toString().replace("[", "(").replace("]", ")"));
-                RowsMap aftersalesmagRowsMap = aftersalesmagRows.toRowsMap("sa_aftersalesmag_itemsid");
-                BigDecimal amountTotal = BigDecimal.ZERO;
-                for (Object object : detailarray) {
-                    JSONObject jsonObject = (JSONObject) object;
-                    String frownum = jsonObject.getString("frownum");
-                    String fitemno = jsonObject.getString("fitemno");
-                    System.err.println(frownum + ":" + fitemno);
-                    BigDecimal fqty = new BigDecimal(jsonObject.getString("fqty"));
-                    fqty = fqty.compareTo(BigDecimal.ZERO) < 0 ? fqty.negate() : fqty;
-                    //String fdetailstockno = jsonObject.getString("fstockno");
-                    long sainvoicedetailid = jsonObject.getLong("sainvoicedetailid");
-                    //String fbatchno = jsonObject.getString("fbatchno");
-                    String fdetailnotes = jsonObject.getString("fnotes");
-                    SQLFactory sqlFactorydetail = new SQLFactory(this, "销售出库单明细新增");
-                    sqlFactorydetail.addParameter("siteid", "lsa");
-                    sqlFactorydetail.addParameter("st_stockbill_itemsid", createTableID("st_stockbill_items"));
-                    sqlFactorydetail.addParameter("st_stockbillid", st_stockbillid);
-                    sqlFactorydetail.addParameter("rowno", frownum);
-                    sqlFactorydetail.addParameter("sa_dispatch_itemsid", sainvoicedetailid);
-                    sqlFactorydetail.addParameter("remarks", fnotes);
-                    if (itemRowsMap.containsKey(fitemno) && itemRowsMap.get(fitemno).isNotEmpty()) {
-                        sqlFactorydetail.addParameter("itemid", itemRowsMap.get(fitemno).get(0).getLong("itemid"));
-                    } else {
-                        sqlFactorydetail.addParameter("itemid", 0);
-                    }
-                    sqlFactorydetail.addParameter("remarks", fdetailnotes);
-                    sqlFactorydetail.addParameter("qty", fqty);
-
-                    if (frb.equals("蓝")) {
-                        if (distiptchRowsMap.containsKey(String.valueOf(sainvoicedetailid)) && distiptchRowsMap.get(sainvoicedetailid).isNotEmpty()) {
-                            sqlFactorydetail.addParameter("price", distiptchRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price"));
-                            amountTotal = amountTotal.add(fqty.multiply(distiptchRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-                            sqlFactorydetail.addParameter("amount", fqty.multiply(distiptchRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-                            sqlFactorydetail.addParameter("sa_orderitemsid", distiptchRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderitemsid"));
-                            sqlFactorydetail.addParameter("sa_orderid", distiptchRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderid"));
-                            System.out.println(amountTotal);
-                            //您的订单【XXX】商品【XXX】工厂已发货,出库单号【XXX】
-                            String message = "您的订单【" + distiptchRowsMap.get(sainvoicedetailid).get(0).getString("sonum") + "】商品【" + distiptchRowsMap.get(sainvoicedetailid).get(0).getString("itemname") + "】工厂已发货,出库单号【" + fbillnum + "】!";
-                            sendMsg(message, st_stockbillid, distiptchRowsMap.get(sainvoicedetailid).get(0).getLong("sys_enterpriseid"));
-                        } else {
-                            sqlFactorydetail.addParameter("price", 0);
-                            sqlFactorydetail.addParameter("amount", 0);
-                            sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-                            sqlFactorydetail.addParameter("sa_orderid", 0);
-                        }
-
-                        /**
-                         * 更新发货单数量
-                         */
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)+" + fqty + " where siteid='lsa' and sa_dispatch_itemsid=" + sainvoicedetailid);
-                    } else {
-                        if (aftersalesmagRowsMap.containsKey(String.valueOf(sainvoicedetailid)) && aftersalesmagRowsMap.get(sainvoicedetailid).isNotEmpty()) {
-                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).toJsonObject().toString());
-                            sqlFactorydetail.addParameter("price", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price"));
-                            sqlFactorydetail.addParameter("amount", fqty.multiply(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderitemsid"));
-                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderid"));
-                            sqlFactorydetail.addParameter("sa_orderitemsid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderitemsid"));
-                            sqlFactorydetail.addParameter("sa_orderid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderid"));
-                        } else {
-                            sqlFactorydetail.addParameter("price", 0);
-                            sqlFactorydetail.addParameter("amount", 0);
-                            sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-                            sqlFactorydetail.addParameter("sa_orderid", 0);
-                        }
-                    }
-
-                    sqlList.add(sqlFactorydetail.getSQL());
-                }
-                if (frb.equals("蓝")) {
-                    BigDecimal billamount = BigDecimal.ZERO;
-                    //返利比例
-                    String icstockbillrebateaccount = Parameter.getString(siteid, "icstockbillrebateaccount"); //经销商销售出库单返利账户
-                    String icstockbillrebaterate1 = Parameter.getString(siteid, "icstockbillrebaterate"); //销售出库单返利比例
-                    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 + "返利");
-                        JSONObject cashbillIncome = Accountbalance.createCashbillIncome(this, sys_enterpriseid, Long.valueOf(icstockbillrebateaccount).longValue(), entity, true, false);
-                        sqlList.addAll(cashbillIncome.getJSONArray("sqlList").toJavaList(String.class));
-                        sa_cashbillid = cashbillIncome.getLong("sa_cashbillid");
-                    }
-
-
-                }
-
-                sqlList.add("update st_stockbill set status='审核',checkby='" + checkby + "',checkdate=CURRENT_TIMESTAMP where st_stockbillid = " + st_stockbillid + " and siteid='lsa'");
-
-            } else if (!stockbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(fstatus)) {
-                /**
-                 * DRP存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需将当前销售出库单先反审核,修改内容后再进行审核
-                 */
-                //销售出库单反审核逻辑待添加
-                if (frb.equals("蓝")) {
-                    BigDecimal billamount = BigDecimal.ZERO;
-                    Rows stockbilldetails = dbConnect.runSqlQuery("select * from st_stockbill_items where st_stockbillid ='"
-                            + stockbillRows.get(0).getLong("st_stockbillid") + "' and  siteid='" + siteid + "'");
-                    for (Row row : stockbilldetails) {
-                        billamount = billamount.add(row.getBigDecimal("amount").abs().negate());
-                    }
-
-                    //返利比例
-                    String icstockbillrebateaccount = Parameter.getString(siteid, "icstockbillrebateaccount"); //经销商销售出库单返利账户
-                    String icstockbillrebaterate1 = Parameter.getString(siteid, "icstockbillrebaterate"); //销售出库单返利比例
-                    BigDecimal icstockbillrebaterate = new BigDecimal(icstockbillrebaterate1);
-                    //经销商返利
-                    BigDecimal rebateamount = icstockbillrebaterate.multiply(billamount);
-
-                    CashbillEntity entity = new CashbillEntity();
-                    entity.setAmount(rebateamount);
-                    entity.setOwnerid(stockbillRows.get(0).getLong("st_stockbillid"));
-                    entity.setOwnertable("st_stockbill");
-                    entity.setSource("");
-                    entity.setRemarks("销售出库单" + fbillnum + "反返利");
-                    JSONObject cashbillIncome = Accountbalance.createCashbillIncome(this, sys_enterpriseid, Long.valueOf(icstockbillrebateaccount).longValue(), entity, true, false);
-                    sqlList.addAll(cashbillIncome.getJSONArray("sqlList").toJavaList(String.class));
-                    sa_cashbillid = cashbillIncome.getLong("sa_cashbillid");
-                    /**
-                     * 更新发货单数量
-                     */
-                    Rows stockbilldetailrows = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and t1.siteid='lsa' group by t1.sa_dispatch_itemsid");
-                    for (Row row : stockbilldetailrows) {
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-" + row.getBigDecimal("qty") + " where siteid='lsa' and sa_dispatch_itemsid=" + row.getLong("sa_dispatch_itemsid"));
-                        sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='lsa' and sa_dispatchid=" + row.getLong("sa_dispatchid"));
-                    }
-                }
-
-                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='lsa'");
-
-                msg = "DRP单据状态为审核,现已反审核,下次同步时进行审核操作";
-                code = 0;
-            } else if (!stockbillRows.isEmpty() && ("1".equals(isdelete) || "新建".equals(fstatus))) {
-                /**
-                 * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入销售出库单先反审核
-                 */
-                //销售出库单反审核逻辑待添加
-                if (frb.equals("蓝")) {
-                    BigDecimal billamount = BigDecimal.ZERO;
-                    Rows stockbilldetails = dbConnect.runSqlQuery("select * from st_stockbill_items where st_stockbillid ='"
-                            + stockbillRows.get(0).getLong("st_stockbillid") + "' and  siteid='" + siteid + "'");
-                    for (Row row : stockbilldetails) {
-                        billamount = billamount.add(row.getBigDecimal("amount").abs().negate());
-                    }
-
-                    //返利比例
-                    String icstockbillrebateaccount = Parameter.getString(siteid, "icstockbillrebateaccount"); //经销商销售出库单返利账户
-                    String icstockbillrebaterate1 = Parameter.getString(siteid, "icstockbillrebaterate"); //销售出库单返利比例
-                    BigDecimal icstockbillrebaterate = new BigDecimal(icstockbillrebaterate1);
-                    //经销商返利
-                    BigDecimal rebateamount = icstockbillrebaterate.multiply(billamount);
-
-                    CashbillEntity entity = new CashbillEntity();
-                    entity.setAmount(rebateamount);
-                    entity.setOwnerid(stockbillRows.get(0).getLong("st_stockbillid"));
-                    entity.setOwnertable("st_stockbill");
-                    entity.setSource("");
-                    entity.setRemarks("销售出库单" + fbillnum + "反返利");
-                    JSONObject cashbillIncome = Accountbalance.createCashbillIncome(this, sys_enterpriseid, Long.valueOf(icstockbillrebateaccount).longValue(), entity, true, false);
-                    sqlList.addAll(cashbillIncome.getJSONArray("sqlList").toJavaList(String.class));
-                    sa_cashbillid = cashbillIncome.getLong("sa_cashbillid");
-                    /**
-                     * 更新发货单数量
-                     */
-                    Rows stockbilldetailrows = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and t1.siteid='lsa' group by t1.sa_dispatch_itemsid");
-                    for (Row row : stockbilldetailrows) {
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-" + row.getBigDecimal("qty") + " where siteid='lsa' and sa_dispatch_itemsid=" + row.getLong("sa_dispatch_itemsid"));
-                        sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='lsa' and sa_dispatchid=" + row.getLong("sa_dispatchid"));
-                    }
-
-
-                }
-
-                sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='lsa'");
-
-            }
-
-            dbConnect.runSqlUpdate(sqlList);
-
-
-            Accountbalance.remindSend(this, sys_enterpriseid, sa_cashbillid);
-            if (stockbillRows.isEmpty() && "0".equals(isdelete) && "审核".equals(fstatus)) {
-                ArrayList<Long> userIdList = dbConnect.runSqlQuery("select userid from sys_enterprise_hr where siteid='" + siteid + "' and sys_enterpriseid=" + sys_enterpriseid).toArrayList("userid", new ArrayList<>());
-                Executor.sendEml(this, "stocck_check", st_stockbillid, siteid, userIdList);
-            }
-
-            Rows stockbillrows = dbConnect.runSqlQuery("select st_stockbillid,status,rb from st_stockbill where billno='" + fbillnum + "' and siteid='lsa'");
-            if (frb.equals("蓝")) {
-                //查询可关闭的发货单
-                Rows dispatchrows = dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty=t.sumoutwarehouseqty");
-                Rows undispatchrows = dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty!=t.sumoutwarehouseqty");
-                ArrayList<String> sqldispatch = new ArrayList<>();
-                for (Row row : dispatchrows) {
-                    sqldispatch.add("update sa_dispatch set status='关闭',closedate=current_time,closeby='admin' where sa_dispatchid='" + row.getLong("sa_dispatchid") + "' and siteid='lsa'");
-                    SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-                    sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-                    sqlFactory.addParameter("ownertable", "sa_dispatch");
-                    sqlFactory.addParameter("ownerid", row.getLong("sa_dispatchid"));
-                    sqlFactory.addParameter("action", "自动关闭");
-                    sqlFactory.addParameter("remarks", "发货单自动关闭成功");
-                    sqlFactory.addParameter("actionuserid", "1");
-                    sqlFactory.addParameter("actionby", "admin");
-                    sqlFactory.addParameter("siteid", "lsa");
-                    sqldispatch.add(sqlFactory.getSQL());
-                }
-                for (Row row : undispatchrows) {
-                    sqldispatch.add("update sa_dispatch set status='复核',closedate=null,closeby='' where sa_dispatchid='" + row.getLong("sa_dispatchid") + "' and siteid='lsa'");
-                    sqldispatch.add("delete from sys_contrllog where ownertable='sa_dispatch' and action='自动关闭' and ownerid='" + row.getLong("sa_dispatchid") + "' and siteid='lsa'");
-                }
-
-                dbConnect.runSqlUpdate(sqldispatch);
-
-                //查询可关闭的订单
-                //订单出库总数量
-                Rows orderinstockrows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.siteid,sum(ifnull(t2.outwarehouseqty,0)) sumoutwarehouseqty from sa_orderitems t1 left join sa_dispatch_items t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where  t1.sa_orderid in(select t3.sa_orderid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t2.sa_orderitemsid=t3.sa_orderitemsid and t2.siteid=t3.siteid  where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='lsa')   group by t1.sa_orderid,t1.siteid");
-                //订单总数量
-                Rows ordersumrows = dbConnect.runSqlQuery("select t1.sa_orderid,t1.siteid,sum(qty) sumqty from sa_orderitems t1  where  t1.sa_orderid in(select t3.sa_orderid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t2.sa_orderitemsid=t3.sa_orderitemsid and t2.siteid=t3.siteid  where t1.st_stockbillid =" + stockbillrows.get(0).getLong("st_stockbillid") + " and t1.siteid='lsa')   group by t1.sa_orderid,t1.siteid");
-                RowsMap orderinstockRowsMap = orderinstockrows.toRowsMap("sa_orderid");
-
-
-                ArrayList<String> sqlorder = new ArrayList<>();
-                ArrayList<Long> sa_orderids = new ArrayList<>();
-                for (Row row : ordersumrows) {
-                    if (orderinstockRowsMap.containsKey(row.getString("sa_orderid"))) {
-                        if (orderinstockRowsMap.get(row.getString("sa_orderid")).get(0).getBigDecimal("sumoutwarehouseqty").compareTo(row.getBigDecimal("sumqty")) == 0) {
-                            sqlorder.add("update sa_order set status='关闭',closedate=current_time,closeby='admin' where sa_orderid='" + row.getLong("sa_orderid") + "' and siteid='lsa'");
-                            SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-                            sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-                            sqlFactory.addParameter("ownertable", "sa_order");
-                            sqlFactory.addParameter("ownerid", row.getLong("sa_orderid"));
-                            sqlFactory.addParameter("action", "自动关闭");
-                            sqlFactory.addParameter("remarks", "订单自动关闭成功");
-                            sqlFactory.addParameter("actionuserid", "1");
-                            sqlFactory.addParameter("actionby", "admin");
-                            sqlFactory.addParameter("siteid", "lsa");
-                            sqlorder.add(sqlFactory.getSQL());
-                            sa_orderids.add(row.getLong("sa_orderid"));
-                        } else {
-                            sqlorder.add("update sa_order set status='审核',closedate=null,closeby='' where sa_orderid='" + row.getLong("sa_orderid") + "' and siteid='lsa'");
-                            sqlorder.add("delete from sys_contrllog  where ownertable='sa_order' and action='自动关闭'  and  ownerid='" + row.getLong("sa_orderid") + "' and siteid='lsa'");
-                        }
-                    } else {
-                        sqlorder.add("update sa_order set status='审核',closedate=null,closeby='' where sa_orderid='" + row.getLong("sa_orderid") + "' and siteid='lsa'");
-                        sqlorder.add("delete from sys_contrllog  where ownertable='sa_order' and action='自动关闭'  and  ownerid='" + row.getLong("sa_orderid") + "' and siteid='lsa'");
-                    }
-
-                }
-                dbConnect.runSqlUpdate(sqlorder);
-
-
-                //是否自动返利结算
-                OrderItemsHelper orderItemsHelper = new OrderItemsHelper(this);
-                for (Long sa_orderid : sa_orderids) {
-                    orderItemsHelper.executeAutoRebate(sa_orderid, sys_enterpriseid);
-                }
-
-
-            }
-
-            /**
-             * 如单据为新建状态,则,先把单据强行删除掉
-             */
-            dbConnect.runSqlUpdate("delete from st_stockbill where status='新建'");
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            msg = e.getMessage();
-            if (msg == null) {
-                msg = "";
-            }
-            code = 0;
-            dbConnect.runSqlUpdate("delete from st_stockbill_items where  st_stockbillid in(select st_stockbillid from st_stockbill where siteid='lsa' and billno='" + fbillnum + "')");
-            dbConnect.runSqlUpdate("delete from st_stockbill where  billno='" + fbillnum + "' and siteid='lsa'");
-
-        }
-        JSONObject returnObject = new JSONObject();
-        returnObject.put("msg", msg);
-        returnObject.put("code", code);
-        return returnObject.toString();
-    }
-
-    public String getDate(String date) {
-        try {
-            Date a = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date);
-            return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(a);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public void sendMsg(String content, Long st_stockbillid, Long sys_enterpriseid) throws YosException {
-
-        ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid).toArrayList("userid", new ArrayList<>());
-        Remind remind = new Remind(this);
-        remind.setTitle("销售出库单消息");
-        remind.setContent(content);
-        remind.setType("应用");
-        remind.setObjectid(st_stockbillid);
-        remind.setObjectname("st_stockbill");
-        remind.setTouserid(userList);
-        remind.sendByDialogMsg().createSys_message();
-    }
-}

+ 0 - 135
src/custom/service/AftersalesmagAutoRecheckService.java

@@ -1,135 +0,0 @@
-package service;
-
-import beans.datacontrllog.DataContrlLog;
-import beans.uploaderpdata.UploadDataToERP_HY;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
-import common.parameter.properties;
-
-import org.apache.log4j.Logger;
-import utility.ERPDocking;
-import utility.tools.WebRequest;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Properties;
-
-
-/**
- * 换货单自动复核任务
- */
-public class AftersalesmagAutoRecheckService extends ServiceController {
-
-
-
-    private static Logger logger = Logger.getLogger(AftersalesmagAutoRecheckService.class);
-
-    String[] siteids = {"CCYOSG", "DLB"};
-
-    @Override
-
-    public void serviceRun() throws YosException {
-        for (String siteid : siteids) {
-            if (dbConnect.runSqlQuery("SELECT 1 from  sys_site WHERE siteid='" + siteid + "'").isEmpty()) {
-                continue;
-            }
-//            Properties yosProperties = properties.getYosProperties();
-//            if (yosProperties.getProperty("system.runmode.debug").equalsIgnoreCase("false")) {
-              if(false){
-                Rows rows = dbConnect.runSqlQuery("select * from sa_aftersalesmag where status='审核' and type='换货单' and siteid='" + siteid + "'");
-                RowsMap rowsMap1 = rows.toRowsMap("billno");
-                ArrayList<String> sqlList = new ArrayList<>();
-                ERPDocking erpDocking = new ERPDocking(siteid);
-                JSONArray ErpSareturns = erpDocking.queryErpSareturns(10000, 1, new JSONArray(), "", "", "换货", "", true);
-                if (!ErpSareturns.isEmpty()) {
-                    for (Object ErpSareturn : ErpSareturns) {
-                        JSONObject erpSareturn = (JSONObject) ErpSareturn;
-                        String billno = erpSareturn.getString("freturnnum");
-                        long sa_aftersalesmagid = 0;
-                        if (rowsMap1.containsKey(billno)) {
-                            if (rowsMap1.get(billno).isNotEmpty()) {
-                                sa_aftersalesmagid = rowsMap1.get(billno).get(0).getLong("sa_aftersalesmagid");
-                            } else {
-                                logger.info("退货单【" + billno + "】不存在:");
-                                continue;
-                            }
-                        } else {
-                            logger.info("退货单【" + billno + "】不存在:");
-                            continue;
-                        }
-                        JSONObject object = new JSONObject();
-                        JSONObject objectdetail = new JSONObject();
-                        object.put("access_token", "basicDrp");
-                        object.put("classname", "Sareturn");
-                        object.put("method", "closeSareturn");
-                        objectdetail.put("freturnnum", billno);
-                        objectdetail.put("isManual", false);
-                        object.put("content", objectdetail);
-
-                        HashMap<String, String> map = new HashMap<>();
-                        map.put("content-Type", "application/json");
-                        String result = new WebRequest().doPost(object.toString(), erpDocking.getUrl(), map);
-
-                        JSONObject resultobject = JSONObject.parseObject(result);
-                        try {
-                            Rows erpupdatelogRows = dbConnect.runSqlQuery(
-                                    "select * from sys_erpupdatelog where ownertable='sa_aftersalesmag' and type='复核erp退/换货单' and ownerid=" + sa_aftersalesmagid);
-                            SQLFactory sqlFactory;
-                            if (!erpupdatelogRows.isEmpty()) {
-                                sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志更新");
-                                sqlFactory.addParameter("sys_erpupdatelogid", erpupdatelogRows.get(0).getLong("sys_erpupdatelogid"));
-                            } else {
-                                sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志新增");
-                                sqlFactory.addParameter("sys_erpupdatelogid", createTableID("sys_erpupdatelog"));
-                            }
-                            sqlFactory.addParameter("siteid", siteid);
-                            sqlFactory.addParameter("userid", 1);
-                            sqlFactory.addParameter("username", "admin");
-                            sqlFactory.addParameter("ownerid", sa_aftersalesmagid);
-                            sqlFactory.addParameter("ownertable", "sa_aftersalesmag");
-                            sqlFactory.addParameter("type", "复核erp退/换货单");
-                            sqlFactory.addParameter("request", object.toString());
-                            sqlFactory.addParameter("response", resultobject.toJSONString());
-
-                            if ("0".equals(resultobject.getString("errcode"))) {
-                                sqlFactory.addParameter("erpbillno", billno);
-                                sqlFactory.addParameter("errmsg", "");
-                            } else {
-                                sqlFactory.addParameter("erpbillno", "");
-                                sqlFactory.addParameter("errmsg", resultobject.getString("errmsg"));
-                            }
-                            sqlFactory.addParameter("status", resultobject.getString("errcode"));
-                            sqlList.add(sqlFactory.getSQL());
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                        if (resultobject.getString("errcode").equals("0")) {
-                            sqlList.add("update sa_aftersalesmag set status='复核' where sa_aftersalesmagid='" + sa_aftersalesmagid + "' and siteid='" + siteid + "'");
-                            SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-                            sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-                            sqlFactory.addParameter("ownertable", "sa_aftersalesmag");
-                            sqlFactory.addParameter("ownerid", sa_aftersalesmagid);
-                            sqlFactory.addParameter("action", "自动复核");
-                            sqlFactory.addParameter("remarks", "换货单自动复核成功");
-                            sqlFactory.addParameter("actionuserid", "1");
-                            sqlFactory.addParameter("actionby", "admin");
-                            sqlFactory.addParameter("siteid", siteid);
-                            sqlList.add(sqlFactory.getSQL());
-                        } else {
-                            logger.info("换货单自动复核错误:" + resultobject.getString("errmsg"));
-                        }
-                    }
-                }
-                dbConnect.runSqlUpdate(sqlList);
-            }
-        }
-    }
-
-
-}

+ 0 - 306
src/custom/service/AutoDockItemService.java

@@ -1,306 +0,0 @@
-package service;
-
-import beans.parameter.Parameter;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.BaseClass;
-import common.ServiceController;
-import common.YosException;
-import common.data.*;
-import common.data.db.DBConnect;
-import common.data.db.initialization.base.YosObject;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
-import restcontroller.webmanage.sale.item.Item;
-import utility.ERPDocking;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-public class AutoDockItemService extends ServiceController {
-
-    String[] siteids = {"CCYOSG", "DLB"};
-
-    @Override
-    public void serviceRun() throws YosException {
-        for (String siteid : siteids) {
-            if (dbConnect.runSqlQuery("SELECT 1 from  sys_site WHERE siteid='" + siteid + "'").isEmpty()) {
-                continue;
-            }
-
-            String paramname = "AutoDockItemServiceTime" + "_" + siteid;
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Etc/GMT-8"));
-            String AutoDockItemServiceTime = getAutoDockItemServiceTime(paramname, simpleDateFormat);
-
-            ArrayList<String> sqlList = new ArrayList<>();
-            Rows itemRows = dbConnect.runSqlQuery("SELECT itemid,itemno from  plm_item WHERE siteid = '" + siteid + "' AND status = '新建' ");
-            Rows itemRowsAll = dbConnect.runSqlQuery("SELECT itemid,itemno,status,isonsale,sa_customschemeid from  plm_item WHERE siteid = '" + siteid + "'");
-            //单位
-            Rows unitRows = dbConnect.runSqlQuery("SELECT unitid,unitname from  plm_unit WHERE siteid = '" + siteid + "'");
-            RowsMap unitRowsMap = unitRows.toRowsMap("unitname");
-
-            RowsMap itemRowsMap = itemRows.toRowsMap("itemno");
-            RowsMap itemRowsMapAll = itemRowsAll.toRowsMap("itemno");
-            ERPDocking erpDocking = new ERPDocking(siteid);
-
-            JSONArray jsonArray = erpDocking.getErpItemRows(AutoDockItemServiceTime, 100000, 1);
-            if (!jsonArray.isEmpty()) {
-                for (Object object : jsonArray) {
-                    JSONObject jsonObject = (JSONObject) object;
-                    System.err.println(jsonObject);
-                    if (!itemRowsMapAll.containsKey(jsonObject.getString("fitemno"))) {
-                        long itemid = createTableID("plm_item");
-                        SQLFactory sqlFactory = new SQLFactory(new Item(jsonObject), "货品档案新增");
-
-                        sqlFactory.addParameter("siteid", siteid);
-                        sqlFactory.addParameter("itemid", itemid);
-                        sqlFactory.addParameter("username", "admin");
-                        sqlFactory.addParameter("userid", 1);
-                        sqlFactory.addParameter("itemno", jsonObject.getString("fitemno"));
-                        sqlFactory.addParameter("marketingcategory", "");
-                        if (unitRowsMap.containsKey(jsonObject.getString("funit"))) {
-                            sqlFactory.addParameter("unitid", unitRowsMap.get(jsonObject.getString("funit")).get(0).getLong("unitid"));
-                        } else {
-                            sqlFactory.addParameter("unitid", 0);
-                        }
-                        sqlFactory.addParameter("isauxunit", 0);
-                        sqlFactory.addParameter("unitgroupid", "null");
-
-                        sqlFactory.addParameter("itemname", jsonObject.getString("fitemname"));
-                        sqlFactory.addParameter("isonsale", 0);
-                        sqlFactory.addParameter("model", jsonObject.getString("fmodel"));
-                        sqlFactory.addParameter("spec", jsonObject.getString("spec"));
-                        // 订单起订量
-                        sqlFactory.addParameter("orderminqty", 1);
-                        // 订单增量
-                        sqlFactory.addParameter("orderaddqty", 1);
-                        // 订单起订量控制单位(0:主单位;1:辅助单位)
-                        sqlFactory.addParameter("orderminqty_auxunit", 0);
-                        // 订单增量控制单位(0:主单位;1:辅助单位)
-                        sqlFactory.addParameter("orderaddqty_auxunit", 0);
-                        // 说明
-                        sqlFactory.addParameter("remarks", "");
-                        // 商品条形码
-                        sqlFactory.addParameter("barcode", "");
-                        // 是否单品管理
-                        sqlFactory.addParameter("skucontrol", 0);
-                        // 是否批次管理
-                        sqlFactory.addParameter("batchcontrol", jsonObject.getBooleanValue("fisbatch"));
-                        // 毛重(g)
-                        sqlFactory.addParameter("grossweight", 0);
-                        // 净重(g)
-                        sqlFactory.addParameter("weight", 0);
-                        // 高度(mm)
-                        sqlFactory.addParameter("height", 0);
-                        // 宽度(mm)
-                        sqlFactory.addParameter("width", 0);
-                        // 长度(mm)
-                        sqlFactory.addParameter("length", 0);
-                        // 交期
-                        sqlFactory.addParameter("delivery", 1);
-                        // 牌价
-                        sqlFactory.addParameter("marketprice", 0);
-                        // 是否工具
-                        sqlFactory.addParameter("istool", 0);
-                        // 产品标准
-                        sqlFactory.addParameter("standards", "");
-                        // 库存缺货标准
-                        sqlFactory.addParameter("stockstatus2", 1);
-                        // 库存充足标准
-                        sqlFactory.addParameter("stockstatus1", 1);
-                        // 保修期(年)
-                        sqlFactory.addParameter("warrantyday", 1);
-                        // 是否营销物料
-                        sqlFactory.addParameter("iswuliao", 0);
-                        // 是否服务物料
-                        sqlFactory.addParameter("isservice", 0);
-
-                        sqlFactory.addParameter("materialschemeid", 0);
-                        sqlFactory.addParameter("colorschemeid", 0);
-                        sqlFactory.addParameter("cheekschemeid", 0);
-
-
-                        sqlFactory.addParameter("color", jsonObject.getStringValue("fcolor"));
-                        sqlFactory.addParameter("cheek", jsonObject.getStringValue("fsizedescription"));
-                        sqlFactory.addParameter("delistingstatus", "");
-
-                        sqlFactory.addParameter("ismodule", 0);
-                        sqlFactory.addParameter("packageqty", (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")));
-                        sqlFactory.addParameter("iswoodproducts", 0);
-
-                        sqlFactory.addParameter("sa_customschemeid", 0);
-                        sqlFactory.addParameter("financeclasstype", jsonObject.getStringValue("fdescription"));
-                        sqlFactory.addParameter("stockno", jsonObject.getStringValue("fstockno"));
-                        sqlFactory.addParameter("volume", jsonObject.getBigDecimal("fvolume"));
-                        sqlFactory.addParameter("pricingmetod", "2");
-
-                        sqlFactory.addParameter("saleprice", 0);
-                        sqlFactory.addParameter("cost", 0);
-                        sqlFactory.addParameter("grossprofit", 0);
-                        sqlFactory.addParameter("grossprofitmargin", 0);
-
-                        sqlList.add(sqlFactory.getSQL());
-                        // 货品档案扩展属性字段表
-
-                        sqlFactory = new SQLFactory(new Item(jsonObject), "货品档案-扩展新增");
-                        sqlFactory.addParameter("siteid", siteid);
-                        sqlFactory.addParameter("userid", 1);
-                        sqlFactory.addParameter("username", "admin");
-                        sqlFactory.addParameter("plm_itemextendid", createTableID("plm_itemextend"));
-                        sqlFactory.addParameter("itemid", itemid);
-                        sqlFactory.addParameter("material", jsonObject.getString("fmaterialdes"));
-                        sqlFactory.addParameter("pressure", "");
-                        sqlFactory.addParameter("caliber", "");
-                        sqlFactory.addParameter("butterflyplatedrive", "");
-                        sqlFactory.addParameter("connection", "");
-                        sqlFactory.addParameter("valveplatematerial", "");
-                        sqlFactory.addParameter("bodymaterial", "");
-                        sqlFactory.addParameter("actuatortype", "");
-                        sqlFactory.addParameter("actuatorbrand", "");
-                        sqlFactory.addParameter("isbutterfly", 0);
-                        sqlFactory.addParameter("erpitemno", jsonObject.getString("fitemno"));
-                        sqlFactory.addParameter("erpitemname", jsonObject.getString("fitemname"));
-                        sqlFactory.addParameter("specalnote", "");
-                        sqlFactory.addParameter("prodline", "");
-                        sqlFactory.addParameter("device", "");
-                        sqlList.add(sqlFactory.getSQL());
-
-                        // 添加领域
-                        Rows tradefieldRows = dbConnect.runSqlQuery("select value,siteid from sys_optiontypemx where isused=1 and (ifnull(siteid,'')='' or siteid='"+siteid+"') and optiontypeid in(select optiontypeid from sys_optiontype where typename='tradefield')");
-                        if (tradefieldRows.isNotEmpty() && tradefieldRows.size()==1) {
-                            sqlFactory = new SQLFactory(new Item(jsonObject), "新增领域");
-                            sqlFactory.addParameter("siteid", siteid);
-                            sqlFactory.addParameter("plm_item_tradefieldid", createTableID("plm_item_tradefield"));
-                            sqlFactory.addParameter("tradefield", tradefieldRows.get(0).getString("value"));
-                            sqlFactory.addParameter("userid", 1);
-                            sqlFactory.addParameter("itemid", itemid);
-                            sqlList.add(sqlFactory.getSQL());
-
-                        }
-
-
-
-                    } else {
-//                        sqlList.add("update plm_item set itemname='" + jsonObject.getString("fitemname") + "',volume='" + jsonObject.getStringValue("fvolume") + "',packageqty='" + (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")) + "' where itemid=" + itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid"));
-//                        System.out.println("update plm_item set itemname='" + jsonObject.getString("fitemname") + "',volume='" + jsonObject.getStringValue("fvolume") + "',packageqty='" + (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")) + "' where itemid=" + itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid"));
-                        Long itemid = itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid");
-                        String spec = jsonObject.getStringValue("spec");//尺寸
-                        String cheek = jsonObject.getStringValue("fsizedescription");//工艺
-                        String material = jsonObject.getStringValue("fmaterialdes");//选项
-                        String color = jsonObject.getStringValue("fcolor");//颜色
-                        boolean isonsale = itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getBoolean("isonsale");
-                        if (dbConnect.runSqlQuery("SELECT 1 FROM plm_item t1 LEFT JOIN plm_itemextend t2 ON t2.itemid=t1.itemid AND t2.siteid=t1.siteid " +
-                                "WHERE spec='" + spec + "' AND cheek='" + cheek + "' AND material='" + material + "' AND color='" + color + "'").isEmpty() && itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("sa_customschemeid")!=0) {
-                            isonsale = false;
-                            sqlList.add("delete from sa_itemgroupmx WHERE itemid=" + itemid + " and siteid='" + siteid + "' ");
-                            Rows rows = dbConnect.runSqlQuery("SELECT sa_itemgroupid from sa_itemgroupmx WHERE itemid=" + itemid + " and siteid='" + siteid + "' ");
-                            ArrayList<Long> sa_itemgroupids = rows.toArrayList("sa_itemgroupid", new ArrayList<>());
-                            for (Long sa_itemgroupid : sa_itemgroupids) {
-                                int count = dbConnect.runSqlQuery(0, "SELECT count(0) count from sa_itemgroupmx WHERE sa_itemgroupid=" + sa_itemgroupid + " and siteid='" + siteid + "' ").getInteger("count");
-                                if (count == 1) {
-                                    sqlList.add("delete from sa_itemgroup WHERE sa_itemgroupid=" + sa_itemgroupid + " and siteid='" + siteid + "' ");
-                                }
-                            }
-                        }
-
-                        if (itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("sa_customschemeid")==0) {
-                            Rows rows = dbConnect.runSqlQuery("SELECT sa_itemgroupid from sa_itemgroupmx WHERE itemid=" + itemid + " and siteid='" + siteid + "' ");
-                            ArrayList<Long> sa_itemgroupids = rows.toArrayList("sa_itemgroupid", new ArrayList<>());
-                            for (Long sa_itemgroupid : sa_itemgroupids) {
-                                int count = dbConnect.runSqlQuery(0, "SELECT count(0) count from sa_itemgroupmx WHERE sa_itemgroupid=" + sa_itemgroupid + " and siteid='" + siteid + "' ").getInteger("count");
-                                if (count == 1) {
-                                    sqlList.add("update sa_itemgroup set groupname='"+jsonObject.getString("fitemname")+"' where sa_itemgroupid=" + sa_itemgroupid + " and siteid='" + siteid + "' ");
-                                }
-                            }
-                        }
-                        boolean iscustomsize = false;
-                        if (spec.equals("custom") || cheek.equals("custom") || material.equals("custom") || color.equals("custom")) {
-                            iscustomsize = true;
-                        }
-
-                        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(new DBConnect(), "plm_item");
-                        updateSQL.setWhere("itemid", itemid);
-                        updateSQL.setSiteid(siteid);
-                        updateSQL.setValue("isonsale", isonsale);
-                        updateSQL.setValue("iscustomsize", iscustomsize);
-                        updateSQL.setValue("itemname", jsonObject.getString("fitemname"));
-                        updateSQL.setValue("volume", jsonObject.getStringValue("fvolume"));
-                        updateSQL.setValue("packageqty", (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")));
-                        updateSQL.setValue("itemno", jsonObject.getString("fitemno"));//商品编码
-                        updateSQL.setValue("model", jsonObject.getString("fmodel"));//型号
-                        updateSQL.setValue("cheek", cheek);//工艺
-                        updateSQL.setValue("changeuserid","1");
-                        updateSQL.setValue("changeby","admin");
-                        updateSQL.setValue("changedate",getDateTime_Str());
-                        updateSQL.setValue("itemname", jsonObject.getString("fitemname"));//品名
-//                        updateSQL.setValue("standards","");//规格
-                        updateSQL.setValue("color", color);//颜色
-                        updateSQL.setValue("batchcontrol", jsonObject.getBooleanValue("fisbatch"));//批次管理
-                        if (unitRowsMap.containsKey(jsonObject.getString("funit"))) {
-                            updateSQL.setValue("unitid", unitRowsMap.get(jsonObject.getString("funit")).get(0).getLong("unitid"));
-                        } else {
-                            updateSQL.setValue("unitid", 0);
-                        }
-                        updateSQL.setValue("spec", spec);//尺寸
-                        if(!iscustomsize){
-                            //updateSQL.setValue("sa_customschemeid", 0);
-                            updateSQL.setValue("materialschemeid", 0);
-                            updateSQL.setValue("colorschemeid", 0);
-                            updateSQL.setValue("cheekschemeid", 0);
-                            updateSQL.setValue("widthschemeid", 0);
-                            updateSQL.setValue("lengthschemeid", 0);
-                        }
-                        sqlList.add(updateSQL.getSQL());
-
-                        if(dbConnect.runSqlQuery("SELECT 1 FROM plm_itemextend WHERE itemid='" + itemid + "'").isEmpty()){
-                            InsertSQL insertSQL = SQLFactory.createInsertSQL(new DBConnect(), "plm_itemextend");
-                            insertSQL.setValue("plm_itemextendid", createTableID("plm_itemextend"));
-                            insertSQL.setValue("siteid", siteid);
-                            insertSQL.setValue("material", material);
-                            insertSQL.setValue("changeuserid","1");
-                            insertSQL.setValue("itemid", itemid);
-                            sqlList.add(insertSQL.getSQL());
-                        }else{
-                            UpdateSQL updateSQL2 = SQLFactory.createUpdateSQL(new DBConnect(), "plm_itemextend");
-                            updateSQL2.setWhere("itemid", itemid);
-                            updateSQL2.setSiteid(siteid);
-                            updateSQL2.setValue("changeuserid","1");
-                            updateSQL2.setValue("material", material);//颜色
-                            sqlList.add(updateSQL2.getSQL());
-                        }
-
-
-                    }
-
-                }
-            }
-            for (String s:
-            sqlList) {
-                System.err.println(s);
-            }
-
-            dbConnect.runSqlUpdate(sqlList);
-
-            YosObject.createParameter( YosObject.ParamType.文本, paramname, simpleDateFormat.format(new Date()), "");
-        }
-    }
-
-    public String getAutoDockItemServiceTime(String paramname, SimpleDateFormat simpleDateFormat) throws YosException {
-        Rows rows = new DBConnect().runSqlQuery("select * from sys_parameter where paramname='" + paramname + "'");
-        Date date = new Date();
-        String AutoDockItemServiceTime = simpleDateFormat.format(date);
-        if (rows.isNotEmpty()) {
-            AutoDockItemServiceTime = rows.get(0).getString("paramvalue");
-            dbConnect.runSqlUpdate("delete from sys_parameter where paramname='" + paramname + "'");
-        } else {
-            YosObject.createParameter( YosObject.ParamType.文本, paramname, simpleDateFormat.format(date), "");
-        }
-
-        return AutoDockItemServiceTime;
-    }
-
-}

+ 0 - 37
src/custom/service/AutoQueryBoclnfosForJH_HY.java

@@ -1,37 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.JHUtils.BBC;
-
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.util.ArrayList;
-
-public class AutoQueryBoclnfosForJH_HY extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        LocalDate now = LocalDate.now();
-        int today = Integer.parseInt(new SimpleDateFormat("yyyyMMdd").format(now));
-        int yesterday = Integer.parseInt(new SimpleDateFormat("yyyyMMdd").format(now.minusDays(1)));
-        String siteid = "HY";
-        JSONArray jsonArray = new BBC().query(siteid, yesterday, today);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "建行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-}

+ 0 - 37
src/custom/service/AutoQueryBoclnfosForJH_NB.java

@@ -1,37 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.JHUtils.BBC;
-
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.util.ArrayList;
-
-public class AutoQueryBoclnfosForJH_NB extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        LocalDate now = LocalDate.now();
-        int today = Integer.parseInt(new SimpleDateFormat("yyyyMMdd").format(now));
-        int yesterday = Integer.parseInt(new SimpleDateFormat("yyyyMMdd").format(now.minusDays(1)));
-        String siteid = "NB";
-        JSONArray jsonArray = new BBC().query(siteid, yesterday, today);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "建行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-}

+ 0 - 37
src/custom/service/AutoQueryBoclnfosForJH_TZ.java

@@ -1,37 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.JHUtils.BBC;
-
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.util.ArrayList;
-
-public class AutoQueryBoclnfosForJH_TZ extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        LocalDate now = LocalDate.now();
-        int today = Integer.parseInt(new SimpleDateFormat("yyyyMMdd").format(now));
-        int yesterday = Integer.parseInt(new SimpleDateFormat("yyyyMMdd").format(now.minusDays(1)));
-        String siteid = "TZ";
-        JSONArray jsonArray = new BBC().query(siteid, yesterday, today);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "建行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-}

+ 0 - 46
src/custom/service/AutoQueryBoclnfosForNH_HY.java

@@ -1,46 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.NHUtils.qyzl;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-
-public class AutoQueryBoclnfosForNH_HY extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        int HOUR_OF_DAY = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
-        if (HOUR_OF_DAY <= 6) {
-            return;
-        }
-        String StartDate;
-        String siteid = "HY";
-        Rows rows = dbConnect.runSqlQuery("select tranflow from sa_bankstatement where siteid='" + siteid + "' and banktype='农行' order by tranflow desc");
-        if (rows.isEmpty()) {
-            StartDate = "0";
-        } else {
-            String tranflow = rows.get(0).getString("tranflow");
-            StartDate = tranflow.substring(0, 8);
-        }
-        JSONArray jsonArray = new qyzl().query(siteid, StartDate);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "农行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-
-}

+ 0 - 46
src/custom/service/AutoQueryBoclnfosForNH_NB.java

@@ -1,46 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.NHUtils.qyzl;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-
-public class AutoQueryBoclnfosForNH_NB extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        int HOUR_OF_DAY = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
-        if (HOUR_OF_DAY <= 6) {
-            return;
-        }
-        String StartDate;
-        String siteid = "NB";
-        Rows rows = dbConnect.runSqlQuery("select tranflow from sa_bankstatement where siteid='" + siteid + "' and banktype='农行' order by tranflow desc");
-        if (rows.isEmpty()) {
-            StartDate = "0";
-        } else {
-            String tranflow = rows.get(0).getString("tranflow");
-            StartDate = tranflow.substring(0, 8);
-        }
-        JSONArray jsonArray = new qyzl().query(siteid, StartDate);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "农行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-
-}

+ 0 - 46
src/custom/service/AutoQueryBoclnfosForNH_TZ.java

@@ -1,46 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.NHUtils.qyzl;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-
-public class AutoQueryBoclnfosForNH_TZ extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        int HOUR_OF_DAY = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
-        if (HOUR_OF_DAY <= 6) {
-            return;
-        }
-        String StartDate;
-        String siteid = "TZ";
-        Rows rows = dbConnect.runSqlQuery("select tranflow from sa_bankstatement where siteid='" + siteid + "' and banktype='农行' order by tranflow desc");
-        if (rows.isEmpty()) {
-            StartDate = "0";
-        } else {
-            String tranflow = rows.get(0).getString("tranflow");
-            StartDate = tranflow.substring(0, 8);
-        }
-        JSONArray jsonArray = new qyzl().query(siteid, StartDate);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "农行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-
-}

+ 0 - 38
src/custom/service/AutoQueryBoclnfosForZH_HY.java

@@ -1,38 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.ZHUtils.BOC;
-
-import java.util.ArrayList;
-
-public class AutoQueryBoclnfosForZH_HY extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        String siteid = "HY";
-        Rows rows = dbConnect.runSqlQuery("select count(0) sum from sa_bankstatement where datediff(now(),createdate)=0 and siteid='" + siteid + "' and banktype ='中行'");
-        long begnum = rows.get(0).getLong("sum") + 1;
-        if (begnum == 0) {
-            begnum = 1;
-        }
-
-        JSONArray jsonArray = new BOC().query(siteid, (int) begnum);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "中行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-}

+ 0 - 38
src/custom/service/AutoQueryBoclnfosForZH_NB.java

@@ -1,38 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.ZHUtils.BOC;
-
-import java.util.ArrayList;
-
-public class AutoQueryBoclnfosForZH_NB extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        String siteid = "NB";
-        Rows rows = dbConnect.runSqlQuery("select count(0) sum from sa_bankstatement where datediff(now(),createdate)=0 and siteid='" + siteid + "' and banktype ='中行'");
-        long begnum = rows.get(0).getLong("sum") + 1;
-        if (begnum == 0) {
-            begnum = 1;
-        }
-
-        JSONArray jsonArray = new BOC().query(siteid, (int) begnum);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "中行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-}

+ 0 - 38
src/custom/service/AutoQueryBoclnfosForZH_TZ.java

@@ -1,38 +0,0 @@
-package service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import restcontroller.webmanage.sale.bankstatement.CreateBankstatement;
-import restcontroller.webmanage.sale.bankstatement.ZHUtils.BOC;
-
-import java.util.ArrayList;
-
-public class AutoQueryBoclnfosForZH_TZ extends ServiceController {
-
-
-    @Override
-    public void serviceRun() throws YosException {
-        String siteid = "TZ";
-        Rows rows = dbConnect.runSqlQuery("select count(0) sum from sa_bankstatement where datediff(now(),createdate)=0 and siteid='" + siteid + "' and banktype ='中行'");
-        long begnum = rows.get(0).getLong("sum") + 1;
-        if (begnum == 0) {
-            begnum = 1;
-        }
-
-        JSONArray jsonArray = new BOC().query(siteid, (int) begnum);
-        if (!jsonArray.isEmpty()) {
-            JSONObject jsonObject = CreateBankstatement.createBankstatement(this, jsonArray, siteid, "中行");
-            dbConnect.runSqlUpdate((ArrayList<String>) jsonObject.get("sqlList"));
-            ArrayList<Long> idList = (ArrayList<Long>) jsonObject.get("idList");
-            for (Long id : idList) {
-                Rows statusRows = dbConnect.runSqlQuery("select status from sa_bankstatement where siteid='" + siteid + "' and sa_bankstatementid=" + id);
-                if (statusRows.isNotEmpty() && statusRows.get(0).getString("status").equals("未入账")) {
-                    CreateBankstatement.autoRemind(this, "bankstatementerr", id, siteid);
-                }
-            }
-        }
-    }
-}

+ 0 - 502
src/custom/service/DispatchAutoCloseService.java

@@ -1,502 +0,0 @@
-package service;
-
-import beans.accountbalance.Accountbalance;
-import beans.accountbalance.CashbillEntity;
-import beans.datacontrllog.DataContrlLog;
-import beans.itemclass.ItemClass;
-import beans.order.Order;
-import beans.parameter.Parameter;
-import beans.remind.Remind;
-import beans.uploaderpdata.UploadDataToERP_HY;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.ServiceController;
-import common.YosException;
-import common.data.*;
-import common.parameter.properties;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import restcontroller.webmanage.executorService.Executor;
-import restcontroller.webmanage.sale.order.OrderItemsHelper;
-import utility.ERPDocking;
-import utility.tools.WebRequest;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Properties;
-
-
-/**
- * 发货单自动关闭任务
- */
-public class DispatchAutoCloseService extends ServiceController {
-
-    private static Logger logger = Logger.getLogger(DispatchAutoCloseService.class);
-    String[] siteids = {"CCYOSG", "DLB"};
-
-    @Override
-
-    public void serviceRun() throws YosException {
-        for (String siteid : siteids) {
-            if (dbConnect.runSqlQuery("SELECT 1 from  sys_site WHERE siteid='" + siteid + "'").isEmpty()) {
-                continue;
-            }
-
-//            Properties yosProperties = properties.getYosProperties();
-//            if (yosProperties.getProperty("system.runmode.debug").equalsIgnoreCase("false")) {
-            if(false){
-                Rows rows = dbConnect.runSqlQuery("select * from sa_dispatch where status='复核' and siteid='" + siteid + "'");
-                Rows rowsdetail = dbConnect.runSqlQuery("select t1.* from sa_dispatch_items t1 inner join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid where t2.status='复核' and t1.siteid='" + siteid + "'");
-                RowsMap rowsMap = rowsdetail.toRowsMap("sa_dispatchid");
-                RowsMap rowsMap1 = rowsdetail.toRowsMap("billno");
-                ArrayList<String> sqlList = new ArrayList<>();
-                ERPDocking erpDocking = new ERPDocking(siteid);
-                JSONArray ErpSainvoices = erpDocking.queryErpSainvoices(10000, 1, new JSONArray(), "", "", "", false, false, true);
-                JSONArray dispatchids = new JSONArray();
-                JSONArray unclosedispatchids = new JSONArray();
-                if (!ErpSainvoices.isEmpty()) {
-                    for (Object ErpSainvoice : ErpSainvoices) {
-                        JSONObject erpSainvoice = (JSONObject) ErpSainvoice;
-                        String billno = erpSainvoice.getString("finvonum");
-                        long sa_dispatchid = 0;
-                        if (rowsMap1.containsKey(billno)) {
-                            if (rowsMap1.get(billno).isNotEmpty()) {
-                                sa_dispatchid = rowsMap1.get(billno).get(0).getLong("sa_dispatchid");
-                                dispatchids.add(sa_dispatchid);
-                            } else {
-                                logger.info("发货单【" + billno + "】不存在:");
-                                continue;
-                            }
-                        } else {
-                            logger.info("发货单【" + billno + "】不存在:");
-                            continue;
-                        }
-                        JSONArray jsonArray = erpDocking.queryErpSainvoice(billno);
-
-                        JSONObject object = new JSONObject();
-                        JSONObject objectdetail = new JSONObject();
-                        object.put("access_token", "basicDrp");
-                        object.put("classname", "Sainvoice");
-                        object.put("method", "closeSainvoice");
-                        objectdetail.put("finvonum", billno);
-                        objectdetail.put("isManual", false);
-                        object.put("content", objectdetail);
-
-                        HashMap<String, String> map = new HashMap<>();
-                        map.put("content-Type", "application/json");
-                        String result = new WebRequest().doPost(object.toString(), erpDocking.getUrl(), map);
-                        JSONObject resultobject = JSONObject.parseObject(result);
-
-                        try {
-                            Rows erpupdatelogRows = dbConnect.runSqlQuery(
-                                    "select * from sys_erpupdatelog where ownertable='sa_dispatch' and type='关闭发货单' and ownerid=" + sa_dispatchid);
-                            SQLFactory sqlFactory;
-                            if (!erpupdatelogRows.isEmpty()) {
-                                sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志更新");
-                                sqlFactory.addParameter("sys_erpupdatelogid", erpupdatelogRows.get(0).getLong("sys_erpupdatelogid"));
-                            } else {
-                                sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志新增");
-                                sqlFactory.addParameter("sys_erpupdatelogid", createTableID("sys_erpupdatelog"));
-                            }
-                            sqlFactory.addParameter("siteid", siteid);
-                            sqlFactory.addParameter("userid", 1);
-                            sqlFactory.addParameter("username", "admin");
-                            sqlFactory.addParameter("ownerid", sa_dispatchid);
-                            sqlFactory.addParameter("ownertable", "sa_dispatch");
-                            sqlFactory.addParameter("type", "关闭发货单");
-                            sqlFactory.addParameter("request", object.toString());
-                            sqlFactory.addParameter("response", resultobject.toJSONString());
-
-                            if ("0".equals(resultobject.getString("errcode"))) {
-                                sqlFactory.addParameter("erpbillno", billno);
-                                sqlFactory.addParameter("errmsg", "");
-                            } else {
-                                sqlFactory.addParameter("erpbillno", "");
-                                sqlFactory.addParameter("errmsg", resultobject.getString("errmsg"));
-                            }
-                            sqlFactory.addParameter("status", resultobject.getString("errcode"));
-                            sqlList.add(sqlFactory.getSQL());
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-
-                        if (resultobject.getString("errcode").equals("0")) {
-                            sqlList.add("update sa_dispatch set status='关闭',closedate=current_time,closeby='admin' where sa_dispatchid='" + sa_dispatchid + "' and siteid='" + siteid + "'");
-                            SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-                            sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-                            sqlFactory.addParameter("ownertable", "sa_dispatch");
-                            sqlFactory.addParameter("ownerid", sa_dispatchid);
-                            sqlFactory.addParameter("action", "自动关闭");
-                            sqlFactory.addParameter("remarks", "发货单自动关闭成功");
-                            sqlFactory.addParameter("actionuserid", "1");
-                            sqlFactory.addParameter("actionby", "admin");
-                            sqlFactory.addParameter("siteid", siteid);
-                            sqlList.add(sqlFactory.getSQL());
-                        } else {
-                            unclosedispatchids.add(sa_dispatchid);
-                            logger.info("发货单自动关闭错误:" + resultobject.getString("errmsg") + "发货单id:" + sa_dispatchid);
-                        }
-                        if (!jsonArray.isEmpty()) {
-                            for (Object object1 : jsonArray) {
-                                JSONObject jsonObject = (JSONObject) object1;
-                                sqlList.add("update sa_dispatch_items set outwarehousedate=current_time,outwarehouseqty=" + jsonObject.getBigDecimal("fqty1") + " where rowno =" + jsonObject.getIntValue("frownum") + " and sa_dispatchid='" + sa_dispatchid + "' and siteid='" + siteid + "'");
-                            }
-                        }
-
-
-                    }
-                }
-                dbConnect.runSqlUpdate(sqlList);
-
-
-                //判断当前单据是否已实际发完货,如果发完,则生把订单变为关闭状态
-                Rows orderRows = new Rows();
-                if (dispatchids.size() > 0) {
-                    String sql = "select distinct t1.sa_orderid from sa_orderitems t1 inner join sa_dispatch_items t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='" + siteid + "' and t2.sa_dispatchid in" + dispatchids.toJSONString();
-                    sql = sql.replace("[", "(").replace("]", ")");
-                    logger.info("sql:" + sql);
-                    orderRows = dbConnect.runSqlQuery(sql);
-                }
-                //总数量
-                Rows totalRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems where siteid='" + siteid + "' group by sa_orderid");
-                RowsMap totalRowsMap = totalRows.toRowsMap("sa_orderid");
-                //已发完数量
-                Rows deliRows = dbConnect.runSqlQuery("select count(1) count,sa_orderid from sa_orderitems t1 inner join (SELECT  t1.sa_orderitemsid,t1.siteid,SUM(ifnull(t1.outwarehouseqty,0)) outwarehouseqty FROM sa_dispatch_items t1 WHERE t1.siteid='" + siteid + "' group by t1.sa_orderitemsid,t1.siteid) t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.qty=t2.outwarehouseqty and t1.siteid='" + siteid + "' group by sa_orderid");
-                RowsMap deliRowsMap = deliRows.toRowsMap("sa_orderid");
-                if (orderRows.size() > 0) {
-                    for (Row row : orderRows) {
-                        logger.info("订单id:" + row.getString("sa_orderid"));
-                        if (totalRowsMap.containsKey(row.getString("sa_orderid")) && deliRowsMap.containsKey(row.getString("sa_orderid"))) {
-                            if (totalRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count") == deliRowsMap.get(row.getString("sa_orderid")).get(0).getLong("count")) {
-                                logger.info("订单关闭:update sa_order set status='关闭',closedate=current_time,closeby='admin' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
-                                dbConnect.runSqlUpdate("update sa_order set status='关闭',closedate=current_time,closeby='admin' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
-                                SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-                                sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-                                sqlFactory.addParameter("ownertable", "sa_order");
-                                sqlFactory.addParameter("ownerid", row.getLong("sa_orderid"));
-                                sqlFactory.addParameter("action", "自动关闭");
-                                sqlFactory.addParameter("remarks", "订单数量发完自动关闭");
-                                sqlFactory.addParameter("actionuserid", "1");
-                                sqlFactory.addParameter("actionby", "admin");
-                                sqlFactory.addParameter("siteid", siteid);
-                                dbConnect.runSqlUpdate(sqlFactory.getSQL());
-
-                                //是否自动返利结算
-                                executeAutoRebate(row.getLong("sa_orderid"), siteid);
-
-                            }
-                        }
-                    }
-                }
-
-                if(siteid.equalsIgnoreCase("CCYOSG")){
-                    //自动关闭erp发货单接口不成功,则手动关闭e订货的发货单(但状态为关闭)
-                    ArrayList<String> uncloseSqlList = new ArrayList<>();
-                    if (unclosedispatchids.size() > 0) {
-                        for (Object object : unclosedispatchids) {
-                            Long sa_dispatchid = Long.valueOf(object.toString());
-                            String billno = "";
-                            Rows dispatchRows = dbConnect.runSqlQuery("select * from sa_dispatch where sa_dispatchid=" + sa_dispatchid + " and siteid='" + siteid + "'");
-                            if (!dispatchRows.isEmpty()) {
-                                billno = dispatchRows.get(0).getString("billno");
-                            } else {
-                                logger.info("发货单" + sa_dispatchid + "不存在:");
-                                continue;
-                            }
-                            //手工关闭发货单
-                            JSONObject jsonobject = new JSONObject();
-                            JSONObject objectdetail = new JSONObject();
-                            jsonobject.put("access_token", "basicDrp");
-                            jsonobject.put("classname", "Sainvoice");
-                            jsonobject.put("method", "closeSainvoice");
-                            objectdetail.put("finvonum", billno);
-                            objectdetail.put("isManual", true);
-                            jsonobject.put("content", objectdetail);
-
-                            HashMap<String, String> map = new HashMap<>();
-                            map.put("content-Type", "application/json");
-                            String result = new WebRequest().doPost(jsonobject.toString(), erpDocking.getUrl(), map);
-                            JSONObject resultobject = JSONObject.parseObject(result);
-                            if (resultobject.getString("errcode").equals("0")) {
-                                Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from sa_dispatch_items where sa_dispatchid=" + sa_dispatchid + ")");
-                                RowsMap rowsOrderDetailMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
-                                Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,sum(t1.outwarehouseqty) outwarehouseqty,t1.sa_orderitemsid,t1.siteid from sa_dispatch_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid  where ifnull(t1.isclose,0)=0 and t1.sa_dispatchid=" + sa_dispatchid + " group by t1.sa_orderitemsid,t1.siteid");
-                                if (!rowsDispatchDetailGroup.isEmpty()) {
-                                    for (Row row : rowsDispatchDetailGroup) {
-                                        logger.info("测试bug:" + "update sa_orderitems set undeliqty=" + rowsOrderDetailMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty").subtract(row.getBigDecimal("outwarehouseqty"))) + ",deliedqty=" + rowsOrderDetailMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty").subtract(row.getBigDecimal("outwarehouseqty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
-                                        uncloseSqlList.add("update sa_orderitems set undeliqty=" + rowsOrderDetailMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty").subtract(row.getBigDecimal("outwarehouseqty"))) + ",deliedqty=" + rowsOrderDetailMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty").subtract(row.getBigDecimal("outwarehouseqty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
-                                    }
-                                }
-//                    Rows orderRows =dbConnect.runSqlQuery("select distinct t1.sa_orderid from sa_orderitems t1 inner join sa_dispatch_items t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='" + siteid + "' and t2.sa_dispatchid=" + sa_dispatchid);
-//                    for (Row row:orderRows) {
-//                        sqlList.add("update sa_order set status='审核' where sa_orderid=" + row.getLong("sa_orderid") + " and siteid='" + siteid + "'");
-//                    }
-                                uncloseSqlList.add("update sa_dispatch set status='关闭',closedate=current_time,closeby='admin' where sa_dispatchid='" + sa_dispatchid + "' and siteid='" + siteid + "'");
-                                SQLFactory sqlFactory = new SQLFactory(this, "数据操作日志新增");
-                                sqlFactory.addParameter("sys_contrllogid", createTableID("sys_contrllog"));
-                                sqlFactory.addParameter("ownertable", "sa_dispatch");
-                                sqlFactory.addParameter("ownerid", sa_dispatchid);
-                                sqlFactory.addParameter("action", "自动关闭");
-                                sqlFactory.addParameter("remarks", "发货单自动关闭成功(未全部发完,未发完数量退回订单并自动关闭)");
-                                sqlFactory.addParameter("actionuserid", "1");
-                                sqlFactory.addParameter("actionby", "admin");
-                                sqlFactory.addParameter("siteid", siteid);
-                                uncloseSqlList.add(sqlFactory.getSQL());
-                            } else {
-                                logger.info("发货单手工关闭错误:" + resultobject.getString("errmsg") + "发货单id:" + sa_dispatchid);
-                                Rows erpupdatelogRows = dbConnect.runSqlQuery(
-                                        "select * from sys_erpupdatelog where ownertable='sa_dispatch' and type='手工关闭发货单' and ownerid=" + sa_dispatchid);
-                                SQLFactory sqlFactory;
-                                if (!erpupdatelogRows.isEmpty()) {
-                                    sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志更新");
-                                    sqlFactory.addParameter("sys_erpupdatelogid", erpupdatelogRows.get(0).getLong("sys_erpupdatelogid"));
-                                } else {
-                                    sqlFactory = new SQLFactory(new UploadDataToERP_HY(), "erp上传日志新增");
-                                    sqlFactory.addParameter("sys_erpupdatelogid", createTableID("sys_erpupdatelog"));
-                                }
-                                sqlFactory.addParameter("siteid", siteid);
-                                sqlFactory.addParameter("userid", 1);
-                                sqlFactory.addParameter("username", "admin");
-                                sqlFactory.addParameter("ownerid", sa_dispatchid);
-                                sqlFactory.addParameter("ownertable", "sa_dispatch");
-                                sqlFactory.addParameter("type", "手工关闭发货单");
-                                sqlFactory.addParameter("request", object.toString());
-                                sqlFactory.addParameter("response", resultobject.toJSONString());
-                                sqlFactory.addParameter("erpbillno", "");
-                                sqlFactory.addParameter("errmsg", resultobject.getString("errmsg"));
-                                sqlFactory.addParameter("status", resultobject.getString("errcode"));
-                                uncloseSqlList.add(sqlFactory.getSQL());
-                            }
-
-
-                        }
-                        dbConnect.runSqlUpdate(uncloseSqlList);
-                    }
-                }
-
-                for (Object o : dispatchids) {
-                    Rows rows1 = dbConnect.runSqlQuery("select t2.userid from sa_dispatch t1 inner join sys_enterprise_hr t2 on t1.siteid=t2.siteid and t1.sys_enterpriseid=t2.sys_enterpriseid where sa_dispatchid=" + o);
-                    HashMap<String, Object> dataextra = new HashMap<>();
-                    dataextra.put("extraUseridList", rows1.toArrayList("userid"));
-                    Executor.sendEml(this, "dispatch_close", (Long) o, siteid, dataextra);
-                }
-
-            }
-        }
-    }
-
-
-    public void executeAutoRebate(Long sa_orderid, String siteid) throws YosException {
-
-        Rows orderRows = dbConnect.runSqlQuery("SELECT * from sa_order WHERE sa_orderid = " + sa_orderid + " and siteid = '" + siteid + "'");
-        if (orderRows.get(0).getString("type").equals("促销订单")) {
-            return;
-        }
-        Long sys_enterpriseid = orderRows.get(0).getLong("sys_enterpriseid");
-
-
-        //是否自动返利结算
-        String isrebate = Parameter.getString(siteid, "isrebate");
-        if (!isrebate.equals("1")) {
-            return;
-        }
-        //查询有效期内,余额大于0 的经销商装修补贴返利
-        String sql = "select * from sa_agentdecorationtrebate WHERE sys_enterpriseid=" + sys_enterpriseid + " and siteid='" + siteid + "' and begindate <= current_date and enddate>=current_date and balance>0";
-        Rows agentdecorationtrebatRows = dbConnect.runSqlQuery(sql);
-        if (agentdecorationtrebatRows.isEmpty()) {
-            return;
-        }
-        //查询装修返利方案
-        Rows rebateschemeRows = dbConnect.runSqlQuery("select * from sa_rebatescheme where siteid='" + siteid + "'");
-        if (rebateschemeRows.isEmpty()) {
-            return;
-        }
-        ArrayList<String> sqlList = new ArrayList<>();
-        Long sa_rebateschemeid = rebateschemeRows.get(0).getLong("sa_rebateschemeid");
-        Long sa_accountclassid = rebateschemeRows.get(0).getLong("sa_accountclassid");
-
-        Rows rebatecategorys = dbConnect.runSqlQuery("select itemclassid from sa_rebatecategory where siteid='" + siteid + "' and sa_rebateschemeid=" + sa_rebateschemeid);
-        Rows rebateunproducts = dbConnect.runSqlQuery("select itemid from sa_rebateunproducts where siteid='" + siteid + "' and sa_rebateschemeid=" + sa_rebateschemeid);
-        Rows rebateunjoinproducts = dbConnect.runSqlQuery("select itemid from sa_rebateunjoinproducts where siteid='" + siteid + "' and sa_rebateschemeid=" + sa_rebateschemeid);
-
-        ArrayList<Long> itemclsids = rebatecategorys.toArrayList("itemclassid", new ArrayList<Long>());
-
-        itemclsids.addAll(ItemClass.getSubItemClassIds(dbConnect, siteid, itemclsids));
-        itemclsids.add(0l);
-        ArrayList<Long> itemids = rebateunproducts.toArrayList("itemid", new ArrayList<Long>());
-        itemids.add(0l);
-        ArrayList<Long> joinitemids = rebateunjoinproducts.toArrayList("itemid", new ArrayList<Long>());
-        String where =" 1=1 ";
-        if(!joinitemids.isEmpty()){
-            where=where+" and t1.itemid in"+joinitemids;
-        }
-
-        SQLFactory sqlFactory = new SQLFactory(new DispatchAutoCloseService(), "查询返利数据");
-        sqlFactory.addParameter("sa_orderid", sa_orderid);
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter_in("itemclassid", itemclsids);
-        sqlFactory.addParameter_in("itemid", itemids);
-        sqlFactory.addParameter_SQL("where", where);
-
-        Rows rows = dbConnect.runSqlQuery(sqlFactory);
-        BigDecimal saorderamount = BigDecimal.ZERO;
-        for (Row row : rows) {
-            saorderamount = saorderamount.add(row.getBigDecimal("amount"));
-        }
-        //查询定制费用
-        sql = "SELECT ifnull(sum(costamount),0) costamount from sa_order_cost WHERE sa_orderid=" + sa_orderid;
-        BigDecimal costamount = dbConnect.runSqlQuery(0, sql).getBigDecimal("costamount");
-        saorderamount = saorderamount.add(costamount);
-
-
-        BigDecimal balance = agentdecorationtrebatRows.get(0).getBigDecimal("balance");
-        BigDecimal brate = agentdecorationtrebatRows.get(0).getBigDecimal("brate");
-
-
-        BigDecimal approvedamount = BigDecimal.ZERO;
-        if (balance.compareTo(saorderamount.multiply(brate)) >= 0) {
-            approvedamount = saorderamount.multiply(brate);
-        } else if (balance.compareTo(BigDecimal.ZERO) > 0) {
-            approvedamount = balance;
-        }
-        System.out.println(saorderamount);
-        System.out.println(approvedamount);
-
-        if (approvedamount.compareTo(BigDecimal.ZERO) > 0) {
-            ArrayList<Long> sa_orderitemsids = rows.toArrayList("sa_orderitemsid", new ArrayList<>());
-            sa_orderitemsids.add(0l);
-
-            //更新订单明细的装修返利标志
-            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(dbConnect, "sa_orderitems");
-            updateSQL.setWhere("sa_orderitemsid", sa_orderitemsids);
-            updateSQL.setValue("decorationrebateflag", "1");
-            sqlList.add(updateSQL.getSQL());
-
-            //更新sa_agentdecorationtrebate
-            updateSQL = SQLFactory.createUpdateSQL(dbConnect, "sa_agentdecorationtrebate");
-            updateSQL.setWhere("sys_enterpriseid", sys_enterpriseid);
-            updateSQL.setSiteid(siteid);
-            updateSQL.setValue("balance", balance.subtract(approvedamount));
-            sqlList.add(updateSQL.getSQL());
-
-            //生成收入凭证
-            CashbillEntity entity = new CashbillEntity();
-            entity.setAmount(approvedamount);
-            entity.setOwnerid(sa_orderid);
-            entity.setOwnertable("sa_order");
-            entity.setSource("订单自动返利");
-            entity.setType("公司支持");
-            entity.setTypemx("装修返利");
-            entity.setSourcenote(orderRows.get(0).getString("sonum"));
-            entity.setRemarks(orderRows.get(0).getString("sonum") + "订单自动返利");
-            JSONObject cashbillIncome = createCashbillIncome(siteid, sys_enterpriseid, sa_accountclassid, entity, true, true);
-            sqlList.addAll(cashbillIncome.getJSONArray("sqlList").toJavaList(String.class));
-
-            System.err.println(sqlList);
-            dbConnect.runSqlUpdate(sqlList);
-        }
-    }
-
-    /**
-     * 创建收入凭证(返回SQL)
-     *
-     * @param siteid
-     * @param sys_enterpriseid  企业id
-     * @param sa_accountclassid 账户id
-     * @param cashbillEntity    收支凭证实体
-     * @param ischeck           是否审核
-     * @return
-     * @throws YosException
-     */
-    public JSONObject createCashbillIncome(String siteid, long sys_enterpriseid, long sa_accountclassid, CashbillEntity cashbillEntity, boolean ischeck, boolean isupdatek3flag) throws YosException {
-
-        long userid = 1;
-        String username = "admin";
-
-        ArrayList<String> sqlList = new ArrayList<>();
-        long sa_cashbillid = createTableID("sa_cashbill");
-        String billcode = createBillCode(siteid, "cashbill");
-        SQLFactory sqlFactory = new SQLFactory(new Accountbalance(), "收支凭证新增");
-        sqlFactory.addParameter("billno", billcode);
-        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-        sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
-        sqlFactory.addParameter("type", 1);
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("remarks", cashbillEntity.getRemarks());
-        sqlFactory.addParameter("amount", cashbillEntity.getAmount());
-        sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("username", username);
-        sqlFactory.addParameter("ownertable", cashbillEntity.getOwnertable());
-        sqlFactory.addParameter("ownerid", cashbillEntity.getOwnerid());
-        sqlFactory.addParameter("source", cashbillEntity.getSource());
-        sqlFactory.addParameter("sourcenote", cashbillEntity.getSourcenote());
-        sqlFactory.addParameter("sa_cashbillid_rebate", "null");
-        sqlFactory.addParameter("period",new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
-        sqlFactory.addParameter("class", cashbillEntity.getType());
-        sqlFactory.addParameter("subclass", cashbillEntity.getTypemx());
-        if (ischeck) {
-            BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
-            sqlFactory.addParameter("status", "审核");
-            if (isupdatek3flag) {
-                sqlFactory.addParameter("updatek3flag", "0");
-            } else {
-                sqlFactory.addParameter("updatek3flag", "");
-            }
-            sqlFactory.addParameter("checkby", username);
-            sqlFactory.addParameter_SQL("checkdate", "CURRENT_TIME");
-
-            // 审核逻辑判断
-            Rows rowsaccountbalance = dbConnect.runSqlQuery(
-                    "select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='"
-                            + sys_enterpriseid + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='"
-                            + siteid + "'");
-
-            if (rowsaccountbalance.isEmpty()) {
-                SQLFactory accountbalanceaddSqlFactory = new SQLFactory(new Accountbalance(), "营销账户余额新增");
-                accountbalanceaddSqlFactory.addParameter("sa_accountbalanceid",
-                        createTableID("sa_accountbalance"));
-                accountbalanceaddSqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                accountbalanceaddSqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
-                accountbalanceaddSqlFactory.addParameter("siteid", siteid);
-                accountbalanceaddSqlFactory.addParameter("balance", cashbillEntity.getAmount());
-                accountbalanceaddSqlFactory.addParameter("userid", userid);
-                accountbalanceaddSqlFactory.addParameter("username", username);
-                balance = cashbillEntity.getAmount();
-                sqlList.add(accountbalanceaddSqlFactory.getSQL());
-            } else {
-                BigDecimal newbalance = cashbillEntity.getAmount().add(rowsaccountbalance.get(0).getBigDecimal("balance"));
-                sqlList.add("update sa_accountbalance set balance='" + newbalance
-                        + "',changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='"
-                        + userid + "' where sys_enterpriseid ='" + sys_enterpriseid
-                        + "' and  sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid
-                        + "'");
-                balance = newbalance;
-            }
-            sqlFactory.addParameter("balance", balance);
-            Rows accountclassrows = dbConnect.runSqlQuery("select * from sa_accountclass where siteid='" + siteid + "' and  sa_accountclassid=" + sa_accountclassid);
-            if (!accountclassrows.isEmpty()) {
-                String content = "您的" + accountclassrows.get(0).getString("accountname") + "已收入【" + cashbillEntity.getAmount() + "】元";
-                new Accountbalance().sendMsg(siteid, content, cashbillEntity.getOwnerid(), sys_enterpriseid);
-            }
-
-        } else {
-            sqlFactory.addParameter("status", "新建");
-            sqlFactory.addParameter("checkby", "null");
-            sqlFactory.addParameter("checkdate", "null");
-            sqlFactory.addParameter("updatek3flag", "");
-            sqlFactory.addParameter("balance", 0);
-        }
-        sqlList.add(sqlFactory.getSQL());
-
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("sa_cashbillid", sa_cashbillid);
-        jsonObject.put("sqlList", sqlList);
-        return jsonObject;
-    }
-}

+ 0 - 286
src/custom/service/StockAutoDockAftersalesmagService.java

@@ -1,286 +0,0 @@
-package service;
-
-import beans.remind.Remind;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.ServiceController;
-import common.YosException;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
-import common.parameter.properties;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import utility.ERPDocking;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Properties;
-
-public class StockAutoDockAftersalesmagService extends ServiceController {
-
-    private static Logger logger = Logger.getLogger(DispatchAutoCloseService.class);
-    String[] siteids = {"CCYOSG", "DLB"};
-
-    @Override
-    public void serviceRun() throws YosException {
-        for (String siteid : siteids) {
-            if (dbConnect.runSqlQuery("SELECT 1 from  sys_site WHERE siteid='" + siteid + "'").isEmpty()) {
-                continue;
-            }
-//            Properties yosProperties = properties.getYosProperties();
-//            if (yosProperties.getProperty("system.runmode.debug").equalsIgnoreCase("false")) {
-            if(false){
-                ArrayList<String> sqlList = new ArrayList<>();
-                ERPDocking erpDocking = new ERPDocking(siteid);
-                JSONArray ErpSainvoices = erpDocking.queryErpStockBill(500, 1, "销售退货");
-                JSONArray flags = new JSONArray();
-                if (!ErpSainvoices.isEmpty()) {
-                    for (Object ErpSainvoice : ErpSainvoices) {
-                        JSONObject erpSainvoice = (JSONObject) ErpSainvoice;
-                        // 经销商编号
-                        String fagentnum = erpSainvoice.getString("fagentnum");
-                        long sys_enterpriseid = 0;
-                        if (dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='" + siteid + "' and  agentnum='" + fagentnum + "'").isNotEmpty()) {
-                            sys_enterpriseid = dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='" + siteid + "' and  agentnum='" + fagentnum + "'").get(0).getLong("sys_enterpriseid");
-                        } else {
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "4");
-                            flag.put("fupdatewarnlog", "yos中不存在【" + fagentnum + "】经销商");
-                            flags.add(flag);
-                            continue;
-                        }
-                        //单号
-                        String fbillnum = erpSainvoice.getString("fbillnum");
-                        // 单据日期
-                        String fdate = erpSainvoice.getString("fdate");
-                        // 会计期间
-                        //  String fperiod = content.getString("fperiod");
-                        // 红蓝字
-                        String frb = erpSainvoice.getString("frb");
-                        // 表头仓库
-                        // String fstockno = content.getString("fstockno");
-                        // 单据类型明细
-                        //String ftypemx = content.getString("ftypemx");
-                        // 单据状态
-                        String fstatus = erpSainvoice.getString("fstatus");
-                        // 制单人
-                        String createby = erpSainvoice.getString("createby");
-                        // 制单日期
-                        String createdate = erpSainvoice.getString("createdate");
-//                    // 审核人
-//                    String checkby = erpSainvoice.getString("checkby");
-//                    // 审核日期
-//                    String checkdate = erpSainvoice.getString("checkdate");
-                        // 备注
-                        String fnotes = erpSainvoice.getString("fnote");
-                        String fsourcebillno = erpSainvoice.getString("fsourcebillno");
-                        long sa_aftersalesmagid = 0;
-                        if (StringUtils.isNotBlank(fsourcebillno)) {
-                            if (dbConnect.runSqlQuery("select sa_aftersalesmagid from sa_aftersalesmag where siteid='" + siteid + "' and  billno='" + fsourcebillno + "'").isNotEmpty()) {
-                                sa_aftersalesmagid = dbConnect.runSqlQuery("select sa_aftersalesmagid from sa_aftersalesmag where siteid='" + siteid + "' and  billno='" + fsourcebillno + "'").get(0).getLong("sa_aftersalesmagid");
-                            } else {
-                                JSONObject flag = new JSONObject();
-                                flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                                flag.put("fupdateflag", "4");
-                                flag.put("fupdatewarnlog", "yos中不存在对应的退货单");
-                                flags.add(flag);
-                                continue;
-                            }
-                        } else {
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "4");
-                            flag.put("fupdatewarnlog", "yos中不存在对应的退货单");
-                            flags.add(flag);
-                            continue;
-                        }
-
-
-                        Long sa_cashbillid = 0L;
-
-                        Rows stockbillRows = dbConnect.runSqlQuery("select * from st_stockbill where siteid='" + siteid + "' and status='审核' and billno='" + fbillnum + "'");
-                        Long st_stockbillid = 0L;
-                        if (stockbillRows.isEmpty() && "审核".equals(fstatus)) {
-                            /**
-                             * DRP不存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需新增该销售出库单
-                             */
-                            SQLFactory sqlFactory = new SQLFactory(this, "销售出库单新增");
-                            st_stockbillid = createTableID("st_stockbill");
-                            sqlFactory.addParameter("siteid", siteid);
-                            sqlFactory.addParameter("st_stockbillid", st_stockbillid);
-                            sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                            sqlFactory.addParameter("billno", fbillnum);
-                            sqlFactory.addParameter("type", "销售退货");
-                            sqlFactory.addParameter("rb", frb.equals("蓝") ? 1 : 0);
-                            sqlFactory.addParameter("billdate", fdate);
-                            sqlFactory.addParameter("createby", createby);
-                            sqlFactory.addParameter("createdate", getDate(createdate));
-                            sqlFactory.addParameter("changeby", createby);
-                            sqlFactory.addParameter("changedate", getDate(createdate));
-                            sqlFactory.addParameter("checkby", createby);
-                            sqlFactory.addParameter("checkdate", getDate(createdate));
-                            sqlFactory.addParameter("remarks", fnotes);
-                            sqlList.add(sqlFactory.getSQL());
-
-                            JSONArray detailarray = erpSainvoice.getJSONArray("details");
-                            StringBuffer str = new StringBuffer();
-
-                            for (Object object : detailarray) {
-                                JSONObject jsonObject = (JSONObject) object;
-                                if (str.toString().equals("")) {
-                                    str.append("'" + jsonObject.getString("fitemno") + "'");
-                                } else {
-                                    str.append(",'" + jsonObject.getString("fitemno") + "'");
-                                }
-                            }
-                            Rows rows;
-                            if (!str.toString().equals("")) {
-                                rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='" + siteid + "' and itemno in " + "(" + str.toString() + ")");
-                            } else {
-                                rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='" + siteid + "' and itemno in('')");
-                            }
-                            RowsMap itemRowsMap = rows.toRowsMap("itemno");
-//                        Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid,t1.rowno,t1.sa_orderitemsid,t2.sa_orderid,t3.sys_enterpriseid,t4.sonum,t5.itemno,t5.itemname 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 left join sa_order t4 on t2.sa_orderid=t4.sa_orderid and t2.siteid=t4.siteid left join plm_item t5 on t1.itemid=t5.itemid and t1.siteid=t5.siteid where t3.status in('审核','复核','关闭') and  t1.siteid='"+siteid+"' and  t1.sa_dispatchid = " + sa_dispatchid);
-//                        RowsMap distiptchRowsMap = distiptchRows.toRowsMap("rowno");
-
-                            Rows aftersalesmagRows = dbConnect.runSqlQuery("select t1.price,t1.sa_aftersalesmag_itemsid,t3.itemno,t1.sa_orderitemsid,t2.sa_orderid from sa_aftersalesmag_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid inner join plm_item t3  on t1.itemid=t3.itemid and t1.siteid=t3.siteid  where  t1.siteid='" + siteid + "' and  t1.sa_aftersalesmagid = " + sa_aftersalesmagid);
-                            RowsMap aftersalesmagRowsMap = aftersalesmagRows.toRowsMap("itemno");
-                            BigDecimal amountTotal = BigDecimal.ZERO;
-                            for (Object object : detailarray) {
-                                JSONObject jsonObject = (JSONObject) object;
-                                String frownum = jsonObject.getString("fentryno");
-                                String fitemno = jsonObject.getString("fitemno");
-                                String fbatchno = jsonObject.getString("fbatchno");
-
-                                System.err.println(frownum + ":" + fitemno);
-                                BigDecimal fqty = new BigDecimal(jsonObject.getString("fqty"));
-                                fqty = fqty.compareTo(BigDecimal.ZERO) < 0 ? fqty.negate() : fqty;
-                                //String fdetailstockno = jsonObject.getString("fstockno");
-                                //String fbatchno = jsonObject.getString("fbatchno");
-                                String fdetailnotes = jsonObject.getString("fnote");
-                                SQLFactory sqlFactorydetail = new SQLFactory(this, "销售出库单明细新增");
-                                sqlFactorydetail.addParameter("siteid", siteid);
-                                sqlFactorydetail.addParameter("st_stockbill_itemsid", createTableID("st_stockbill_items"));
-                                sqlFactorydetail.addParameter("st_stockbillid", st_stockbillid);
-                                sqlFactorydetail.addParameter("rowno", frownum);
-                                sqlFactorydetail.addParameter("remarks", fnotes);
-                                if (itemRowsMap.containsKey(fitemno) && itemRowsMap.get(fitemno).isNotEmpty()) {
-                                    sqlFactorydetail.addParameter("itemid", itemRowsMap.get(fitemno).get(0).getLong("itemid"));
-                                } else {
-                                    sqlFactorydetail.addParameter("itemid", 0);
-                                }
-                                sqlFactorydetail.addParameter("remarks", fdetailnotes);
-                                sqlFactorydetail.addParameter("qty", fqty);
-
-//                            if (frb.equals("蓝")) {
-//                                if (aftersalesmagRows.containsKey(String.valueOf(frownum)) && aftersalesmagRows.get(frownum).isNotEmpty()) {
-//                                    sqlFactorydetail.addParameter("sa_dispatch_itemsid",  distiptchRowsMap.get(frownum).get(0).getLong("sa_dispatch_itemsid"));
-//                                    sqlFactorydetail.addParameter("price", distiptchRowsMap.get(frownum).get(0).getBigDecimal("price"));
-//                                    amountTotal = amountTotal.add(fqty.multiply(distiptchRowsMap.get(frownum).get(0).getBigDecimal("price")));
-//                                    sqlFactorydetail.addParameter("amount", fqty.multiply(distiptchRowsMap.get(frownum).get(0).getBigDecimal("price")));
-//                                    sqlFactorydetail.addParameter("sa_orderitemsid", distiptchRowsMap.get(frownum).get(0).getLong("sa_orderitemsid"));
-//                                    sqlFactorydetail.addParameter("sa_orderid", distiptchRowsMap.get(frownum).get(0).getLong("sa_orderid"));
-//                                    System.out.println(amountTotal);
-//                                    //您的订单【XXX】商品【XXX】工厂已发货,出库单号【XXX】
-//                                    String message = "您的订单【" + distiptchRowsMap.get(frownum).get(0).getString("sonum") + "】商品【" + distiptchRowsMap.get(frownum).get(0).getString("itemname") + "】工厂已发货,出库单号【" + fbillnum + "】!";
-//                                    sendMsg(message, st_stockbillid, distiptchRowsMap.get(frownum).get(0).getLong("sys_enterpriseid"));
-//                                } else {
-//                                    sqlFactorydetail.addParameter("price", 0);
-//                                    sqlFactorydetail.addParameter("amount", 0);
-//                                    sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-//                                    sqlFactorydetail.addParameter("sa_orderid", 0);
-//                                }
-//                            }
-                                if (frb.equals("红")) {
-                                    if (aftersalesmagRowsMap.containsKey(String.valueOf(fitemno)) && aftersalesmagRowsMap.get(fitemno).isNotEmpty()) {
-                                        logger.info(aftersalesmagRowsMap.get(fitemno).get(0).toJsonObject().toString());
-                                        sqlFactorydetail.addParameter("sa_dispatch_itemsid", aftersalesmagRowsMap.get(fitemno).get(0).getLong("sa_aftersalesmag_itemsid"));
-                                        sqlFactorydetail.addParameter("price", aftersalesmagRowsMap.get(fitemno).get(0).getBigDecimal("price"));
-                                        sqlFactorydetail.addParameter("amount", fqty.multiply(aftersalesmagRowsMap.get(fitemno).get(0).getBigDecimal("price")));
-                                        logger.info(aftersalesmagRowsMap.get(fitemno).get(0).getBigDecimal("sa_orderitemsid"));
-                                        logger.info(aftersalesmagRowsMap.get(fitemno).get(0).getBigDecimal("sa_orderid"));
-                                        sqlFactorydetail.addParameter("sa_orderitemsid", aftersalesmagRowsMap.get(fitemno).get(0).getLong("sa_orderitemsid"));
-                                        sqlFactorydetail.addParameter("sa_orderid", aftersalesmagRowsMap.get(fitemno).get(0).getLong("sa_orderid"));
-                                    } else {
-                                        sqlFactorydetail.addParameter("sa_dispatch_itemsid", 0);
-                                        sqlFactorydetail.addParameter("price", 0);
-                                        sqlFactorydetail.addParameter("amount", 0);
-                                        sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-                                        sqlFactorydetail.addParameter("sa_orderid", 0);
-                                    }
-                                }
-
-                                sqlList.add(sqlFactorydetail.getSQL());
-                            }
-                            sqlList.add("update st_stockbill set status='审核',checkby='" + createby + "',checkdate=CURRENT_TIMESTAMP where st_stockbillid = " + st_stockbillid + " and siteid='" + siteid + "'");
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "1");
-                            flag.put("fupdatewarnlog", "");
-                            flags.add(flag);
-
-                        } else if (!stockbillRows.isEmpty() && "审核".equals(fstatus)) {
-                            /**
-                             * DRP存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需将当前销售出库单先反审核,修改内容后再进行审核
-                             */
-                            sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='" + siteid + "'");
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "99");
-                            flag.put("fupdatewarnlog", "");
-                            flags.add(flag);
-                            continue;
-                        } else if (!stockbillRows.isEmpty() && "新建".equals(fstatus)) {
-                            /**
-                             * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入销售出库单先反审核
-                             */
-                            sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='" + siteid + "'");
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "1");
-                            flag.put("fupdatewarnlog", "");
-                            flags.add(flag);
-                        }
-                    }
-                }
-                if (erpDocking.updateErpupdateFlag(flags).equals("true")) {
-                    dbConnect.runSqlUpdate(sqlList);
-                    /**
-                     * 如单据为新建状态,则,先把单据强行删除掉
-                     */
-                    dbConnect.runSqlUpdate("delete from st_stockbill where status='新建'");
-                }
-            }
-
-
-        }
-    }
-
-    public String getDate(String date) {
-        try {
-            Date a = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date);
-            return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(a);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public void sendMsg(String siteid,String content, Long st_stockbillid, Long sys_enterpriseid) throws YosException {
-
-        ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid, siteid).toArrayList("userid", new ArrayList<>());
-        Remind remind = new Remind(new Controller(new JSONObject()));
-        remind.setTitle("销售出库单消息");
-        remind.setContent(content);
-        remind.setType("应用");
-        remind.setObjectid(st_stockbillid);
-        remind.setObjectname("st_stockbill");
-        remind.setTouserid(userList);
-        remind.sendByDialogMsg().createSys_message();
-    }
-}

+ 0 - 298
src/custom/service/StockAutoDockDispatchService.java

@@ -1,298 +0,0 @@
-package service;
-
-import beans.accountbalance.Accountbalance;
-import beans.accountbalance.CashbillEntity;
-import beans.parameter.Parameter;
-import beans.remind.Remind;
-import beans.uploaderpdata.UploadDataToERP_HY;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import common.Controller;
-import common.ServiceController;
-import common.YosException;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
-import common.parameter.properties;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import restcontroller.webmanage.executorService.Executor;
-import utility.ERPDocking;
-import utility.tools.WebRequest;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-public class StockAutoDockDispatchService extends ServiceController {
-
-    private static Logger logger = Logger.getLogger(DispatchAutoCloseService.class);
-    String[] siteids = {"CCYOSG", "DLB"};
-
-    @Override
-    public void serviceRun() throws YosException {
-        for (String siteid : siteids) {
-            if (dbConnect.runSqlQuery("SELECT 1 from  sys_site WHERE siteid='" + siteid + "'").isEmpty()) {
-                continue;
-            }
-            System.out.println("销售出库单自动同步任务");
-//            Properties yosProperties = properties.getYosProperties();
-//            if (yosProperties.getProperty("system.runmode.debug").equalsIgnoreCase("false")) {
-            if(false){
-                ArrayList<String> sqlList = new ArrayList<>();
-                ERPDocking erpDocking = new ERPDocking(siteid);
-                JSONArray ErpSainvoices = erpDocking.queryErpStockBill(500, 1, "销售出库");
-                JSONArray flags = new JSONArray();
-                if (!ErpSainvoices.isEmpty()) {
-                    for (Object ErpSainvoice : ErpSainvoices) {
-                        JSONObject erpSainvoice = (JSONObject) ErpSainvoice;
-                        // 经销商编号
-                        String fagentnum = erpSainvoice.getString("fagentnum");
-                        long sys_enterpriseid = 0;
-                        if (dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='" + siteid + "' and  agentnum='" + fagentnum + "'").isNotEmpty()) {
-                            sys_enterpriseid = dbConnect.runSqlQuery("select sys_enterpriseid from sa_agents where siteid='" + siteid + "' and  agentnum='" + fagentnum + "'").get(0).getLong("sys_enterpriseid");
-                        } else {
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "4");
-                            flag.put("fupdatewarnlog", "yos中不存在【" + fagentnum + "】经销商");
-                            flags.add(flag);
-                            continue;
-                        }
-                        //单号
-                        String fbillnum = erpSainvoice.getString("fbillnum");
-                        // 单据日期
-                        String fdate = erpSainvoice.getString("fdate");
-                        // 会计期间
-                        //  String fperiod = content.getString("fperiod");
-                        // 红蓝字
-                        String frb = erpSainvoice.getString("frb");
-                        // 表头仓库
-                        // String fstockno = content.getString("fstockno");
-                        // 单据类型明细
-                        //String ftypemx = content.getString("ftypemx");
-                        // 单据状态
-                        String fstatus = erpSainvoice.getString("fstatus");
-                        // 制单人
-                        String createby = erpSainvoice.getString("createby");
-                        // 制单日期
-                        String createdate = erpSainvoice.getString("createdate");
-//                    // 审核人
-//                    String checkby = erpSainvoice.getString("checkby");
-//                    // 审核日期
-//                    String checkdate = erpSainvoice.getString("checkdate");
-                        // 备注
-                        String fnotes = erpSainvoice.getString("fnote");
-                        String fsourcebillno = erpSainvoice.getString("fsourcebillno");
-                        String fsourcetype = erpSainvoice.getString("fsourcetype");
-                        long sa_dispatchid = 0;
-                        if(siteid.equalsIgnoreCase("CCYOSG")){
-                            if (StringUtils.isNotBlank(fsourcebillno)) {
-                                if (dbConnect.runSqlQuery("select sa_dispatchid from sa_dispatch where siteid='" + siteid + "' and  billno='" + fsourcebillno + "'").isNotEmpty()) {
-                                    sa_dispatchid = dbConnect.runSqlQuery("select sa_dispatchid from sa_dispatch where siteid='" + siteid + "' and  billno='" + fsourcebillno + "'").get(0).getLong("sa_dispatchid");
-                                } else {
-                                    JSONObject flag = new JSONObject();
-                                    flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                                    flag.put("fupdateflag", "4");
-                                    flag.put("fupdatewarnlog", "yos中不存在对应的发货单");
-                                    flags.add(flag);
-                                    continue;
-                                }
-                            } else {
-                                JSONObject flag = new JSONObject();
-                                flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                                flag.put("fupdateflag", "4");
-                                flag.put("fupdatewarnlog", "yos中不存在对应的发货单");
-                                flags.add(flag);
-                                continue;
-                            }
-                        }
-
-
-
-                        Long sa_cashbillid = 0L;
-
-                        Rows stockbillRows = dbConnect.runSqlQuery("select * from st_stockbill where siteid='" + siteid + "' and status='审核' and billno='" + fbillnum + "'");
-                        Long st_stockbillid = 0L;
-                        if (stockbillRows.isEmpty() && "审核".equals(fstatus)) {
-                            /**
-                             * DRP不存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需新增该销售出库单
-                             */
-                            SQLFactory sqlFactory = new SQLFactory(this, "销售出库单新增");
-                            st_stockbillid = createTableID("st_stockbill");
-                            sqlFactory.addParameter("siteid", siteid);
-                            sqlFactory.addParameter("st_stockbillid", st_stockbillid);
-                            sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-                            sqlFactory.addParameter("billno", fbillnum);
-                            sqlFactory.addParameter("type", "销售出库");
-                            sqlFactory.addParameter("rb", frb.equals("蓝") ? 1 : 0);
-                            sqlFactory.addParameter("billdate", fdate);
-                            sqlFactory.addParameter("createby", createby);
-                            sqlFactory.addParameter("createdate", getDate(createdate));
-                            sqlFactory.addParameter("changeby", createby);
-                            sqlFactory.addParameter("changedate", getDate(createdate));
-                            sqlFactory.addParameter("checkby", createby);
-                            sqlFactory.addParameter("checkdate", getDate(createdate));
-                            sqlFactory.addParameter("remarks", fnotes);
-                            sqlList.add(sqlFactory.getSQL());
-
-                            JSONArray detailarray = erpSainvoice.getJSONArray("details");
-                            StringBuffer str = new StringBuffer();
-
-                            for (Object object : detailarray) {
-                                JSONObject jsonObject = (JSONObject) object;
-                                if (str.toString().equals("")) {
-                                    str.append("'" + jsonObject.getString("fitemno") + "'");
-                                } else {
-                                    str.append(",'" + jsonObject.getString("fitemno") + "'");
-                                }
-                            }
-                            Rows rows;
-                            if (!str.toString().equals("")) {
-                                rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='" + siteid + "' and itemno in " + "(" + str.toString() + ")");
-                            } else {
-                                rows = dbConnect.runSqlQuery("select * from plm_item  where siteid='" + siteid + "' and itemno in('')");
-                            }
-                            RowsMap itemRowsMap = rows.toRowsMap("itemno");
-//                            Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid,t1.rowno,t1.sa_orderitemsid,t2.sa_orderid,t3.sys_enterpriseid,t4.sonum,t5.itemno,t5.itemname 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 left join sa_order t4 on t2.sa_orderid=t4.sa_orderid and t2.siteid=t4.siteid left join plm_item t5 on t1.itemid=t5.itemid and t1.siteid=t5.siteid where t3.status in('审核','复核','关闭') and  t1.siteid='" + siteid + "' and  t1.sa_dispatchid = " + sa_dispatchid);
-//                            RowsMap distiptchRowsMap = distiptchRows.toRowsMap("rowno");
-
-//                        Rows aftersalesmagRows = dbConnect.runSqlQuery("select t1.price,t1.sa_aftersalesmag_itemsid,t1.sa_orderitemsid,t2.sa_orderid from sa_aftersalesmag_items t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid  where  t1.siteid='"+siteid+"' and  t1.sa_aftersalesmag_itemsid in " + sa_dispatch_itemsids.toString().replace("[", "(").replace("]", ")"));
-//                        RowsMap aftersalesmagRowsMap = aftersalesmagRows.toRowsMap("rowno");
-                            BigDecimal amountTotal = BigDecimal.ZERO;
-                            for (Object object : detailarray) {
-                                JSONObject jsonObject = (JSONObject) object;
-                                String frownum = jsonObject.getString("finvorownum");
-                                String finvonum = jsonObject.getString("finvonum");
-                                String fitemno = jsonObject.getString("fitemno");
-                                String fbatchno = jsonObject.getString("fbatchno");
-
-                                System.err.println(frownum + ":" + fitemno);
-                                BigDecimal fqty = new BigDecimal(jsonObject.getString("fqty"));
-                                fqty = fqty.compareTo(BigDecimal.ZERO) < 0 ? fqty.negate() : fqty;
-                                //String fdetailstockno = jsonObject.getString("fstockno");
-                                //String fbatchno = jsonObject.getString("fbatchno");
-                                String fdetailnotes = jsonObject.getString("fnote");
-                                SQLFactory sqlFactorydetail = new SQLFactory(this, "销售出库单明细新增");
-                                sqlFactorydetail.addParameter("siteid", siteid);
-                                sqlFactorydetail.addParameter("st_stockbill_itemsid", createTableID("st_stockbill_items"));
-                                sqlFactorydetail.addParameter("st_stockbillid", st_stockbillid);
-                                sqlFactorydetail.addParameter("rowno", frownum);
-                                sqlFactorydetail.addParameter("remarks", fnotes);
-                                if (itemRowsMap.containsKey(fitemno) && itemRowsMap.get(fitemno).isNotEmpty()) {
-                                    sqlFactorydetail.addParameter("itemid", itemRowsMap.get(fitemno).get(0).getLong("itemid"));
-                                } else {
-                                    sqlFactorydetail.addParameter("itemid", 0);
-                                }
-                                sqlFactorydetail.addParameter("remarks", fdetailnotes);
-                                sqlFactorydetail.addParameter("qty", fqty);
-
-                                if (frb.equals("蓝")) {
-                                    Rows distiptchRows = dbConnect.runSqlQuery("select t2.price,t1.sa_dispatch_itemsid,t1.rowno,t1.sa_orderitemsid,t2.sa_orderid,t3.sys_enterpriseid,t4.sonum,t5.itemno,t5.itemname 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 left join sa_order t4 on t2.sa_orderid=t4.sa_orderid and t2.siteid=t4.siteid left join plm_item t5 on t1.itemid=t5.itemid and t1.siteid=t5.siteid where t3.status in('审核','复核','关闭') and t3.billno='"+finvonum+"' and  t1.siteid='" + siteid + "' and  t1.rowno = " + frownum);
-                                    if (distiptchRows.isNotEmpty()) {
-                                        sqlFactorydetail.addParameter("sa_dispatch_itemsid", distiptchRows.get(0).getLong("sa_dispatch_itemsid"));
-                                        sqlFactorydetail.addParameter("price", distiptchRows.get(0).getBigDecimal("price"));
-                                        amountTotal = amountTotal.add(fqty.multiply(distiptchRows.get(0).getBigDecimal("price")));
-                                        sqlFactorydetail.addParameter("amount", fqty.multiply(distiptchRows.get(0).getBigDecimal("price")));
-                                        sqlFactorydetail.addParameter("sa_orderitemsid", distiptchRows.get(0).getLong("sa_orderitemsid"));
-                                        sqlFactorydetail.addParameter("sa_orderid", distiptchRows.get(0).getLong("sa_orderid"));
-                                        System.out.println(amountTotal);
-                                        //您的订单【XXX】商品【XXX】工厂已发货,出库单号【XXX】
-                                        String message = "您的订单【" + distiptchRows.get(0).getString("sonum") + "】商品【" + distiptchRows.get(0).getString("itemname") + "】工厂已发货,出库单号【" + fbillnum + "】!";
-                                        sendMsg(siteid,message, st_stockbillid,distiptchRows.get(0).getLong("sys_enterpriseid"));
-                                    } else {
-                                        sqlFactorydetail.addParameter("sa_dispatch_itemsid", 0);
-                                        sqlFactorydetail.addParameter("price", 0);
-                                        sqlFactorydetail.addParameter("amount", 0);
-                                        sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-                                        sqlFactorydetail.addParameter("sa_orderid", 0);
-                                    }
-                                }
-//                            else {
-//                                if (aftersalesmagRowsMap.containsKey(String.valueOf(sainvoicedetailid)) && aftersalesmagRowsMap.get(sainvoicedetailid).isNotEmpty()) {
-//                                    logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).toJsonObject().toString());
-//                                    sqlFactorydetail.addParameter("price", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price"));
-//                                    sqlFactorydetail.addParameter("amount", fqty.multiply(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-//                                    logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderitemsid"));
-//                                    logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderid"));
-//                                    sqlFactorydetail.addParameter("sa_orderitemsid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderitemsid"));
-//                                    sqlFactorydetail.addParameter("sa_orderid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderid"));
-//                                } else {
-//                                    sqlFactorydetail.addParameter("price", 0);
-//                                    sqlFactorydetail.addParameter("amount", 0);
-//                                    sqlFactorydetail.addParameter("sa_orderitemsid", 0);
-//                                    sqlFactorydetail.addParameter("sa_orderid", 0);
-//                                }
-//                            }
-
-                                sqlList.add(sqlFactorydetail.getSQL());
-                            }
-                            sqlList.add("update st_stockbill set status='审核',checkby='" + createby + "',checkdate=CURRENT_TIMESTAMP where st_stockbillid = " + st_stockbillid + " and siteid='" + siteid + "'");
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "1");
-                            flag.put("fupdatewarnlog", "");
-                            flags.add(flag);
-
-                        } else if (!stockbillRows.isEmpty() && "审核".equals(fstatus)) {
-                            /**
-                             * DRP存在销售出库单,且中间表状态为审核且不在删除状态时,DRP中需将当前销售出库单先反审核,修改内容后再进行审核
-                             */
-                            sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='" + siteid + "'");
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "99");
-                            flag.put("fupdatewarnlog", "");
-                            flags.add(flag);
-                            continue;
-                        } else if (!stockbillRows.isEmpty() && "新建".equals(fstatus)) {
-                            /**
-                             * DRP存在收入凭证,且中间表状态为新建或在删除状态时,DRP中需将当前收入销售出库单先反审核
-                             */
-                            sqlList.add("update st_stockbill set status='新建',checkby='',checkdate=null where st_stockbillid = " + stockbillRows.get(0).getLong("st_stockbillid") + " and siteid='" + siteid + "'");
-                            JSONObject flag = new JSONObject();
-                            flag.put("syncyosid", erpSainvoice.getStringValue("syncyosid"));
-                            flag.put("fupdateflag", "1");
-                            flag.put("fupdatewarnlog", "");
-                            flags.add(flag);
-                        }
-                    }
-                }
-                if (erpDocking.updateErpupdateFlag(flags).equals("true")) {
-                    dbConnect.runSqlUpdate(sqlList);
-                    /**
-                     * 如单据为新建状态,则,先把单据强行删除掉
-                     */
-                    dbConnect.runSqlUpdate("delete from st_stockbill_items where st_stockbillid in(select st_stockbillid from st_stockbill where status='新建')");
-                    dbConnect.runSqlUpdate("delete from st_stockbill where status='新建'");
-                }
-
-
-            }
-        }
-    }
-
-    public String getDate(String date) {
-        try {
-            Date a = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date);
-            return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(a);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public void sendMsg(String siteid,String content, Long st_stockbillid, Long sys_enterpriseid) throws YosException {
-
-        ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid, siteid).toArrayList("userid", new ArrayList<>());
-        Remind remind = new Remind(new Controller(new JSONObject()));
-        remind.setTitle("销售出库单消息");
-        remind.setContent(content);
-        remind.setType("应用");
-        remind.setObjectid(st_stockbillid);
-        remind.setObjectname("st_stockbill");
-        remind.setTouserid(userList);
-        remind.sendByDialogMsg().createSys_message();
-    }
-}