Преглед изворни кода

服务申请单作废功能

hu пре 4 месеци
родитељ
комит
03a7a9c3a0

+ 10 - 0
src/custom/restcontroller/R.java

@@ -6956,6 +6956,16 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025121517474303 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025121519311203 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 8 - 2
src/custom/restcontroller/webmanage/sale/serviceorder/SQL/服务申请单列表查询.sql

@@ -16,7 +16,11 @@ SELECT
     t9.itemno,
     t9.itemname,
     t9.model,
-    t9.spec
+    t9.spec,
+    t12.sys_enterpriseid sys_enterpriseid_initiate,
+    t12.agentnum agentnum_initiate,
+    t12.enterprisename enterprisename_initiate,
+    t12.abbreviation abbreviation_initiate
 FROM
     sa_serviceorder t1
         LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid
@@ -31,4 +35,6 @@ FROM
         left join (SELECT * FROM (SELECT *,ROW_NUMBER() OVER (PARTITION BY sa_serviceorderid ORDER BY sa_serviceorderitemsid ASC) AS rowno FROM sa_serviceorderitems) t WHERE rowno = 1) t8 on t8.sa_serviceorderid=t1.sa_serviceorderid and t8.siteid=t1.siteid
         left join plm_item t9 on t9.itemid=t8.itemid and t9.siteid=t8.siteid
         left join sa_workorder t10 on t10.sa_serviceorderid=t1.sa_serviceorderid and t10.siteid=t1.siteid and t10.status !='作废'
-	where t1.siteid=$siteid$ and $where$
+        left join sys_enterprise_hr t11 on t11.userid=t1.createuserid  AND t11.siteid = t1.siteid
+        left join sv_agents t12 on t12.sys_enterpriseid=t11.sys_enterpriseid  AND t12.siteid = t11.siteid
+where t1.siteid=$siteid$ and $where$

+ 2 - 2
src/custom/restcontroller/webmanage/sale/serviceorder/SQL/服务申请单新增.sql

@@ -1,4 +1,4 @@
 insert into sa_serviceorder (siteid, sa_serviceorderid,createuserid,createby, createdate, billno,billdate,changeuserid,changeby, changedate,
-                                sys_enterpriseid,sa_orderid,reason,remarks,servicetype,class1,class2,province,city,county,address,scenecontact,scenecontactrole,scenecontactphonenumber,begdate,enddate, status,saler_hrid,name,phonenumber,sa_customersid,isonlinesales,sys_enterpriseid_service)
+                                sys_enterpriseid,sa_orderid,reason,remarks,servicetype,class1,class2,province,city,county,address,scenecontact,scenecontactrole,scenecontactphonenumber,begdate,enddate, status,saler_hrid,name,phonenumber,sa_customersid,isonlinesales,isallowance,sys_enterpriseid_service,initiator)
 values ($siteid$, $sa_serviceorderid$,$userid$,$username$, CURRENT_TIME, $billno$,$billdate$,$userid$, $username$, CURRENT_TIME, $sys_enterpriseid$,$sa_orderid$,$reason$,$remarks$,$servicetype$,$class1$,$class2$,
-        $province$,$city$,$county$,$address$,$scenecontact$,$scenecontactrole$,$scenecontactphonenumber$,$begdate$,$enddate$,'新建',$saler_hrid$,$name$,$phonenumber$,$sa_customersid$,$isonlinesales$,$sys_enterpriseid_service$);
+        $province$,$city$,$county$,$address$,$scenecontact$,$scenecontactrole$,$scenecontactphonenumber$,$begdate$,$enddate$,'新建',$saler_hrid$,$name$,$phonenumber$,$sa_customersid$,$isonlinesales$,$isallowance$,$sys_enterpriseid_service$,$initiator$);

+ 1 - 0
src/custom/restcontroller/webmanage/sale/serviceorder/SQL/服务申请单更新.sql

@@ -24,6 +24,7 @@ SET
     phonenumber=$phonenumber$,
     sa_customersid=$sa_customersid$,
     isonlinesales=$isonlinesales$,
+    isallowance=$isallowance$,
     sys_enterpriseid_service=$sys_enterpriseid_service$
 WHERE sa_serviceorderid = $sa_serviceorderid$ and siteid=$siteid$
 

+ 7 - 1
src/custom/restcontroller/webmanage/sale/serviceorder/SQL/服务申请单详情查询.sql

@@ -18,7 +18,11 @@ SELECT
     t9.model,
     t9.spec,
     t10.begdate cardbegdate,
