Selaa lähdekoodia

供需广场及供需管理接口新增

沈静伟 4 vuotta sitten
vanhempi
commit
76555fc5eb

+ 13 - 0
src/dsb/com/cnd3b/restcontroller/customer/supplyanddemand/SQL/供需列表查询.sql

@@ -0,0 +1,13 @@
+select
+t1.tsupplyanddemandid,
+t1.fissupply,
+t1.ftype,
+t1.ftitle,
+t1.fcontent,
+t1.fstatus,
+t1.checkdate,
+t1.fenddate,
+t2.fagentname
+from tsupplyanddemand t1
+inner join tagents t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid
+where t1.siteid=$siteid$ and t1.fstatus not in ('н¨') and $where$

+ 8 - 0
src/dsb/com/cnd3b/restcontroller/customer/supplyanddemand/SQL/供需详情查询.sql

@@ -0,0 +1,8 @@
+select t1.tsupplyanddemandid, t1.ftitle,t1.fissupply,
+       t1.ftype, t1.fstatus, t1.checkdate,
+       t1.fenddate,t1.tcooperationagentsid,t2.fagentname,t3.fname,t3.fphonenumber,
+       t1.fcontent,t1.tenterprise_userid
+from tsupplyanddemand t1
+inner join tagents t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid
+inner join tenterprise_users t3 on t1.siteid=t3.siteid and t1.tenterprise_userid=t3.tenterprise_userid
+where t1.siteid=$siteid$ and t1.tagentsid=$tagentsid$ and tsupplyanddemandid=$tsupplyanddemandid$

+ 10 - 0
src/dsb/com/cnd3b/restcontroller/customer/supplyanddemand/SQL/即时通讯群人员添加.sql

@@ -0,0 +1,10 @@
+declare @timdialogusersid bigint
+set @timdialogusersid = (select isnull(MAX(timdialogusersid), 0) from timdialogusers)
+
+insert into timdialogusers
+(timdialogusersid, siteid, createby, changeby, createdate, changedate, rmkenable, fimdialognotes,fisremove,fname, tenterprise_userid,timdialogid)
+select @timdialogusersid + ROW_NUMBER() over (order by t1.fname),
+       t1.siteid, $createby$, $createby$, getdate(), getdate(), 0, null,0,t1.fname, t1.tenterprise_userid,$timdialogid$
+from tenterprise_users t1
+where t1.siteid=$siteid$ and t1.tenterprise_userid in $tenterprise_userid$
+and not exists(select * from timdialogusers where siteid=$siteid$ and timdialogid=$timdialogid$ and tenterprise_userid=t1.tenterprise_userid )

+ 17 - 0
src/dsb/com/cnd3b/restcontroller/customer/supplyanddemand/SQL/我的供需列表查询.sql

@@ -0,0 +1,17 @@
+select
+t1.tsupplyanddemandid,
+t1.fissupply,
+t1.ftype,
+t1.ftitle,
+t1.fcontent,
+t1.fstatus,
+t1.checkdate,
+t1.fenddate,
+t2.fagentname,
+10 as fcommunicationtimes,
+t1.tcooperationagentsid,
+t3.fagentname as fcooperationagentname
+from tsupplyanddemand t1
+inner join tagents t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid
+left join tagents t3 on t1.siteid=t3.siteid and t1.tcooperationagentsid=t3.tagentsid
+where t1.siteid=$siteid$ and t1.tagentsid=$tagentsid$ and $where$

+ 9 - 0
src/dsb/com/cnd3b/restcontroller/customer/supplyanddemand/SQL/我的供需详情查询.sql

@@ -0,0 +1,9 @@
+select t1.tsupplyanddemandid, t1.ftitle,t1.fissupply,
+       t1.ftype, t1.fstatus, t1.checkdate,
+       t1.fenddate,t1.tcooperationagentsid,
+       t1.fcontent,t4.fagentname as fcooperationagentname,10 as fcommunicationtimes
+from tsupplyanddemand t1
+inner join tagents t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid
+inner join tenterprise_users t3 on t1.siteid=t3.siteid and t1.tenterprise_userid=t3.tenterprise_userid
+left join tagents t4 on t1.siteid=t4.siteid and t1.tcooperationagentsid=t4.tagentsid
+where t1.siteid=$siteid$ and t1.tagentsid=$tagentsid$ and tsupplyanddemandid=$tsupplyanddemandid$

+ 6 - 0
src/dsb/com/cnd3b/restcontroller/customer/supplyanddemand/SQL/我的供需详情查询_对话框列表.sql

