|
@@ -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();
|
|
|
}
|
|
|
|