|
|
@@ -22,17 +22,14 @@ import restcontroller.webmanage.executorService.Executor;
|
|
|
import restcontroller.webmanage.sale.bom.SortByNum;
|
|
|
import restcontroller.webmanage.sale.serviceorder.serviceorder;
|
|
|
import restcontroller.webmanage.sale.serviceorder.serviceorderItems;
|
|
|
+import utility.sms.Sms;
|
|
|
|
|
|
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 java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 服务工单管理
|
|
|
@@ -81,8 +78,7 @@ public class workorder extends Controller {
|
|
|
long itemid = content.getLongValue("itemid");
|
|
|
|
|
|
|
|
|
- Rows rows = dbConnect.runSqlQuery(
|
|
|
- "select * from sa_workorder where sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_workorder where sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
if (rows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该工单不存在").toString();
|
|
|
}
|
|
|
@@ -90,8 +86,7 @@ public class workorder extends Controller {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "服务工单更新");
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_workorder", sa_workorderid, "更新", "服务工单更新成功").getSQL());
|
|
|
if (projectlearders != null && !projectlearders.isEmpty()) {
|
|
|
- sqlList.add("delete from sys_datateam where ownertable='sa_workorder' and ownerid="
|
|
|
- + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
+ sqlList.add("delete from sys_datateam where ownertable='sa_workorder' and ownerid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
for (Object obj : projectlearders) {
|
|
|
sqlList.addAll(DataTeam.createTeamSQL(this, "sa_workorder", sa_workorderid, (int) obj));
|
|
|
}
|
|
|
@@ -145,7 +140,7 @@ public class workorder extends Controller {
|
|
|
|
|
|
sqlList.add(updateSQL.getSQL());
|
|
|
|
|
|
- sqlList.add("update sa_serviceorderitems set itemid='"+itemid+"',sku='"+sku+"',cardno='"+cardno+"' where sa_serviceorderid="+sa_serviceorderid+" and siteid ='"+siteid+"'");
|
|
|
+ sqlList.add("update sa_serviceorderitems set itemid='" + itemid + "',sku='" + sku + "',cardno='" + cardno + "' where sa_serviceorderid=" + sa_serviceorderid + " and siteid ='" + siteid + "'");
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
content.put("sa_workorderid", sa_workorderid);
|
|
|
|
|
|
@@ -223,76 +218,73 @@ public class workorder extends Controller {
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
|
|
|
- if(rows.isNotEmpty()){
|
|
|
- Rows serviceorderitemsrows = dbConnect.runSqlQuery("SELECT t1.itemid,t1.sku, t1.cardno,t11.itemno,t11.itemname,t11.model,t11.spec,t12.begdate cardbegdate,t12.enddate cardenddate FROM sa_serviceorderitems t1 left join sa_warrantycard t12 on t1.cardno=t12.cardno left join plm_item t11 on t11.itemid=t1.itemid and t11.siteid=t1.siteid WHERE t1.sa_serviceorderid="+rows.get(0).getLong("sa_serviceorderid")+" ORDER BY t1.sa_serviceorderitemsid ASC");
|
|
|
- if(serviceorderitemsrows.isEmpty()){
|
|
|
- rows.get(0).put("itemid","");
|
|
|
- rows.get(0).put("sku","");
|
|
|
- rows.get(0).put("cardno","");
|
|
|
- rows.get(0).put("itemno","");
|
|
|
- rows.get(0).put("itemname","");
|
|
|
- rows.get(0).put("model","");
|
|
|
- rows.get(0).put("spec","");
|
|
|
- rows.get(0).put("cardbegdate","");
|
|
|
- rows.get(0).put("cardenddate","");
|
|
|
- }else{
|
|
|
- rows.get(0).put("itemid",serviceorderitemsrows.get(0).getString("itemid"));
|
|
|
- rows.get(0).put("sku",serviceorderitemsrows.get(0).getString("sku"));
|
|
|
- rows.get(0).put("cardno",serviceorderitemsrows.get(0).getString("cardno"));
|
|
|
- rows.get(0).put("itemno",serviceorderitemsrows.get(0).getString("itemno"));
|
|
|
- rows.get(0).put("itemname",serviceorderitemsrows.get(0).getString("itemname"));
|
|
|
- rows.get(0).put("model",serviceorderitemsrows.get(0).getString("model"));
|
|
|
- rows.get(0).put("spec",serviceorderitemsrows.get(0).getString("spec"));
|
|
|
- rows.get(0).put("cardbegdate",serviceorderitemsrows.get(0).getString("cardbegdate"));
|
|
|
- rows.get(0).put("cardenddate",serviceorderitemsrows.get(0).getString("cardenddate"));
|
|
|
- }
|
|
|
- Rows amountrows = dbConnect.runSqlQuery("select sa_workorderid,max(ifnull(accessoryamount,0)) accessoryamount,max(ifnull(dooramount,0)) dooramount,max(ifnull(amount,0)) amount from sa_workorder_node where sa_workorderid="+sa_workorderid+" group by sa_workorderid");
|
|
|
- if(amountrows.isEmpty()){
|
|
|
- rows.get(0).put("accessoryamount",0);
|
|
|
- rows.get(0).put("dooramount",0);
|
|
|
- rows.get(0).put("amount",0);
|
|
|
- }else{
|
|
|
- rows.get(0).put("accessoryamount",amountrows.get(0).getString("accessoryamount"));
|
|
|
- rows.get(0).put("dooramount",amountrows.get(0).getString("dooramount"));
|
|
|
- rows.get(0).put("amount",amountrows.get(0).getString("amount"));
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- QuerySQL userquerySQL = SQLFactory.createQuerySQL(this, "sys_users","userid");
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ Rows serviceorderitemsrows = dbConnect.runSqlQuery("SELECT t1.itemid,t1.sku, t1.cardno,t11.itemno,t11.itemname,t11.model,t11.spec,t12.begdate cardbegdate,t12.enddate cardenddate FROM sa_serviceorderitems t1 left join sa_warrantycard t12 on t1.cardno=t12.cardno left join plm_item t11 on t11.itemid=t1.itemid and t11.siteid=t1.siteid WHERE t1.sa_serviceorderid=" + rows.get(0).getLong("sa_serviceorderid") + " ORDER BY t1.sa_serviceorderitemsid ASC");
|
|
|
+ if (serviceorderitemsrows.isEmpty()) {
|
|
|
+ rows.get(0).put("itemid", "");
|
|
|
+ rows.get(0).put("sku", "");
|
|
|
+ rows.get(0).put("cardno", "");
|
|
|
+ rows.get(0).put("itemno", "");
|
|
|
+ rows.get(0).put("itemname", "");
|
|
|
+ rows.get(0).put("model", "");
|
|
|
+ rows.get(0).put("spec", "");
|
|
|
+ rows.get(0).put("cardbegdate", "");
|
|
|
+ rows.get(0).put("cardenddate", "");
|
|
|
+ } else {
|
|
|
+ rows.get(0).put("itemid", serviceorderitemsrows.get(0).getString("itemid"));
|
|
|
+ rows.get(0).put("sku", serviceorderitemsrows.get(0).getString("sku"));
|
|
|
+ rows.get(0).put("cardno", serviceorderitemsrows.get(0).getString("cardno"));
|
|
|
+ rows.get(0).put("itemno", serviceorderitemsrows.get(0).getString("itemno"));
|
|
|
+ rows.get(0).put("itemname", serviceorderitemsrows.get(0).getString("itemname"));
|
|
|
+ rows.get(0).put("model", serviceorderitemsrows.get(0).getString("model"));
|
|
|
+ rows.get(0).put("spec", serviceorderitemsrows.get(0).getString("spec"));
|
|
|
+ rows.get(0).put("cardbegdate", serviceorderitemsrows.get(0).getString("cardbegdate"));
|
|
|
+ rows.get(0).put("cardenddate", serviceorderitemsrows.get(0).getString("cardenddate"));
|
|
|
+ }
|
|
|
+ Rows amountrows = dbConnect.runSqlQuery("select sa_workorderid,max(ifnull(accessoryamount,0)) accessoryamount,max(ifnull(dooramount,0)) dooramount,max(ifnull(amount,0)) amount from sa_workorder_node where sa_workorderid=" + sa_workorderid + " group by sa_workorderid");
|
|
|
+ if (amountrows.isEmpty()) {
|
|
|
+ rows.get(0).put("accessoryamount", 0);
|
|
|
+ rows.get(0).put("dooramount", 0);
|
|
|
+ rows.get(0).put("amount", 0);
|
|
|
+ } else {
|
|
|
+ rows.get(0).put("accessoryamount", amountrows.get(0).getString("accessoryamount"));
|
|
|
+ rows.get(0).put("dooramount", amountrows.get(0).getString("dooramount"));
|
|
|
+ rows.get(0).put("amount", amountrows.get(0).getString("amount"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL userquerySQL = SQLFactory.createQuerySQL(this, "sys_users", "userid");
|
|
|
userquerySQL.setTableAlias("t1");
|
|
|
userquerySQL.addJoinTable(JOINTYPE.left, "sys_usersite", "t2", "t1.userid = t2.userid", "usertype");
|
|
|
- userquerySQL.setWhere("t2.siteid",siteid);
|
|
|
- userquerySQL.setWhere("t1.userid",rows.toArrayList("serviceordercreateuserid"));
|
|
|
+ userquerySQL.setWhere("t2.siteid", siteid);
|
|
|
+ userquerySQL.setWhere("t1.userid", rows.toArrayList("serviceordercreateuserid"));
|
|
|
Rows userrows = userquerySQL.query();
|
|
|
- RowsMap userrowsMap =userrows.toRowsMap("userid");
|
|
|
+ RowsMap userrowsMap = userrows.toRowsMap("userid");
|
|
|
|
|
|
- if(userrowsMap.containsKey(row.getString("serviceordercreateuserid"))){
|
|
|
- if(userrowsMap.get(row.getString("serviceordercreateuserid")).get(0).getLong("usertype")==99){
|
|
|
+ if (userrowsMap.containsKey(row.getString("serviceordercreateuserid"))) {
|
|
|
+ if (userrowsMap.get(row.getString("serviceordercreateuserid")).get(0).getLong("usertype") == 99) {
|
|
|
row.put("needcode", true);
|
|
|
- }else{
|
|
|
- if(row.getString("type").equals("安装")){
|
|
|
+ } else {
|
|
|
+ if (row.getString("type").equals("安装")) {
|
|
|
row.put("needcode", true);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
row.put("needcode", false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
row.put("needcode", true);
|
|
|
}
|
|
|
|
|
|
if (!row.isEmpty()) {
|
|
|
/** 工单工序查询 **/
|
|
|
- Rows rowsOneLevelWorkpreset = dbConnect
|
|
|
- .runSqlQuery("select t2.*,t1.sa_workorder_template_worksid,t1.sequence,t1.parentid from sa_workorder_template_works t1 left join sa_workpreset t2 on t1.sa_workpresetid=t2.sa_workpresetid and t1.siteid=t2.siteid where t1.parentid=0 and t1.sa_workorder_templateid=" + row.getLong("sa_workorder_templateid")
|
|
|
- + " and t1.siteid='" + siteid + "'");
|
|
|
+ Rows rowsOneLevelWorkpreset = dbConnect.runSqlQuery("select t2.*,t1.sa_workorder_template_worksid,t1.sequence,t1.parentid from sa_workorder_template_works t1 left join sa_workpreset t2 on t1.sa_workpresetid=t2.sa_workpresetid and t1.siteid=t2.siteid where t1.parentid=0 and t1.sa_workorder_templateid=" + row.getLong("sa_workorder_templateid") + " and t1.siteid='" + siteid + "'");
|
|
|
RowsMap rowsOneLevelMapWorkpreset = rowsOneLevelWorkpreset.toRowsMap("sequence");
|
|
|
- Rows rowsOneLevel = dbConnect
|
|
|
- .runSqlQuery("SELECT *,ROW_NUMBER() OVER (PARTITION BY parentid, sa_workorderid, siteid ORDER BY sa_workorder_nodeid) AS rownum FROM sa_workorder_node WHERE siteid = '"+siteid+"' AND sa_workorderid = "+sa_workorderid+" ORDER BY parentid, rownum");
|
|
|
- Rows rowsTwoLevel =new Rows();
|
|
|
- for (Row rowOneLevel :rowsOneLevel) {
|
|
|
- if(rowOneLevel.getInteger("parentid")!=0){
|
|
|
+ Rows rowsOneLevel = dbConnect.runSqlQuery("SELECT *,ROW_NUMBER() OVER (PARTITION BY parentid, sa_workorderid, siteid ORDER BY sa_workorder_nodeid) AS rownum FROM sa_workorder_node WHERE siteid = '" + siteid + "' AND sa_workorderid = " + sa_workorderid + " ORDER BY parentid, rownum");
|
|
|
+ Rows rowsTwoLevel = new Rows();
|
|
|
+ for (Row rowOneLevel : rowsOneLevel) {
|
|
|
+ if (rowOneLevel.getInteger("parentid") != 0) {
|
|
|
rowsTwoLevel.add(rowOneLevel);
|
|
|
}
|
|
|
}
|
|
|
@@ -303,7 +295,7 @@ public class workorder extends Controller {
|
|
|
ids.addAll(rowsTwoLevel.toArrayList("sa_workorder_nodeid", new ArrayList<>()));
|
|
|
RowsMap attRowsMap = getAttachmentUrl("sa_workorder_node", ids);
|
|
|
|
|
|
- RowsMap rowsMapdetails = queryWorkOrderNodedetails(sa_workorderid, row.getLong("sys_enterpriseid"),attRowsMap);
|
|
|
+ RowsMap rowsMapdetails = queryWorkOrderNodedetails(sa_workorderid, row.getLong("sys_enterpriseid"), attRowsMap);
|
|
|
if (rowsOneLevelMap.containsKey("0")) {
|
|
|
for (Row rowOneLevel : rowsOneLevelMap.get("0")) {
|
|
|
long sa_workorder_template_worksid = 0;
|
|
|
@@ -314,8 +306,7 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- rowOneLevel.put("attinfos",
|
|
|
- attRowsMap.get(rowOneLevel.getString("sa_workorder_nodeid")));
|
|
|
+ rowOneLevel.put("attinfos", attRowsMap.get(rowOneLevel.getString("sa_workorder_nodeid")));
|
|
|
rowOneLevel.put("detail", rowsMapdetails.get(rowOneLevel.getString("sa_workorder_nodeid")));
|
|
|
Rows lowerRows = rowsTwoLevelMap.get(rowOneLevel.getString("sa_workorder_nodeid"));
|
|
|
if (!lowerRows.isEmpty()) {
|
|
|
@@ -324,24 +315,20 @@ public class workorder extends Controller {
|
|
|
lowerRow.put("workpresetjson", queryCorrespondingWorkpresetInfo(row.getLong("sa_workorder_templateid"), lowerRow.getString("rownum"), sa_workorder_template_worksid));
|
|
|
}
|
|
|
|
|
|
- lowerRow.put("attinfos",
|
|
|
- attRowsMap.get(lowerRow.getString("sa_workorder_nodeid")));
|
|
|
+ lowerRow.put("attinfos", attRowsMap.get(lowerRow.getString("sa_workorder_nodeid")));
|
|
|
lowerRow.put("detail", rowsMapdetails.get(lowerRow.getString("sa_workorder_nodeid")));
|
|
|
}
|
|
|
}
|
|
|
rowOneLevel.put("child", lowerRows);
|
|
|
}
|
|
|
}
|
|
|
- row.put("nodes", rowsOneLevelMap.get("0"));
|
|
|
+ row.put("nodes", rowsOneLevelMap.get("0"));
|
|
|
/** 工单团队查询 **/
|
|
|
- Rows workorderteamRows = dbConnect.runSqlQuery("select t1.*,t2.phonenumber from sys_datateam t1 left join sys_users t2 on t1.userid=t2.userid where t1.siteid='" + siteid
|
|
|
- + "' and t1.ownertable='sa_workorder' and t1.ownerid=" + sa_workorderid);
|
|
|
+ Rows workorderteamRows = dbConnect.runSqlQuery("select t1.*,t2.phonenumber from sys_datateam t1 left join sys_users t2 on t1.userid=t2.userid where t1.siteid='" + siteid + "' and t1.ownertable='sa_workorder' and t1.ownerid=" + sa_workorderid);
|
|
|
row.put("team", workorderteamRows);
|
|
|
|
|
|
/** 工单物料查询 **/
|
|
|
- Rows workorderitemRows = dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where ifnull(t1.sa_workorder_nodeid,0)=0 and t1.sa_workorderid="
|
|
|
- + sa_workorderid + " and t1.siteid='" + siteid + "'");
|
|
|
+ Rows workorderitemRows = dbConnect.runSqlQuery("select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where ifnull(t1.sa_workorder_nodeid,0)=0 and t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='" + siteid + "'");
|
|
|
row.put("titems", workorderitemRows);
|
|
|
}
|
|
|
|
|
|
@@ -353,7 +340,7 @@ public class workorder extends Controller {
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
|
|
|
|
- public RowsMap queryWorkOrderNodedetails(long sa_workorderid, long sys_enterpriseid,RowsMap attRowsMap) throws YosException {
|
|
|
+ public RowsMap queryWorkOrderNodedetails(long sa_workorderid, long sys_enterpriseid, RowsMap attRowsMap) throws YosException {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "服务工单节点查询全部");
|
|
|
sqlFactory.addParameter("sa_workorderid", sa_workorderid);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
@@ -365,17 +352,11 @@ public class workorder extends Controller {
|
|
|
sa_workorder_templateid = sa_workorder_templateids.get(0).getLong("sa_workorder_templateid");
|
|
|
}
|
|
|
|
|
|
- Rows workorderteamRows = dbConnect
|
|
|
- .runSqlQuery("select * from sys_datateam where ownertable='sa_workorder_node' and siteid='" + siteid
|
|
|
- + "'");
|
|
|
+ Rows workorderteamRows = dbConnect.runSqlQuery("select * from sys_datateam where ownertable='sa_workorder_node' and siteid='" + siteid + "'");
|
|
|
RowsMap workorderteamRowsMap = workorderteamRows.toRowsMap("ownerid");
|
|
|
|
|
|
/** 工单节点物料查询 **/
|
|
|
- Rows workorderitemRows = dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec,t7.bomfullname,ifnull(t1.isnew,0) isnew from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.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.sa_workorderid=" + sa_workorderid + " and t1.siteid='"
|
|
|
- + siteid + "'");
|
|
|
+ Rows workorderitemRows = dbConnect.runSqlQuery("select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec,t7.bomfullname,ifnull(t1.isnew,0) isnew from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.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.sa_workorderid=" + sa_workorderid + " and t1.siteid='" + siteid + "'");
|
|
|
// 默认商品图片
|
|
|
Rows defaultImageRows = beans.Item.Item.getItemdefaultImage(this);
|
|
|
// 附件
|
|
|
@@ -398,9 +379,7 @@ public class workorder extends Controller {
|
|
|
RowsMap workorderitemRowsMap = workorderitemRows.toRowsMap("sa_workorder_nodeid");
|
|
|
|
|
|
/** 节点关联培训人员查询 **/
|
|
|
- Rows trainers = dbConnect.runSqlQuery(
|
|
|
- "select t1.sa_workorder_node_teamid,t1.createuserid,t1.createby,t1.createdate,t1.sa_workorderid,t1.sa_workorder_nodeid,if(t1.userid>0,t3.name,t1.name) name,if(t1.userid>0,t3.phonenumber,t1.phonenumber) phonenumber,if(t1.userid>0,t3.position,t1.position) position,t2.enterprisename,t2.phonenumber enterprisephonenumber from sa_workorder_node_team t1 left join sys_enterprise t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sys_hr t3 on t1.userid=t3.userid and t1.siteid=t3.siteid where t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='"
|
|
|
- + siteid + "'");
|
|
|
+ Rows trainers = dbConnect.runSqlQuery("select t1.sa_workorder_node_teamid,t1.createuserid,t1.createby,t1.createdate,t1.sa_workorderid,t1.sa_workorder_nodeid,if(t1.userid>0,t3.name,t1.name) name,if(t1.userid>0,t3.phonenumber,t1.phonenumber) phonenumber,if(t1.userid>0,t3.position,t1.position) position,t2.enterprisename,t2.phonenumber enterprisephonenumber from sa_workorder_node_team t1 left join sys_enterprise t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sys_hr t3 on t1.userid=t3.userid and t1.siteid=t3.siteid where t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='" + siteid + "'");
|
|
|
RowsMap trainersRowsMap = trainers.toRowsMap("sa_workorder_nodeid");
|
|
|
ArrayList<Long> ids = rows.toArrayList("sa_workorder_nodeid", new ArrayList<>());
|
|
|
for (Row row : rows) {
|
|
|
@@ -408,7 +387,7 @@ public class workorder extends Controller {
|
|
|
if (row.getLong("parentid") == 0) {
|
|
|
row.put("workpresetjson", queryCorrespondingWorkpresetInfo(sa_workorder_templateid, row.getString("rownum"), 0));
|
|
|
} else {
|
|
|
- Rows sa_workorder_template_worksids = dbConnect.runSqlQuery("SELECT sa_workorder_template_worksid FROM sa_workorder_template_works WHERE sa_workorder_templateid = "+sa_workorder_templateid+" AND parentid = 0 AND sequence = (SELECT rownum FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY parentid, sa_workorderid, siteid ORDER BY sa_workorder_nodeid) AS rownum FROM sa_workorder_node WHERE sa_workorder_nodeid = "+ row.getLong("parentid") +" AND siteid ='"+siteid+"') t);");
|
|
|
+ Rows sa_workorder_template_worksids = dbConnect.runSqlQuery("SELECT sa_workorder_template_worksid FROM sa_workorder_template_works WHERE sa_workorder_templateid = " + sa_workorder_templateid + " AND parentid = 0 AND sequence = (SELECT rownum FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY parentid, sa_workorderid, siteid ORDER BY sa_workorder_nodeid) AS rownum FROM sa_workorder_node WHERE sa_workorder_nodeid = " + row.getLong("parentid") + " AND siteid ='" + siteid + "') t);");
|
|
|
if (!sa_workorder_template_worksids.isEmpty()) {
|
|
|
row.put("workpresetjson", queryCorrespondingWorkpresetInfo(sa_workorder_templateid, row.getString("sequence"), sa_workorder_template_worksids.get(0).getLong("sa_workorder_template_worksid")));
|
|
|
}
|
|
|
@@ -450,17 +429,15 @@ public class workorder extends Controller {
|
|
|
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
if (!content.getBooleanValue("isadmin")) {
|
|
|
- where.append(
|
|
|
- " and exists(select 1 from sys_datateam where ownerid=t1.sa_workorderid and ownertable='sa_workorder' and userid='")
|
|
|
- .append(userid).append("')");
|
|
|
+ where.append(" and exists(select 1 from sys_datateam where ownerid=t1.sa_workorderid and ownertable='sa_workorder' and userid='").append(userid).append("')");
|
|
|
}
|
|
|
if (sys_enterpriseid != 0) {
|
|
|
where.append(" and t2.sys_enterpriseid_service ='").append(sys_enterpriseid).append("'");
|
|
|
}
|
|
|
|
|
|
- Rows usertyperows = dbConnect.runSqlQuery("select t2.usertype from sys_usersite t2 where t2.siteid = 'md' and t2.userid="+userid);
|
|
|
- if(usertyperows.isNotEmpty()){
|
|
|
- if(usertyperows.get(0).getString("usertype").equals("2")){
|
|
|
+ Rows usertyperows = dbConnect.runSqlQuery("select t2.usertype from sys_usersite t2 where t2.siteid = 'md' and t2.userid=" + userid);
|
|
|
+ if (usertyperows.isNotEmpty()) {
|
|
|
+ if (usertyperows.get(0).getString("usertype").equals("2")) {
|
|
|
SQLFactory areasqlFactory = new SQLFactory(new promotion(content), "区域经理查询下属营销区域");
|
|
|
areasqlFactory.addParameter("siteid", siteid);
|
|
|
areasqlFactory.addParameter("hrid", hrid);
|
|
|
@@ -545,28 +522,28 @@ public class workorder extends Controller {
|
|
|
// sqlFactory2.addParameter_SQL("where", where);
|
|
|
// Rows rows_total = dbConnect.runSqlQuery(sqlFactory2.getSQL());
|
|
|
|
|
|
- QuerySQL userquerySQL = SQLFactory.createQuerySQL(this, "sys_users","userid");
|
|
|
+ QuerySQL userquerySQL = SQLFactory.createQuerySQL(this, "sys_users", "userid");
|
|
|
userquerySQL.setTableAlias("t1");
|
|
|
userquerySQL.addJoinTable(JOINTYPE.left, "sys_usersite", "t2", "t1.userid = t2.userid", "usertype");
|
|
|
- userquerySQL.setWhere("t2.siteid",siteid);
|
|
|
- userquerySQL.setWhere("t1.userid",rows.toArrayList("serviceordercreateuserid"));
|
|
|
+ userquerySQL.setWhere("t2.siteid", siteid);
|
|
|
+ userquerySQL.setWhere("t1.userid", rows.toArrayList("serviceordercreateuserid"));
|
|
|
Rows userrows = userquerySQL.query();
|
|
|
- RowsMap userrowsMap =userrows.toRowsMap("userid");
|
|
|
+ RowsMap userrowsMap = userrows.toRowsMap("userid");
|
|
|
|
|
|
if (!rows.isEmpty()) {
|
|
|
for (Row row : rows) {
|
|
|
- if(userrowsMap.containsKey(row.getString("serviceordercreateuserid"))){
|
|
|
- if(userrowsMap.get(row.getString("serviceordercreateuserid")).get(0).getLong("usertype")==99){
|
|
|
+ if (userrowsMap.containsKey(row.getString("serviceordercreateuserid"))) {
|
|
|
+ if (userrowsMap.get(row.getString("serviceordercreateuserid")).get(0).getLong("usertype") == 99) {
|
|
|
row.put("needcode", true);
|
|
|
- }else{
|
|
|
- if(row.getString("type").equals("安装")){
|
|
|
+ } else {
|
|
|
+ if (row.getString("type").equals("安装")) {
|
|
|
row.put("needcode", true);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
row.put("needcode", false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
row.put("needcode", true);
|
|
|
}
|
|
|
|
|
|
@@ -575,7 +552,6 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
@@ -608,7 +584,7 @@ public class workorder extends Controller {
|
|
|
|
|
|
row.put("workpresetjson", queryCorrespondingWorkpresetInfo(sa_workorder_templateid, row.getString("rownum"), 0));
|
|
|
} else {
|
|
|
- Rows sa_workorder_template_worksids = dbConnect.runSqlQuery("SELECT sa_workorder_template_worksid FROM sa_workorder_template_works WHERE sa_workorder_templateid = "+sa_workorder_templateid+" AND parentid = 0 AND sequence = (SELECT rownum FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY parentid, sa_workorderid, siteid ORDER BY sa_workorder_nodeid) AS rownum FROM sa_workorder_node WHERE sa_workorder_nodeid = "+ row.getLong("parentid") +" AND siteid ='"+siteid+"') t);");
|
|
|
+ Rows sa_workorder_template_worksids = dbConnect.runSqlQuery("SELECT sa_workorder_template_worksid FROM sa_workorder_template_works WHERE sa_workorder_templateid = " + sa_workorder_templateid + " AND parentid = 0 AND sequence = (SELECT rownum FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY parentid, sa_workorderid, siteid ORDER BY sa_workorder_nodeid) AS rownum FROM sa_workorder_node WHERE sa_workorder_nodeid = " + row.getLong("parentid") + " AND siteid ='" + siteid + "') t);");
|
|
|
if (!sa_workorder_template_worksids.isEmpty()) {
|
|
|
row.put("workpresetjson", queryCorrespondingWorkpresetInfo(sa_workorder_templateid, row.getString("sequence"), sa_workorder_template_worksids.get(0).getLong("sa_workorder_template_worksid")));
|
|
|
}
|
|
|
@@ -623,18 +599,11 @@ public class workorder extends Controller {
|
|
|
RowsMap attRowsMap = getAttachmentUrl("sa_workorder_node", ids);
|
|
|
row.put("attinfos", attRowsMap.get(row.getString("sa_workorder_nodeid")));
|
|
|
/** 工单节点团队查询 **/
|
|
|
- Rows workorderteamRows = dbConnect
|
|
|
- .runSqlQuery("select * from sys_datateam where ownertable='sa_workorder_node' and siteid='" + siteid
|
|
|
- + "' and ownerid=" + sa_workorder_nodeid);
|
|
|
+ Rows workorderteamRows = dbConnect.runSqlQuery("select * from sys_datateam where ownertable='sa_workorder_node' and siteid='" + siteid + "' and ownerid=" + sa_workorder_nodeid);
|
|
|
row.put("team", workorderteamRows);
|
|
|
|
|
|
/** 工单节点物料查询 **/
|
|
|
- Rows workorderitemRows = dbConnect.runSqlQuery(
|
|
|
- "select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec,t7.bomfullname,ifnull(t1.isnew,0) isnew from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.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.sa_workorder_nodeid="
|
|
|
- + sa_workorder_nodeid + " and t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='"
|
|
|
- + siteid + "'");
|
|
|
+ Rows workorderitemRows = dbConnect.runSqlQuery("select t1.*,t2.itemno,t2.model,t2.itemname,t2.spec,t7.bomfullname,ifnull(t1.isnew,0) isnew from sa_workorder_node_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.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.sa_workorder_nodeid=" + sa_workorder_nodeid + " and t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='" + siteid + "'");
|
|
|
// 默认商品图片
|
|
|
Rows defaultImageRows = beans.Item.Item.getItemdefaultImage(this);
|
|
|
// 附件
|
|
|
@@ -663,10 +632,7 @@ public class workorder extends Controller {
|
|
|
// row.put("traintitem", traintitem);
|
|
|
|
|
|
/** 节点关联培训人员查询 **/
|
|
|
- Rows trainers = dbConnect.runSqlQuery(
|
|
|
- "select t1.sa_workorder_node_teamid,t1.createuserid,t1.createby,t1.createdate,t1.sa_workorderid,t1.sa_workorder_nodeid,if(t1.userid>0,t3.name,t1.name) name,if(t1.userid>0,t3.phonenumber,t1.phonenumber) phonenumber,if(t1.userid>0,t3.position,t1.position) position,t2.enterprisename,t2.phonenumber enterprisephonenumber from sa_workorder_node_team t1 left join sys_enterprise t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sys_hr t3 on t1.userid=t3.userid and t1.siteid=t3.siteid where t1.sa_workorder_nodeid="
|
|
|
- + sa_workorder_nodeid + " and t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='"
|
|
|
- + siteid + "'");
|
|
|
+ Rows trainers = dbConnect.runSqlQuery("select t1.sa_workorder_node_teamid,t1.createuserid,t1.createby,t1.createdate,t1.sa_workorderid,t1.sa_workorder_nodeid,if(t1.userid>0,t3.name,t1.name) name,if(t1.userid>0,t3.phonenumber,t1.phonenumber) phonenumber,if(t1.userid>0,t3.position,t1.position) position,t2.enterprisename,t2.phonenumber enterprisephonenumber from sa_workorder_node_team t1 left join sys_enterprise t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sys_hr t3 on t1.userid=t3.userid and t1.siteid=t3.siteid where t1.sa_workorder_nodeid=" + sa_workorder_nodeid + " and t1.sa_workorderid=" + sa_workorderid + " and t1.siteid='" + siteid + "'");
|
|
|
row.put("trainers", trainers);
|
|
|
|
|
|
}
|
|
|
@@ -682,8 +648,7 @@ public class workorder extends Controller {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
Long sa_workorder_nodeid = content.getLong("sa_workorder_nodeid");
|
|
|
|
|
|
- Rows workerorderrows = dbConnect.runSqlQuery("select sa_workorderid,status from sa_workorder where siteid='"
|
|
|
- + siteid + "' and sa_workorderid=" + sa_workorderid);
|
|
|
+ Rows workerorderrows = dbConnect.runSqlQuery("select sa_workorderid,status from sa_workorder where siteid='" + siteid + "' and sa_workorderid=" + sa_workorderid);
|
|
|
if (workerorderrows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该工单不存在").toString();
|
|
|
} else {
|
|
|
@@ -722,11 +687,9 @@ public class workorder extends Controller {
|
|
|
|
|
|
JSONArray team = content.getJSONArray("team");
|
|
|
if (!team.isEmpty() && team != null) {
|
|
|
- sqlList.add("delete from sys_datateam where ownertable='sa_workorder_node' and ownerid="
|
|
|
- + sa_workorder_nodeid + " and siteid='" + siteid + "'");
|
|
|
+ sqlList.add("delete from sys_datateam where ownertable='sa_workorder_node' and ownerid=" + sa_workorder_nodeid + " and siteid='" + siteid + "'");
|
|
|
for (Object obj : team) {
|
|
|
- sqlList.addAll(
|
|
|
- DataTeam.createTeamSQL(this, "sa_workorder_node", sa_workorder_nodeid, (int) obj));
|
|
|
+ sqlList.addAll(DataTeam.createTeamSQL(this, "sa_workorder_node", sa_workorder_nodeid, (int) obj));
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -736,19 +699,16 @@ public class workorder extends Controller {
|
|
|
/** 添加培训人员 **/
|
|
|
if (content.containsKey("trainers")) {
|
|
|
JSONArray trainers = content.getJSONArray("trainers");
|
|
|
- sqlList.add("delete from sa_workorder_node_team where sa_workorderid=" + sa_workorderid
|
|
|
- + " and sa_workorder_nodeid=" + sa_workorder_nodeid + " and siteid='" + siteid + "'");
|
|
|
+ sqlList.add("delete from sa_workorder_node_team where sa_workorderid=" + sa_workorderid + " and sa_workorder_nodeid=" + sa_workorder_nodeid + " and siteid='" + siteid + "'");
|
|
|
if (!trainers.isEmpty() && trainers != null) {
|
|
|
for (Object o : trainers) {
|
|
|
JSONObject jsonObject = (JSONObject) o;
|
|
|
|
|
|
SQLFactory addtrainersqlFactory = new SQLFactory(this, "服务工单节点参与人员新增");
|
|
|
- addtrainersqlFactory.addParameter("sa_workorder_node_teamid",
|
|
|
- createTableID("sa_workorder_node_team"));
|
|
|
+ addtrainersqlFactory.addParameter("sa_workorder_node_teamid", createTableID("sa_workorder_node_team"));
|
|
|
addtrainersqlFactory.addParameter("sa_workorderid", sa_workorderid);
|
|
|
addtrainersqlFactory.addParameter("sa_workorder_nodeid", sa_workorder_nodeid);
|
|
|
- addtrainersqlFactory.addParameter("sys_enterpriseid",
|
|
|
- jsonObject.getLongValue("sys_enterpriseid"));
|
|
|
+ addtrainersqlFactory.addParameter("sys_enterpriseid", jsonObject.getLongValue("sys_enterpriseid"));
|
|
|
addtrainersqlFactory.addParameter("userid", jsonObject.getLongValue("userid"));
|
|
|
addtrainersqlFactory.addParameter("name", jsonObject.getStringValue("name"));
|
|
|
addtrainersqlFactory.addParameter("phonenumber", jsonObject.getStringValue("phonenumber"));
|
|
|
@@ -765,15 +725,13 @@ public class workorder extends Controller {
|
|
|
/** 添加培训商品 **/
|
|
|
if (content.containsKey("traintitem")) {
|
|
|
JSONArray traintitem = content.getJSONArray("traintitem");
|
|
|
- sqlList.add("delete from sa_workorder_node_items where sa_workorderid=" + sa_workorderid
|
|
|
- + " and sa_workorder_nodeid=" + sa_workorder_nodeid + " and siteid='" + siteid + "'");
|
|
|
+ sqlList.add("delete from sa_workorder_node_items where sa_workorderid=" + sa_workorderid + " and sa_workorder_nodeid=" + sa_workorder_nodeid + " and siteid='" + siteid + "'");
|
|
|
if (!traintitem.isEmpty() && traintitem != null) {
|
|
|
for (Object o : traintitem) {
|
|
|
JSONObject jsonObject = (JSONObject) o;
|
|
|
|
|
|
SQLFactory addtraintitemsqlFactory = new SQLFactory(this, "服务工单节点货品明细新增");
|
|
|
- addtraintitemsqlFactory.addParameter("sa_workorder_node_itemsid",
|
|
|
- createTableID("sa_workorder_node_items"));
|
|
|
+ addtraintitemsqlFactory.addParameter("sa_workorder_node_itemsid", createTableID("sa_workorder_node_items"));
|
|
|
addtraintitemsqlFactory.addParameter("sa_workorderid", sa_workorderid);
|
|
|
addtraintitemsqlFactory.addParameter("sa_workorder_nodeid", sa_workorder_nodeid);
|
|
|
addtraintitemsqlFactory.addParameter("itemid", jsonObject.getLongValue("itemid"));
|
|
|
@@ -794,8 +752,7 @@ public class workorder extends Controller {
|
|
|
/** 添加服务价格 **/
|
|
|
if (content.containsKey("amount") && content.getDouble("amount") > 0) {
|
|
|
updateNodesqlFactory.addParameter("amount", content.getBigDecimal("amount"));
|
|
|
- sqlList.add("update sa_workorder set amount=" + content.getBigDecimal("amount")
|
|
|
- + " where sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
+ sqlList.add("update sa_workorder set amount=" + content.getBigDecimal("amount") + " where sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
} else {
|
|
|
updateNodesqlFactory.addParameter("amount", 0);
|
|
|
}
|
|
|
@@ -845,30 +802,24 @@ public class workorder extends Controller {
|
|
|
@API(title = "查询工单所选新配件金额", apiversion = R.ID2025112114461803.v1.class)
|
|
|
public String querynewitemamount() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
- Rows amountrows = dbConnect.runSqlQuery("select ROUND(t1.qty*ifnull(t2.marketprice,0), 2) amount from sa_workorder_node_items t1 inner join plm_item t2 on t1.itemid=t2.itemid where t1.isnew=1 and t1.sa_workorderid="+sa_workorderid);
|
|
|
+ Rows amountrows = dbConnect.runSqlQuery("select ROUND(t1.qty*ifnull(t2.marketprice,0), 2) amount from sa_workorder_node_items t1 inner join plm_item t2 on t1.itemid=t2.itemid where t1.isnew=1 and t1.sa_workorderid=" + sa_workorderid);
|
|
|
return getSucReturnObject().setData(amountrows.sum("amount")).toString();
|
|
|
}
|
|
|
|
|
|
|
|
|
@API(title = "工单接单", apiversion = R.ID20230210101103.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class,
|
|
|
- R.ID20230209091103.v1.class, R.ID20230206091603.v1.class, R.ID20230206101303.v1.class,
|
|
|
- R.ID20230206091703.v1.class, R.ID20230207154203.v1.class, R.ID20230217100703.v1.class, R.ID20230217133003.v1.class})
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class, R.ID20230209091103.v1.class, R.ID20230206091603.v1.class, R.ID20230206101303.v1.class, R.ID20230206091703.v1.class, R.ID20230207154203.v1.class, R.ID20230217100703.v1.class, R.ID20230217133003.v1.class})
|
|
|
public String accept() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
for (Row row : rows) {
|
|
|
if (!row.getString("status").equals("待接单")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非待接单状态,无法接单")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非待接单状态,无法接单").toString();
|
|
|
}
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- sqlList.add(
|
|
|
- "update sa_workorder set status='待开始',startdate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
+ sqlList.add("update sa_workorder set status='待开始',startdate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_workorder", sa_workorderid, "工单接单", "服务工单接单成功").getSQL());
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
@@ -876,26 +827,19 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "开始工单", apiversion = R.ID20230209144503.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class,
|
|
|
- R.ID20230209091103.v1.class, R.ID20230206091603.v1.class, R.ID20230206101303.v1.class,
|
|
|
- R.ID20230206091703.v1.class, R.ID20230207154203.v1.class, R.ID20230217100703.v1.class, R.ID20230217133003.v1.class})
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class, R.ID20230209091103.v1.class, R.ID20230206091603.v1.class, R.ID20230206101303.v1.class, R.ID20230206091703.v1.class, R.ID20230207154203.v1.class, R.ID20230217100703.v1.class, R.ID20230217133003.v1.class})
|
|
|
public String start() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
for (Row row : rows) {
|
|
|
if (!row.getString("status").equals("待开始")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非待开始状态,无法开始工单")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非待开始状态,无法开始工单").toString();
|
|
|
}
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- sqlList.add(
|
|
|
- "update sa_workorder set status='进行中',startdate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
- sqlList.add("update sa_serviceorder set status='服务中' where sa_serviceorderid="
|
|
|
- + rows.get(0).getLong("sa_serviceorderid"));
|
|
|
+ sqlList.add("update sa_workorder set status='进行中',startdate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
+ sqlList.add("update sa_serviceorder set status='服务中' where sa_serviceorderid=" + rows.get(0).getLong("sa_serviceorderid"));
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_workorder", sa_workorderid, "工单开始", "服务工单开始成功").getSQL());
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
@@ -903,18 +847,14 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "暂停工单", apiversion = R.ID20230209144603.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class,
|
|
|
- R.ID20230209091103.v1.class, R.ID20230207154203.v1.class})
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class, R.ID20230209091103.v1.class, R.ID20230207154203.v1.class})
|
|
|
public String stop() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
for (Row row : rows) {
|
|
|
if (!row.getString("status").equals("进行中")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非进行中状态,无法暂停工单")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非进行中状态,无法暂停工单").toString();
|
|
|
}
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
@@ -926,18 +866,14 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "启用工单", apiversion = R.ID20230209144703.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class,
|
|
|
- R.ID20230209091103.v1.class, R.ID20230207154203.v1.class})
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20230208140103.v1.class, R.ID20230208140203.v1.class, R.ID20230209091103.v1.class, R.ID20230207154203.v1.class})
|
|
|
public String used() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
for (Row row : rows) {
|
|
|
if (!row.getString("status").equals("暂停")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非暂停状态,无法启用工单")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非暂停状态,无法启用工单").toString();
|
|
|
}
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
@@ -954,16 +890,13 @@ public class workorder extends Controller {
|
|
|
public String cancel() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
long sa_serviceorderid = 0;
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
if (!rows.isEmpty()) {
|
|
|
sa_serviceorderid = rows.get(0).getLong("sa_serviceorderid");
|
|
|
}
|
|
|
for (Row row : rows) {
|
|
|
if (row.getString("status").equals("已完工")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非已完工状态,无法作废工单")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非已完工状态,无法作废工单").toString();
|
|
|
}
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
@@ -999,13 +932,10 @@ public class workorder extends Controller {
|
|
|
public String submit() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
for (Row row : rows) {
|
|
|
if (!row.getString("status").equals("进行中")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非进行中状态,无法提交工单")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非进行中状态,无法提交工单").toString();
|
|
|
}
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
@@ -1013,9 +943,7 @@ public class workorder extends Controller {
|
|
|
int allcount = 0; // 必须完成工作项数量
|
|
|
int count = 0; // 已完成必须完成工作项数量
|
|
|
String str = "";
|
|
|
- Rows noderows = dbConnect.runSqlQuery(
|
|
|
- "select sa_workorder_nodeid,status,workpresetjson from sa_workorder_node where parentid !=0 and sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "' ");
|
|
|
+ Rows noderows = dbConnect.runSqlQuery("select sa_workorder_nodeid,status,workpresetjson from sa_workorder_node where parentid !=0 and sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "' ");
|
|
|
if (!noderows.isEmpty()) {
|
|
|
for (Row row : noderows) {
|
|
|
workpresetInfo workpresetInfo = JSON.parseObject(row.getString("workpresetjson"), workpresetInfo.class);
|
|
|
@@ -1030,11 +958,9 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
}
|
|
|
if (count != allcount) {
|
|
|
- return getErrReturnObject().setErrMsg("【" + str.substring(0, str.length() - 1) + "】" + "的工序未完成,无法提交工单!")
|
|
|
- .toString();
|
|
|
+ return getErrReturnObject().setErrMsg("【" + str.substring(0, str.length() - 1) + "】" + "的工序未完成,无法提交工单!").toString();
|
|
|
}
|
|
|
- sqlList.add(
|
|
|
- "update sa_workorder set status='提交',changeby='"+username+"',changedate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
+ sqlList.add("update sa_workorder set status='提交',changeby='" + username + "',changedate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_workorder", sa_workorderid, "工单提交", "服务工单提交成功").getSQL());
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
@@ -1046,22 +972,11 @@ public class workorder extends Controller {
|
|
|
JSONArray sa_workorderids = content.getJSONArray("sa_workorderids");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_workorderids.size());
|
|
|
- for(Object object :sa_workorderids){
|
|
|
- long sa_workorderid =Long.parseLong(object.toString());
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno,type,finishby,finishdate from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ for (Object object : sa_workorderids) {
|
|
|
+ long sa_workorderid = Long.parseLong(object.toString());
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno,type,finishby,finishdate from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
if (rows.get(0).getString("type").equals("安装") && rows.get(0).getString("status").equals("提交")) {
|
|
|
- Rows itemrows = dbConnect.runSqlQuery("select t1.sku,t3.scenecontact,t3.scenecontactphonenumber,t3.sa_customersid,t5.sa_agentsid customeragentsid," +
|
|
|
- "case when t3.sa_customersid!=0 then t5.name else t3.name end name,case when t3.sa_customersid!=0 then t5.phonenumber else t3.phonenumber end phonenumber," +
|
|
|
- "t3.province,t3.city,t3.county, case when t3.sa_customersid!=0 then t5.address else t3.address end address,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid,t6.sa_agentsid sa_agentsid_to,t6.agentnum toagentnum,t7.itemid from sa_serviceorderitems t1 \n" +
|
|
|
- " inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid \n" +
|
|
|
- " left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid \n" +
|
|
|
- " left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid \n" +
|
|
|
- " left join sa_customers t5 on t5.sa_customersid=t3.sa_customersid and t5.siteid=t3.siteid \n" +
|
|
|
- " left join sa_agents t6 on t3.sys_enterpriseid_service=t6.sys_enterpriseid and t3.siteid=t6.siteid \n" +
|
|
|
- " left join sa_itemsku t7 on t7.sku=t1.sku and t7.siteid=t1.siteid " +
|
|
|
- "where t1.sa_serviceorderid=" + rows.get(0).getLong("sa_serviceorderid") + " and t1.siteid='" + siteid + "' ");
|
|
|
+ Rows itemrows = dbConnect.runSqlQuery("select t1.sku,t3.scenecontact,t3.scenecontactphonenumber,t3.sa_customersid,t5.sa_agentsid customeragentsid," + "case when t3.sa_customersid!=0 then t5.name else t3.name end name,case when t3.sa_customersid!=0 then t5.phonenumber else t3.phonenumber end phonenumber," + "t3.province,t3.city,t3.county, case when t3.sa_customersid!=0 then t5.address else t3.address end address,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid,t6.sa_agentsid sa_agentsid_to,t6.agentnum toagentnum,t7.itemid from sa_serviceorderitems t1 \n" + " inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid \n" + " left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid \n" + " left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid \n" + " left join sa_customers t5 on t5.sa_customersid=t3.sa_customersid and t5.siteid=t3.siteid \n" + " left join sa_agents t6 on t3.sys_enterpriseid_service=t6.sys_enterpriseid and t3.siteid=t6.siteid \n" + " left join sa_itemsku t7 on t7.sku=t1.sku and t7.siteid=t1.siteid " + "where t1.sa_serviceorderid=" + rows.get(0).getLong("sa_serviceorderid") + " and t1.siteid='" + siteid + "' ");
|
|
|
|
|
|
if (itemrows.isNotEmpty()) {
|
|
|
|
|
|
@@ -1072,7 +987,7 @@ public class workorder extends Controller {
|
|
|
if (itemrows.get(0).getLong("sa_customersid") != 0) {
|
|
|
sa_customersid = itemrows.get(0).getLong("sa_customersid");
|
|
|
customeragentsid = itemrows.get(0).getLong("customeragentsid");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// return getErrReturnObject().setErrMsg("客户不存在").toString();
|
|
|
// InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_customers");
|
|
|
// sa_customersid = createTableID("sa_customers");
|
|
|
@@ -1097,10 +1012,10 @@ public class workorder extends Controller {
|
|
|
// sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
|
LocalDate now;
|
|
|
- if(StringUtils.isBlank(rows.get(0).getString("finishdate"))){
|
|
|
- now = LocalDate.now();
|
|
|
- }else{
|
|
|
- now = LocalDate.parse(getDate_Str(rows.get(0).getDate("finishdate")));
|
|
|
+ if (StringUtils.isBlank(rows.get(0).getString("finishdate"))) {
|
|
|
+ now = LocalDate.now();
|
|
|
+ } else {
|
|
|
+ now = LocalDate.parse(getDate_Str(rows.get(0).getDate("finishdate")));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1116,10 +1031,10 @@ public class workorder extends Controller {
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_warrantycard");
|
|
|
insertSQL.setUniqueid(createTableID("sa_warrantycard"));
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
- if(sa_customersid!=0){
|
|
|
+ if (sa_customersid != 0) {
|
|
|
insertSQL.setValue("sa_agentsid", customeragentsid);
|
|
|
insertSQL.setValue("toagentnum", itemrows.get(0).getString("toagentnum"));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
insertSQL.setValue("sa_agentsid", itemrows.get(0).getString("sa_agentsid_to"));
|
|
|
insertSQL.setValue("toagentnum", itemrows.get(0).getString("toagentnum"));
|
|
|
}
|
|
|
@@ -1135,13 +1050,13 @@ public class workorder extends Controller {
|
|
|
insertSQL.setValue("county", itemrows.get(0).getString("county"));
|
|
|
insertSQL.setValue("enddate", formattedDate);
|
|
|
insertSQL.setValue("begdate", now.format(formatter));
|
|
|
- insertSQL.setValue("itemid", itemrows.get(0).getLong("itemid"));
|
|
|
+ insertSQL.setValue("itemid", itemrows.get(0).getLong("itemid"));
|
|
|
insertSQL.setValue("createby", rows.get(0).getString("finishby"));
|
|
|
- insertSQL.setValue("createdate", StringUtils.isBlank(rows.get(0).getString("finishdate"))?"CURRENT_TIME":rows.get(0).getString("finishdate"));
|
|
|
+ insertSQL.setValue("createdate", StringUtils.isBlank(rows.get(0).getString("finishdate")) ? "CURRENT_TIME" : rows.get(0).getString("finishdate"));
|
|
|
if (dbConnect.runSqlQuery("select * from sa_warrantycard where sku='" + itemrows.get(0).getString("sku") + "' and siteid='" + siteid + "' and isvoid=0").isNotEmpty()) {
|
|
|
batchDeleteErr.addErr(sa_workorderid, "该序列号已安装,无法再次安装");
|
|
|
continue;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
|
sqlList.add("update sa_workorder set status='已完工' where sa_workorderid=" + sa_workorderid);
|
|
|
@@ -1161,9 +1076,7 @@ public class workorder extends Controller {
|
|
|
public String completeorder() throws YosException {
|
|
|
Long sa_workorderid = content.getLong("sa_workorderid");
|
|
|
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno,type,address from sa_workorder where sa_workorderid ='"
|
|
|
- + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno,type,address from sa_workorder where sa_workorderid ='" + sa_workorderid + "' and siteid='" + siteid + "'");
|
|
|
if (!rows.isEmpty()) {
|
|
|
if (!rows.get(0).getString("status").equals("提交")) {
|
|
|
return getErrReturnObject().setErrMsg("非提交状态无法完结工单").toString();
|
|
|
@@ -1190,36 +1103,23 @@ public class workorder extends Controller {
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
+
|
|
|
+ long sa_serviceorderid = rows.get(0).getLong("sa_serviceorderid");
|
|
|
+ String type = rows.get(0).getString("type");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
/** 判断预约单是否可以完成 **/
|
|
|
- Rows workorders = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_serviceorderid ='"
|
|
|
- + rows.get(0).getLong("sa_serviceorderid") + "' and siteid='" + siteid
|
|
|
- + "' and sa_workorderid !=" + sa_workorderid);
|
|
|
+ Rows workorders = dbConnect.runSqlQuery("select sa_serviceorderid,status,billno from sa_workorder where sa_serviceorderid ='" + sa_serviceorderid + "' and siteid='" + siteid + "' and sa_workorderid !=" + sa_workorderid);
|
|
|
boolean isallcomplete = true;
|
|
|
for (int i = 0; i < workorders.size(); i++) {
|
|
|
- if (!workorders.get(i).getString("status").equals("已完工")
|
|
|
- && !workorders.get(i).getString("status").equals("关闭")
|
|
|
- && !workorders.get(i).getString("status").equals("作废")) {
|
|
|
+ if (!workorders.get(i).getString("status").equals("已完工") && !workorders.get(i).getString("status").equals("关闭") && !workorders.get(i).getString("status").equals("作废")) {
|
|
|
isallcomplete = false;
|
|
|
}
|
|
|
}
|
|
|
if (isallcomplete) {
|
|
|
- sqlList.add("update sa_serviceorder set status='已完结' where sa_serviceorderid="
|
|
|
- + rows.get(0).getLong("sa_serviceorderid"));
|
|
|
- }
|
|
|
-
|
|
|
- if (rows.get(0).getString("type").equals("安装")) {
|
|
|
- Rows itemrows = dbConnect.runSqlQuery("select t1.sku,t3.scenecontact,t3.scenecontactphonenumber,t3.sa_customersid,t7.sys_enterpriseid skuenterpriseid,t7.sa_agentsid skuagentsid," +
|
|
|
- "case when t3.sa_customersid!=0 then t5.name else t3.name end name,case when t3.sa_customersid!=0 then t5.phonenumber else t3.phonenumber end phonenumber," +
|
|
|
- "t3.province,t3.city,t3.county, case when t3.sa_customersid!=0 then t5.address else t3.address end address,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid,t6.sa_agentsid sa_agentsid_to,t6.agentnum toagentnum,t7.itemid from sa_serviceorderitems t1 \n" +
|
|
|
- " inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid \n" +
|
|
|
- " left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid \n" +
|
|
|
- " left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid \n" +
|
|
|
- " left join sa_customers t5 on t5.sa_customersid=t3.sa_customersid and t5.siteid=t3.siteid \n" +
|
|
|
- " left join sa_agents t6 on t3.sys_enterpriseid_service=t6.sys_enterpriseid and t3.siteid=t6.siteid \n" +
|
|
|
- " left join sa_itemsku t7 on t7.sku=t1.sku and t7.siteid=t1.siteid " +
|
|
|
- "where t1.sa_serviceorderid=" + rows.get(0).getLong("sa_serviceorderid") + " and t1.siteid='" + siteid + "' ");
|
|
|
+ sqlList.add("update sa_serviceorder set status='已完结' where sa_serviceorderid=" + sa_serviceorderid);
|
|
|
+ }
|
|
|
+ if (type.equals("安装")) {
|
|
|
+ Rows itemrows = dbConnect.runSqlQuery("select t1.sku,t3.scenecontact,t3.scenecontactphonenumber,t3.sa_customersid,t7.sys_enterpriseid skuenterpriseid,t7.sa_agentsid skuagentsid," + "case when t3.sa_customersid!=0 then t5.name else t3.name end name,case when t3.sa_customersid!=0 then t5.phonenumber else t3.phonenumber end phonenumber," + "t3.province,t3.city,t3.county, case when t3.sa_customersid!=0 then t5.address else t3.address end address,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid,t6.sa_agentsid sa_agentsid_to,t6.agentnum toagentnum,t7.itemid from sa_serviceorderitems t1 \n" + " inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid \n" + " left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid \n" + " left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid \n" + " left join sa_customers t5 on t5.sa_customersid=t3.sa_customersid and t5.siteid=t3.siteid \n" + " left join sa_agents t6 on t3.sys_enterpriseid_service=t6.sys_enterpriseid and t3.siteid=t6.siteid \n" + " left join sa_itemsku t7 on t7.sku=t1.sku and t7.siteid=t1.siteid " + "where t1.sa_serviceorderid=" + sa_serviceorderid + " and t1.siteid='" + siteid + "' ");
|
|
|
|
|
|
if (itemrows.isNotEmpty()) {
|
|
|
|
|
|
@@ -1229,10 +1129,10 @@ public class workorder extends Controller {
|
|
|
long customeragentsid = 0;
|
|
|
sa_customersid = itemrows.get(0).getLong("sa_customersid");
|
|
|
customeragentsid = itemrows.get(0).getLong("skuagentsid");
|
|
|
- if(customeragentsid==0){
|
|
|
- Rows agentsrows = dbConnect.runSqlQuery("select sa_agentsid from sa_agents where sys_enterpriseid="+itemrows.get(0).getLong("skuenterpriseid"));
|
|
|
- if(agentsrows.isNotEmpty()){
|
|
|
- customeragentsid=agentsrows.get(0).getLong("sa_agentsid");
|
|
|
+ if (customeragentsid == 0) {
|
|
|
+ Rows agentsrows = dbConnect.runSqlQuery("select sa_agentsid from sa_agents where sys_enterpriseid=" + itemrows.get(0).getLong("skuenterpriseid"));
|
|
|
+ if (agentsrows.isNotEmpty()) {
|
|
|
+ customeragentsid = agentsrows.get(0).getLong("sa_agentsid");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1264,23 +1164,31 @@ 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);
|
|
|
+ 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{
|
|
|
+ } else {
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- sqlList.add("update sa_workorder set status='已完工',finishby='" + username
|
|
|
- + "',finishdate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
+ sqlList.add("update sa_workorder set status='已完工',finishby='" + username + "',finishdate=CURRENT_TIME where sa_workorderid=" + sa_workorderid);
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_workorder", sa_workorderid, "工单完结", "服务工单完结成功").getSQL());
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ //短信消息提醒
|
|
|
+ Rows sa_serviceorderRows = dbConnect.runSqlQuery("selet scenecontactphonenumber from sa_serviceorder where sa_serviceorderid=" + sa_serviceorderid);
|
|
|
+ if (sa_serviceorderRows.isNotEmpty() && Arrays.asList(new String[]{"安装", "清洗", "维修"}).contains(type)) {
|
|
|
+ String scenecontactphonenumber = sa_serviceorderRows.get(0).getString("scenecontactphonenumber");
|
|
|
+ if (!scenecontactphonenumber.isBlank()) {
|
|
|
+ new Sms().sendout(Sms.SmsType.Notice, siteid, scenecontactphonenumber, "尊敬的美大用户您好,您购买的美大产品" + type + "服务已完成!谢谢您的配合!有美大,家更美!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
Executor.sendEml(this, "sa_workorderover", sa_workorderid, siteid);
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
@@ -1353,12 +1261,9 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private ArrayList<String> getAddWorkorderNodeSql(long sa_workorder_templateid, long sa_workorderid)
|
|
|
- throws YosException {
|
|
|
+ private ArrayList<String> getAddWorkorderNodeSql(long sa_workorder_templateid, long sa_workorderid) throws YosException {
|
|
|
ArrayList sqList = new ArrayList<String>();
|
|
|
- Rows rows = dbConnect.runSqlQuery(
|
|
|
- "select t1.sa_workorder_template_worksid,t1.sequence,t1.parentid,t2.* from sa_workorder_template_works t1 inner join sa_workpreset t2 on t1.siteid=t2.siteid and t1.sa_workpresetid=t2.sa_workpresetid where t1.siteid='"
|
|
|
- + siteid + "' and t1.sa_workorder_templateid =" + sa_workorder_templateid + " order by t1.sequence asc");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t1.sa_workorder_template_worksid,t1.sequence,t1.parentid,t2.* from sa_workorder_template_works t1 inner join sa_workpreset t2 on t1.siteid=t2.siteid and t1.sa_workpresetid=t2.sa_workpresetid where t1.siteid='" + siteid + "' and t1.sa_workorder_templateid =" + sa_workorder_templateid + " order by t1.sequence asc");
|
|
|
RowsMap rowsMap = rows.toRowsMap("parentid");
|
|
|
if (!rowsMap.get(0).isEmpty()) {
|
|
|
for (Row row : rowsMap.get(0)) {
|
|
|
@@ -1448,8 +1353,7 @@ public class workorder extends Controller {
|
|
|
**/
|
|
|
public String fiscomplate(long sa_workorderid, long sa_workorder_nodeid) throws YosException {
|
|
|
|
|
|
- Rows rows = dbConnect.runSqlQuery("select * from sa_workorder_node where sa_workorderid=" + sa_workorderid
|
|
|
- + " and sa_workorder_nodeid =" + sa_workorder_nodeid);
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_workorder_node where sa_workorderid=" + sa_workorderid + " and sa_workorder_nodeid =" + sa_workorder_nodeid);
|
|
|
if (rows.isEmpty()) {
|
|
|
return "工单节点不存在";
|
|
|
}
|
|
|
@@ -1465,17 +1369,14 @@ public class workorder extends Controller {
|
|
|
ArrayList<Long> ids = new ArrayList<Long>();
|
|
|
ids.add(sa_workorder_nodeid);
|
|
|
RowsMap attRowsMap = getAttachmentUrl("sa_workorder_node", ids);
|
|
|
- if (attRowsMap.get(sa_workorder_nodeid) == null
|
|
|
- || attRowsMap.get(sa_workorder_nodeid).isEmpty()) {
|
|
|
+ if (attRowsMap.get(sa_workorder_nodeid) == null || attRowsMap.get(sa_workorder_nodeid).isEmpty()) {
|
|
|
//return "请填写完整工序内容:附件没有上传";
|
|
|
}
|
|
|
}
|
|
|
// 是否添加物料
|
|
|
if (workpresetInfo.getAdditem() == 11) {
|
|
|
/** 工单节点物料查询 **/
|
|
|
- Rows workorderitemRows = dbConnect.runSqlQuery(
|
|
|
- "select * from sa_workorder_node_items where sa_workorder_nodeid=" + sa_workorder_nodeid
|
|
|
- + " and sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
+ Rows workorderitemRows = dbConnect.runSqlQuery("select * from sa_workorder_node_items where sa_workorder_nodeid=" + sa_workorder_nodeid + " and sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
if (workorderitemRows.isEmpty()) {
|
|
|
return "请填写完整工序内容:没有添加物料";
|
|
|
}
|
|
|
@@ -1483,8 +1384,7 @@ public class workorder extends Controller {
|
|
|
// 是否添加人员
|
|
|
if (workpresetInfo.getAddperson() == 11) {
|
|
|
/** 工单节点人员查询 **/
|
|
|
- Rows trainers = dbConnect.runSqlQuery("select * from sa_workorder_node_team where sa_workorder_nodeid="
|
|
|
- + sa_workorder_nodeid + " and sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
+ Rows trainers = dbConnect.runSqlQuery("select * from sa_workorder_node_team where sa_workorder_nodeid=" + sa_workorder_nodeid + " and sa_workorderid=" + sa_workorderid + " and siteid='" + siteid + "'");
|
|
|
if (trainers.isEmpty()) {
|
|
|
return "请填写完整工序内容:没有添加人员";
|
|
|
}
|
|
|
@@ -1526,18 +1426,14 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
// 是否上传合同
|
|
|
if (workpresetInfo.getContractupload() == 11) {
|
|
|
- Rows contractRows = dbConnect.runSqlQuery("select * from sys_attachment_links where ownerid="
|
|
|
- + sa_workorder_nodeid + " and ownertable='sa_workorder_node' and usetype='contract' and siteid='"
|
|
|
- + siteid + "'");
|
|
|
+ Rows contractRows = dbConnect.runSqlQuery("select * from sys_attachment_links where ownerid=" + sa_workorder_nodeid + " and ownertable='sa_workorder_node' and usetype='contract' and siteid='" + siteid + "'");
|
|
|
if (contractRows.isEmpty()) {
|
|
|
return "请填写完整工序内容:合同没有上传";
|
|
|
}
|
|
|
}
|
|
|
// 是否客户签名
|
|
|
if (workpresetInfo.getSignature() == 11) {
|
|
|
- Rows contractRows = dbConnect.runSqlQuery("select * from sys_attachment_links where ownerid="
|
|
|
- + sa_workorder_nodeid + " and ownertable='sa_workorder_node' and usetype='signature' and siteid='"
|
|
|
- + siteid + "'");
|
|
|
+ Rows contractRows = dbConnect.runSqlQuery("select * from sys_attachment_links where ownerid=" + sa_workorder_nodeid + " and ownertable='sa_workorder_node' and usetype='signature' and siteid='" + siteid + "'");
|
|
|
if (contractRows.isEmpty()) {
|
|
|
return "请填写完整工序内容:客户签名没有上传";
|
|
|
}
|