|
|
@@ -39,62 +39,69 @@ public class datafollowup extends Controller {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
where.append(" and(");
|
|
|
- where.append("t.content like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t.target like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t.results like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t.nextplan like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t.createby like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("t1.content like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.target like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.results like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.nextplan like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.createby like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
where.append(")");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ where.append(" and t1.createuserid=").append(userid);
|
|
|
+
|
|
|
+ int type = content.getIntValue("type");
|
|
|
+
|
|
|
String ownertable = content.getString("ownertable");
|
|
|
long ownerid = content.getLong("ownerid");
|
|
|
|
|
|
- SQLFactory sqlFactory;
|
|
|
- if (ownertable.equals("sys_phonebook")) {
|
|
|
- sqlFactory = new SQLFactory(this, "数据跟进日志查询_通讯录", pageSize, pageNumber, pageSorting);
|
|
|
- } else {
|
|
|
- sqlFactory = new SQLFactory(this, "数据跟进日志查询", pageSize, pageNumber, pageSorting);
|
|
|
- }
|
|
|
- // HYADMIN,NBADMIN,TZADMIN
|
|
|
- if (!getHr(userid).isEmpty() || usertype == 0 || userid == 1788 || userid == 1441 || userid == 1442) {
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
- } else {
|
|
|
- //如果当前账号没有在组织架构中,则只允许查询到自己填写到跟进动态
|
|
|
- where.append(" and createuserid=").append(userid);
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
- }
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("ownertable", ownertable);
|
|
|
- sqlFactory.addParameter("ownerid", ownerid);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(dbConnect, "sys_datafollowup", "t1.*").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t2", "t2.sa_customersid=t1.sa_customersid and t2.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t21", "t21.sys_enterpriseid=t2.sys_enterpriseid and t21.siteid=t2.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_hospitaldep", "t3", "t3.sa_hospitaldepid=t1.sa_hospitaldepid and t3.siteid=t1.siteid",
|
|
|
+ "hospitaldepname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_doctor", "t4", "t4.sa_doctorid=t1.sa_doctorid and t4.siteid=t1.siteid",
|
|
|
+ "doctorname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_task", "t5", "t5.sys_taskid=t1.sys_taskid and t5.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t6", "t6.sa_agentsid=t1.sa_agentsid and t6.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t61", "t61.sys_enterpriseid=t6.sys_enterpriseid and t61.siteid=t6.siteid");
|
|
|
+ querySQL.addQueryFields("hospitalname", "t21.enterprisename");
|
|
|
+ querySQL.addQueryFields("tasktitle", "t5.title");
|
|
|
+ querySQL.addQueryFields("agentsname", "t61.enterprisename");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+
|
|
|
+ switch (ownertable) {
|
|
|
+ case "sa_customers":
|
|
|
+ querySQL.setWhere("t1.sa_customersid", ownerid);
|
|
|
+ break;
|
|
|
+ case "sa_hospitaldep":
|
|
|
+ querySQL.setWhere("t1.sa_hospitaldepid", ownerid);
|
|
|
+ break;
|
|
|
+ case "sa_doctor":
|
|
|
+ querySQL.setWhere("t1.sa_doctorid", ownerid);
|
|
|
+ break;
|
|
|
+ case "sa_agents":
|
|
|
+ querySQL.setWhere("t1.sa_agentsid", ownerid);
|
|
|
+ break;
|
|
|
+ case "sys_task":
|
|
|
+ querySQL.setWhere("t1.sys_taskid", ownerid);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ querySQL.setWhere("ownertable", ownertable);
|
|
|
+ querySQL.setWhere("ownerid", ownerid);
|
|
|
+ }
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
|
|
|
ArrayList<Long> sys_datafollowupids = rows.toArrayList("sys_datafollowupid", new ArrayList<Long>());
|
|
|
|
|
|
- HashMap<String, BigDecimal> followupsalefeesHashMap;
|
|
|
- if (ownertable.equals("sys_phonebook")) {
|
|
|
- RowsMap rowsMap = rows.toRowsMap("ownertable");
|
|
|
- ArrayList<Long> sys_phonebookfollowids = rowsMap.get("sys_phonebook").toArrayList("sys_datafollowupid", new ArrayList<>());
|
|
|
- ArrayList<Long> sa_customersfollowids = rowsMap.get("sa_customers").toArrayList("sys_datafollowupid", new ArrayList<>());
|
|
|
- ArrayList<Long> sa_projectfollowids = rowsMap.get("sa_project").toArrayList("sys_datafollowupid", new ArrayList<>());
|
|
|
-
|
|
|
- followupsalefeesHashMap = SalesFees.getfollowupsalefeesamount(this, "sys_phonebook", sys_phonebookfollowids);
|
|
|
- followupsalefeesHashMap.putAll(SalesFees.getfollowupsalefeesamount(this, "sa_customers", sa_customersfollowids));
|
|
|
- followupsalefeesHashMap.putAll(SalesFees.getfollowupsalefeesamount(this, "sa_project", sa_projectfollowids));
|
|
|
- } else {
|
|
|
- followupsalefeesHashMap = SalesFees.getfollowupsalefeesamount(this, ownertable, sys_datafollowupids);
|
|
|
- }
|
|
|
-
|
|
|
+ HashMap<String, BigDecimal> followupsalefeesHashMap = SalesFees.getfollowupsalefeesamount(this, ownertable, sys_datafollowupids);
|
|
|
|
|
|
RowsMap map = getAttachmentUrl("sys_datafollowup", sys_datafollowupids);
|
|
|
|
|
|
-
|
|
|
RowsMap userExtendMsgMap = User.getUserExtendMsg(this, rows.toArrayList("createuserid", new ArrayList<>()));
|
|
|
|
|
|
- RowsMap allCommentsRowsMap = DataComment.getsubcomment(this, "sys_datafollowup", sys_datafollowupids);
|
|
|
-
|
|
|
- RowsMap contactsRowsMap = Datafollowup.getContacts(this, rows.toArrayList("sys_datafollowupid"));
|
|
|
for (Row row : rows) {
|
|
|
String sys_datafollowupid = row.getString("sys_datafollowupid");
|
|
|
row.put("headpic", getHeadPic(row.getLong("createuserid")));
|
|
|
@@ -106,50 +113,7 @@ public class datafollowup extends Controller {
|
|
|
} else {
|
|
|
row.put("salesfeesamount", "");
|
|
|
}
|
|
|
- Rows commentRows = allCommentsRowsMap.get(sys_datafollowupid);
|
|
|
- commentRows.sortby("createdate desc");
|
|
|
- row.put("comment", commentRows);
|
|
|
- row.put("commentqty", commentRows.size() + commentRows.sum("subcommentqty").intValue());
|
|
|
- JSONObject dataextend = row.getJSONObject("dataextend");
|
|
|
- row.put("dataextend", dataextend);
|
|
|
- Rows temprow = new Rows();
|
|
|
- if (dataextend.containsKey("sat_orderclueids")) {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_orderclue",
|
|
|
- "sat_orderclueid", "enterprisename");
|
|
|
- querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("sat_orderclueid", dataextend.getJSONArray("sat_orderclueids"));
|
|
|
- temprow = querySQL.query();
|
|
|
- }
|
|
|
- row.put("sat_orderclue", temprow);
|
|
|
- if (dataextend.containsKey("sa_customersids")) {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_customers",
|
|
|
- "sa_customersid", "name");
|
|
|
- querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("sa_customersid", dataextend.getJSONArray("sa_customersids"));
|
|
|
- temprow = querySQL.query();
|
|
|
- }
|
|
|
- row.put("sa_customers", temprow);
|
|
|
- if (dataextend.containsKey("sa_projectids")) {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_project",
|
|
|
- "projectname", "sa_projectid");
|
|
|
- querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("sa_projectid", dataextend.getJSONArray("sa_projectids"));
|
|
|
- temprow = querySQL.query();
|
|
|
- }
|
|
|
- row.put("sa_project", temprow);
|
|
|
- Rows contactsRows = contactsRowsMap.get(sys_datafollowupid);
|
|
|
- if (contactsRows.isNotEmpty()) {
|
|
|
- row.put("contacts", contactsRows);
|
|
|
- } else {
|
|
|
- if (dataextend.containsKey("contactsid")) {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_phonebook",
|
|
|
- "sys_phonebookid", "name");
|
|
|
- querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("sys_phonebookid", dataextend.getJSONArray("contactsid"));
|
|
|
- temprow = querySQL.query();
|
|
|
- row.put("contacts", temprow);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
@@ -157,13 +121,25 @@ public class datafollowup extends Controller {
|
|
|
@API(title = "数据跟进日志详情查询", apiversion = R.ID20221026085601.v1.class)
|
|
|
public String queryFollowUpMain() throws YosException {
|
|
|
Long sys_datafollowupid = content.getLong("sys_datafollowupid");
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "数据跟进日志详情查询");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("sys_datafollowupid", sys_datafollowupid);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(dbConnect, "sys_datafollowup", "t1.*").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t2", "t2.sa_customersid=t1.sa_customersid and t2.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t21", "t21.sys_enterpriseid=t2.sys_enterpriseid and t21.siteid=t2.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_hospitaldep", "t3", "t3.sa_hospitaldepid=t1.sa_hospitaldepid and t3.siteid=t1.siteid",
|
|
|
+ "hospitaldepname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_doctor", "t4", "t4.sa_doctorid=t1.sa_doctorid and t4.siteid=t1.siteid",
|
|
|
+ "doctorname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_task", "t5", "t5.sys_taskid=t1.sys_taskid and t5.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t6", "t6.sa_agentsid=t1.sa_agentsid and t6.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t61", "t61.sys_enterpriseid=t6.sys_enterpriseid and t61.siteid=t6.siteid");
|
|
|
+ querySQL.addQueryFields("hospitalname", "t21.enterprisename");
|
|
|
+ querySQL.addQueryFields("tasktitle", "t5.title");
|
|
|
+ querySQL.addQueryFields("agentsname", "t61.enterprisename");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sys_datafollowupid", sys_datafollowupid);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
|
|
|
RowsMap userExtendMsgMap = User.getUserExtendMsg(this, rows.toArrayList("createuserid", new ArrayList<>()));
|
|
|
- Rows contactsRows = Datafollowup.getContacts(this, String.valueOf(sys_datafollowupid));
|
|
|
for (Row row : rows) {
|
|
|
String ownertable = row.getString("ownertable");
|
|
|
Rows attachmentUrlRows = getAttachmentUrl("sys_datafollowup", sys_datafollowupid);
|
|
|
@@ -172,34 +148,6 @@ public class datafollowup extends Controller {
|
|
|
row.put("attinfos", attachmentUrlRows);
|
|
|
row.put("userextend", userExtendMsgMap.get(row.getString("createuserid")));
|
|
|
row.put("salesfeesamount", salesfeesamount);
|
|
|
- row.put("contacts", contactsRows);
|
|
|
- JSONObject dataextend = row.getJSONObject("dataextend");
|
|
|
- row.put("dataextend", dataextend);
|
|
|
- Rows temprow = new Rows();
|
|
|
- if (dataextend.containsKey("sat_orderclueids")) {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_orderclue",
|
|
|
- "sat_orderclueid", "enterprisename");
|
|
|
- querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("sat_orderclueid", dataextend.getJSONArray("sat_orderclueids"));
|
|
|
- temprow = querySQL.query();
|
|
|
- }
|
|
|
- row.put("sat_orderclue", temprow);
|
|
|
- if (dataextend.containsKey("sa_customersids")) {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_customers",
|
|
|
- "sa_customersid", "name");
|
|
|
- querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("sa_customersid", dataextend.getJSONArray("sa_customersids"));
|
|
|
- temprow = querySQL.query();
|
|
|
- }
|
|
|
- row.put("sa_customers", temprow);
|
|
|
- if (dataextend.containsKey("sa_projectids")) {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_project",
|
|
|
- "projectname", "sa_projectid");
|
|
|
- querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("sa_projectid", dataextend.getJSONArray("sa_projectids"));
|
|
|
- temprow = querySQL.query();
|
|
|
- }
|
|
|
- row.put("sa_project", temprow);
|
|
|
}
|
|
|
return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Row()).toString();
|
|
|
}
|
|
|
@@ -210,235 +158,60 @@ public class datafollowup extends Controller {
|
|
|
long sys_datafollowupid = content.getLongValue("sys_datafollowupid");
|
|
|
String ownertable = content.getString("ownertable");
|
|
|
long ownerid = content.getLong("ownerid");
|
|
|
- String type = content.getStringValue("type");
|
|
|
String contentstr = content.getStringValue("content");
|
|
|
- String target = content.getStringValue("target");
|
|
|
- String results = content.getStringValue("results");
|
|
|
- String nextplan = content.getStringValue("nextplan");
|
|
|
- String resource = content.getStringValue("resource");
|
|
|
- if (resource.equals("通讯录")) {
|
|
|
- resource = "联系人";
|
|
|
- }
|
|
|
- HashSet<Object> contactsidList = new HashSet<>();
|
|
|
- HashSet<Object> sat_orderclueids = new HashSet<>();
|
|
|
- HashSet<Object> sa_customersids = new HashSet<>();
|
|
|
- HashSet<Object> sa_projectids = new HashSet<>();
|
|
|
- JSONObject dataextend = new JSONObject();
|
|
|
- if (content.containsKey("dataextend")) {
|
|
|
- dataextend = content.getJSONObject("dataextend");
|
|
|
- }
|
|
|
- if (dataextend.containsKey("contactsid")) {
|
|
|
- contactsidList = new HashSet<>(dataextend.getJSONArray("contactsid"));
|
|
|
- dataextend.put("contactsid", contactsidList);
|
|
|
- }
|
|
|
- if (dataextend.containsKey("sat_orderclueids")) {
|
|
|
- sat_orderclueids = new HashSet<>(dataextend.getJSONArray("sat_orderclueids"));
|
|
|
- dataextend.put("sat_orderclueids", sat_orderclueids);
|
|
|
- }
|
|
|
- if (dataextend.containsKey("sa_customersids")) {
|
|
|
- sa_customersids = new HashSet<>(dataextend.getJSONArray("sa_customersids"));
|
|
|
- dataextend.put("sa_customersids", sa_customersids);
|
|
|
- }
|
|
|
- if (dataextend.containsKey("sa_projectids")) {
|
|
|
- sa_projectids = new HashSet<>(dataextend.getJSONArray("sa_projectids"));
|
|
|
- dataextend.put("sa_projectids", sa_projectids);
|
|
|
- }
|
|
|
- //关联线索
|
|
|
- if (ownertable.equals("sys_phonebook")) {
|
|
|
- if (sat_orderclueids.size() == 0 && sa_customersids.size() == 0 && sa_projectids.size() == 0) {
|
|
|
- return getErrReturnObject().setErrMsg("关联线索、关联客户、关联项目至少选择一项").toString();
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- SQLFactory sqlFactory;
|
|
|
- if (sys_datafollowupid <= 0 || dbConnect.runSqlQuery("select * from sys_datafollowup where siteid='" + siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and sys_datafollowupid='" + sys_datafollowupid + "'").isEmpty()) {
|
|
|
+ if (sys_datafollowupid <= 0) {
|
|
|
sys_datafollowupid = createTableID("sys_datafollowup");
|
|
|
- sqlFactory = new SQLFactory(this, "数据跟进日志创建");
|
|
|
- sqlFactory.addParameter("sys_datafollowupid", sys_datafollowupid);
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("type", type);
|
|
|
- sqlFactory.addParameter("ownertable", ownertable);
|
|
|
- sqlFactory.addParameter("ownerid", ownerid);
|
|
|
- sqlFactory.addParameter("content", contentstr);
|
|
|
- sqlFactory.addParameter("resource", resource);
|
|
|
- sqlFactory.addParameter("dataextend", dataextend.toString());
|
|
|
- sqlFactory.addParameter("target", target);
|
|
|
- sqlFactory.addParameter("results", results);
|
|
|
- sqlFactory.addParameter("nextplan", nextplan);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- content.put("sys_datafollowupid", sys_datafollowupid);
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datafollowup");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(sys_datafollowupid);
|
|
|
+ insertSQL.setValue("ownertable", ownertable);
|
|
|
+ insertSQL.setValue("ownerid", ownerid);
|
|
|
+ insertSQL.setValue("content", contentstr);
|
|
|
+ insertSQL.setValue("resource", content.getStringValue("resource"));
|
|
|
+ insertSQL.setValue("target", content.getStringValue("target"));
|
|
|
+ insertSQL.setValue("results", content.getStringValue("results"));
|
|
|
+ insertSQL.setValue("nextplan", content.getStringValue("nextplan"));
|
|
|
+ insertSQL.setValue("type", content.getStringValue("type"));
|
|
|
+ insertSQL.setValue("followobj", content.getStringValue("followobj"));
|
|
|
+ insertSQL.setValue("products", content.getStringValue("products"));
|
|
|
+ insertSQL.setValue("sys_taskid", content.getLongValue("sys_taskid"));
|
|
|
+ insertSQL.setValue("sa_agentsid", content.getLongValue("sa_agentsid"));
|
|
|
+ insertSQL.setValue("sa_hospitaldepid", content.getLongValue("sa_hospitaldepid"));
|
|
|
+ insertSQL.setValue("sa_doctorid", content.getLongValue("sa_doctorid"));
|
|
|
+ insertSQL.setValue("sa_customersid", content.getLongValue("sa_customersid"));
|
|
|
+
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
sqlList.add(DataContrlLog.createLog(this, ownertable, ownerid, "新增跟进动态", "新增跟进动态【" + contentstr + "】").getSQL());
|
|
|
+ content.put("sys_datafollowupid", sys_datafollowupid);
|
|
|
} else {
|
|
|
Rows rows = dbConnect.runSqlQuery("select *from sys_datafollowup where siteid='" + siteid + "' and sys_datafollowupid=" + sys_datafollowupid);
|
|
|
if (rows.get(0).getLong("createuserid") != userid) {
|
|
|
return getReturnObject().setCode("0134", new String[0]).toString();//非跟进创建人不可进行修改操作
|
|
|
}
|
|
|
- sqlFactory = new SQLFactory(this, "数据跟进日志修改");
|
|
|
- sqlFactory.addParameter("sys_datafollowupid", sys_datafollowupid);
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("type", type);
|
|
|
- sqlFactory.addParameter("ownertable", ownertable);
|
|
|
- sqlFactory.addParameter("ownerid", ownerid);
|
|
|
- sqlFactory.addParameter("content", contentstr);
|
|
|
- sqlFactory.addParameter("target", target);
|
|
|
- sqlFactory.addParameter("results", results);
|
|
|
- sqlFactory.addParameter("nextplan", nextplan);
|
|
|
- sqlFactory.addParameter("dataextend", dataextend.toString());
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_datafollowup");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sys_datafollowupid);
|
|
|
+ updateSQL.setValue("content", contentstr);
|
|
|
+ updateSQL.setValue("resource", content.getStringValue("resource"));
|
|
|
+ updateSQL.setValue("target", content.getStringValue("target"));
|
|
|
+ updateSQL.setValue("results", content.getStringValue("results"));
|
|
|
+ updateSQL.setValue("nextplan", content.getStringValue("nextplan"));
|
|
|
+ updateSQL.setValue("type", content.getStringValue("type"));
|
|
|
+ updateSQL.setValue("followobj", content.getStringValue("followobj"));
|
|
|
+ updateSQL.setValue("products", content.getStringValue("products"));
|
|
|
+ updateSQL.setValue("sys_taskid", content.getLongValue("sys_taskid"));
|
|
|
+ updateSQL.setValue("sa_agentsid", content.getLongValue("sa_agentsid"));
|
|
|
+ updateSQL.setValue("sa_hospitaldepid", content.getLongValue("sa_hospitaldepid"));
|
|
|
+ updateSQL.setValue("sa_doctorid", content.getLongValue("sa_doctorid"));
|
|
|
+ updateSQL.setValue("sa_customersid", content.getLongValue("sa_customersid"));
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
sqlList.add(DataContrlLog.createLog(this, ownertable, ownerid, "编辑跟进动态", "编辑跟进动态【" + contentstr + "】").getSQL());
|
|
|
}
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
- sqlList.add("delete from sa_datafollowuptarget where siteid='" + siteid + "' and sys_datafollowupid=" + sys_datafollowupid);
|
|
|
-
|
|
|
- for (Object o : contactsidList) {
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(dbConnect, "sa_datafollowuptarget");
|
|
|
- insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setUniqueid(insertSQL.createTableID("sa_datafollowuptarget"));
|
|
|
- insertSQL.setValue("sys_phonebookid", o);
|
|
|
- insertSQL.setValue("sys_datafollowupid", sys_datafollowupid);
|
|
|
- sqlList.add(insertSQL.getSQL());
|
|
|
- }
|
|
|
- //关联线索
|
|
|
- if (ownertable.equals("sys_phonebook") && resource.equals("联系人")) {
|
|
|
- Rows datafollowuprows = dbConnect.runSqlQuery("select *from sys_datafollowup where siteid='" + siteid + "' and sys_datafollowupid=" + sys_datafollowupid);
|
|
|
- //删除数据
|
|
|
- if (datafollowuprows.isNotEmpty()) {
|
|
|
- JSONObject temp_dataextend = new JSONObject();
|
|
|
- JSONArray temp_sat_orderclueids = new JSONArray();
|
|
|
- JSONArray temp_sa_customersids = new JSONArray();
|
|
|
- JSONArray temp_sa_projectids = new JSONArray();
|
|
|
- temp_dataextend = content.getJSONObject("dataextend");
|
|
|
- if (dataextend.containsKey("sat_orderclueids")) {
|
|
|
- temp_sat_orderclueids = temp_dataextend.getJSONArray("sat_orderclueids");
|
|
|
- }
|
|
|
- if (dataextend.containsKey("sa_customersids")) {
|
|
|
- temp_sa_customersids = temp_dataextend.getJSONArray("sa_customersids");
|
|
|
- }
|
|
|
- if (dataextend.containsKey("sa_projectids")) {
|
|
|
- temp_sa_projectids = temp_dataextend.getJSONArray("sa_projectids");
|
|
|
- }
|
|
|
- //删除关联线索的联系人
|
|
|
- DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_orderclue_contacts");
|
|
|
- deleteSQL.setSiteid(siteid);
|
|
|
- deleteSQL.setWhere("sat_orderclueid", temp_sat_orderclueids);
|
|
|
- deleteSQL.setWhere("sys_phonebookid", ownerid);
|
|
|
- deleteSQL.delete();
|
|
|
- //删除关联客户的联系人
|
|
|
- for (Object o : temp_sa_customersids) {
|
|
|
- Long sa_customersid = Long.parseLong(o.toString());
|
|
|
- Long sys_enterpriseid = 0L;
|
|
|
- Rows customersrows = dbConnect.runSqlQuery("SELECT * from sa_customers WHERE sa_customersid=" + sa_customersid + " and siteid='" + siteid + "'");
|
|
|
- if (customersrows.isNotEmpty()) {
|
|
|
- sys_enterpriseid = customersrows.get(0).getLong("sys_enterpriseid");
|
|
|
- deleteSQL = SQLFactory.createDeleteSQL(this, "sys_enterprise_contacts");
|
|
|
- deleteSQL.setSiteid(siteid);
|
|
|
- deleteSQL.setWhere("sys_enterpriseid", sys_enterpriseid);
|
|
|
- deleteSQL.setWhere("sys_phonebookid", ownerid);
|
|
|
- deleteSQL.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- //删除关联项目的联系人
|
|
|
- deleteSQL = SQLFactory.createDeleteSQL(this, "sa_project_contacts");
|
|
|
- deleteSQL.setSiteid(siteid);
|
|
|
- deleteSQL.setWhere("sa_projectid", temp_sa_projectids);
|
|
|
- deleteSQL.setWhere("sys_phonebookid", ownerid);
|
|
|
- sqlList.add(deleteSQL.getSQL());
|
|
|
- for (Object o : temp_sa_projectids) {
|
|
|
- Long sa_projectid = Long.parseLong(o.toString());
|
|
|
- Rows contactsrows = dbConnect.runSqlQuery("SELECT * from sa_project_contacts WHERE sa_projectid=" + sa_projectid + " and siteid='" + siteid + "'");
|
|
|
- if (contactsrows.isNotEmpty()) {
|
|
|
- deleteSQL = SQLFactory.createDeleteSQL(this, "sys_enterprise_contacts");
|
|
|
- deleteSQL.setSiteid(siteid);
|
|
|
- deleteSQL.setWhere("contactsid", contactsrows.toArray("contactsid"));
|
|
|
- deleteSQL.setWhere("sys_phonebookid", ownerid);
|
|
|
- deleteSQL.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- dbConnect.runSqlUpdate("DELETE from sys_datafollowup WHERE sourcetable='sys_datafollowup' and sourceid='" + sys_datafollowupid + "' and siteid='" + siteid + "'");
|
|
|
- dbConnect.runSqlUpdate("DELETE from sat_ordercluefollowuplog WHERE sourcetable='sys_datafollowup' and sourceid='" + sys_datafollowupid + "' and siteid='" + siteid + "'");
|
|
|
-
|
|
|
- long sys_phonebookid = ownerid;
|
|
|
- //关联线索
|
|
|
- for (Object o : sat_orderclueids) {
|
|
|
- Long sat_orderclueid = Long.parseLong(o.toString());
|
|
|
- //新增联系人
|
|
|
- sqlList.add(get_orderclue_contacts(sys_phonebookid, sat_orderclueid).getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sat_orderclue", sat_orderclueid, "关联联系人", "联系人:" + content.getStringValue("name")).getSQL());
|
|
|
- //新增跟进记录
|
|
|
- sqlList.add(get_ordercluefollowuplog(sys_datafollowupid, sat_orderclueid, content).getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sat_orderclue", sat_orderclueid, "关联跟进记录", "内容:" + content.getStringValue("content")).getSQL());
|
|
|
- }
|
|
|
-
|
|
|
- //关联客户
|
|
|
- for (Object o : sa_customersids) {
|
|
|
- Long sa_customersid = Long.parseLong(o.toString());
|
|
|
- Long sys_enterpriseid = 0L;
|
|
|
- Rows customersrows = dbConnect.runSqlQuery("SELECT * from sa_customers WHERE sa_customersid=" + sa_customersid + " and siteid='" + siteid + "'");
|
|
|
- if (customersrows.isNotEmpty()) {
|
|
|
- sys_enterpriseid = customersrows.get(0).getLong("sys_enterpriseid");
|
|
|
- }
|
|
|
- //新增联系人
|
|
|
- Long contactsid = 0L;
|
|
|
- Rows enterprise_contactsrows = dbConnect.runSqlQuery("SELECT * from sys_enterprise_contacts WHERE deleted=0 and sys_enterpriseid=" + sys_enterpriseid + " and siteid='" + siteid + "' and sys_phonebookid='" + sys_phonebookid + "'");
|
|
|
- if (enterprise_contactsrows.isNotEmpty()) {
|
|
|
- contactsid = enterprise_contactsrows.get(0).getLong("contactsid");
|
|
|
- } else {
|
|
|
- contactsid = createTableID("sys_enterprise_contacts");
|
|
|
- sqlList.add(get_enterprise_contacts(sys_phonebookid, contactsid, sys_enterpriseid).getSQL());
|
|
|
- }
|
|
|
-
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "关联联系人", "联系人:" + content.getStringValue("name")).getSQL());
|
|
|
-
|
|
|
- //新增跟进记录
|
|
|
- sqlList.add(get_datafollowup(sys_datafollowupid, "sa_customers", sa_customersid, content).getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "关联跟进记录", "内容:" + content.getStringValue("content")).getSQL());
|
|
|
- }
|
|
|
- //关联项目
|
|
|
- for (Object o : sa_projectids) {
|
|
|
- Long sa_projectid = Long.parseLong(o.toString());
|
|
|
- //新增联系人
|
|
|
- Long contactsid = 0L;
|
|
|
- Rows enterprise_contactsrows = dbConnect.runSqlQuery("SELECT * from sys_enterprise_contacts WHERE deleted=0 and sys_enterpriseid=" + sys_enterpriseid + " and siteid='" + siteid + "' and sys_phonebookid='" + sys_phonebookid + "'");
|
|
|
- if (enterprise_contactsrows.isNotEmpty()) {
|
|
|
- contactsid = enterprise_contactsrows.get(0).getLong("contactsid");
|
|
|
- } else {
|
|
|
- contactsid = createTableID("sys_enterprise_contacts");
|
|
|
- sqlList.add(get_enterprise_contacts(sys_phonebookid, contactsid, sys_enterpriseid).getSQL());
|
|
|
- }
|
|
|
- sqlList.add(get_project_contacts(sys_phonebookid, sa_projectid, contactsid).getSQL());
|
|
|
- //新增跟进记录
|
|
|
- //新增跟进记录
|
|
|
- sqlList.add(get_datafollowup(sys_datafollowupid, "sa_project", sa_projectid, content).getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_project", sa_projectid, "关联跟进记录", "内容:" + content.getStringValue("content")).getSQL());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
- Rows leaderRows = DataTeam.getLeaderWithoutHeadpic(this, ownertable, ownerid);
|
|
|
- Long leaderuserid = leaderRows.isNotEmpty() ? leaderRows.get(0).getLong("userid") : 0;
|
|
|
- Long departmentid = getDepartment(leaderuserid).getLong("departmentid");
|
|
|
- ArrayList<Long> userids = new ArrayList<>();
|
|
|
- userids.add(leaderuserid);
|
|
|
- userids.add(userid);
|
|
|
- userids.add(Hr.getReportUserid(this, leaderuserid));
|
|
|
- userids.addAll(Hr.getLeaderRows(this, departmentid).toArrayList("userid", new ArrayList<Long>()));
|
|
|
- JSONObject extradata = new JSONObject();
|
|
|
- extradata.put("extraUserList", userids);
|
|
|
-
|
|
|
- if (ownertable.equals("sa_customers")) {
|
|
|
- Executor.sendEml_controller(this, "customers_follow_my", ownerid, extradata);
|
|
|
- }
|
|
|
- if (ownertable.equals("sa_project")) {
|
|
|
- Executor.sendEml_controller(this, "project_follow", ownerid, extradata);
|
|
|
- }
|
|
|
+ //更新医院的状态
|
|
|
if (ownertable.equals("sa_customers")) {
|
|
|
UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_customers");
|
|
|
updateSQL.setSiteid(siteid);
|
|
|
@@ -450,81 +223,6 @@ public class datafollowup extends Controller {
|
|
|
return queryFollowUpMain();
|
|
|
}
|
|
|
|
|
|
- public InsertSQL get_orderclue_contacts(Long sys_phonebookid, Long sat_orderclueid) throws YosException {
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_orderclue_contacts");
|
|
|
- insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sat_orderclue_contactsid", createTableID("sat_orderclue_contacts"));
|
|
|
- insertSQL.setValue("sys_phonebookid", sys_phonebookid);
|
|
|
- insertSQL.setValue("sat_orderclueid", sat_orderclueid);
|
|
|
- return insertSQL;
|
|
|
- }
|
|
|
-
|
|
|
- public InsertSQL get_project_contacts(Long sys_phonebookid, Long sa_projectid, Long contactsid) throws YosException {
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_project_contacts");
|
|
|
- insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sa_project_contactsid", createTableID("sa_project_contacts"));
|
|
|
- insertSQL.setValue("sys_phonebookid", sys_phonebookid);
|
|
|
- insertSQL.setValue("sa_projectid", sa_projectid);
|
|
|
- insertSQL.setValue("contactsid", contactsid);
|
|
|
- return insertSQL;
|
|
|
- }
|
|
|
-
|
|
|
- public InsertSQL get_enterprise_contacts(Long sys_phonebookid, Long contactsid, Long sys_enterpriseid) throws YosException {
|
|
|
-
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
|
|
|
- insertSQL.setValue("contactsid", contactsid);
|
|
|
- insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
- insertSQL.setValue("workaddress", 0);
|
|
|
- insertSQL.setValue("sys_phonebookid", sys_phonebookid);
|
|
|
- insertSQL.setSiteid(siteid);
|
|
|
-
|
|
|
- return insertSQL;
|
|
|
- }
|
|
|
-
|
|
|
- public InsertSQL get_ordercluefollowuplog(Long sys_datafollowupid, Long sat_orderclueid, JSONObject content) throws YosException {
|
|
|
-
|
|
|
- Long sat_orderclue_authid = 0L;
|
|
|
- Rows rows = dbConnect.runSqlQuery("SELECT sat_orderclue_authid from sat_ordercluefollowuplog WHERE sat_orderclueid=" + sat_orderclueid);
|
|
|
- if (rows.isNotEmpty()) {
|
|
|
- sat_orderclue_authid = rows.get(0).getLong("sat_orderclue_authid");
|
|
|
- }
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_ordercluefollowuplog");
|
|
|
- insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sat_ordercluefollowuplogid", createTableID("sat_ordercluefollowuplog"));
|
|
|
- insertSQL.setValue("sat_orderclueid", sat_orderclueid);
|
|
|
- insertSQL.setValue("sourcetable", "sys_datafollowup");
|
|
|
- insertSQL.setValue("sourceid", sys_datafollowupid);
|
|
|
- insertSQL.setValue("dataextend", content.getStringValue("dataextend"));
|
|
|
- insertSQL.setValue("results", content.getStringValue("results"));
|
|
|
- insertSQL.setValue("target", content.getStringValue("target"));
|
|
|
- insertSQL.setValue("nextplan", content.getStringValue("nextplan"));
|
|
|
- insertSQL.setValue("resource", "联系人");
|
|
|
- insertSQL.setValue("sat_orderclue_authid", sat_orderclue_authid);
|
|
|
- insertSQL.setValue("logtype", "跟进");
|
|
|
- insertSQL.setValue("followupmode", content.getStringValue("type"));
|
|
|
- insertSQL.setValue("content", content.getStringValue("content"));
|
|
|
- return insertSQL;
|
|
|
- }
|
|
|
-
|
|
|
- public InsertSQL get_datafollowup(Long sys_datafollowupid, String ownertable, Long ownerid, JSONObject content) throws YosException {
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_datafollowup");
|
|
|
- insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sys_datafollowupid", createTableID("sys_datafollowup"));
|
|
|
- insertSQL.setValue("ownertable", ownertable);
|
|
|
- insertSQL.setValue("ownerid", ownerid);
|
|
|
- insertSQL.setValue("sourcetable", "sys_datafollowup");
|
|
|
- insertSQL.setValue("sourceid", sys_datafollowupid);
|
|
|
- insertSQL.setValue("dataextend", content.getStringValue("dataextend"));
|
|
|
- insertSQL.setValue("results", content.getStringValue("results"));
|
|
|
- insertSQL.setValue("target", content.getStringValue("target"));
|
|
|
- insertSQL.setValue("nextplan", content.getStringValue("nextplan"));
|
|
|
- insertSQL.setValue("resource", "联系人");
|
|
|
- insertSQL.setValue("iswrite", "1");
|
|
|
- insertSQL.setValue("type", content.getStringValue("type"));
|
|
|
- insertSQL.setValue("content", content.getStringValue("content"));
|
|
|
- return insertSQL;
|
|
|
- }
|
|
|
-
|
|
|
@API(title = "数据跟进日志删除", apiversion = R.ID20220930121701.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = R.ID20220930121501.class)
|
|
|
public String deleteFollowUp() throws YosException {
|