|
@@ -1,6 +1,7 @@
|
|
|
package restcontroller.webmanage.sale.workorder;
|
|
package restcontroller.webmanage.sale.workorder;
|
|
|
|
|
|
|
|
import beans.brand.Brand;
|
|
import beans.brand.Brand;
|
|
|
|
|
+import beans.data.BatchDeleteErr;
|
|
|
import beans.datacontrllog.DataContrlLog;
|
|
import beans.datacontrllog.DataContrlLog;
|
|
|
import beans.datateam.DataTeam;
|
|
import beans.datateam.DataTeam;
|
|
|
import beans.itemprice.ItemPrice;
|
|
import beans.itemprice.ItemPrice;
|
|
@@ -1009,6 +1010,116 @@ public class workorder extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @API(title = "批量完结工单(仅用于刷数据)", apiversion = R.ID2025121309582703.v1.class)
|
|
|
|
|
+ public String completeorder_piliang() throws YosException {
|
|
|
|
|
+ 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 + "'");
|
|
|
|
|
+ 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 + "' ");
|
|
|
|
|
+
|
|
|
|
|
+ if (itemrows.isNotEmpty()) {
|
|
|
|
|
+
|
|
|
|
|
+ //判断客户id
|
|
|
|
|
+ long sa_customersid = 0;
|
|
|
|
|
+ //判断客户id对应的经销商id
|
|
|
|
|
+ long customeragentsid = 0;
|
|
|
|
|
+ if (itemrows.get(0).getLong("sa_customersid") != 0) {
|
|
|
|
|
+ sa_customersid = itemrows.get(0).getLong("sa_customersid");
|
|
|
|
|
+ customeragentsid = itemrows.get(0).getLong("customeragentsid");
|
|
|
|
|
+ }else {
|
|
|
|
|
+// return getErrReturnObject().setErrMsg("客户不存在").toString();
|
|
|
|
|
+// InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_customers");
|
|
|
|
|
+// sa_customersid = createTableID("sa_customers");
|
|
|
|
|
+// insertSQL.setUniqueid(sa_customersid);
|
|
|
|
|
+// insertSQL.setSiteid(siteid);
|
|
|
|
|
+// if (itemrows.get(0).getLong("sa_agentsid") == 0) {
|
|
|
|
|
+// insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid_to"));
|
|
|
|
|
+// customeragentsid = itemrows.get(0).getLong("sa_agentsid_to");
|
|
|
|
|
+// } else {
|
|
|
|
|
+// insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid"));
|
|
|
|
|
+// customeragentsid = itemrows.get(0).getLong("sa_agentsid");
|
|
|
|
|
+// }
|
|
|
|
|
+// insertSQL.setValue("sa_agentsid_to", itemrows.get(0).getLong("sa_agentsid_to"));
|
|
|
|
|
+// insertSQL.setValue("name", itemrows.get(0).getString("name"));
|
|
|
|
|
+// insertSQL.setValue("phonenumber", itemrows.get(0).getString("phonenumber"));
|
|
|
|
|
+// insertSQL.setValue("province", itemrows.get(0).getString("province"));
|
|
|
|
|
+// insertSQL.setValue("city", itemrows.get(0).getString("city"));
|
|
|
|
|
+// insertSQL.setValue("county", itemrows.get(0).getString("county"));
|
|
|
|
|
+// insertSQL.setValue("address", itemrows.get(0).getString("address"));
|
|
|
|
|
+// insertSQL.setValue("sa_customersid", sa_customersid);
|
|
|
|
|
+// insertSQL.setValue("itemid", itemrows.get(0).getLong("itemid"));
|
|
|
|
|
+// sqlList.add(insertSQL.getSQL());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
|
+
|
|
|
|
|
+ // 将当前日期加上年
|
|
|
|
|
+ LocalDate futureDate = now.plusYears(itemrows.get(0).getInteger("warrantyday"));
|
|
|
|
|
+
|
|
|
|
|
+ // 定义日期格式
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+
|
|
|
|
|
+ // 格式化日期
|
|
|
|
|
+ String formattedDate = futureDate.format(formatter);
|
|
|
|
|
+
|
|
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_warrantycard");
|
|
|
|
|
+ insertSQL.setUniqueid(createTableID("sa_warrantycard"));
|
|
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
|
|
+ if(sa_customersid!=0){
|
|
|
|
|
+ insertSQL.setValue("sa_agentsid", customeragentsid);
|
|
|
|
|
+ insertSQL.setValue("toagentnum", itemrows.get(0).getString("toagentnum"));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ insertSQL.setValue("sa_agentsid", itemrows.get(0).getString("sa_agentsid_to"));
|
|
|
|
|
+ insertSQL.setValue("toagentnum", itemrows.get(0).getString("toagentnum"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ insertSQL.setValue("sku", itemrows.get(0).getString("sku"));
|
|
|
|
|
+ insertSQL.setValue("cardno", createBillCode("warrantycard"));
|
|
|
|
|
+ insertSQL.setValue("sa_customersid", sa_customersid);
|
|
|
|
|
+ insertSQL.setValue("name", itemrows.get(0).getString("scenecontact"));
|
|
|
|
|
+ insertSQL.setValue("phonenumber", itemrows.get(0).getString("scenecontactphonenumber"));
|
|
|
|
|
+ insertSQL.setValue("address", itemrows.get(0).getString("address"));
|
|
|
|
|
+ insertSQL.setValue("province", itemrows.get(0).getString("province"));
|
|
|
|
|
+ insertSQL.setValue("city", itemrows.get(0).getString("city"));
|
|
|
|
|
+ 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("createby", rows.get(0).getString("finishby"));
|
|
|
|
|
+ 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{
|
|
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlList.add("update sa_workorder set status='已完工' where sa_workorderid=" + sa_workorderid);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
+
|
|
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@API(title = "完结工单", apiversion = R.ID20230209144903.v1.class)
|
|
@API(title = "完结工单", apiversion = R.ID20230209144903.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = {workorder.class, serviceorder.class})
|
|
@CACHEING_CLEAN(apiversions = {workorder.class, serviceorder.class})
|
|
|
public String completeorder() throws YosException {
|
|
public String completeorder() throws YosException {
|