|
|
@@ -2,18 +2,36 @@ package com.xunmei.core.information.service.impl;
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
+import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
+import com.xunmei.core.information.service.ICoreMessageCenterService;
|
|
|
+import com.xunmei.system.api.RemoteJobService;
|
|
|
+import com.xunmei.system.api.domain.SysUser;
|
|
|
+import com.xunmei.system.api.dto.SysJobDTO;
|
|
|
+import com.xunmei.system.api.dto.SysRoleOrgDTO;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
+import com.xunmei.core.information.domain.CoreMessageCenter;
|
|
|
import com.xunmei.core.information.domain.CoreResumptionConfiguration;
|
|
|
+import com.xunmei.core.information.mapper.CoreMessageCenterMapper;
|
|
|
+import com.xunmei.core.resumption.domain.Resumption;
|
|
|
import com.xunmei.core.resumption.dto.CoreResumptionConfigurationDTO;
|
|
|
import com.xunmei.core.information.mapper.CoreResumptionConfigurationMapper;
|
|
|
import com.xunmei.core.information.service.ICoreResumptionConfigurationService;
|
|
|
+import com.xunmei.core.resumption.mapper.ResumptionMapper;
|
|
|
import com.xunmei.core.resumption.vo.CoreResumptionConfigurationVO;
|
|
|
+import com.xunmei.system.api.RemoteUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -26,50 +44,20 @@ import java.util.List;
|
|
|
public class CoreResumptionConfigurationServiceImpl extends ServiceImpl<CoreResumptionConfigurationMapper, CoreResumptionConfiguration> implements ICoreResumptionConfigurationService {
|
|
|
@Autowired
|
|
|
private CoreResumptionConfigurationMapper coreResumptionConfigurationMapper;
|
|
|
- /* @Autowired
|
|
|
- private ISysOrgService orgService;*/
|
|
|
-
|
|
|
-/* @Override
|
|
|
- public TableDataInfo<CoreResumptionConfiguration> selectPage(CoreResumptionConfiguration coreResumptionConfiguration) {
|
|
|
- //未删除
|
|
|
- coreResumptionConfiguration.setDeleted(0L);
|
|
|
- Page<CoreResumptionConfiguration> page;
|
|
|
- //分页
|
|
|
- if (coreResumptionConfiguration.getPageNum()!=null&&coreResumptionConfiguration.getPageSize()!=null)
|
|
|
- {
|
|
|
- page = new Page<>(coreResumptionConfiguration.getPageNum(), coreResumptionConfiguration.getPageSize());
|
|
|
- }else{
|
|
|
- page = new Page<>();
|
|
|
- }
|
|
|
- //查询条件
|
|
|
- QueryWrapper<CoreResumptionConfiguration> query = new QueryWrapper<>(coreResumptionConfiguration);
|
|
|
- //下穿
|
|
|
- if (coreResumptionConfiguration.getCheckSub()){
|
|
|
- List<Long> ids = orgService.selectCheckSubOrgIdList(coreResumptionConfiguration.getOrgId());
|
|
|
- //清空前端传递的org_id
|
|
|
- coreResumptionConfiguration.setOrgId(null);
|
|
|
- //添加in条件
|
|
|
- query.in("org_id",ids);
|
|
|
- }
|
|
|
- //时间范围查询
|
|
|
- if (coreResumptionConfiguration.getParams().get("beginTime")!=null&&coreResumptionConfiguration.getParams().get("endTime")!=null){
|
|
|
- query.between("create_time", coreResumptionConfiguration.getParams().get("beginTime"), coreResumptionConfiguration.getParams().get("endTime"));
|
|
|
- }
|
|
|
- //获取数据
|
|
|
- page = coreResumptionConfigurationMapper.selectPage(page, query);
|
|
|
- //抓换为TableDataInfo适配前端
|
|
|
- return TableDataInfo.build(page);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }*/
|
|
|
+ @Autowired
|
|
|
+ private ResumptionMapper resumptionMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RemoteUserService remoteUserService;
|
|
|
+ @Autowired
|
|
|
+ private ICoreMessageCenterService coreMessageCenterService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteJobService remoteJobService;
|
|
|
|
|
|
/**
|
|
|
* 查询履职任务定时提醒
|
|
|
*
|
|
|
- * @param id 履职任务定时提醒主键
|
|
|
+ * @param
|
|
|
* @return 履职任务定时提醒
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -99,6 +87,8 @@ public class CoreResumptionConfigurationServiceImpl extends ServiceImpl<CoreResu
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertCoreResumptionConfiguration(CoreResumptionConfigurationDTO coreResumptionConfiguration) {
|
|
|
+ Long[] jobIds = {100l, 101L, 102L, 103L};
|
|
|
+ remoteJobService.remoteRemove(jobIds, SecurityConstants.INNER);
|
|
|
int insert = 0;
|
|
|
for (CoreResumptionConfiguration c : coreResumptionConfiguration.getCoreResumptionConfiguration()) {
|
|
|
if (null == c.getId()) {
|
|
|
@@ -110,6 +100,43 @@ public class CoreResumptionConfigurationServiceImpl extends ServiceImpl<CoreResu
|
|
|
c.setUpdateBy(SecurityUtils.getUsername());
|
|
|
insert = coreResumptionConfigurationMapper.updateById(c);
|
|
|
}
|
|
|
+ //每天
|
|
|
+ if (c.getResumptionCycle().equals("2")) {
|
|
|
+ SysJobDTO sysJobDTO = new SysJobDTO();
|
|
|
+ sysJobDTO.setJobName("营业前定时提醒");
|
|
|
+ sysJobDTO.setJobGroup("DEFAULT");
|
|
|
+ String front = "0 0 " + c.getFront() + " * * ?";
|
|
|
+ sysJobDTO.setCronExpression(front);
|
|
|
+ sysJobDTO.setMisfirePolicy("1");
|
|
|
+ sysJobDTO.setConcurrent("1");
|
|
|
+ sysJobDTO.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ sysJobDTO.setJobId(100L);
|
|
|
+ sysJobDTO.setInvokeTarget("CoreMessageSendTask.font");
|
|
|
+ sysJobDTO.setStatus("0");
|
|
|
+ //营业前
|
|
|
+ remoteJobService.remoteAdd(sysJobDTO, SecurityConstants.INNER);
|
|
|
+ sysJobDTO.setJobName("营业中定时提醒");
|
|
|
+ String centre = "0 0 " + c.getCentre() + " * * ?";
|
|
|
+ sysJobDTO.setCronExpression(centre);
|
|
|
+ sysJobDTO.setJobId(101L);
|
|
|
+ sysJobDTO.setInvokeTarget("CoreMessageSendTask.centre");
|
|
|
+ //营业中
|
|
|
+ remoteJobService.remoteAdd(sysJobDTO, SecurityConstants.INNER);
|
|
|
+ sysJobDTO.setJobName("营业后定时提醒");
|
|
|
+ String after = "0 0 " + c.getAfter() + " * * ?";
|
|
|
+ sysJobDTO.setCronExpression(after);
|
|
|
+ sysJobDTO.setJobId(102L);
|
|
|
+ sysJobDTO.setInvokeTarget("CoreMessageSendTask.after");
|
|
|
+ //营业后
|
|
|
+ remoteJobService.remoteAdd(sysJobDTO, SecurityConstants.INNER);
|
|
|
+ sysJobDTO.setJobName("全天定时提醒");
|
|
|
+ String allDay = "0 0 " + c.getAllDay() + " * * ?";
|
|
|
+ sysJobDTO.setCronExpression(allDay);
|
|
|
+ sysJobDTO.setJobId(103L);
|
|
|
+ sysJobDTO.setInvokeTarget("CoreMessageSendTask.allDay");
|
|
|
+ //全天
|
|
|
+ remoteJobService.remoteAdd(sysJobDTO, SecurityConstants.INNER);
|
|
|
+ }
|
|
|
if (insert < 1) {
|
|
|
return insert;
|
|
|
}
|
|
|
@@ -150,4 +177,113 @@ public class CoreResumptionConfigurationServiceImpl extends ServiceImpl<CoreResu
|
|
|
public int deleteCoreResumptionConfigurationById(Long id) {
|
|
|
return coreResumptionConfigurationMapper.deleteById(id);
|
|
|
}
|
|
|
+
|
|
|
+ private String getTime(int time) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ c.set(Calendar.MINUTE, 0);
|
|
|
+ c.set(Calendar.SECOND, 0);
|
|
|
+ c.set(Calendar.MILLISECOND, 0);
|
|
|
+ c.add(Calendar.DAY_OF_MONTH, time);
|
|
|
+ System.out.print(simpleDateFormat.format(c.getTime()));
|
|
|
+ return simpleDateFormat.format(c.getTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addMassageCenter(String taskName, String time, String cycle, Long orgId, Long roleId) {
|
|
|
+ SysRoleOrgDTO sysRoleOrgDTO = new SysRoleOrgDTO();
|
|
|
+ sysRoleOrgDTO.setRoleId(roleId);
|
|
|
+ sysRoleOrgDTO.setOrgId(orgId);
|
|
|
+ //根据角色和机构查人
|
|
|
+ List<SysUser> sysUsers = remoteUserService.userListByRoleAndOrg(sysRoleOrgDTO, SecurityConstants.INNER);
|
|
|
+ if (CollectionUtils.isNotEmpty(sysUsers)) {
|
|
|
+ List<CoreMessageCenter> coreMessageCenters = new ArrayList<>();
|
|
|
+ for (SysUser sysUser : sysUsers) {
|
|
|
+ CoreMessageCenter coreMessageCenter = new CoreMessageCenter();
|
|
|
+ coreMessageCenter.setType("2");
|
|
|
+ coreMessageCenter.setTitle("履职临期提醒");
|
|
|
+ coreMessageCenter.setIsRead("0");
|
|
|
+ String timeUnit = "天";
|
|
|
+ if (cycle.equals("1")) {
|
|
|
+ coreMessageCenter.setContent("您有履职任务" + taskName + "快到期");
|
|
|
+ }else {
|
|
|
+ coreMessageCenter.setContent("您有履职任务" + taskName + "还有" + time + timeUnit + "到期");
|
|
|
+ }
|
|
|
+ coreMessageCenter.setUserId(sysUser.getId());
|
|
|
+ coreMessageCenter.setCreateTime(DateUtils.getNowDate());
|
|
|
+ coreMessageCenter.setId(IdWorker.getId());
|
|
|
+ coreMessageCenters.add(coreMessageCenter);
|
|
|
+ }
|
|
|
+ coreMessageCenterService.saveBatch(coreMessageCenters);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void resumptionRemind(LocalDate taskTime) {
|
|
|
+ List<CoreResumptionConfiguration> coreResumptionConfigurations = baseMapper.selectCoreResumptionConfigurationList(new CoreResumptionConfiguration());
|
|
|
+ for (CoreResumptionConfiguration c : coreResumptionConfigurations) {
|
|
|
+ switch (c.getResumptionCycle()) {
|
|
|
+ //天
|
|
|
+ case "2":
|
|
|
+ break;
|
|
|
+
|
|
|
+ //默认为周月季度年等
|
|
|
+ default:
|
|
|
+ //查询临期任务,只匹配年月日
|
|
|
+ List<Resumption> resumptions = resumptionMapper.selectAllByPlanStartTime(Integer.valueOf(c.getResumptionCycle()), getTime(Integer.parseInt(c.getAllDay())));
|
|
|
+ resumptions.forEach(resumption -> {
|
|
|
+ addMassageCenter(resumption.getName(), c.getAllDay(), c.getTimeUnit(), resumption.getOrgId(), resumption.getRoleId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void font() {
|
|
|
+ CoreResumptionConfiguration coreResumptionConfiguration=new CoreResumptionConfiguration();
|
|
|
+ coreResumptionConfiguration.setTimeUnit("1");
|
|
|
+ coreResumptionConfiguration.setDelFlag("0");
|
|
|
+ List<CoreResumptionConfiguration> coreResumptionConfigurations = baseMapper.selectCoreResumptionConfigurationList(coreResumptionConfiguration);
|
|
|
+ List<Resumption> resumptions = resumptionMapper.selectDay(getTime(0),"2");
|
|
|
+ resumptions.forEach(r->{
|
|
|
+ addMassageCenter(r.getName(),null, coreResumptionConfigurations.get(0).getTimeUnit(),r.getOrgId(),r.getRoleId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void centre() {
|
|
|
+ CoreResumptionConfiguration coreResumptionConfiguration=new CoreResumptionConfiguration();
|
|
|
+ coreResumptionConfiguration.setTimeUnit("1");
|
|
|
+ coreResumptionConfiguration.setDelFlag("0");
|
|
|
+ List<CoreResumptionConfiguration> coreResumptionConfigurations = baseMapper.selectCoreResumptionConfigurationList(coreResumptionConfiguration);
|
|
|
+ List<Resumption> resumptions = resumptionMapper.selectDay(getTime(0),"3");
|
|
|
+ resumptions.forEach(r->{
|
|
|
+ addMassageCenter(r.getName(),null, coreResumptionConfigurations.get(0).getTimeUnit(),r.getOrgId(),r.getRoleId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void after() {
|
|
|
+ CoreResumptionConfiguration coreResumptionConfiguration=new CoreResumptionConfiguration();
|
|
|
+ coreResumptionConfiguration.setTimeUnit("1");
|
|
|
+ coreResumptionConfiguration.setDelFlag("0");
|
|
|
+ List<CoreResumptionConfiguration> coreResumptionConfigurations = baseMapper.selectCoreResumptionConfigurationList(coreResumptionConfiguration);
|
|
|
+ List<Resumption> resumptions = resumptionMapper.selectDay(getTime(0),"4");
|
|
|
+ resumptions.forEach(r->{
|
|
|
+ addMassageCenter(r.getName(),null, coreResumptionConfigurations.get(0).getTimeUnit(),r.getOrgId(),r.getRoleId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void allDay() {
|
|
|
+ CoreResumptionConfiguration coreResumptionConfiguration=new CoreResumptionConfiguration();
|
|
|
+ coreResumptionConfiguration.setTimeUnit("1");
|
|
|
+ coreResumptionConfiguration.setDelFlag("0");
|
|
|
+ List<CoreResumptionConfiguration> coreResumptionConfigurations = baseMapper.selectCoreResumptionConfigurationList(coreResumptionConfiguration);
|
|
|
+ List<Resumption> resumptions = resumptionMapper.selectDay(getTime(0),"1");
|
|
|
+ resumptions.forEach(r->{
|
|
|
+ addMassageCenter(r.getName(),null, coreResumptionConfigurations.get(0).getTimeUnit(),r.getOrgId(),r.getRoleId());
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|