-    t10.enddate cardenddate
+    t10.enddate cardenddate,
+    t12.sys_enterpriseid sys_enterpriseid_initiate,
+    t12.agentnum agentnum_initiate,
+    t12.enterprisename enterprisename_initiate,
+    t12.abbreviation abbreviation_initiate
 FROM
     sa_serviceorder t1
         LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid
@@ -33,4 +37,6 @@ FROM
         left join (SELECT * FROM (SELECT *,ROW_NUMBER() OVER (PARTITION BY sa_serviceorderid ORDER BY sa_serviceorderitemsid ASC) AS rowno FROM sa_serviceorderitems) t WHERE rowno = 1) t8 on t8.sa_serviceorderid=t1.sa_serviceorderid and t8.siteid=t1.siteid
         left join plm_item t9 on t9.itemid=t8.itemid and t9.siteid=t8.siteid
         left join sa_warrantycard t10 on t8.cardno=t10.cardno
+        left join sys_enterprise_hr t11 on t11.userid=t1.createuserid  AND t11.siteid = t1.siteid
+        left join sv_agents t12 on t12.sys_enterpriseid=t11.sys_enterpriseid  AND t12.siteid = t11.siteid
 	where t1.siteid=$siteid$  and t1.sa_serviceorderid=$sa_serviceorderid$

+ 69 - 0
src/custom/restcontroller/webmanage/sale/serviceorder/serviceorder.java

@@ -14,10 +14,12 @@ import common.YosException;
 import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
+import common.crm.bean.warrantycard;
 import common.data.*;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.configuration.security.DNConstraintsType;
+import org.glassfish.grizzly.utils.StringFilter;
 import restcontroller.R;
 import restcontroller.webmanage.executorService.Executor;
 import restcontroller.webmanage.sale.serviceorder.tools.HttpURLRest;
@@ -69,6 +71,8 @@ public class serviceorder extends Controller {
         String enddate = content.getStringValue("enddate");
         long saler_hrid = content.getLongValue("saler_hrid");
         boolean isonlinesales = content.getBooleanValue("isonlinesales");
+        boolean isallowance = content.getBooleanValue("isallowance");
+
         long sys_enterpriseid_service = content.getLongValue("sys_enterpriseid_service");
 
         String sku = content.getStringValue("sku");
@@ -87,7 +91,20 @@ public class serviceorder extends Controller {
                 }
             }
         }
+        String initiator="";
+        Rows userrows = dbConnect.runSqlQuery("select t2.usertype,t1.phonenumber from  sys_users t1 inner join sys_usersite t2 on t1.userid = t2.userid where t2.siteid = '" + siteid + "' and t1.userid=" + userid);
+        long usertype = 0;
 