@@ -0,0 +1,6 @@
+select t1.timdialogid,t4.fagentname,t2.fname  from timdialog t1
+inner join timdialogusers t2 on t1.siteid=t2.siteid and t1.timdialogid=t2.timdialogid
+inner join tenterprise_users t3 on t2.siteid=t3.siteid and t2.tenterprise_userid=t3.tenterprise_userid
+inner join tagents t4 on t3.siteid=t4.siteid and t3.tagentsid=t4.tagentsid
+where t1.siteid=$siteid$ and t1.ownertable='tsupplyanddemand' and t1.ownerid=$tsupplyanddemandid$
+and t2.tenterprise_userid!=$userid$

+ 278 - 0
src/dsb/com/cnd3b/restcontroller/customer/supplyanddemand/supplyanddemand.java

@@ -0,0 +1,278 @@
+package com.cnd3b.restcontroller.customer.supplyanddemand;
+
+import com.alibaba.fastjson.JSONObject;
+import com.cnd3b.common.Controller;
+import com.cnd3b.common.D3bException;
+import com.cnd3b.common.data.Row;
+import com.cnd3b.common.data.Rows;
+import com.cnd3b.common.data.RowsMap;
+import com.cnd3b.common.data.SQLFactory;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2Exception;
+
+import java.util.Arrays;
+
+public class supplyanddemand extends Controller {
+    public supplyanddemand(JSONObject content) {
+        super(content);
+    }
+
+    /**
+     * 供需列表查询
+     *
+     * @return
+     */
+    public String query_supplyanddemandList() {
+        /**
+         *排序条件设置
+         */
+        String[] sortfield = {"t1.tsupplyanddemandid desc"};
+        String sort = getSort(sortfield, "t1.tsupplyanddemandid desc");
+        /**
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.ftitle like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("ftype") && !"".equals(whereObject.getString("ftype"))) {
+                where.append(" and t1.ftype ='").append(whereObject.getString("ftype")).append("' ");
+            }
+            if (whereObject.containsKey("fissupply")) {
+                where.append(" and t1.fissupply =").append(whereObject.getBooleanValue("fissupply") ? 1 : 0);
+            }
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "供需列表查询", pageSize, pageNumber, sort);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_SQL("where", where);
+
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
+
+        for (Row row : rows) {
+            row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
+        }
+        return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
+    }
+
+    /**
+     * 供需详情查询
+     *
+     * @return
+     */
+    public String query_supplyanddemandMain() throws P2Exception {
+        long tsupplyanddemandid = content.getLong("tsupplyanddemandid");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "供需详情查询");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("tagentsid", tagentsid);
+        sqlFactory.addParameter("tsupplyanddemandid", tsupplyanddemandid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+
+        RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
+
+        for (Row row : rows) {
+            row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
+
+            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 {
+                //聊天对话框不存在时,自动生成一个聊天对话框
+                PaoSetRemote timdialogSet = getP2ServerSystemPaoSet("timdialog");
+                PaoRemote timdialog = timdialogSet.addAtEnd();
+                timdialog.setValue("siteid", siteid, 11L);//企业ID
+                timdialog.setValue("createby", username, 11L);//创建人
+                timdialog.setValue("createdate", sysdate, 11L);//创建时间
+                timdialog.setValue("fimdialogtype", "供需", 11L);//对话框类型
+                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);//对话框类型
+                timdialogid = timdialog.getUniqueIDValue();
+                timdialogSet.save();
+
+                SQLFactory addusers = new SQLFactory(this, "即时通讯群人员添加");
+                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")});
+                dbConnect.runSqlUpdate(addusers.getSQL());
+            }
+            row.put("timdialogid", timdialogid);
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    /**
+     * 我的供需列表查询
+     *
+     * @return
+     */
+    public String query_mysupplyanddemandList() {
+        /**
+         *排序条件设置
+         */
+        String[] sortfield = {"t1.tsupplyanddemandid desc"};
+        String sort = getSort(sortfield, "t1.tsupplyanddemandid desc");
+        /**
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.ftitle like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("ftype") && !"".equals(whereObject.getString("ftype"))) {
+                where.append(" and t1.ftype ='").append(whereObject.getString("ftype")).append("' ");
+            }
+            if (whereObject.containsKey("fissupply")) {
+                where.append(" and t1.fissupply =").append(whereObject.getBooleanValue("fissupply") ? 1 : 0);
+            }
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "我的供需列表查询", pageSize, pageNumber, sort);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("tagentsid", tagentsid);
+        sqlFactory.addParameter_SQL("where", where);
+
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
+
+        for (Row row : rows) {
+            row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
+        }
+        return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
+    }
+
+    /**
+     * 我的供需详情查询
+     *
+     * @return
+     */
+    public String query_mysupplyanddemandMain() {
+        long tsupplyanddemandid = content.getLong("tsupplyanddemandid");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "我的供需详情查询");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("tagentsid", tagentsid);
+        sqlFactory.addParameter("tsupplyanddemandid", tsupplyanddemandid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+
+        SQLFactory dialoglistSQL = new SQLFactory(this, "我的供需详情查询_对话框列表");
+        dialoglistSQL.addParameter("siteid", siteid);
+        dialoglistSQL.addParameter("tagentsid", tagentsid);
+        dialoglistSQL.addParameter("tsupplyanddemandid", tsupplyanddemandid);
+        dialoglistSQL.addParameter("userid", userid);
+        Rows dialogrows = dbConnect.runSqlQuery(dialoglistSQL.getSQL());
+        System.err.println(dialoglistSQL.getSQL());
+
+        RowsMap attinfoRowsMap = getAttachmentUrl("tsupplyanddemand", rows.toArrayList("tsupplyanddemandid"));
+        for (Row row : rows) {
+            row.put("attinfos", attinfoRowsMap.get(row.getString("tsupplyanddemandid")));
+            row.put("imdialogs", dialogrows);
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    /**
+     * 新增或修改供需
+     *
+     * @return
+     */
+    public String insertormodify() throws D3bException, P2Exception {
+        long tsupplyanddemandid = content.getLongValue("tsupplyanddemandid");//需求ID,新增时传0
+        String ftype = content.getString("ftype");
+        String ftitle = content.getString("ftitle", "tsupplyanddemand.ftitle", "需求标题");
+        String fcontent = content.getString("fcontent", "tsupplyanddemand.fcontent", "需求内容");
+        String fenddate = content.getString("fenddate");
+        boolean fissupply = content.getBoolean("fissupply");
+
+        PaoSetRemote tsupplyanddemandSet = getP2ServerSystemPaoSet("tsupplyanddemand", "siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
+        PaoRemote tsupplyanddemand = null;
+        if (tsupplyanddemandid <= 0 || tsupplyanddemandSet.isEmpty()) {
+            tsupplyanddemand = tsupplyanddemandSet.addAtEnd();
+            tsupplyanddemand.setValue("siteid", siteid, 11L);//企业ID
+            tsupplyanddemand.setValue("tagentsid", tagentsid, 11L);//企业ID
+            tsupplyanddemand.setValue("createby", username, 11L);//录入人
+            tsupplyanddemand.setValue("createdate", sysdate, 11L);//录入时间
+            tsupplyanddemand.setValue("tenterprise_userid", userid, 11L);//发布人账号ID
+            tsupplyanddemand.setValue("fissupply", fissupply, 11L);//供、需
+            tsupplyanddemand.setValue("fstatus", "新建", 11L);//状态
+        } else {
+            tsupplyanddemand = tsupplyanddemandSet.getPao(0);
+        }
+        tsupplyanddemand.setValue("ftype", ftype, 11L);//产品名称
+        tsupplyanddemand.setValue("ftitle", ftitle, 11L);//需求标题
+        tsupplyanddemand.setValue("fcontent", fcontent, 11L);//需求内容
+        tsupplyanddemand.setValue("fenddate", fenddate, 11L);//到期时间
+
+        tsupplyanddemand.setValue("changeby", username, 11L);//修改人
+        tsupplyanddemand.setValue("changedate", sysdate, 11L);//修改时间
+        content.put("tsupplyanddemandid", tsupplyanddemand.getUniqueIDValue());
+        tsupplyanddemandSet.save();
+        return query_mysupplyanddemandMain();
+    }
+
+    /**
+     * 供需状态变更
+     *
+     * @return
+     */
+    public String updatesupplyanddemandstatus() {
+        long tsupplyanddemandid = content.getLong("tsupplyanddemandid");
+        String fstatus = content.getString("fstatus");
+        Rows rows = dbConnect.runSqlQuery("select * from tsupplyanddemand where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("供需内容不存在").toString();
+        }
+        if (!Arrays.asList(new String[]{"新建", "发布", "待对接", "正在对接", "已解决", "已过期"}).contains(fstatus)) {
+            return getErrReturnObject().setErrMsg("无效的供需状态").toString();
+        }
+        switch (fstatus) {
+            case "新建": {
+                dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='新建',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 + "'");
+                break;
+            }
+            default: {
+                dbConnect.runSqlUpdate("update tsupplyanddemand set fstatus='" + fstatus + "' where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
+                break;
+            }
+        }
+        return query_mysupplyanddemandMain();
+    }
+
+    /**
+     * 供需删除
+     *
+     * @return
+     */
+    public String deletesupplyanddemand() {
+        long tsupplyanddemandid = content.getLongValue("tsupplyanddemandid");
+        Rows rows = dbConnect.runSqlQuery("select * from tsupplyanddemand where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
+        if (!rows.isEmpty() && !"新建".equals(rows.get(0).getString("fstatus"))) {
+            return getErrReturnObject().setErrMsg("当前状态不可删除").toString();
+        }
+        String status = dbConnect.runSqlUpdate("delete from tsupplyanddemand where siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tsupplyanddemandid='" + tsupplyanddemandid + "'");
+        if ("true".equals(status)) {
+            return getSucReturnObject().toString();
+        } else {
+            return getErrReturnObject().toString();
+        }
+    }
+}

+ 2 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/supplyanddemand/supplyanddemand.java

@@ -61,4 +61,6 @@ public class supplyanddemand extends Controller {
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
         return getSucReturnObject().setData(rows).toString();
     }
+
+
 }

+ 1 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/system/SQL/供需分类删除.sql

@@ -0,0 +1 @@
+delete from ttypedetail where ftype='¹©Ðè·ÖÀà' and siteid=$siteid$ and ttypedetailid=$ttypedetailid$

+ 5 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/system/SQL/供需分类查询.sql

@@ -0,0 +1,5 @@
+select ttypedetailid, siteid, fvalue as ftype,fisused
+from ttypedetail
+where ftype = '¹©Ðè·ÖÀà'
+  and siteid =$siteid$
+order by sequence

+ 84 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/system/supplyanddemand.java

@@ -0,0 +1,84 @@
+package com.cnd3b.restcontroller.enterprise.system;
+
+import com.alibaba.fastjson.JSONObject;
+import com.cnd3b.common.Controller;
+import com.cnd3b.common.D3bException;
+import com.cnd3b.common.data.Rows;
+import com.cnd3b.common.data.SQLFactory;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2Exception;
+
+public class supplyanddemand extends Controller {
+    public supplyanddemand(JSONObject content) {
+        super(content);
+    }
+
+    /**
+     * 供需分类列表查询
+     *
+     * @return
+     */
+    public String query_typeList() {
+        SQLFactory sql = new SQLFactory(this, "供需分类查询");
+        sql.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sql.getSQL());
+        return getSucReturnObject().setData(rows).saveToDataPool().toString();
+    }
+
+    /**
+     * 供需分类新增修改
+     *
+     * @return
+     */
+    public String insert_modify_type() throws D3bException, P2Exception {
+        long ttypedetailid = content.getLongValue("ttypedetailid");//新增为0
+        String ftype = content.getString("ftype", "ttypedetail.fvalue", "供需分类");
+        boolean fisused = content.getBoolean("fisused");
+
+        Rows rows = dbConnect.runSqlQuery("select * from ttypedetail where siteid='" + siteid + "' and ftype='供需分类' and fvalue='" + ftype + "'");
+        if (!rows.isEmpty() && rows.get(0).getLong("ttypedetailid") != ttypedetailid) {
+            return getErrReturnObject().setErrMsg("供需分类不可重复").toString();
+        }
+        PaoSetRemote ttypedetailSet = getP2ServerSystemPaoSet("ttypedetail", "siteid='" + siteid + "' and ttypedetailid='" + ttypedetailid + "'");
+        PaoRemote ttypedetail = null;
+        if (ttypedetailSet.isEmpty()) {
+            ttypedetail = ttypedetailSet.addAtEnd();
+            ttypedetail.setValue("siteid", siteid, 11L);//企业ID
+            ttypedetail.setValue("ftype", "供需分类", 11L);
+        } else {
+            ttypedetail = ttypedetailSet.getPao(0);
+        }
+        ttypedetail.setValue("fvalue", ftype, 11L);
+        ttypedetail.setValue("fisused", fisused, 11L);
+        ttypedetailSet.save();
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 供需分类删除
+     *
+     * @return
+     */
+    public String delete_type() {
+        SQLFactory sqlFactory = new SQLFactory(this, "供需分类删除");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("ttypedetailid", content.getString("ttypedetailid"));
+        String result = dbConnect.runSqlUpdate(sqlFactory.getSQL());
+        if ("true".equals(result)) {
+            return getSucReturnObject().toString();
+        } else {
+            return getErrReturnObject().setErrMsg(result).toString();
+        }
+    }
+
+    /**
+     * 供需分类选择查询
+     *
+     * @return
+     */
+    public String query_typeselectList() {
+        Rows rows = dbConnect.runSqlQuery("select fvalue as ftype from ttypedetail where ftype = '供需分类' and siteid ='" + siteid + "' and fisused=1 order by sequence");
+        return getSucReturnObject().setData(rows.toArray("ftype")).toString();
+    }
+}