|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|