+        if (userrows.isNotEmpty()) {
+            usertype = userrows.get(0).getLong("usertype");
+        }
+        if(usertype==99){
+            initiator="消费者";
+        }else if(usertype==21 || usertype==22){
+            initiator="经销商";
+        }else{
+            initiator="总部";
+        }
         if (sa_serviceorderid <= 0 || dbConnect.runSqlQuery(
                         "select sa_serviceorderid from sa_serviceorder where sa_serviceorderid=" + sa_serviceorderid)
                 .isEmpty()) {
@@ -152,6 +169,12 @@ public class serviceorder extends Controller {
         sqlFactory.addParameter("phonenumber", content.getStringValue("phonenumber"));
         sqlFactory.addParameter("sa_customersid", content.getStringValue("sa_customersid"));
         sqlFactory.addParameter("isonlinesales",isonlinesales);
+        sqlFactory.addParameter("isallowance",isallowance);
+
+        sqlFactory.addParameter("initiator",initiator);
+
+
+
         sqlFactory.addParameter("sys_enterpriseid_service",sys_enterpriseid_service);
 
 
@@ -176,6 +199,15 @@ public class serviceorder extends Controller {
         return queryserviceorderMain();
     }
 
+    @API(title = "更新是否补贴", apiversion = R.ID2025121517474303.v1.class)
+    public String cheangeisallowance() throws YosException {
+        Long sa_serviceorderid = content.getLong("sa_serviceorderid");
+        boolean isallowance = content.getBooleanValue("isallowance");
+        dbConnect.runSqlUpdate("update sa_serviceorder set isallowance="+isallowance+" where sa_serviceorderid="+sa_serviceorderid);
+        return getSucReturnObject().toString();
+    }
+
+
     /**
      * 服务分类查询
      **/
@@ -542,8 +574,12 @@ public class serviceorder extends Controller {
         querySQL.setTableAlias("t0");
         querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
         querySQL.setPage(pageSize, pageNumber);
+
         Rows rows = querySQL.query();
 
+
+
+
         ArrayList<Long> ids = rows.toArrayList("sa_serviceorderid", new ArrayList<>());
         HashMap<Long, ArrayList<String>> tagRows = DataTag.queryTag(this, "sa_serviceorder", ids, true);
         for (Row row : rows) {
@@ -819,6 +855,39 @@ public class serviceorder extends Controller {
 
     }
 
+    @API(title = "作废服务申请单", apiversion = R.ID2025121519311203.v1.class)
+    @CACHEING_CLEAN(apiClass = {workorder.class, serviceorder.class, warrantycard.class})
+    public String cancelServiceOrder() throws YosException {
+        long sa_serviceorderid = content.getLong("sa_serviceorderid");
+        String voidreason =content.getStringValue("voidreason");
+        ArrayList<String> sqllist = new ArrayList<>();
+        Rows workorderrows = dbConnect.runSqlQuery("select sa_workorderid from sa_workorder where sa_serviceorderid ='"
+                + sa_serviceorderid + "' and  siteid='" + siteid + "' and status!='作废'");
+        sqllist.add("update sa_serviceorder set voidreason='"+voidreason+"',status='作废' where sa_serviceorderid="+sa_serviceorderid);
+        sqllist.add(DataContrlLog.createLog(this, "sa_serviceorder", sa_serviceorderid, "作废", "服务申请单作废成功")
+                .getSQL());
+        if(workorderrows.isNotEmpty()){
+            long sa_workorderid= workorderrows.get(0).getLong("sa_workorderid");
+            voidreason="【服务申请单作废】"+voidreason;
+            sqllist.add("update sa_workorder set voidreason='"+voidreason+"',status='作废' where sa_workorderid="+sa_workorderid);
+            sqllist.add(DataContrlLog.createLog(this, "sa_workorder", sa_serviceorderid, "作废", "工单作废成功")
+                    .getSQL());
+            Rows warrantycardrows = dbConnect.runSqlQuery("select sa_warrantycardid from sa_warrantycard where sa_workorderid ='"
+                    + sa_workorderid + "' and  siteid='" + siteid + "' and isvoid=0");
+            if(warrantycardrows.isNotEmpty()){
+                sqllist.add("update sa_warrantycard set voiddate=CURRENT_TIME,voidreason='"+voidreason+"',isvoid=1 where sa_warrantycardid="+warrantycardrows.get(0).getLong("sa_warrantycardid"));
+                sqllist.add(DataContrlLog.createLog(this, "sa_warrantycard", warrantycardrows.get(0).getLong("sa_warrantycardid"), "作废", "保修卡作废成功")
+                        .getSQL());
+            }
+
+        }
+
+        dbConnect.runSqlUpdate(sqllist);
+
+        return getSucReturnObject().toString();
+    }
+
+
     @API(title = "发送手机验证码", apiversion = R.ID20230215173103.v1.class, accesstoken = false)
     public String sendMessage() throws YosException {
         String customerphone = "";

+ 39 - 6
src/custom/restcontroller/webmanage/sale/stockbill/stockbillitemssku.java

@@ -98,25 +98,58 @@ public class stockbillitemssku extends Controller {
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, st_stockbill_items_skuids.size());
 
         for (Object o : st_stockbill_items_skuids) {
+            ArrayList<String> sqllist = new ArrayList<>();
             long st_stockbill_items_skuid = Long.parseLong(o.toString());
-            Rows RowsStatus = dbConnect.runSqlQuery("select t1.st_stockbill_items_skuid,t2.status,t2.isreceiver,t1.st_stockbillid from st_stockbill_items_sku t1 left join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.siteid='"
+            Rows RowsStatus = dbConnect.runSqlQuery("select t1.st_stockbill_items_skuid,t2.type,t2.rb,t2.status,t2.isreceiver,t1.st_stockbillid,t1.stockid,t1.sku from st_stockbill_items_sku t1 left join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.siteid='"
                     + siteid + "' and t1.st_stockbill_items_skuid='" + st_stockbill_items_skuid + "'");
 
             if (RowsStatus.isNotEmpty()) {
-
                 if (RowsStatus.get(0).getBoolean("isreceiver")) {
                     batchDeleteErr.addErr(st_stockbill_items_skuid, "到货确认的出库单序列号明细无法删除");
                     continue;
                 }
+                if(RowsStatus.get(0).getString("status").equals("审核")){
+                    sqllist.add("update sa_itemsku set stockid=" + RowsStatus.get(0).getLong("stockid") + " where sku='" + RowsStatus.get(0).getString("sku") + "'");
+                    if (RowsStatus.get(0).getString("type").equals("销售出库")) {
+                        sqllist.add("update sa_itemsku set sa_agentsid=0,sys_enterpriseid=0 where sku='" + RowsStatus.get(0).getString("sku") + "'");
+                    }
+                }
             }
-            ArrayList<String> list = new ArrayList<>();
-            list.add("delete from st_stockbill_items_sku where siteid='" + siteid
+            sqllist.add("delete from st_stockbill_items_sku where siteid='" + siteid
                     + "' and st_stockbill_items_skuid=" + st_stockbill_items_skuid);
-
-            dbConnect.runSqlUpdate(list);
+            dbConnect.runSqlUpdate(sqllist);
         }
+
         return batchDeleteErr.getReturnObject().toString();
     }
 
+    /**
+     * @param type
+     * @param rb
+     * @param fischeck
+     * @return
+     */
+    public boolean isinstock(String type, String rb, boolean fischeck) {
+        if (type.equals("其他出库") || type.equals("销售出库")
+                || type.equals("生产领料出库") || type.equals("委外领料出库")
+                || type.equals("返修出库")) {
+            if ((fischeck && rb.equals("1")) || (!fischeck && rb.equals("0"))) {
+                return false;
+            } else {
+                return true;
+            }
+
+        } else if (type.equals("其他入库") || type.equals("外购入库")
+                || type.equals("生产入库") || type.equals("委外入库")
+                || type.equals("返修入库")) {
+            if ((fischeck && rb.equals("1")) || (!fischeck && rb.equals("0"))) {
+                return true;
+            } else {
+                return false;
+            }
+        }
+        return false;
+    }
+
 
 }

+ 1 - 14
src/custom/restcontroller/webmanage/sale/workorder/workorder.java

@@ -495,8 +495,6 @@ public class workorder extends Controller {
         sqlFactory2.addParameter("siteid", siteid);
         sqlFactory2.addParameter_SQL("where", where);
         Rows rows_total = dbConnect.runSqlQuery(sqlFactory2.getSQL());
-        Rows curnodesRows = dbConnect.runSqlQuery("select sa_workorderid,siteid,workpresetjson,status from (select ROW_NUMBER() over(partition by t.sa_workorderid,t.siteid order by t.sequence asc) RowNum ,t.* from sa_workorder_node t where t.status!=1 and t.parentid!=0) as t1  where RowNum = 1");
-        RowsMap curnodesRowsMap = curnodesRows.toRowsMap("sa_workorderid");
 
         QuerySQL userquerySQL = SQLFactory.createQuerySQL(this, "sys_users","userid");
         userquerySQL.setTableAlias("t1");
@@ -508,17 +506,6 @@ public class workorder extends Controller {
 
         if (!rows.isEmpty()) {
             for (Row row : rows) {
-                if (curnodesRowsMap.containsKey(row.getString("sa_workorderid"))) {
-                    if (!curnodesRowsMap.get(row.getString("sa_workorderid")).isEmpty()) {
-                        workpresetInfo workpresetInfo = JSON.parseObject(curnodesRowsMap.get(row.getString("sa_workorderid")).get(0).getString("workpresetjson"), workpresetInfo.class);
-                        row.put("curcontent", workpresetInfo.getWorkname());
-                    } else {
-                        row.put("curcontent", "");
-                    }
-
-                } else {
-                    row.put("curcontent", "");
-                }
                 if(userrowsMap.containsKey(row.getString("serviceordercreateuserid"))){
                     if(userrowsMap.get(row.getString("serviceordercreateuserid")).get(0).getLong("usertype")==99){
                         row.put("needcode", true);
@@ -1257,7 +1244,7 @@ public class workorder extends Controller {
                 insertSQL.setValue("county", itemrows.get(0).getString("county"));
                 insertSQL.setValue("enddate", formattedDate);
                 insertSQL.setValue("begdate", getDateTime_Str());
-                insertSQL.setValue("itemid",  itemrows.get(0).getLong("itemid"));
+                insertSQL.setValue("sa_workorderid",sa_workorderid);
                 if (dbConnect.runSqlQuery("select * from sa_warrantycard where sku='" + itemrows.get(0).getString("sku") + "' and siteid='" + siteid + "' and isvoid=0").isNotEmpty()) {
                     return getErrReturnObject().setErrMsg("该序列号已安装,无法再次安装").toString();
                 }else{