|
|
@@ -27,8 +27,8 @@ public class PublicClue extends Controller {
|
|
|
@API(title = "公海线索-线索列表", apiversion = R.ID20221101094402.v1.class)
|
|
|
public String selectList() throws YosException, IOException {
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_orderclue", "sat_orderclueid", "name", "phonenumber", "province", "city", "county", "address", "notes", "cluesource", "status", "cluetype", "createdate", "changedate").setTableAlias("t1");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sat_orderclue_auth", "t2", "t1.sat_orderclueid=t2.sat_orderclueid ");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t2.sys_enterpriseid=t3.sys_enterpriseid", "enterprisename");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sat_orderclue_auth", "t2", "t1.sat_orderclueid=t2.sat_orderclueid ", "createdate as authtime");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sv_agents", "t3", "t2.sys_enterpriseid=t3.sys_enterpriseid", "agentnum", "enterprisename", "abbreviation");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_hr", "t4", "t2.hrid=t4.sys_enterprise_hrid");
|
|
|
querySQL.addQueryFields("leadername", "ifnull(t4.name, '')");
|
|
|
querySQL.setWhere("t1.isprivate", 0);
|
|
|
@@ -38,15 +38,20 @@ public class PublicClue extends Controller {
|
|
|
|
|
|
QuerySQL lastfollowuplogquery = SQLFactory.createQuerySQL(this, "sat_ordercluefollowuplog", "sat_orderclueid");
|
|
|
lastfollowuplogquery.addQueryFields("sat_ordercluefollowuplogid", "max(sat_ordercluefollowuplogid)");
|
|
|
+ lastfollowuplogquery.addQueryFields("first_ordercluefollowuplogid", "min(sat_ordercluefollowuplogid)");
|
|
|
lastfollowuplogquery.addQueryFields("count", "count(0)");
|
|
|
lastfollowuplogquery.addGroupBy("sat_orderclueid");
|
|
|
lastfollowuplogquery.setWhere("sat_orderclueid", rows.toArrayList("sat_orderclueid"));
|
|
|
Rows followuplogRows = lastfollowuplogquery.query();
|
|
|
RowsMap followuplogRowsMap = followuplogRows.toRowsMap("sat_orderclueid");
|
|
|
ArrayList<Long> sat_ordercluefollowuplogids = followuplogRows.toArrayList("sat_ordercluefollowuplogid", new ArrayList<>());
|
|
|
-
|
|
|
RowsMap lastfollowuplogRowsMap = SQLFactory.createQuerySQL(this, "sat_ordercluefollowuplog").setWhere("sat_ordercluefollowuplogid", sat_ordercluefollowuplogids).query().toRowsMap("sat_orderclueid");
|
|
|
|
|
|
+
|
|
|
+ ArrayList<Long> first_ordercluefollowuplogids = followuplogRows.toArrayList("first_ordercluefollowuplogid", new ArrayList<>());
|
|
|
+ RowsMap firstfollowuplogRowsMap = SQLFactory.createQuerySQL(this, "sat_ordercluefollowuplog").setWhere("sat_ordercluefollowuplogid", first_ordercluefollowuplogids).query().toRowsMap("sat_orderclueid");
|
|
|
+
|
|
|
+
|
|
|
for (Row row : rows) {
|
|
|
Rows lognumRows = followuplogRowsMap.get(row.getString("sat_orderclueid"));
|
|
|
if (lognumRows.isNotEmpty()) {
|
|
|
@@ -62,6 +67,13 @@ public class PublicClue extends Controller {
|
|
|
row.put("logtype", "");
|
|
|
row.put("followcontent", "");
|
|
|
}
|
|
|
+
|
|
|
+ Rows firstlogtypeRows = firstfollowuplogRowsMap.get(row.getString("sat_orderclueid"));
|
|
|
+ if (firstlogtypeRows.isNotEmpty()) {
|
|
|
+ row.put("firstfollowuptime", firstlogtypeRows.get(0).getString("createdate"));
|
|
|
+ } else {
|
|
|
+ row.put("firstfollowuptime", "");
|
|
|
+ }
|
|
|
}
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|