Browse Source

装备资源库浏览数发送数bug修复

eganwu 1 year ago
parent
commit
f3b4743f20

+ 18 - 16
src/custom/restcontroller/webmanage/saletool/sharematerial/DailySign.java

@@ -223,22 +223,24 @@ public class DailySign extends Controller {
 
         Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
 
-        InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_sharematerial_read");
-        insertSQL.setUniqueid(createTableID("sat_sharematerial_read"));
-        insertSQL.setSiteid(siteid);
-        insertSQL.setValue("sat_sharematerialid", sat_sharematerialid);
-        insertSQL.setValue("type", content.getIntValue("type"));
-        insertSQL.insert();
-
-        if (content.getIntValue("type") == 0) {
-            dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET readcount=readcount+1 WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
-        }
-        if (content.getIntValue("type") == 1) {
-            dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET downloadcount=downloadcount+1 WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
-        }
-        if (content.getIntValue("type") == 2) {
-            dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET mailcount=mailcount+1 WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
-        }
+        SharematerialHelper.updateReadLog(this,sat_sharematerialid,content.getIntValue("type"));
+
+//        InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_sharematerial_read");
+//        insertSQL.setUniqueid(createTableID("sat_sharematerial_read"));
+//        insertSQL.setSiteid(siteid);
+//        insertSQL.setValue("sat_sharematerialid", sat_sharematerialid);
+//        insertSQL.setValue("type", content.getIntValue("type"));
+//        insertSQL.insert();
+//
+//        if (content.getIntValue("type") == 0) {
+//            dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET readcount=readcount+1 WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
+//        }
+//        if (content.getIntValue("type") == 1) {
+//            dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET downloadcount=downloadcount+1 WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
+//        }
+//        if (content.getIntValue("type") == 2) {
+//            dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET mailcount=mailcount+1 WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + siteid + "'");
+//        }
 
         return getSucReturnObject().toString();
     }

+ 3 - 0
src/custom/restcontroller/webmanage/saletool/sharematerial/EquipmentResourceLibrary.java

@@ -163,6 +163,8 @@ public class EquipmentResourceLibrary extends Controller {
 
         detailRow.put("attinfos_pic", attachmentRows);
 
+        SharematerialHelper.updateReadLog(this,sat_sharematerialid,0);
+
 
         return getSucReturnObject().setData(detailRow).toString();
     }
@@ -429,6 +431,7 @@ public class EquipmentResourceLibrary extends Controller {
         remind.setContent(emailContent);
         remind.sendByMail();
 
+        SharematerialHelper.updateReadLog(this,sat_sharematerialid,2);
 
         return getSucReturnObject().toString();
     }

+ 30 - 0
src/custom/restcontroller/webmanage/saletool/sharematerial/SharematerialHelper.java

@@ -0,0 +1,30 @@
+package restcontroller.webmanage.saletool.sharematerial;
+
+import common.Controller;
+import common.YosException;
+import common.data.InsertSQL;
+import common.data.Rows;
+import common.data.SQLFactory;
+
+public class SharematerialHelper {
+    public static void updateReadLog(Controller controller, long sat_sharematerialid, int type) throws YosException {
+        InsertSQL insertSQL = SQLFactory.createInsertSQL(controller, "sat_sharematerial_read");
+        insertSQL.setUniqueid(controller.createTableID("sat_sharematerial_read"));
+        insertSQL.setSiteid(controller.siteid);
+        insertSQL.setValue("sat_sharematerialid", sat_sharematerialid);
+        insertSQL.setValue("type", type);
+        insertSQL.insert();
+
+        Rows rows = controller.dbConnect.runSqlQuery("SELECT count(*) count from sat_sharematerial_read WHERE type=" + type + " and sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + controller.siteid + "'");
+        long count = rows.get(0).getLong("count");
+        if (type == 0) {
+            controller.dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET readcount=" + count + " WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + controller.siteid + "'");
+        }
+        if (type == 1) {
+            controller.dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET downloadcount=" + count + " WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + controller.siteid + "'");
+        }
+        if (type == 2) {
+            controller.dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET mailcount=" + count + " WHERE sat_sharematerialid=" + sat_sharematerialid + " and siteid='" + controller.siteid + "'");
+        }
+    }
+}