|
@@ -0,0 +1,70 @@
|
|
|
+package com.jeeplus.modules.monitor.task;
|
|
|
+
|
|
|
+import com.github.abel533.echarts.code.X;
|
|
|
+import com.jeeplus.common.utils.SpringContextHolder;
|
|
|
+import com.jeeplus.common.websocket.service.system.SystemInfoSocketHandler;
|
|
|
+import com.jeeplus.modules.monitor.entity.Task;
|
|
|
+import com.jeeplus.modules.oa.entity.OaNotify;
|
|
|
+import com.jeeplus.modules.oa.entity.OaNotifyRecord;
|
|
|
+import com.jeeplus.modules.oa.service.OaNotifyService;
|
|
|
+import com.jeeplus.modules.sg.managementcenter.activiti.utils.MyActiviUtils;
|
|
|
+import com.jeeplus.modules.sg.managementcenter.constructionProject.entity.ConstructionProject;
|
|
|
+import com.jeeplus.modules.sg.materialmodule.activiti.entity.MaterialModule;
|
|
|
+import com.jeeplus.modules.sg.materialmodule.activiti.service.MaterialModuleService;
|
|
|
+import com.jeeplus.modules.sg.materialmodule.activiti.web.MaterialModuleController;
|
|
|
+import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
+import org.quartz.DisallowConcurrentExecution;
|
|
|
+
|
|
|
+import javax.servlet.ServletContext;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@DisallowConcurrentExecution
|
|
|
+public class runTask extends Task{
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ MaterialModuleService materialModuleService = SpringContextHolder.getBean(MaterialModuleService.class);
|
|
|
+ OaNotifyService oaNotifyService = SpringContextHolder.getBean(OaNotifyService.class);
|
|
|
+ //查询出当月所有的计划项目的(项目名称,项目是否竣工)
|
|
|
+ List<ConstructionProject> monthProject = materialModuleService.findMonthProject();
|
|
|
+ String msg = "";
|
|
|
+ //判断项目是否竣工
|
|
|
+ for (ConstructionProject c : monthProject) {
|
|
|
+ if (c.getEndFlag()!=1) {
|
|
|
+ msg+=c.getProjectName()+":未完成竣工\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置需要发送通知的人员登陆名称
|
|
|
+ String[] needUser = {"施工项目经理A"};
|
|
|
+ //将人员名称数组转变为list
|
|
|
+ List<String> listUserId = MyActiviUtils.getListUserId(needUser);
|
|
|
+ //根据角色名查找用户id
|
|
|
+ List<String> userId = materialModuleService.findUserId(listUserId);
|
|
|
+ //将查询到的用户名list拼接为字符串
|
|
|
+ String stringJoiningTogether = MyActiviUtils.getStringJoiningTogether(userId);
|
|
|
+ //创建通知对象类
|
|
|
+ OaNotify oaNotify = new OaNotify();
|
|
|
+ //设置类型
|
|
|
+ oaNotify.setType("4");
|
|
|
+ oaNotify.setTitle("每月未竣工项目信息");
|
|
|
+ oaNotify.setStatus("1");
|
|
|
+ oaNotify.setOaNotifyRecordIds(stringJoiningTogether);
|
|
|
+ //根据流程实例id查询对应的项目信息(如果没有,发送通知,没有该项目计划信息)
|
|
|
+ if ("".equals(msg)) {
|
|
|
+ msg = "本月没有项目未完成竣工";
|
|
|
+ }
|
|
|
+ oaNotify.setContent(msg);
|
|
|
+ oaNotify.setCreateBy(UserUtils.get("1"));
|
|
|
+ oaNotify.setUpdateBy(UserUtils.get("1"));
|
|
|
+ oaNotifyService.save(oaNotify);
|
|
|
+ List<OaNotifyRecord> list = oaNotify.getOaNotifyRecordList();
|
|
|
+ for (OaNotifyRecord o : list) {
|
|
|
+ //发送通知到客户端
|
|
|
+ ServletContext context = SpringContextHolder.getBean(ServletContext.class);
|
|
|
+ new SystemInfoSocketHandler().sendMessageToUser(UserUtils.get(o.getUser().getId()).getLoginName(), "收到一条新通知,请到我的通知查看!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|