|
@@ -7,6 +7,7 @@ import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.TimeAutoExcludeService;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
+import org.apache.poi.ss.formula.ptg.NotEqualPtg;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -38,23 +39,84 @@ public class TimeAutoExcludeController {
|
|
|
private DepartmentMapper departmentMapper;
|
|
|
@Resource
|
|
|
private WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
+ @Resource
|
|
|
+ private TimeAutoExcludeMapper timeAutoExcludeMapper;
|
|
|
|
|
|
@RequestMapping("/addOrMod")
|
|
|
public HttpRespMsg addOrMod(TimeAutoExclude item) {
|
|
|
+ String start1 = item.getStartTime();
|
|
|
+ String end1 = item.getEndTime();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (item.getType().equals(1)){
|
|
|
+ List<TimeAutoExclude> timeItem = timeAutoExcludeMapper.selectList(new QueryWrapper<TimeAutoExclude>().eq("company_id", user.getCompanyId()));
|
|
|
+ for (TimeAutoExclude timeAutoExclude : timeItem) {
|
|
|
+ if (timeAutoExclude.getDId() == null){
|
|
|
+ Boolean b = timeAutoExcludeService.timeCheck(start1, timeAutoExclude.getStartTime(), end1, timeAutoExclude.getEndTime());
|
|
|
+ if (item.getId() == null){
|
|
|
+ //如果是新增
|
|
|
+ if (b) {
|
|
|
+ msg.setError("与已设置时间段存在重叠情况,请重新设置!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //如果是修改
|
|
|
+ if (b && !timeAutoExclude.getId().equals(item.getId())) {
|
|
|
+ msg.setError("与已设置时间段存在重叠情况,请重新设置!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setCompanyId(user.getCompanyId());
|
|
|
+ timeAutoExcludeService.saveOrUpdate(item);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
//修改
|
|
|
if (item.getId() != null){
|
|
|
+ TimeAutoExclude timeAutoExclude = timeAutoExcludeMapper.selectById(item.getId());
|
|
|
+ item.setDId(item.getDepartmentId().get(0));
|
|
|
+ if (!item.getDepartmentId().get(0).equals(timeAutoExclude.getDId())){
|
|
|
+ //如果修改了部门
|
|
|
+ Department department = departmentMapper.selectById(item.getDId());
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
|
|
|
+ item.setDName(department.getCorpwxDeptid()==null?"":department.getCorpwxDeptid().toString());
|
|
|
+ }else {
|
|
|
+ item.setDName(department.getDepartmentName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TimeAutoExclude> dList = timeAutoExcludeMapper.selectList(new QueryWrapper<TimeAutoExclude>().eq("d_id", item.getDId()).ne("id",item.getId()));
|
|
|
+ for (TimeAutoExclude autoExclude : dList) {
|
|
|
+ Boolean b = timeAutoExcludeService.timeCheck(start1, autoExclude.getStartTime(), end1, autoExclude.getEndTime());
|
|
|
+ if (b) {
|
|
|
+ msg.setError("与已设置时间段存在重叠情况,请重新设置!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+// List<TimeAutoExclude> dList = timeAutoExcludeMapper.selectList(new QueryWrapper<TimeAutoExclude>().eq("d_id", item.getDId()).ne("id",item.getId()));
|
|
|
+// for (TimeAutoExclude autoExclude : dList) {
|
|
|
+// Boolean b = timeAutoExcludeService.timeCheck(start1, autoExclude.getStartTime(), end1, autoExclude.getEndTime());
|
|
|
+// if (b && !timeAutoExclude.getId().equals(item.getId())) {
|
|
|
+// msg.setError("与已设置时间段存在重叠情况,请重新设置!");
|
|
|
+// return msg;
|
|
|
+// }
|
|
|
+// }
|
|
|
timeAutoExcludeService.updateById(item);
|
|
|
- return new HttpRespMsg();
|
|
|
+ return msg;
|
|
|
}
|
|
|
//新增
|
|
|
- //先去重
|
|
|
- item.setDepartmentId(item.getDepartmentId().stream().distinct().collect(Collectors.toList()));
|
|
|
- //删除掉已设置过的部门
|
|
|
- timeAutoExcludeService.remove(new QueryWrapper<TimeAutoExclude>().in("d_id",item.getDepartmentId()));
|
|
|
+ //如果某部门曾设置过重叠的时间段,不予添加
|
|
|
+ List<TimeAutoExclude> times = timeAutoExcludeMapper.selectList(new QueryWrapper<TimeAutoExclude>().in("d_id", item.getDepartmentId()).ne("id",item.getId()));
|
|
|
+ for (TimeAutoExclude t : times) {
|
|
|
+ Boolean b = timeAutoExcludeService.timeCheck(start1, t.getStartTime(), end1, t.getEndTime());
|
|
|
+ if (b) {
|
|
|
+ msg.setError("与已设置时间段存在重叠情况,请重新设置!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
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();
|
|
@@ -76,11 +138,14 @@ public class TimeAutoExcludeController {
|
|
|
}
|
|
|
|
|
|
timeAutoExcludeService.saveBatch(timeAutoExcludes);
|
|
|
- return new HttpRespMsg();
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/delete")
|
|
|
public HttpRespMsg delete(Integer id) {
|
|
|
+ if (id == null){
|
|
|
+ return new HttpRespMsg();
|
|
|
+ }
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(token);
|