|
|
@@ -8,6 +8,7 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
import common.annotation.cm;
|
|
|
+import common.data.Row;
|
|
|
import common.data.Rows;
|
|
|
import common.data.SQLFactory;
|
|
|
import restcontroller.R;
|
|
|
@@ -29,83 +30,81 @@ public class enterprisetarget extends Controller {
|
|
|
public String insert() throws YosException {
|
|
|
Long year = content.getLong("year");
|
|
|
Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
|
|
|
- Long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
- Long sa_contractid = content.getLong("sa_contractid");
|
|
|
- String tradefield = content.getString("tradefield");
|
|
|
+ JSONArray agentsArray = content.getJSONArray("agents");
|
|
|
+ String assessmentindicators=content.getString("assessmentindicators");
|
|
|
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
if (sa_salestargetbillid <= 0) {
|
|
|
//查询创建年度是否存在
|
|
|
- String sql = "SELECT sa_salestargetbillid FROM sa_salestargetbill WHERE `year` = " + year + " AND targettype ='企业目标' AND siteid = '" + siteid + "' and sys_enterpriseid = " + sys_enterpriseid + " and tradefield='" + tradefield + "'";
|
|
|
+ String sql = "SELECT sa_salestargetbillid FROM sa_salestargetbill WHERE `year` = " + year + " AND targettype ='企业目标' AND siteid = '" + siteid + "'";
|
|
|
Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
if (rows.isNotEmpty()) {
|
|
|
- sa_salestargetbillid = rows.get(0).getLong("sa_salestargetbillid");
|
|
|
+ return getErrReturnObject().setErrMsg("当前业绩目标已存在,无法添加").toString();
|
|
|
} else {
|
|
|
sa_salestargetbillid = createTableID("sa_salestargetbill");
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "创建新年度");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.addParameter("sys_enterpriseid", 0);
|
|
|
sqlFactory.addParameter("username", username);
|
|
|
sqlFactory.addParameter("userid", userid);
|
|
|
sqlFactory.addParameter("year", year);
|
|
|
sqlFactory.addParameter("targettype", "企业目标");
|
|
|
- sqlFactory.addParameter("tradefield", tradefield);
|
|
|
+ sqlFactory.addParameter("tradefield", "");
|
|
|
+ sqlFactory.addParameter("assessmentindicators", assessmentindicators);
|
|
|
+
|
|
|
sqlList.add(sqlFactory.getSQL());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (dbConnect.runSqlQuery("SELECT * from sa_salestarget WHERE sa_salestargetbillid = " + sa_salestargetbillid + " and sa_contractid = " + sa_contractid + " and siteid = '" + siteid + "' and tradefield='" + tradefield + "'").isNotEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("当前领域业绩目标已存在,无法添加").toString();
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
String[] types = {"年", "季", "月"};
|
|
|
|
|
|
- String sql = "SELECT 1 FROM sa_salestargethr WHERE sa_salestargetbillid = " + sa_salestargetbillid + " and siteid = '" + siteid + "' and sys_enterpriseid = " + sys_enterpriseid;
|
|
|
- Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
- if (rows.isEmpty()) {
|
|
|
+ for (Object obj : agentsArray) {
|
|
|
+ JSONObject saleObj = (JSONObject) obj;
|
|
|
+ System.out.println(saleObj.toString());
|
|
|
SQLFactory saleFactory = new SQLFactory(this, "企业范围新增");
|
|
|
saleFactory.addParameter("siteid", siteid);
|
|
|
saleFactory.addParameter("sa_salestargethrid", createTableID("sa_salestargethr"));
|
|
|
- saleFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ saleFactory.addParameter("sys_enterpriseid", saleObj.getLong("sys_enterpriseid"));
|
|
|
saleFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
sqlList.add(saleFactory.getSQL());
|
|
|
- }
|
|
|
|
|
|
|
|
|
- for (String type : types) {
|
|
|
- int point;
|
|
|
- if (type.equals("年")) {
|
|
|
- point = 1;
|
|
|
- } else if (type.equals("季")) {
|
|
|
- point = 4;
|
|
|
- } else if (type.equals("月")) {
|
|
|
- point = 12;
|
|
|
- } else {
|
|
|
- point = 0;
|
|
|
+ for (String type : types) {
|
|
|
+ int point;
|
|
|
+ if (type.equals("年")) {
|
|
|
+ point = 1;
|
|
|
+ } else if (type.equals("季")) {
|
|
|
+ point = 4;
|
|
|
+ } else if (type.equals("月")) {
|
|
|
+ point = 12;
|
|
|
+ } else {
|
|
|
+ point = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < point; i++) {
|
|
|
+ SQLFactory targetFactory = new SQLFactory(this, "企业-目标明细新增");
|
|
|
+ targetFactory.addParameter("siteid", siteid);
|
|
|
+ targetFactory.addParameter("sa_salestargetid", createTableID("sa_salestarget"));
|
|
|
+ targetFactory.addParameter("type", type);
|
|
|
+ targetFactory.addParameter("point", i + 1);
|
|
|
+ targetFactory.addParameter("targettype", "企业目标");
|
|
|
+ targetFactory.addParameter("sys_enterpriseid", saleObj.getLong("sys_enterpriseid"));
|
|
|
+ targetFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
+ targetFactory.addParameter("year", year);
|
|
|
+ targetFactory.addParameter("sa_contractid", 0);
|
|
|
+ targetFactory.addParameter("createby", username);
|
|
|
+ targetFactory.addParameter("target_l", 0);
|
|
|
+ targetFactory.addParameter("target_h", 0);
|
|
|
+ targetFactory.addParameter("tradefield", "");
|
|
|
+ sqlList.add(targetFactory.getSQL());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- for (int i = 0; i < point; i++) {
|
|
|
- SQLFactory targetFactory = new SQLFactory(this, "企业-目标明细新增");
|
|
|
- targetFactory.addParameter("siteid", siteid);
|
|
|
- targetFactory.addParameter("sa_salestargetid", createTableID("sa_salestarget"));
|
|
|
- targetFactory.addParameter("type", type);
|
|
|
- targetFactory.addParameter("point", i + 1);
|
|
|
- targetFactory.addParameter("targettype", "企业目标");
|
|
|
- targetFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- targetFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
|
|
|
- targetFactory.addParameter("year", year);
|
|
|
- targetFactory.addParameter("sa_contractid", sa_contractid);
|
|
|
- targetFactory.addParameter("createby", username);
|
|
|
- targetFactory.addParameter("target_l", 0);
|
|
|
- targetFactory.addParameter("target_h", 0);
|
|
|
- targetFactory.addParameter("tradefield", tradefield);
|
|
|
- sqlList.add(targetFactory.getSQL());
|
|
|
- }
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sys_enterprise", sys_enterpriseid, "添加业绩目标", "添加业绩目标" + year + "年目标").getSQL());
|
|
|
}
|
|
|
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_contract", sa_contractid, "添加业绩目标", "添加业绩目标" + year + "年" + tradefield + "领域目标").getSQL());
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
return getSucReturnObject().toString();
|
|
|
@@ -115,8 +114,13 @@ public class enterprisetarget extends Controller {
|
|
|
@CACHEING_CLEAN(cms = {@cm(clazz = personnel.class, method = {"queryList", "queryDetailList"}), @cm(clazz = personnelstatistics.class, method = {"queryList"})})
|
|
|
public String edit() throws YosException {
|
|
|
Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
|
|
|
+ if(sa_salestargetbillid<=0){
|
|
|
+ Rows rows =dbConnect.runSqlQuery("SELECT sa_salestargetbillid FROM sa_salestargetbill WHERE `year` = " + content.getLong("year") + " AND targettype ='企业目标' AND siteid = '" + siteid + "'");
|
|
|
+ if(rows.isNotEmpty()){
|
|
|
+ sa_salestargetbillid=rows.get(0).getLong("sa_salestargetbillid");
|
|
|
+ }
|
|
|
+ }
|
|
|
Long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
- Long sa_contractid = content.getLong("sa_contractid");
|
|
|
if (sa_salestargetbillid <= 0) {
|
|
|
return getErrReturnObject().setErrMsg("年度目标不存在").toString();
|
|
|
}
|
|
|
@@ -125,13 +129,13 @@ public class enterprisetarget extends Controller {
|
|
|
String key_l = "y1l";
|
|
|
String key_h = "y1h";
|
|
|
if (content.containsKey(key_l) && content.containsKey(key_h)) {
|
|
|
- sqlList.add(getSql(content.getString(key_l), content.getString(key_h), sa_salestargetbillid, sys_enterpriseid, sa_contractid, "年", 1));
|
|
|
+ sqlList.add(getSql(content.getString(key_l), content.getString(key_h), sa_salestargetbillid, sys_enterpriseid, "年", 1));
|
|
|
}
|
|
|
for (int i = 1; i < 5; i++) {
|
|
|
key_l = "s" + i + "l";
|
|
|
key_h = "s" + i + "h";
|
|
|
if (content.containsKey(key_l) && content.containsKey(key_h)) {
|
|
|
- sqlList.add(getSql(content.getString(key_l), content.getString(key_h), sa_salestargetbillid, sys_enterpriseid, sa_contractid, "季", i));
|
|
|
+ sqlList.add(getSql(content.getString(key_l), content.getString(key_h), sa_salestargetbillid, sys_enterpriseid, "季", i));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -139,53 +143,82 @@ public class enterprisetarget extends Controller {
|
|
|
key_l = "m" + i + "l";
|
|
|
key_h = "m" + i + "h";
|
|
|
if (content.containsKey(key_l) && content.containsKey(key_h)) {
|
|
|
- sqlList.add(getSql(content.getString(key_l), content.getString(key_h), sa_salestargetbillid, sys_enterpriseid, sa_contractid, "月", i));
|
|
|
+ sqlList.add(getSql(content.getString(key_l), content.getString(key_h), sa_salestargetbillid, sys_enterpriseid, "月", i));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//操作记录
|
|
|
Long year = 0L;
|
|
|
- String tradefield = "";
|
|
|
- Rows rows = dbConnect.runSqlQuery("SELECT year,tradefield from sa_salestargetbill WHERE sa_salestargetbillid =" + sa_salestargetbillid + " and siteid='" + siteid + "'");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT year from sa_salestargetbill WHERE sa_salestargetbillid =" + sa_salestargetbillid + " and siteid='" + siteid + "'");
|
|
|
if (rows.isNotEmpty()) {
|
|
|
year = rows.get(0).getLong("year");
|
|
|
- tradefield = rows.get(0).getString("tradefield");
|
|
|
}
|
|
|
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_contract", sa_contractid, "编辑业绩目标", "编辑业绩目标" + year + "年" + tradefield + "领域目标").getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_salestargetbill", sa_salestargetbillid, "编辑业绩目标", "编辑业绩目标" + year + "年目标").getSQL());
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
- public String getSql(String target_l, String target_h, Long id, Long sys_enterpriseid, Long sa_contractid, String type, int point) {
|
|
|
|
|
|
- return " UPDATE sa_salestarget SET target_l=" + target_l + ",target_h = " + target_h + " WHERE sa_salestargetbillid =" + id + " and sys_enterpriseid =" + sys_enterpriseid + " and type ='" + type + "' AND point = " + point + " AND sa_contractid = " + sa_contractid;
|
|
|
- }
|
|
|
+ @API(title = "企业业绩目标(经销商)", apiversion = R.ID20231018142103.v1.class)
|
|
|
+ public String selectList() throws YosException {
|
|
|
+ /*
|
|
|
+ 过滤条件设置
|
|
|
+ */
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("year") && !"".equals(whereObject.getString("year"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("year like'%").append(whereObject.getString("year")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
|
|
|
- @API(title = "删除", apiversion = R.ID20221229141102.v1.class)
|
|
|
- public String delete() throws YosException {
|
|
|
+ if (whereObject.containsKey("sys_enterpriseid") && !"".equals(whereObject.getString("sys_enterpriseid"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("sys_enterpriseid ='").append(whereObject.getString("sys_enterpriseid")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
|
|
|
- Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
|
|
|
- Long sa_contractid = content.getLong("sa_contractid");
|
|
|
+ }
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "企业-业绩目标完成列表");
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ String sql = sqlFactory.getSQL();
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- sqlList.add("delete from sa_salestarget WHERE siteid = '" + siteid + "' and sa_salestargetbillid = " + sa_salestargetbillid + " and sa_contractid = " + sa_contractid);
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
|
|
|
- //操作记录
|
|
|
- Long year = 0L;
|
|
|
- String tradefield = "";
|
|
|
- Rows rows = dbConnect.runSqlQuery("SELECT year,tradefield from sa_salestargetbill WHERE sa_salestargetbillid =" + sa_salestargetbillid + " and siteid='" + siteid + "'");
|
|
|
- if (rows.isNotEmpty()) {
|
|
|
- year = rows.get(0).getLong("year");
|
|
|
- tradefield = rows.get(0).getString("tradefield");
|
|
|
- }
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_contract", sa_contractid, "删除业绩目标", "删除业绩目标" + year + "年" + tradefield + "领域目标").getSQL());
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
+ public String getSql(String target_l, String target_h, Long id, Long sys_enterpriseid, String type, int point) {
|
|
|
|
|
|
- return getSucReturnObject().toString();
|
|
|
+ return " UPDATE sa_salestarget SET target_l=" + target_l + ",target_h = " + target_h + " WHERE sa_salestargetbillid =" + id + " and sys_enterpriseid =" + sys_enterpriseid + " and type ='" + type + "' AND point = " + point;
|
|
|
}
|
|
|
|
|
|
+// @API(title = "删除", apiversion = R.ID20221229141102.v1.class)
|
|
|
+// public String delete() throws YosException {
|
|
|
+//
|
|
|
+// Long sa_salestargetbillid = content.getLong("sa_salestargetbillid");
|
|
|
+// Long sa_contractid = content.getLong("sa_contractid");
|
|
|
+//
|
|
|
+// ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+// sqlList.add("delete from sa_salestarget WHERE siteid = '" + siteid + "' and sa_salestargetbillid = " + sa_salestargetbillid + " and sa_contractid = " + sa_contractid);
|
|
|
+//
|
|
|
+// //操作记录
|
|
|
+// Long year = 0L;
|
|
|
+// String tradefield = "";
|
|
|
+// Rows rows = dbConnect.runSqlQuery("SELECT year,tradefield from sa_salestargetbill WHERE sa_salestargetbillid =" + sa_salestargetbillid + " and siteid='" + siteid + "'");
|
|
|
+// if (rows.isNotEmpty()) {
|
|
|
+// year = rows.get(0).getLong("year");
|
|
|
+// tradefield = rows.get(0).getString("tradefield");
|
|
|
+// }
|
|
|
+// sqlList.add(DataContrlLog.createLog(this, "sa_contract", sa_contractid, "删除业绩目标", "删除业绩目标" + year + "年" + tradefield + "领域目标").getSQL());
|
|
|
+// dbConnect.runSqlUpdate(sqlList);
|
|
|
+//
|
|
|
+// return getSucReturnObject().toString();
|
|
|
+// }
|
|
|
+
|
|
|
@API(title = "查询对应企业的年度", apiversion = R.ID20230103102302.v1.class)
|
|
|
public String getYear() throws YosException {
|
|
|
|