|
|
@@ -17,6 +17,7 @@ import restcontroller.webmanage.executorService.Executor;
|
|
|
import restcontroller.webmanage.sale.order.Order;
|
|
|
import restcontroller.webmanage.sale.order.OrderItems;
|
|
|
import restcontroller.webmanage.sale.serviceorder.serviceorder;
|
|
|
+import restcontroller.webmanage.sale.serviceorder.tools.VerificationManage;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -25,6 +26,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 服务工单管理
|
|
|
@@ -172,6 +174,9 @@ public class workorder extends Controller {
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+
|
|
|
+ RowsMap rowsMapdetails = queryWorkOrderNodedetails(sa_workorderid);
|
|
|
+
|
|
|
if (!row.isEmpty()) {
|
|
|
/** 工单工序查询 **/
|
|
|
Rows rowsOneLevelWorkpreset = dbConnect
|
|
|
@@ -201,6 +206,7 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
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()) {
|
|
|
for (Row lowerRow : lowerRows) {
|
|
|
@@ -210,6 +216,7 @@ public class workorder extends Controller {
|
|
|
|
|
|
lowerRow.put("attinfos",
|
|
|
attRowsMap.get(lowerRow.getString("sa_workorder_nodeid")));
|
|
|
+ lowerRow.put("detail",rowsMapdetails.get(lowerRow.getString("sa_workorder_nodeid")));
|
|
|
}
|
|
|
}
|
|
|
rowOneLevel.put("child", lowerRows);
|
|
|
@@ -236,16 +243,94 @@ public class workorder extends Controller {
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
|
|
|
|
+ public RowsMap queryWorkOrderNodedetails(long sa_workorderid) throws YosException {
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "服务工单节点查询全部");
|
|
|
+ sqlFactory.addParameter("sa_workorderid", sa_workorderid);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ //System.out.println(sqlFactory.getSQL());
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ Rows sa_workorder_templateids = dbConnect.runSqlQuery("select sa_workorder_templateid from sa_workorder where sa_workorderid=" + sa_workorderid);
|
|
|
+ long sa_workorder_templateid = 0;
|
|
|
+ if (!sa_workorder_templateids.isEmpty()) {
|
|
|
+ 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
|
|
|
+ + "'");
|
|
|
+ RowsMap workorderteamRowsMap = workorderteamRows.toRowsMap("ownerid");
|
|
|
+
|
|
|
+ /** 工单节点物料查询 **/
|
|
|
+ Rows oldworkorderitemRows = 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 t1.sa_workorderid=" + sa_workorderid + " and ifnull(t1.isnew,0)=0 and t1.siteid='"
|
|
|
+ + siteid + "'");
|
|
|
+ RowsMap oldworkorderitemRowsMap = oldworkorderitemRows.toRowsMap("sa_workorder_nodeid");
|
|
|
+
|
|
|
+ Rows newworkorderitemRows = 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 t1.sa_workorderid=" + sa_workorderid + " and ifnull(t1.isnew,0)=1 and t1.siteid='"
|
|
|
+ + siteid + "'");
|
|
|
+ RowsMap newworkorderitemRowsMap = newworkorderitemRows.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 + "'");
|
|
|
+ RowsMap trainersRowsMap = trainers.toRowsMap("sa_workorder_nodeid");
|
|
|
+ for(Row row :rows){
|
|
|
+ if (row.getJSONObject("workpresetjson") == null || row.getJSONObject("workpresetjson").isEmpty()) {
|
|
|
+ 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 t.rownum from (SELECT * FROM(SELECT( @i := CASE WHEN ( @parentid = parentid AND @sa_workorderid = sa_workorderid ) THEN @i + 1 ELSE 1 END ) rownum,( @parentid := parentid ),( @sa_workorderid := sa_workorderid ),( @siteid := siteid ),b.* FROM sa_workorder_node b,( SELECT @i:= 0, @parentid := '', @sa_workorderid := '', @siteid := '' ) AS a )t) t where t.sa_workorder_nodeid=" + row.getLong("parentid") + ")");
|
|
|
+ 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")));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ row.put("workpresetjson", JSONObject.parseObject(row.getString("workpresetjson"))); // 转化成json
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 工单节点附件 **/
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_workorder_nodeid", new ArrayList<>());
|
|
|
+ RowsMap attRowsMap = getAttachmentUrl("sa_workorder_node", ids);
|
|
|
+ row.put("attinfos", attRowsMap.get(row.getString("sa_workorder_nodeid")));
|
|
|
+ /** 工单节点团队查询 **/
|
|
|
+
|
|
|
+ row.put("team", workorderteamRowsMap.get(row.getString("sa_workorder_nodeid")));
|
|
|
+
|
|
|
+ /** 工单节点物料查询 **/
|
|
|
+ row.put("oldtitems", oldworkorderitemRowsMap.get(row.getString("sa_workorder_nodeid")));
|
|
|
+
|
|
|
+
|
|
|
+ row.put("newtitems", newworkorderitemRowsMap.get(row.getString("sa_workorder_nodeid")));
|
|
|
+
|
|
|
+// /** 节点关联培训物料查询 **/
|
|
|
+// Rows traintitem = dbConnect.runSqlQuery("select * from sa_workorder_node_items where sa_workorder_nodeid="+sa_workorder_nodeid+" and sa_workorderid="
|
|
|
+// + sa_workorderid+" and siteid='"+siteid+"'");
|
|
|
+// row.put("traintitem", traintitem);
|
|
|
+
|
|
|
+ /** 节点关联培训人员查询 **/
|
|
|
+
|
|
|
+ row.put("trainers", trainersRowsMap.get(row.getString("sa_workorder_nodeid")));
|
|
|
+ }
|
|
|
+
|
|
|
+ return rows.toRowsMap("sa_workorder_nodeid");
|
|
|
+ }
|
|
|
+
|
|
|
@API(title = "查询服务工单列表", apiversion = R.ID20230208140203.v1.class)
|
|
|
@CACHEING
|
|
|
public String queryworkorderList() throws YosException {
|
|
|
|
|
|
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("')");
|
|
|
-// }
|
|
|
+ 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("')");
|
|
|
+ }
|
|
|
+ if(sys_enterpriseid!=0){
|
|
|
+ where.append(" and t2.sys_enterpriseid_service ='").append(sys_enterpriseid).append("'");
|
|
|
+ }
|
|
|
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
@@ -255,6 +340,7 @@ public class workorder extends Controller {
|
|
|
where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
where.append(")");
|
|
|
}
|
|
|
+
|
|
|
if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
where.append(" and t1.status ='").append(whereObject.getString("status")).append("'");
|
|
|
}
|
|
|
@@ -656,8 +742,8 @@ public class workorder extends Controller {
|
|
|
sa_serviceorderid = rows.get(0).getLong("sa_serviceorderid");
|
|
|
}
|
|
|
for (Row row : rows) {
|
|
|
- if (row.getString("status").equals("已完成")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非已完成状态,无法作废工单")
|
|
|
+ if (row.getString("status").equals("已完工")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的工单为非已完工状态,无法作废工单")
|
|
|
.toString();
|
|
|
}
|
|
|
}
|
|
|
@@ -757,7 +843,7 @@ public class workorder extends Controller {
|
|
|
+ "' and sa_workorderid !=" + sa_workorderid);
|
|
|
boolean isallcomplete = true;
|
|
|
for (int i = 0; i < workorders.size(); i++) {
|
|
|
- if (!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;
|
|
|
@@ -799,7 +885,7 @@ public class workorder extends Controller {
|
|
|
|
|
|
}
|
|
|
|
|
|
- sqlList.add("update sa_workorder set status='已完成',finishby='" + username
|
|
|
+ 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());
|
|
|
|
|
|
@@ -808,6 +894,21 @@ public class workorder extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "验证手机", apiversion = R.ID2025072809441203.v1.class, accesstoken = false)
|
|
|
+ @CACHEING
|
|
|
+ public String sendMessage() throws YosException {
|
|
|
+ String customerphone = content.getStringValue("customerphone");
|
|
|
+ if (!Pattern.matches("^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$", customerphone)) {
|
|
|
+ return getErrReturnObject().setErrMsg("手机格式有误").toString();
|
|
|
+ }
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t1.*,t2.accountno,t3.isservice from sys_enterprise_hr t1 inner join sys_users t2 on t2.userid = t1.userid inner join sa_agents t3 on t1.sys_enterpriseid=t3.sys_enterpriseid where t1.siteid='" + siteid + "' and t3.isservice=1 and t1.phonenumber=" + customerphone);
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("您的手机号暂无使用权限!").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
private ArrayList<String> getAddWorkorderNodeSql(long sa_workorder_templateid, long sa_workorderid)
|
|
|
throws YosException {
|
|
|
ArrayList sqList = new ArrayList<String>();
|
|
|
@@ -831,6 +932,8 @@ 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"));
|
|
|
String workpresetjson = JSONObject.toJSONString(workpresetInfo);
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "服务工单流程节点新增");
|
|
|
long sa_workorder_nodeid = createTableID("sa_workorder_node");
|
|
|
@@ -1001,6 +1104,8 @@ 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"));
|
|
|
jsonObject = JSONArray.parseObject(JSON.toJSONString(workpresetInfo));
|
|
|
|
|
|
}
|