Browse Source

休息时间段设置部门

cs 2 năm trước cách đây
mục cha
commit
114dfd7198

+ 39 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TimeAutoExcludeController.java

@@ -2,10 +2,8 @@ package com.management.platform.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.management.platform.entity.TimeAutoExclude;
-import com.management.platform.entity.User;
-import com.management.platform.mapper.TimeAutoExcludeMapper;
-import com.management.platform.mapper.UserMapper;
+import com.management.platform.entity.*;
+import com.management.platform.mapper.*;
 import com.management.platform.service.TimeAutoExcludeService;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
@@ -15,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -34,12 +33,46 @@ public class TimeAutoExcludeController {
     private TimeAutoExcludeService timeAutoExcludeService;
     @Resource
     private UserMapper userMapper;
+    @Resource
+    private DepartmentMapper departmentMapper;
+    @Resource
+    private WxCorpInfoMapper wxCorpInfoMapper;
+
     @RequestMapping("/addOrMod")
     public HttpRespMsg addOrMod(TimeAutoExclude item) {
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
-        item.setCompanyId(user.getCompanyId());
-        timeAutoExcludeService.saveOrUpdate(item);
+        //修改
+        if (item.getId() != null){
+            timeAutoExcludeService.updateById(item);
+            return new HttpRespMsg();
+        }
+        //新增
+        //先删除掉已设置过的部门
+        timeAutoExcludeService.removeByIds(item.getDepartmentId());
+        List<Department> deptList = departmentMapper.selectList(new QueryWrapper<Department>().in("department_id", item.getDepartmentId()));
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        ArrayList<TimeAutoExclude> timeAutoExcludes = new ArrayList<>();
+        for (Integer deptId : item.getDepartmentId()) {
+            TimeAutoExclude timeAutoExclude = new TimeAutoExclude();
+            timeAutoExclude.setCompanyId(user.getCompanyId());
+            timeAutoExclude.setStartTime(item.getStartTime());
+            timeAutoExclude.setEndTime(item.getEndTime());
+            timeAutoExclude.setDId(deptId);
+            for (Department deptItem : deptList) {
+                if (deptItem.getDepartmentId().equals(deptId)){
+                    if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
+                        timeAutoExclude.setDName(deptItem.getCorpwxDeptid().toString());
+                    }else {
+                        timeAutoExclude.setDName(deptItem.getDepartmentName());
+                    }
+                    break;
+                }
+            }
+            timeAutoExcludes.add(timeAutoExclude);
+        }
+
+        timeAutoExcludeService.saveBatch(timeAutoExcludes);
         return new HttpRespMsg();
     }
 

+ 21 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TimeAutoExclude.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+import java.util.List;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -15,7 +17,7 @@ import lombok.experimental.Accessors;
  * </p>
  *
  * @author Seyason
- * @since 2022-05-09
+ * @since 2023-04-11
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -30,6 +32,24 @@ public class TimeAutoExclude extends Model<TimeAutoExclude> {
     @TableField("company_id")
     private Integer companyId;
 
+    /**
+     * 部门id数据
+     */
+    @TableField(exist = false)
+    private List<Integer> departmentId;
+
+    /**
+     * 部门id
+     */
+    @TableField("d_id")
+    private Integer dId;
+
+    /**
+     * 部门名
+     */
+    @TableField("d_name")
+    private String dName;
+
     @TableField("start_time")
     private String startTime;
 

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TimeAutoExcludeMapper.xml

@@ -6,13 +6,15 @@
     <resultMap id="BaseResultMap" type="com.management.platform.entity.TimeAutoExclude">
         <id column="id" property="id" />
         <result column="company_id" property="companyId" />
+        <result column="d_id" property="dId" />
+        <result column="d_name" property="dName" />
         <result column="start_time" property="startTime" />
         <result column="end_time" property="endTime" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, company_id, start_time, end_time
+        id, company_id, d_id, d_name, start_time, end_time
     </sql>
 
 </mapper>