|
|
@@ -1,5 +1,6 @@
|
|
|
package restcontroller.webmanage.saletool.phonebook;
|
|
|
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
import beans.datatag.DataTag;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -17,13 +18,13 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
@API(title = "通讯录")
|
|
|
public class phonebook extends Controller {
|
|
|
|
|
|
public phonebook(JSONObject content) throws YosException {
|
|
|
super(content);
|
|
|
- // TODO Auto-generated constructor stub
|
|
|
}
|
|
|
|
|
|
@API(title = "通讯录新增修改", apiversion = R.ID20220831164503.v1.class)
|
|
|
@@ -32,7 +33,7 @@ public class phonebook extends Controller {
|
|
|
long sys_phonebookid = content.getLong("sys_phonebookid");
|
|
|
ArrayList<String> sqllist = new ArrayList<>();
|
|
|
String sys_phonebookgroupid = content.getString("sys_phonebookgroupid");
|
|
|
- String phonenumber = content.getString("phonenumber");
|
|
|
+ String phonenumber = content.getStringValue("phonenumber");
|
|
|
String name = content.getString("name", "sys_phonebook");
|
|
|
String company = content.getString("company");
|
|
|
String depname = content.getString("depname", "sys_phonebook");
|
|
|
@@ -45,15 +46,15 @@ public class phonebook extends Controller {
|
|
|
String birthday = content.getString("birthday");
|
|
|
String homeaddress = content.getString("homeaddress");
|
|
|
String remarks = content.getString("remarks");
|
|
|
-
|
|
|
- if (sys_phonebookid <= 0 || dbConnect
|
|
|
- .runSqlQuery("select sys_phonebookid from sys_phonebook where sys_phonebookid=" + sys_phonebookid)
|
|
|
- .isEmpty()) {
|
|
|
+ String fax = content.getStringValue("fax");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select phonenumber,telephone from sys_phonebook where sys_phonebookid=" + sys_phonebookid);
|
|
|
+ if (sys_phonebookid <= 0 || rows.isEmpty()) {
|
|
|
sys_phonebookid = createTableID("sys_phonebook");
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "通讯录新增");
|
|
|
sqlFactory.addParameter("sys_phonebookid", sys_phonebookid);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter("userid", userid);
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
if (!StringUtils.isBlank(sys_phonebookgroupid)) {
|
|
|
sqlFactory.addParameter("sys_phonebookgroupid", sys_phonebookgroupid);
|
|
|
} else {
|
|
|
@@ -63,6 +64,7 @@ public class phonebook extends Controller {
|
|
|
sqlFactory.addParameter("name", name);
|
|
|
sqlFactory.addParameter("company", company);
|
|
|
sqlFactory.addParameter("depname", depname);
|
|
|
+ sqlFactory.addParameter("wechatnum", content.getStringValue("wechatnum"));
|
|
|
sqlFactory.addParameter("position", position);
|
|
|
sqlFactory.addParameter("email", email);
|
|
|
DataTag.updateTag(this, "sys_phonebook", sys_phonebookid, list);
|
|
|
@@ -75,8 +77,10 @@ public class phonebook extends Controller {
|
|
|
}
|
|
|
sqlFactory.addParameter("homeaddress", homeaddress);
|
|
|
sqlFactory.addParameter("remarks", remarks);
|
|
|
+ sqlFactory.addParameter("fax", fax);
|
|
|
content.put("sys_phonebookid", sys_phonebookid);
|
|
|
sqllist.add(sqlFactory.getSQL());
|
|
|
+ sqllist.add(DataContrlLog.createLog(this, "sys_phonebook", sys_phonebookid, "通讯录新增", "通讯录新增:" + name).getSQL());
|
|
|
} else {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "通讯录更新");
|
|
|
sqlFactory.addParameter("sys_phonebookid", sys_phonebookid);
|
|
|
@@ -92,6 +96,7 @@ public class phonebook extends Controller {
|
|
|
sqlFactory.addParameter("company", company);
|
|
|
sqlFactory.addParameter("depname", depname);
|
|
|
sqlFactory.addParameter("position", position);
|
|
|
+ sqlFactory.addParameter("wechatnum", content.getStringValue("wechatnum"));
|
|
|
sqlFactory.addParameter("email", email);
|
|
|
DataTag.updateTag(this, "sys_phonebook", sys_phonebookid, list);
|
|
|
sqlFactory.addParameter("tag", tagArray.toJSONString());
|
|
|
@@ -103,7 +108,9 @@ public class phonebook extends Controller {
|
|
|
}
|
|
|
sqlFactory.addParameter("homeaddress", homeaddress);
|
|
|
sqlFactory.addParameter("remarks", remarks);
|
|
|
+ sqlFactory.addParameter("fax", fax);
|
|
|
sqllist.add(sqlFactory.getSQL());
|
|
|
+ sqllist.add(DataContrlLog.createLog(this, "sys_phonebook", sys_phonebookid, "通讯录更新", "通讯录更新:" + name).getSQL());
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqllist);
|
|
|
return queryPhonebookMain();
|
|
|
@@ -113,7 +120,8 @@ public class phonebook extends Controller {
|
|
|
@API(title = "通讯录列表", apiversion = R.ID20220831164603.v1.class)
|
|
|
@CACHEING
|
|
|
public String queryPhonebookList() throws YosException {
|
|
|
-
|
|
|
+ boolean isqueryall = content.getBooleanValue("isqueryall");
|
|
|
+ String where3 = " 1=1 ";
|
|
|
/*
|
|
|
* 过滤条件设置
|
|
|
*/
|
|
|
@@ -128,20 +136,56 @@ public class phonebook extends Controller {
|
|
|
if (whereObject.containsKey("groupname") && !"".equals(whereObject.getString("groupname"))) {
|
|
|
where = where + " and t.groupname ='" + whereObject.getString("groupname") + "' ";
|
|
|
}
|
|
|
+ if (whereObject.containsKey("tag") && !"".equals(whereObject.getString("tag"))) {
|
|
|
+ where3 = where3 + " and t3.tag ='" + whereObject.getString("tag") + "'";
|
|
|
+ }
|
|
|
}
|
|
|
SQLFactory factory = new SQLFactory(this, "通讯录分组列表查询");
|
|
|
factory.addParameter("siteid", siteid);
|
|
|
factory.addParameter("userid", userid);
|
|
|
factory.addParameter_SQL("where", " 1=1 ");
|
|
|
+ if (isqueryall) {
|
|
|
+ factory.addParameter_SQL("where1", "1=1");
|
|
|
+ } else {
|
|
|
+ factory.addParameter_SQL("where1", "userid = " + userid);
|
|
|
+ }
|
|
|
Rows rowsgroup = dbConnect.runSqlQuery(factory.getSQL());
|
|
|
- if (content.getBooleanValue("isqueryall")) {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询");
|
|
|
+
|
|
|
+ if (isqueryall) {
|
|
|
+ Rows rows =new Rows();
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询_默认群组");
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter_SQL("where3", where3);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_SQL("where1", " 1=1 and t.userid=" + userid);
|
|
|
+ rows.addAll( dbConnect.runSqlQuery(sqlFactory));
|
|
|
+
|
|
|
+ sqlFactory = new SQLFactory(this, "通讯录列表查询_客户联系人");
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter_SQL("where3", where3);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter_SQL("where1", " 1=1 and t.userid=" + userid);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ rows.addAll( dbConnect.runSqlQuery(sqlFactory));
|
|
|
+
|
|
|
+ sqlFactory = new SQLFactory(this, "通讯录列表查询_项目联系人");
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter_SQL("where3", where3);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_SQL("where1", " 1=1 and t.userid=" + userid);
|
|
|
+ rows.addAll( dbConnect.runSqlQuery(sqlFactory));
|
|
|
+
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap = DataTag.queryTag(this, "sys_phonebook", rows.toArrayList("sys_phonebookid", new ArrayList<Long>()), false);
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap2 = DataTag.queryTag(this, "sys_phonebook", rows.toArrayList("sys_phonebookid", new ArrayList<Long>()), true);
|
|
|
for (Row row2 : rows) {
|
|
|
- ArrayList<String> list = DataTag.queryTag(this, "sys_phonebook", row2.getLong("sys_phonebookid"), false);
|
|
|
+ ArrayList<String> list = hashMap.get(row2.getLong("sys_phonebookid"));
|
|
|
+ ArrayList<String> list1 = hashMap2.get(row2.getLong("sys_phonebookid"));
|
|
|
+ if(list==null){
|
|
|
+ list=new ArrayList<>();
|
|
|
+ }
|
|
|
+ if(list1==null){
|
|
|
+ list1=new ArrayList<>();
|
|
|
+ }
|
|
|
+ list.addAll(list1);
|
|
|
row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
|
|
|
}
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
@@ -149,51 +193,84 @@ public class phonebook extends Controller {
|
|
|
for (Row row : rowsgroup) {
|
|
|
String where1 = "";
|
|
|
if (row.getLong("sys_phonebookgroupid") == 0 && row.getString("groupname").equals("默认群组")) {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询_默认群组");
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_SQL("where3", where3);
|
|
|
where1 = " ifnull(t.sys_phonebookgroupid,0)=0 and t.groupname ='默认群组' and t.userid=" + userid;
|
|
|
sqlFactory.addParameter_SQL("where1", where1);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
for (Row row2 : rows) {
|
|
|
- ArrayList<String> list = DataTag.queryTag(this, "sys_phonebook", row2.getLong("sys_phonebookid"), false);
|
|
|
- row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
|
|
|
+ row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(new ArrayList<>())));
|
|
|
}
|
|
|
row.put("phonebook", rows);
|
|
|
} else if (row.getLong("sys_phonebookgroupid") == 0 && row.getString("groupname").equals("客户联系人")) {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询_客户联系人");
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter_SQL("where3", where3);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
where1 = " ifnull(t.sys_phonebookgroupid,0)=0 and t.groupname ='客户联系人' ";
|
|
|
sqlFactory.addParameter_SQL("where1", where1);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap = DataTag.queryTag(this, "sys_enterprise_contacts", rows.toArrayList("contactsid", new ArrayList<Long>()), false);
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap2 = DataTag.queryTag(this, "sys_enterprise_contacts", rows.toArrayList("contactsid", new ArrayList<Long>()), true);
|
|
|
for (Row row2 : rows) {
|
|
|
- ArrayList<String> list = DataTag.queryTag(this, "sys_phonebook", row2.getLong("sys_phonebookid"), false);
|
|
|
+ ArrayList<String> list = hashMap.get(row2.getLong("contactsid"));
|
|
|
+ ArrayList<String> list1 = hashMap2.get(row2.getLong("contactsid"));
|
|
|
+ if(list==null){
|
|
|
+ list=new ArrayList<>();
|
|
|
+ }
|
|
|
+ if(list1==null){
|
|
|
+ list1=new ArrayList<>();
|
|
|
+ }
|
|
|
+ list.addAll(list1);
|
|
|
row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
|
|
|
}
|
|
|
row.put("phonebook", rows);
|
|
|
|
|
|
} else if (row.getLong("sys_phonebookgroupid") == 0 && row.getString("groupname").equals("项目联系人")) {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询_项目联系人");
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter_SQL("where3", where3);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
where1 = " ifnull(t.sys_phonebookgroupid,0)=0 and t.groupname ='项目联系人' ";
|
|
|
sqlFactory.addParameter_SQL("where1", where1);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap = DataTag.queryTag(this, "sa_project_contacts", rows.toArrayList("sa_project_contactsid", new ArrayList<Long>()), false);
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap2 = DataTag.queryTag(this, "sa_project_contacts", rows.toArrayList("sa_project_contactsid", new ArrayList<Long>()), true);
|
|
|
for (Row row2 : rows) {
|
|
|
- ArrayList<String> list = DataTag.queryTag(this, "sys_phonebook", row2.getLong("sys_phonebookid"), false);
|
|
|
+ ArrayList<String> list = hashMap.get(row2.getLong("sa_project_contactsid"));
|
|
|
+ ArrayList<String> list1 = hashMap2.get(row2.getLong("sa_project_contactsid"));
|
|
|
+ if(list==null){
|
|
|
+ list=new ArrayList<>();
|
|
|
+ }
|
|
|
+ if(list1==null){
|
|
|
+ list1=new ArrayList<>();
|
|
|
+ }
|
|
|
+ list.addAll(list1);
|
|
|
row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
|
|
|
}
|
|
|
row.put("phonebook", rows);
|
|
|
} else if (row.getLong("sys_phonebookgroupid") != 0) {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "通讯录列表查询_默认群组");
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
+ sqlFactory.addParameter_SQL("where3", where3);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
where1 = " t.sys_phonebookgroupid= " + row.getLong("sys_phonebookgroupid") + " and t.userid=" + userid;
|
|
|
sqlFactory.addParameter_SQL("where1", where1);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap = DataTag.queryTag(this, "sys_phonebook", rows.toArrayList("sys_phonebookid", new ArrayList<Long>()), false);
|
|
|
+ HashMap<Long, ArrayList<String>> hashMap2 = DataTag.queryTag(this, "sys_phonebook", rows.toArrayList("sys_phonebookid", new ArrayList<Long>()), true);
|
|
|
for (Row row2 : rows) {
|
|
|
- ArrayList<String> list = DataTag.queryTag(this, "sys_phonebook", row2.getLong("sys_phonebookid"), false);
|
|
|
+ ArrayList<String> list = hashMap.get(row2.getLong("sys_phonebookid"));
|
|
|
+ ArrayList<String> list1 = hashMap2.get(row2.getLong("sys_phonebookid"));
|
|
|
+ if(list==null){
|
|
|
+ list=new ArrayList<>();
|
|
|
+ }
|
|
|
+ if(list1==null){
|
|
|
+ list1=new ArrayList<>();
|
|
|
+ }
|
|
|
+ list.addAll(list1);
|
|
|
row2.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
|
|
|
}
|
|
|
row.put("phonebook", rows);
|