Browse Source

行事历

wu 3 days ago
parent
commit
fcca77fbda
2 changed files with 195 additions and 0 deletions
  1. 20 0
      src/custom/restcontroller/R.java
  2. 175 0
      src/custom/restcontroller/common/task/task2.java

+ 20 - 0
src/custom/restcontroller/R.java

@@ -7573,6 +7573,26 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025122209075802 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025122210022002 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025122210193402 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025122211095302 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 175 - 0
src/custom/restcontroller/common/task/task2.java

@@ -0,0 +1,175 @@
+package restcontroller.common.task;
+
+import beans.datacontrllog.DataContrlLog;
+import beans.salearea.SaleArea;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.*;
+import restcontroller.R;
+
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.List;
+
+public class task2 extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public task2(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "创建任务", apiversion = R.ID2025122209075802.v1.class)
+    public String insertTask() throws YosException {
+
+        String begindate = content.getStringValueForDate("begindate", "yyyy-MM-dd", "");
+        String enddate = content.getStringValueForDate("enddate", "yyyy-MM-dd", "");
+
+        if (begindate.isEmpty()) {
+            begindate = getDate_Str();
+        }
+        if (enddate.isEmpty()) {
+            enddate = getDate_Str();
+        }
+        ArrayList<String> sqlList = new ArrayList<>();
+        for (String date : getAlldates(begindate, enddate)) {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_task");
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(createTableID("sys_task"));
+            insertSQL.setValue("taskdate", date);
+            insertSQL.setValue("title", content.getStringValue("title"));
+            insertSQL.setValue("contenttext", content.getStringValue("contenttext"));
+            insertSQL.setValue("begindate", begindate);
+            insertSQL.setValue("enddate", enddate);
+            sqlList.add(insertSQL.getSQL());
+            sqlList.add(DataContrlLog.createLog(this, "sys_task", insertSQL.getUniqueid(), "新建", "新建成功").getSQL());
+        }
+
+        dbConnect.runSqlUpdate(sqlList);
+
+        return getSucReturnObject().toString();
+    }
+
+    //返回2个日期间的所有日期
+    public ArrayList<String> getAlldates(String begindate, String enddate) {
+        LocalDate start = LocalDate.parse(begindate);
+        LocalDate end = LocalDate.parse(enddate);
+        ArrayList<String> dates = new ArrayList<>();
+        long daysBetween = ChronoUnit.DAYS.between(start, end);
+
+        for (long i = 0; i <= daysBetween; i++) {
+            dates.add(start.plusDays(i).toString());
+        }
+        return dates;
+    }
+
+    @API(title = "任务详情", apiversion = R.ID2025122210022002.v1.class)
+    public String taskDetail() throws YosException {
+
+        Long sys_taskid = content.getLongValue("sys_taskid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_task", "t1.*").setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("sys_taskid", sys_taskid);
+
+        Rows row = querySQL.query();
+        Row detailRow = row.get(0);
+        return getSucReturnObject().setData(detailRow).toString();
+    }
+
+    @API(title = "获取指定的月份的任务列表", apiversion = R.ID2025122210193402.v1.class)
+    public String list() throws YosException {
+
+        int year = content.getIntValue("year");
+        int month = content.getIntValue("month");
+        Long taskUserid = content.getLongValue("taskUserid");
+
+        //指定的日期数据
+        List<String> dates = getAllDatesInMonth(year, month);
+
+        //任务数据
+        QuerySQL taskquerySQL = SQLFactory.createQuerySQL(this, "sys_task", "t1.*").setTableAlias("t1");
+        taskquerySQL.setSiteid(siteid);
+        taskquerySQL.setWhere("createuserid", taskUserid);
+        taskquerySQL.setWhere("year(createdate)=" + year);
+        taskquerySQL.setWhere("month(createdate)=" + month);
+        taskquerySQL.setCondition("t1.title");
+        Rows taskrows = taskquerySQL.query();
+        RowsMap taskRowsMap = taskrows.toRowsMap("taskdate");
+
+        //跟进数据
+
+        QuerySQL followquerySQL = SQLFactory.createQuerySQL(this, "sys_datafollowup", "t1.*").setTableAlias("t1");
+        followquerySQL.setSiteid(siteid);
+        followquerySQL.addQueryFields("followdate", "DATE_FORMAT(t1.createdate,'%Y-%m-%d')");
+        followquerySQL.setWhere("createuserid", taskUserid);
+        followquerySQL.setWhere("year(createdate)=" + year);
+        followquerySQL.setWhere("month(createdate)=" + month);
+        Rows followrows = followquerySQL.query();
+        RowsMap followRowsMap = followrows.toRowsMap("followdate");
+
+        Row row = new Row();
+        for (String date : dates) {
+            //任务
+            Rows taskRows = taskRowsMap.getOrDefault(date, new Rows());
+            //跟进
+            Rows followRows = followRowsMap.getOrDefault(date, new Rows());
+
+            Row subrow = new Row();
+            subrow.put("task", taskRows);
+            subrow.put("follow", followRows);
+            row.put(date, subrow);
+
+        }
+
+
+        return getSucReturnObject().setData(row).toString();
+    }
+
+    public static List<String> getAllDatesInMonth(int year, int month) {
+        YearMonth yearMonth = YearMonth.of(year, month);
+        int daysInMonth = yearMonth.lengthOfMonth(); // 获取该月天数
+
+        List<String> dateStrings = new ArrayList<>();
+        for (int day = 1; day <= daysInMonth; day++) {
+            LocalDate date = LocalDate.of(year, month, day);
+            dateStrings.add(date.toString()); // 默认格式 "yyyy-MM-dd"
+        }
+        return dateStrings;
+    }
+
+    @API(title = "获取当前账号的下级信息", apiversion = R.ID2025122211095302.v1.class)
+    public String usertask() throws YosException {
+
+
+        Rows salearearows = dbConnect.runSqlQuery("SELECT sa_saleareaid from sa_salearea_hr WHERE hrid=" + hrid + " and siteid='" + siteid + "'");
+        ArrayList<Long> saleareaids = salearearows.toArrayList("sa_saleareaid", new ArrayList<>());
+        saleareaids.add(-1L);
+        ArrayList<Long> subsaleareaids = SaleArea.getSubSaleAreaIds(this, saleareaids);
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_salearea_hr", "hrid");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("sa_saleareaid", subsaleareaids);
+
+        ArrayList<Long> hrids = querySQL.query().toArrayList("hrid", new ArrayList<>());
+        hrids.add(hrid);
+
+        querySQL = SQLFactory.createQuerySQL(this, "sys_hr", "userid", "hrid", "name")
+                .setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("status=0 and userid>0");
+        querySQL.setWhere("t1.hrid", hrids);
+        querySQL.setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+}