|
|
@@ -1,5 +1,7 @@
|
|
|
package com.cnd3b.restcontroller.customer.supplyanddemand;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.cnd3b.common.Controller;
|
|
|
import com.cnd3b.common.D3bException;
|
|
|
@@ -89,12 +91,25 @@ public class supplyanddemand extends Controller {
|
|
|
row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
|
|
|
//创建者头像
|
|
|
row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid")));
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
|
|
|
- Rows imdialogRows = dbConnect.runSqlQuery("select timdialogid from timdialog where siteid='" + siteid + "' and ownertable='tsupplyanddemand' and ownerid='" + tsupplyanddemandid + "' and tenterprise_userid=" + userid);
|
|
|
- long timdialogid;
|
|
|
- if (!imdialogRows.isEmpty()) {
|
|
|
- timdialogid = imdialogRows.get(0).getLong("timdialogid");
|
|
|
- } else {
|
|
|
+ /**
|
|
|
+ * 一键联系(创建聊天对话框)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String OpenImDialog() throws P2Exception {
|
|
|
+ long tsupplyanddemandid = content.getLong("tsupplyanddemandid");
|
|
|
+
|
|
|
+ Rows imdialogRows = dbConnect.runSqlQuery("select timdialogid,tenterprise_userid from timdialog where siteid='" + siteid + "' and ownertable='tsupplyanddemand' and ownerid='" + tsupplyanddemandid + "' and tenterprise_userid=" + userid);
|
|
|
+ long timdialogid;
|
|
|
+ if (!imdialogRows.isEmpty()) {
|
|
|
+ timdialogid = imdialogRows.get(0).getLong("timdialogid");
|
|
|
+ } else {
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select ftitle from tsupplyanddemand where siteid='" + siteid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
+ if (!rows.isEmpty()) {
|
|
|
//聊天对话框不存在时,自动生成一个聊天对话框
|
|
|
PaoSetRemote timdialogSet = getP2ServerSystemPaoSet("timdialog");
|
|
|
PaoRemote timdialog = timdialogSet.addAtEnd();
|
|
|
@@ -105,7 +120,7 @@ public class supplyanddemand extends Controller {
|
|
|
timdialog.setValue("ownertable", "tsupplyanddemand", 11L);//所有表
|
|
|
timdialog.setValue("ownerid", tsupplyanddemandid, 11L);//所有表ID
|
|
|
timdialog.setValue("tenterprise_userid", userid, 11L);//创建账号ID
|
|
|
- timdialog.setValue("fimdialogname", row.getString("ftitle"), 11L);//对话框类型
|
|
|
+ timdialog.setValue("fimdialogname", rows.get(0).getString("ftitle"), 11L);
|
|
|
timdialogid = timdialog.getUniqueIDValue();
|
|
|
timdialogSet.save();
|
|
|
|
|
|
@@ -113,12 +128,18 @@ public class supplyanddemand extends Controller {
|
|
|
addusers.addParameter("createby", username);
|
|
|
addusers.addParameter("timdialogid", timdialogid);
|
|
|
addusers.addParameter("siteid", siteid);
|
|
|
- addusers.addParameter_in("tenterprise_userid", new String[]{String.valueOf(userid), row.getString("tenterprise_userid")});
|
|
|
+ addusers.addParameter_in("tenterprise_userid", new String[]{String.valueOf(userid), rows.get(0).getString("tenterprise_userid")});
|
|
|
dbConnect.runSqlUpdate(addusers.getSQL());
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("一键联系失败!").toString();
|
|
|
}
|
|
|
- row.put("timdialogid", timdialogid);
|
|
|
}
|
|
|
- return getSucReturnObject().setData(rows).toString();
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("timdialogid", timdialogid);
|
|
|
+
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ array.add(object);
|
|
|
+ return getSucReturnObject().setData(array).toString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -186,6 +207,15 @@ public class supplyanddemand extends Controller {
|
|
|
dialoglistSQL.addParameter("tsupplyanddemandid", tsupplyanddemandid);
|
|
|
dialoglistSQL.addParameter("userid", userid);
|
|
|
Rows dialogrows = dbConnect.runSqlQuery(dialoglistSQL.getSQL());
|
|
|
+
|
|
|
+ SQLFactory timnewmsgSQL = new SQLFactory(this, "即时通讯群最新消息查询");
|
|
|
+ timnewmsgSQL.addParameter("siteid", siteid);
|
|
|
+ timnewmsgSQL.addParameter_in("timdialogid", rows.toArrayList("timdialogid"));
|
|
|
+ RowsMap newmsgmap = timnewmsgSQL.runSqlQuery().toRowsMap("timdialogid");
|
|
|
+ for (Row row : dialogrows) {
|
|
|
+ row.put("latestnews", newmsgmap.get(row.getString("timdialogid")));//最新消息
|
|
|
+ }
|
|
|
+
|
|
|
RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
|
|
|
for (Row row : rows) {
|
|
|
row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
|
|
|
@@ -193,7 +223,6 @@ public class supplyanddemand extends Controller {
|
|
|
//创建者头像
|
|
|
row.put("headportraiturl", getHeadPic(row.getLong("tenterprise_userid")));
|
|
|
}
|
|
|
-
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
@@ -253,18 +282,24 @@ public class supplyanddemand extends Controller {
|
|
|
}
|
|
|
switch (fstatus) {
|
|
|
case "新建": {
|
|
|
- dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='新建',checkby=null,checkdate=null where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
+ dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='新建',changeby='" + username + "',changedate=getDate(),checkby=null,checkdate=null where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
break;
|
|
|
}
|
|
|
case "发布": {
|
|
|
if (!"新建".equals(rows.get(0).getString("fstatus"))) {
|
|
|
return getErrReturnObject().setErrMsg("当前状态不可发布").toString();
|
|
|
}
|
|
|
- dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='待对接',checkby='" + username + "',checkdate=getDate() where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
+ dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='待对接',changeby='" + username + "',changedate=getDate(),checkby='" + username + "',checkdate=getDate() where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "已解决": {
|
|
|
+ long tenterprise_userid = content.getLong("tenterprise_userid");
|
|
|
+ long tcooperationagentsid = getUser(tenterprise_userid).getLong("tagentsid");
|
|
|
+ dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='已解决',changeby='" + username + "',changedate=getDate(),tcooperationagentsid='" + tcooperationagentsid + "' where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
break;
|
|
|
}
|
|
|
default: {
|
|
|
- dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='" + fstatus + "' where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
+ dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='" + fstatus + "',changeby='" + username + "',changedate=getDate() where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
|
|
|
break;
|
|
|
}
|
|
|
}
|