|
@@ -8,10 +8,7 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
-import common.data.QuerySQL;
|
|
|
-import common.data.Row;
|
|
|
-import common.data.Rows;
|
|
|
-import common.data.SQLFactory;
|
|
|
+import common.data.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
|
import restcontroller.webmanage.executorService.Executor;
|
|
@@ -64,11 +61,21 @@ public class serviceorder extends Controller {
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_serviceorder", "*");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid","enterprisename","abbreviation","phonenumber");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t3", "t1.sa_orderid = t3.sa_orderid AND t1.siteid = t3.siteid","sonum");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t5", "t1.sys_enterpriseid = t5.sys_enterpriseid AND t1.siteid = t5.siteid","agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t3", "t2.sys_enterpriseid = t3.sys_enterpriseid AND t2.siteid = t3.siteid","agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t4", "t1.sys_enterpriseid_service = t4.sys_enterpriseid AND t1.siteid = t4.siteid","enterprisename","abbreviation","phonenumber");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t5", "t4.sys_enterpriseid = t5.sys_enterpriseid AND t4.siteid = t5.siteid","agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "(SELECT * FROM (SELECT *,ROW_NUMBER() OVER (PARTITION BY sa_serviceorderid ORDER BY sa_serviceorderitemsid ASC) AS rowno FROM sa_serviceorderitems) t WHERE rowno = 1)",
|
|
|
+ "t8", "t8.sa_serviceorderid=t1.sa_serviceorderid and t8.siteid=t1.siteid","itemid","sku","cardno");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t9", "t9.itemid=t8.itemid and t9.siteid=t8.siteid","itemno","itemname","model","spec");
|
|
|
+ querySQL.addQueryFields("serviceenterprisename","t4.enterprisename");
|
|
|
+ querySQL.addQueryFields("serviceabbreviation","t4.abbreviation");
|
|
|
+ querySQL.addQueryFields("servicephonenumber","t4.phonenumber");
|
|
|
+ querySQL.addQueryFields("serviceagentnum","t5.agentnum");
|
|
|
+
|
|
|
+
|
|
|
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.sys_enterpriseid",sys_enterpriseid);
|
|
|
+ querySQL.setWhere("(t1.sys_enterpriseid="+sys_enterpriseid+" or t1.sys_enterpriseid_service="+sys_enterpriseid+")");
|
|
|
querySQL.setWhere(where.toString());
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
@@ -81,9 +88,9 @@ public class serviceorder extends Controller {
|
|
|
R.ID20230206101303.v1.class, R.ID20230217100703.v1.class, R.ID20230217133003.v1.class})
|
|
|
public String sumbit() throws YosException {
|
|
|
Long sa_serviceorderid = content.getLong("sa_serviceorderid");
|
|
|
- boolean issumbit = content.getBooleanValue("issumbit");
|
|
|
+ boolean issumbit = true;
|
|
|
Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_serviceorderid,status,billno from sa_serviceorder where sa_serviceorderid ='"
|
|
|
+ .runSqlQuery("select sa_serviceorderid,status,billno,sys_enterpriseid,province,city,county from sa_serviceorder where sa_serviceorderid ='"
|
|
|
+ sa_serviceorderid + "' and siteid='" + siteid + "'");
|
|
|
for (Row row : rows) {
|
|
|
if (issumbit) {
|
|
@@ -123,8 +130,48 @@ public class serviceorder extends Controller {
|
|
|
sqlFactoryupdate.addParameter("submitby", username);
|
|
|
sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
if (issumbit) {
|
|
|
+ Rows agents = dbConnect.runSqlQuery("select * from sa_agents where siteid='"+siteid+"' and sys_enterpriseid="+ rows.get(0).getLong("sys_enterpriseid"));
|
|
|
+ if(agents.isNotEmpty()){
|
|
|
+ if(agents.get(0).getBoolean("isservice")){
|
|
|
+ sqlList.add("update sa_serviceorder set status='待受理',sys_enterpriseid_service="+agents.get(0).getLong("sys_enterpriseid")+" where sa_serviceorderid="+sa_serviceorderid);
|
|
|
+ }else{
|
|
|
+ Rows serviceagents = dbConnect.runSqlQuery("select t1.sys_enterpriseid,t2.province,t2.city,t2.county from sa_agents t1 inner join sa_agents_salescope t2 on t1.sa_agentsid=t2.sa_agentsid and t1.siteid=t2.siteid where t1.siteid='"+siteid+"'");
|
|
|
+ System.out.println(serviceagents.get(0).getString("city"));
|
|
|
+ System.out.println(rows.get(0).getString("city"));
|
|
|
+ RowsMap countyRowsMap=serviceagents.toRowsMap("county");
|
|
|
+ RowsMap cityRowsMap=serviceagents.toRowsMap("city");
|
|
|
+ RowsMap provinceRowsMap=serviceagents.toRowsMap("province");
|
|
|
+ if(countyRowsMap.containsKey(rows.get(0).getString("county"))){
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_serviceorder");
|
|
|
+ updateSQL.setUniqueid(sa_serviceorderid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", "待受理");
|
|
|
+ updateSQL.setValue("sys_enterpriseid_service", countyRowsMap.get(rows.get(0).getString("county")).get(0).getLong("sys_enterpriseid"));
|
|
|
+ updateSQL.setDateValue("allocationdate");
|
|
|
+ updateSQL.setValue("allocationby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }else if(cityRowsMap.containsKey(rows.get(0).getString("city"))){
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_serviceorder");
|
|
|
+ updateSQL.setUniqueid(sa_serviceorderid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", "待受理");
|
|
|
+ updateSQL.setValue("sys_enterpriseid_service", cityRowsMap.get(rows.get(0).getString("city")).get(0).getLong("sys_enterpriseid"));
|
|
|
+ updateSQL.setDateValue("allocationdate");
|
|
|
+ updateSQL.setValue("allocationby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }else if(provinceRowsMap.containsKey(rows.get(0).getString("province"))){
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_serviceorder");
|
|
|
+ updateSQL.setUniqueid(sa_serviceorderid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", "待受理");
|
|
|
+ updateSQL.setValue("sys_enterpriseid_service", provinceRowsMap.get(rows.get(0).getString("province")).get(0).getLong("sys_enterpriseid"));
|
|
|
+ updateSQL.setDateValue("allocationdate");
|
|
|
+ updateSQL.setValue("allocationby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Rows workersRows = dbConnect.runSqlQuery(
|
|
|
"select t3.phonenumber from sys_hr t1 left join sys_users t3 on t1.userid = t3.userid left join sys_hr t4 on t1.siteid = t4.siteid and t1.reporthrid = t4.hrid where t1.siteid = '"
|
|
|
+ siteid + "' and t1.isworker=1 and t1.isleader=1");
|
|
@@ -147,7 +194,34 @@ public class serviceorder extends Controller {
|
|
|
Executor.sendEml(this, "serviceordersub", sa_serviceorderid,siteid);
|
|
|
}
|
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "手工分配服务商", apiversion = R.ID2025071710525303.v1.class)
|
|
|
+ public String assignserviceagentbyhand() throws YosException {
|
|
|
+ Long sa_serviceorderid = content.getLong("sa_serviceorderid");
|
|
|
+ sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("select sa_serviceorderid,status,billno,sys_enterpriseid from sa_serviceorder where sa_serviceorderid ='"
|
|
|
+ + sa_serviceorderid + "' and siteid='" + siteid + "'");
|
|
|
+ if(rows.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("该服务申请单不存在").toString();
|
|
|
+ }
|
|
|
+ if(!rows.get(0).getString("status").equals("待分配")){
|
|
|
+ return getErrReturnObject().setErrMsg("非待分配的服务申请单无法分配服务商").toString();
|
|
|
+ }
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_serviceorder");
|
|
|
+ updateSQL.setUniqueid(sa_serviceorderid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", "待受理");
|
|
|
+ updateSQL.setValue("sys_enterpriseid_service", sys_enterpriseid);
|
|
|
+ updateSQL.setDateValue("allocationdate");
|
|
|
+ updateSQL.setValue("allocationby", username);
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(updateSQL.getSQL());
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|