瀏覽代碼

工单详情-进行中-添加配件

hu 4 天之前
父節點
當前提交
b2eaeaebce

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

@@ -6476,6 +6476,21 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025080610424703 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025080610425103 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025080610425503 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 1 - 1
src/custom/restcontroller/webmanage/sale/accessoryorder/accessoryorder.java

@@ -362,7 +362,7 @@ public class accessoryorder extends Controller {
 
         QuerySQL querySQL=SQLFactory.createQuerySQL(this,"sa_aftersalesbom_pjs","*");
         querySQL.setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.inner,"plm_item","t3","t1.itemid = t3.itemid AND t1.siteid = t3.siteid","itemno","itemname","model","spec");
+        querySQL.addJoinTable(JOINTYPE.inner,"plm_item","t3","t1.itemid = t3.itemid AND t1.siteid = t3.siteid","model","spec");
         querySQL.setWhere("t1.siteid",siteid);
         querySQL.setWhere("t1.sa_aftersalesbomid",sa_aftersalesbomid);
         querySQL.setWhere(where.toString());

+ 6 - 1
src/custom/restcontroller/webmanage/sale/invbal/invbal.java

@@ -97,12 +97,17 @@ public class invbal extends Controller {
                 where.append("or t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append(")");
             }
+            if (whereObject.containsKey("ismodule") && !"".equals(whereObject.getString("ismodule"))) {
+                where.append(" and(");
+                where.append("t2.ismodule ='").append(whereObject.getString("ismodule")).append("' ");
+                where.append(")");
+            }
         }
         SQLFactory sqlFactory;
         QuerySQL querySQL;
         if (istotal) {
 //            sqlFactory = new SQLFactory(this, "销售库存列表查询", pageSize, pageNumber, pageSorting);
-            querySQL = SQLFactory.createQuerySQL(this, "st_invbal_sale", "*");
+            querySQL = SQLFactory.createQuerySQL(this, "st_invbal_total", "*");
             querySQL.setTableAlias("t1");
             querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.itemid = t2.itemid AND t1.siteid = t2.siteid","itemno","itemname","model");
             querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t3", "t3.unitid = t2.unitid AND t3.siteid = t2.siteid","unitname");

+ 8 - 1
src/custom/restcontroller/webmanage/sale/sendplan/sendplan.java

@@ -33,7 +33,7 @@ public class sendplan extends Controller {
         Long departmentid = content.getLongValue("departmentid");
         String senddate = content.getStringValue("senddate",false,"null");
         String type = content.getStringValue("type");
-        if (dbConnect.runSqlQuery("select * from sa_sendplan where siteid='"+siteid+"'").isEmpty()) {
+        if (dbConnect.runSqlQuery("select * from sa_sendplan where type='"+type+"' and  siteid='"+siteid+"'").isEmpty()) {
             sa_sendplanid = createTableID(tableName);
             InsertSQL insertSQL = SQLFactory.createInsertSQL(this, tableName);
             insertSQL.setUniqueid(sa_sendplanid).setSiteid(siteid);
@@ -77,7 +77,14 @@ public class sendplan extends Controller {
         /*
           过滤条件设置
          */
+        boolean ishuahuo= content.getBooleanValue("ishuahuo");
         StringBuffer where = new StringBuffer(" 1=1 ");
+        if(ishuahuo){
+            where.append(" and t1.type!='配件订单' ");
+        }else{
+            where.append(" and t1.type='配件订单' ");
+        }
+
 //        if (content.containsKey("where")) {
 //            JSONObject whereObject = content.getJSONObject("where");
 //            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {

+ 3 - 2
src/custom/restcontroller/webmanage/sale/serviceorder/serviceorder.java

@@ -638,8 +638,9 @@ public class serviceorder extends Controller {
                 workpresetInfo.setRequired(row.getLong("required"));
                 workpresetInfo.setTextedit(row.getLong("textedit"));
                 workpresetInfo.setSignature(row.getLong("signature"));
-                workpresetInfo.setPasscheck(row.getString("passcheck"));
-                workpresetInfo.setQuestionedit(row.getString("questionedit"));
+                workpresetInfo.setPasscheck(row.getLong("passcheck"));
+                workpresetInfo.setQuestionedit(row.getLong("questionedit"));
+                workpresetInfo.setQuestionoption(row.getLong("questionoption"));
                 String workpresetjson = JSONObject.toJSONString(workpresetInfo);
                 SQLFactory sqlFactory = new SQLFactory(this, "服务工单流程节点新增");
                 long sa_workorder_nodeid = createTableID("sa_workorder_node");

+ 4 - 1
src/custom/restcontroller/webmanage/sale/workorder/SQL/服务工单节点更新.sql

@@ -6,5 +6,8 @@ SET
     remarks = $remarks$,
     textcontent=$textcontent$,
     confirm_value = $confirm_value$,
-    amount=$amount$
+    amount=$amount$,
+    questionoption=$questionoption$,
+    questionedit=$questionedit$,
+    passcheck=$passcheck$
 WHERE sa_workorderid = $sa_workorderid$ and sa_workorder_nodeid=$sa_workorder_nodeid$ and siteid=$siteid$

+ 47 - 0
src/custom/restcontroller/webmanage/sale/workorder/SQL/查询可添加配件列表.sql

@@ -0,0 +1,47 @@
+SELECT t1.itemid,
+       t1.itemno,
+       t1.itemname,
+       t1.model,
+       t1.batchcontrol,
+       t1.orderminqty_auxunit,
+       t1.orderminqty,
+       t1.orderaddqty_auxunit,
+       t1.orderaddqty,
+       t1.spec,
+       t1.standards,
+       t1.delistingstatus,
+       t1.marketprice,
+       t1.packageqty,
+       t1.iscustomsize,
+       t1.widthschemeid,
+       t1.lengthschemeid,
+       t1.materialschemeid,
+       t1.colorschemeid,
+       t1.cheekschemeid,
+       t1.sa_customschemeid,
+       t4.unitname unit,
+       t5.unitname auxunit,
+       t2.conversionrate,
+       t3.material,
+       t3.erpitemno,
+       t3.erpitemname,
+       t3.specalnote,
+       t3.prodline,
+       t3.device,
+       t7.bomfullname
+from plm_item t1
+         LEFT JOIN plm_unitgroup t2 ON t2.unitgroupid = t1.unitgroupid and t2.siteid = t1.siteid
+         left join plm_itemextend t3 on t3.itemid = t1.itemid and t3.siteid = t1.siteid
+         LEFT JOIN plm_unit t4 ON t4.unitid = t1.unitid AND t4.siteid = t1.siteid
+         LEFT JOIN plm_unit t5 ON t5.unitid = t2.auxunitid AND t5.siteid = t2.siteid
+         LEFT JOIN sa_itemsalebom t6 on t1.itemid=t6.itemid and t6.siteid = t1.siteid
+         LEFT JOIN plm_bom t7 on t7.plm_bomid=t6.plm_bomid and t6.siteid = t7.siteid
+WHERE t1.siteid = $siteid$
+  and t1.isonsale = 1
+  and t1.isused = 1
+  and t1.ismodule=1
+  and $where$
+  and t1.itemid not in (SELECT t1.itemid
+                    from sa_workorder_node_items t1
+                    WHERE t1.siteid = $siteid$
+                      and t1.sa_workorderid = $sa_workorderid$)

+ 21 - 0
src/custom/restcontroller/webmanage/sale/workorder/SQL/查询所有分类.sql

@@ -0,0 +1,21 @@
+with recursive saleclass as (select t1.plm_bomid,
+                                    t1.bomname,
+                                    t1.bomfullname,
+                                    ifnull(t1.parentid, 0) as parentid,
+                                    t1.num,
+                                    t1.isdeep
+                             from plm_bom t1
+                             where t1.siteid = $siteid$
+                             union
+                             select t2.plm_bomid,
+                                    t2.bomname,
+                                    t2.bomfullname,
+                                    ifnull(t2.parentid, 0) as parentid,
+                                    t2.num,
+                                    t2.isdeep
+                             from plm_bom t2,
+                                  saleclass t3
+                             where t2.siteid = $siteid$
+                               and t2.plm_bomid = t3.parentid)
+select *
+from saleclass

+ 219 - 4
src/custom/restcontroller/webmanage/sale/workorder/workorder.java

@@ -1,7 +1,9 @@
 package restcontroller.webmanage.sale.workorder;
 
+import beans.brand.Brand;
 import beans.datacontrllog.DataContrlLog;
 import beans.datateam.DataTeam;
+import beans.itemprice.ItemPrice;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -15,17 +17,23 @@ import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
 import restcontroller.webmanage.executorService.Executor;
 
+import restcontroller.webmanage.sale.bom.SortByNum;
 import restcontroller.webmanage.sale.serviceorder.serviceorder;
 import restcontroller.webmanage.sale.serviceorder.serviceorderItems;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.regex.Pattern;
 
+import static beans.order.Order.getOrderRows;
+
 /**
  * 服务工单管理
  */
@@ -551,6 +559,10 @@ public class workorder extends Controller {
             /** 添加备注 **/
             updateNodesqlFactory.addParameter("remarks", content.getStringValue("remarks"));
 
+            updateNodesqlFactory.addParameter("questionedit", content.getStringValue("questionedit"));
+            updateNodesqlFactory.addParameter("questionoption", content.getStringValue("questionoption"));
+            updateNodesqlFactory.addParameter("passcheck", content.getStringValue("passcheck"));
+
             /** 添加团队 **/
             if (content.containsKey("team")) {
 
@@ -996,8 +1008,9 @@ public class workorder extends Controller {
                 workpresetInfo.setRequired(row.getLong("required"));
                 workpresetInfo.setTextedit(row.getLong("textedit"));
                 workpresetInfo.setSignature(row.getLong("signature"));
-                workpresetInfo.setPasscheck(row.getString("passcheck"));
-                workpresetInfo.setQuestionedit(row.getString("questionedit"));
+                workpresetInfo.setPasscheck(row.getLong("passcheck"));
+                workpresetInfo.setQuestionedit(row.getLong("questionedit"));
+                workpresetInfo.setQuestionoption(row.getLong("questionoption"));
                 String workpresetjson = JSONObject.toJSONString(workpresetInfo);
                 SQLFactory sqlFactory = new SQLFactory(this, "服务工单流程节点新增");
                 long sa_workorder_nodeid = createTableID("sa_workorder_node");
@@ -1111,6 +1124,27 @@ public class workorder extends Controller {
                 return "请填写完整工序内容:没有添加文本";
             }
 
+        }
+        // 是否问题填写
+        if (workpresetInfo.getQuestionedit() == 11) {
+            if (StringUtils.isBlank(rows.get(0).getString("questionedit"))) {
+                return "请填写完整工序内容:没有添加问题填写";
+            }
+
+        }
+        // 是否合格确认
+        if (workpresetInfo.getPasscheck() == 11) {
+            if (StringUtils.isBlank(rows.get(0).getString("passcheck"))) {
+                return "请填写完整工序内容:没有合格确认";
+            }
+
+        }
+        // 是否填写问题选项分类
+        if (workpresetInfo.getQuestionoption() == 11) {
+            if (StringUtils.isBlank(rows.get(0).getString("questionoption"))) {
+                return "请填写完整工序内容:没有填写问题选项分类";
+            }
+
         }
         // 是否有偿
         if (workpresetInfo.getAmountpay() == 11) {
@@ -1168,11 +1202,192 @@ public class workorder extends Controller {
             workpresetInfo.setRequired(row.getLong("required"));
             workpresetInfo.setTextedit(row.getLong("textedit"));
             workpresetInfo.setSignature(row.getLong("signature"));
-            workpresetInfo.setPasscheck(row.getString("passcheck"));
-            workpresetInfo.setQuestionedit(row.getString("questionedit"));
+            workpresetInfo.setPasscheck(row.getLong("passcheck"));
+            workpresetInfo.setQuestionedit(row.getLong("questionedit"));
+            workpresetInfo.setQuestionoption(row.getLong("questionoption"));
             jsonObject = JSONArray.parseObject(JSON.toJSONString(workpresetInfo));
 
         }
         return jsonObject;
     }
+
+    @API(title = "判断产品信息是否有售后配件bom", apiversion = R.ID2025080610424703.v1.class)
+    public String judgeitemhasbom() throws YosException {
+        long itemid =content.getLongValue("itemid");
+        String sku =content.getStringValue("sku");
+        long sa_aftersalesbomid=0;
+        if(StringUtils.isBlank(sku)){
+            return getSucReturnObject().setData(sa_aftersalesbomid).toString();
+        }
+        Rows aftersalesbomitemsrows =dbConnect.runSqlQuery("select * from sa_aftersalesbom_items where itemid="+itemid+" and siteid='"+siteid+"'");
+        if(aftersalesbomitemsrows.isNotEmpty()){
+            sa_aftersalesbomid=aftersalesbomitemsrows.get(0).getLong("sa_aftersalesbomid");
+        }
+        return getSucReturnObject().setData(sa_aftersalesbomid).toString();
+    }
+
+    @API(title = "配件列表查询", apiversion = R.ID2025080610425103.v1.class)
+    public String queryAccessoryList() throws YosException {
+        long sa_workorderid= content.getLong("sa_workorderid");
+        sys_enterpriseid=content.getLong("sys_enterpriseid");
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.itemname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.model like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.bomfullname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+
+
+        }
+
+        SQLFactory sqlFactory = new SQLFactory(this, "查询可添加配件列表");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("sa_workorderid", sa_workorderid);
+        sqlFactory.addParameter_SQL("where", where);
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter",  "sys_site_parameterid");
+        querySQL.setTableAlias("t");
+        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "'111' = t.siteid ","*");
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+        ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
+        ids.add(0l);
+        //查询附件
+        RowsMap attinfoRowsMap = getAttachmentUrl("plm_item", ids);
+        //商品领域
+        RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
+        //品牌
+        RowsMap brandRowsMap = Brand.getBrandRowsMap(this, ids);
+        //价格
+        HashMap<Long, ItemPrice> itemPriceRowsMap = ItemPrice.getItemPrice(this, sys_enterpriseid, ids);
+        for (Row row : rows) {
+            row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+            row.put("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+            row.put("brand", brandRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+            if (itemPriceRowsMap.containsKey(row.getLong("itemid"))) {
+                row.put("price", itemPriceRowsMap.get(row.getLong("itemid")).getPrice());
+            } else {
+                row.put("price", 0);
+            }
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "查询售后bom的配件列表(按层级)", apiversion = R.ID2025080610425503.v1.class)
+    public String queryListByLevl() throws YosException, ParseException {
+        long sa_aftersalesbomid=content.getLong("sa_aftersalesbomid");
+        String sku =content.getStringValue("sku");
+        sys_enterpriseid=content.getLong("sys_enterpriseid");
+        Rows rows = dbConnect.runSqlQuery("select * from sa_aftersalesbom where sa_aftersalesbomid="+sa_aftersalesbomid);
+        Rows skurows = dbConnect.runSqlQuery("select * from sa_itemsku where sku='"+sku+"' and siteid='"+siteid+"'");
+        String skucreatedate="";
+        if(skurows.isNotEmpty()){
+            skucreatedate=skurows.get(0).getString("createdate");
+        }
+        String where ="1=1";
+        if (StringUtils.isNotBlank(skucreatedate)) {
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+            String skudate = format.format(format.parse(skucreatedate));
+            where = where + " and DATE_FORMAT(t1.begindate, '%Y-%m-%d') <='" + skudate + "'";
+            where = where + " and DATE_FORMAT(t1.enddate, '%Y-%m-%d') >='" + skudate+ "'";
+        }
+        String productcategories="";
+        if(rows.isNotEmpty()){
+            productcategories=rows.get(0).getString("productcategories");
+        }
+        QuerySQL querySQL=SQLFactory.createQuerySQL(this,"sa_aftersalesbom_pjs","*");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.inner,"plm_item","t3","t1.itemid = t3.itemid AND t1.siteid = t3.siteid","model","spec");
+        querySQL.setWhere("t1.siteid",siteid);
+        querySQL.setWhere("t1.sa_aftersalesbomid",sa_aftersalesbomid);
+        querySQL.setWhere(where.toString());
+        querySQL.addQueryFields("typename","if(ifnull(accessorie,'')='',if(ifnull(component,''),module,component),accessorie)");
+        Rows pjrows=querySQL.query();
+
+        ArrayList<Long> ids = pjrows.toArrayList("itemid", new ArrayList<>());
+        //查询附件
+        RowsMap attinfoRowsMap = getAttachmentUrl("plm_item", ids);
+        //商品领域
+        RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
+        //品牌
+        RowsMap brandRowsMap = Brand.getBrandRowsMap(this, ids);
+        //价格
+        HashMap<Long, ItemPrice> itemPriceRowsMap = ItemPrice.getItemPrice(this, sys_enterpriseid, ids);
+        for (Row row : pjrows) {
+            row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+            row.put("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+            row.put("brand", brandRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+            if (itemPriceRowsMap.containsKey(row.getLong("itemid"))) {
+                row.put("price", itemPriceRowsMap.get(row.getLong("itemid")).getPrice());
+            } else {
+                row.put("price", 0);
+            }
+        }
+        RowsMap pjrowsMap=pjrows.toRowsMap("typename");
+
+
+        /*
+         * 查询所有分类
+         */
+        SQLFactory sqlFactory = new SQLFactory(this, "查询所有分类");
+        sqlFactory.addParameter("siteid", siteid);
+
+        String sql = sqlFactory.getSQL();
+        Rows allrows = dbConnect.runSqlQuery(sql);
+        /*
+         * 获取所有一级分类
+         */
+        Rows rows2 =new Rows();
+        Row row =new Row();
+        Rows toprows1 = allrows.toRowsMap("parentid").get("0");
+        Rows toprows =new Rows();
+        for(Row row1 :toprows1){
+            if(row1.getString("bomname").equals(productcategories)){
+                toprows.add(row1);
+            }
+        }
+        Collections.sort(toprows, new restcontroller.webmanage.sale.bom.SortByNum());
+        /*
+         * 递归查询
+         */
+        for (Row row1 : toprows) {
+            Rows rows1 = getSubbom(row1, allrows,pjrowsMap);
+            //Collections.sort(rows1, new SortByNum());
+            row1.put("subdep", rows1);
+        }
+        row.put("bom", toprows);
+        rows2.add(row);
+        if (rows2.isNotEmpty()) {
+            if (((Rows) rows2.get(0).get("bom")).isNotEmpty()) {
+                Collections.sort((Rows) rows2.get(0).get("bom"), new SortByNum());
+            }
+        }
+        return getSucReturnObject().setData(rows2).toString();
+    }
+
+    /**
+     * 递归查询下级产品类别
+     *
+     * @param root
+     * @param allboms
+     * @return
+     */
+    private Rows getSubbom(Row root, Rows allboms,RowsMap rowsMap) {
+        Rows childrenRows = allboms.toRowsMap("parentid").get(root.getString("plm_bomid"));
+        Collections.sort(childrenRows, new SortByNum());
+
+        for (Row row : childrenRows) {
+            if(rowsMap.containsKey(row.getString("bomname"))){
+                row.put("items",rowsMap.get(row.getString("bomname")));
+            }
+            row.put("subdep", getSubbom(row, allboms,rowsMap));
+        }
+        return childrenRows;
+    }
+
 }

+ 16 - 6
src/custom/restcontroller/webmanage/sale/workorder/workpresetInfo.java

@@ -17,22 +17,32 @@ public class workpresetInfo {
 	private Long amountpay;
 	private Long required;
 	private Long signature;
-	private String passcheck;
-	private String questionedit;
+	private Long passcheck;
+	private Long questionedit;
 
-	public String getPasscheck() {
+	private Long questionoption;
+
+
+	public Long getQuestionoption() {
+		return questionoption;
+	}
+
+	public void setQuestionoption(Long questionoption) {
+		this.questionoption = questionoption;
+	}
+	public Long getPasscheck() {
 		return passcheck;
 	}
 
-	public void setPasscheck(String passcheck) {
+	public void setPasscheck(Long passcheck) {
 		this.passcheck = passcheck;
 	}
 
-	public String getQuestionedit() {
+	public Long getQuestionedit() {
 		return questionedit;
 	}
 
-	public void setQuestionedit(String questionedit) {
+	public void setQuestionedit(Long questionedit) {
 		this.questionedit = questionedit;
 	}