5 lat temu
rodzic
commit
3631d3e8d3

+ 6 - 0
pcbms/src/main/java/com/hssx/pcbms/constant/Constant.java

@@ -19,6 +19,12 @@ public class Constant {
     public static final String EXAMINE_NO_PASS= "审核未通过";
     public static final String EXAMINE_SUBMIT= "已提交任务";
     public static final String TASK_DELAY= "将任务延期至";
+    public static final String TASK_DISTRIBUTE= "将任务派发给";
+    public static final String TO_BE_DISTRIBUTE= "待派发";
+    public static final String ALREADY_DISTRIBUTED= "已派发";
+    public static final String ALREADY_ACCEPT= "已接受";
+    public static final String TASK_ACCEPTED= "已接受任务";
+    public static final String ALREADY_DELAY= "已逾期";
     public static final String TASK_COMPLETED= "已完成";
     public static final String TASK_NO_PASS= "未通过";
     public static final String TASK_PULISH= "发布任务";

+ 29 - 2
pcbms/src/main/java/com/hssx/pcbms/controller/TaskController.java

@@ -12,9 +12,11 @@ import com.hssx.pcbms.util.UploadFileToFileNameUtil;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
@@ -48,10 +50,23 @@ public class TaskController {
     @ApiOperation(value = "任务录入/修改", notes = "任务录入/修改方法")
     @RequestMapping("/addOrUpdate")
     @ResponseBody
-    public HttpRespMsg addOrUpdate(Task task,String participantsIdes) {
+    public HttpRespMsg addOrUpdate(Task task,@RequestParam(required = false) String participantsIdes) {
         HttpRespMsg msg = taskService.addOrUpdate(task,participantsIdes);
         return msg;
     }
+    /**
+     * 任务接受
+     * 参数:id:任务id,recipientId:接收人id
+     *
+     */
+    @ApiOperation(value = "任务接受", notes = "任务录入/修改方法")
+    @RequestMapping("/acceptTask")
+    @ResponseBody
+    public HttpRespMsg acceptTask(Task task) {
+        HttpRespMsg msg = taskService.acceptTask(task);
+        return msg;
+    }
+
 
     /**
      * 任务列表
@@ -79,7 +94,19 @@ public class TaskController {
         return msg;
     }
 
-
+    /**
+     * 任务失效检测定时任务
+     * 参数:
+     * @return
+     */
+    @ApiOperation(value = "任务失效检测定时任务", notes = "任务失效检测定时任务")
+    @RequestMapping("/taskInvalidChecking")
+    @ResponseBody
+    @Scheduled(cron = "0 0 1 * * ?")//配置时间点触发(每日凌晨1点)
+    public HttpRespMsg taskInvalidChecking() {
+        HttpRespMsg msg = taskService.taskInvalidChecking();
+        return msg;
+    }
 
 
 

+ 4 - 1
pcbms/src/main/java/com/hssx/pcbms/entity/Task.java

@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -100,7 +102,7 @@ public class Task extends Model<Task> {
     private String delayTime;
 
     /**
-     * 状态0-待派发 1-已派发 2-已接受 3-待审核 4-未通过 5-已完成
+     * 状态0-待派发 1-已派发 2-已接受 3-待审核 4-未通过 5-已完成 6-已延期 7-已失效
      */
     @TableField("state")
     private Integer state;
@@ -121,6 +123,7 @@ public class Task extends Model<Task> {
      * 排序时间
      */
     @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private LocalDateTime indate;
 
 

+ 3 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/TaskDynamic.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -47,6 +49,7 @@ public class TaskDynamic extends Model<TaskDynamic> {
      * 时间
      */
     @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
     /**

+ 4 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/TaskExamine.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -71,12 +73,14 @@ public class TaskExamine extends Model<TaskExamine> {
      * 发布日期
      */
     @TableField("publish_date")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime publishDate;
 
     /**
      * 回复日期
      */
     @TableField("respond_date")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime respondDate;
 
     /**

+ 4 - 2
pcbms/src/main/java/com/hssx/pcbms/entity/vo/TaskDTO.java

@@ -16,6 +16,8 @@ import java.util.List;
 public class TaskDTO extends Task {
     private List<TaskParticipantsVO> participantsVOS;
     private String tagName;
-    private String publishName;
-    private String recipient;
+    private String publisherName;
+    private String recipientName;
+    private String publisherHedaPic;
+    private String recipientHedaPic;
 }

+ 4 - 0
pcbms/src/main/java/com/hssx/pcbms/service/TaskService.java

@@ -21,4 +21,8 @@ public interface TaskService extends IService<Task> {
     HttpRespMsg getListByCondition(TaskVO taskVO, PageUtil page);
 
     HttpRespMsg detail(TaskVO taskVO);
+
+    HttpRespMsg acceptTask(Task task);
+
+    HttpRespMsg taskInvalidChecking();
 }

+ 97 - 16
pcbms/src/main/java/com/hssx/pcbms/service/impl/TaskServiceImpl.java

@@ -4,14 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.hssx.pcbms.constant.Constant;
-import com.hssx.pcbms.entity.Task;
-import com.hssx.pcbms.entity.TaskDynamic;
-import com.hssx.pcbms.entity.TaskParticipants;
+import com.hssx.pcbms.entity.*;
 import com.hssx.pcbms.entity.vo.TaskDTO;
 import com.hssx.pcbms.entity.vo.TaskVO;
-import com.hssx.pcbms.mapper.TaskDynamicMapper;
-import com.hssx.pcbms.mapper.TaskMapper;
-import com.hssx.pcbms.mapper.UserMapper;
+import com.hssx.pcbms.mapper.*;
 import com.hssx.pcbms.service.TaskParticipantsService;
 import com.hssx.pcbms.service.TaskService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -19,8 +15,11 @@ import com.hssx.pcbms.util.HttpRespMsg;
 import com.hssx.pcbms.util.ListUtil;
 import com.hssx.pcbms.util.PageUtil;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -44,19 +43,44 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     private TaskDynamicMapper taskDynamicMapper;
     @Resource
     private UserMapper userMapper;
+    @Resource
+    private NewsNoticeMapper newsNoticeMapper;
+    @Resource
+    private NewsNoticeUserMapper newsNoticeUserMapper;
 
     @Override
     public HttpRespMsg addOrUpdate(Task task,String participantsIdes) {
         HttpRespMsg msg = new HttpRespMsg();
         List<TaskParticipants> taskParticipants = new ArrayList<>();
         if(null == task.getId()){
-            taskMapper.insert(task);
             TaskDynamic taskDynamic = new TaskDynamic();
+            if(task.getRecipientId() != null){
+                task.setState(1);//已派发
+                taskDynamic.setTaskState(1);//已派发
+                taskDynamic.setStateContent(Constant.ALREADY_DISTRIBUTED);
+                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DISTRIBUTE+userMapper.selectById(task.getRecipientId()).getName());
+                //给接收人发送消息
+                NewsNotice newsNotice = new NewsNotice();
+                newsNotice.setNoticeType(2);
+                newsNotice.setRefId(Integer.parseInt(task.getId()));
+                newsNotice.setRafName(task.getName());
+                newsNotice.setContent("有新的任务待您接受");
+                newsNoticeMapper.insert(newsNotice);
+                NewsNoticeUser noticeUser = new NewsNoticeUser();
+                noticeUser.setIsRead(0);
+                noticeUser.setUserId(task.getRecipientId());
+                noticeUser.setNewsId(newsNotice.getId());
+                newsNoticeUserMapper.insert(noticeUser);
+            }else{
+                task.setState(0);//待派发
+                taskDynamic.setTaskState(0);//待派发
+                taskDynamic.setStateContent(Constant.TO_BE_DISTRIBUTE);
+                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_PULISH);
+            }
+            taskMapper.insert(task);
             taskDynamic.setTaskId(task.getId());
-            taskDynamic.setTaskState(0);//待派发
-            taskDynamic.setStateContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_PULISH);
             taskDynamicMapper.insert(taskDynamic);
-            if(participantsIdes.length()>0 && participantsIdes != ""){
+            if(participantsIdes != null && participantsIdes != ""){
                 List<Integer> ids = ListUtil.convertIntegerIdsArrayToList(participantsIdes);
                 for (Integer id : ids) {
                     TaskParticipants participants = new TaskParticipants();
@@ -67,17 +91,37 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 taskParticipantsService.saveBatch(taskParticipants);
             }
         }else{
-            if(task.getDelayTime()!=null){
+            Task oldTask = taskMapper.selectById(task.getId());
+            TaskDynamic taskDynamic = new TaskDynamic();
+            taskDynamic.setTaskId(task.getId());
+            if(task.getDelayTime()!=null && oldTask.getDelayTime() == null){
                 //添加动态
-                TaskDynamic taskDynamic = new TaskDynamic();
-                taskDynamic.setTaskId(task.getId());
                 taskDynamic.setTaskState(6);//已延期
-                taskDynamic.setStateContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DELAY+task.getDelayTime());
+                taskDynamic.setStateContent(Constant.ALREADY_DELAY);
+                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DELAY+task.getDelayTime());
+                taskDynamicMapper.insert(taskDynamic);
+            }
+            if(task.getRecipientId() != null && oldTask.getRecipientId() == null){
+                task.setState(1);//已派发
+                taskDynamic.setTaskState(1);//已派发
+                taskDynamic.setStateContent(Constant.ALREADY_DISTRIBUTED);
+                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DISTRIBUTE+userMapper.selectById(task.getRecipientId()).getName());
                 taskDynamicMapper.insert(taskDynamic);
+                //给接收人发送消息
+                NewsNotice newsNotice = new NewsNotice();
+                newsNotice.setNoticeType(2);
+                newsNotice.setRefId(Integer.parseInt(task.getId()));
+                newsNotice.setRafName(task.getName());
+                newsNotice.setContent("有新的任务待您接受");
+                newsNoticeMapper.insert(newsNotice);
+                NewsNoticeUser noticeUser = new NewsNoticeUser();
+                noticeUser.setIsRead(0);
+                noticeUser.setUserId(task.getRecipientId());
+                noticeUser.setNewsId(newsNotice.getId());
+                newsNoticeUserMapper.insert(noticeUser);
             }
             taskMapper.updateById(task);
-
-            if(participantsIdes.length()>0 && participantsIdes != ""){
+            if(participantsIdes != null && participantsIdes != ""){
                 taskParticipantsService.remove(new QueryWrapper<TaskParticipants>().eq("task_id",task.getId()));
                 List<Integer> ids = ListUtil.convertIntegerIdsArrayToList(participantsIdes);
                 for (Integer id : ids) {
@@ -128,4 +172,41 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         msg.data = dto;
         return msg;
     }
+
+    @Override
+    public HttpRespMsg acceptTask(Task task) {
+        HttpRespMsg msg= new HttpRespMsg();
+        task.setState(2);//已接受
+        taskMapper.updateById(task);
+        TaskDynamic dynamic = new TaskDynamic();
+        dynamic.setTaskId(task.getId());
+        dynamic.setStateContent(Constant.ALREADY_ACCEPT);
+        dynamic.setContent(userMapper.selectById(task.getRecipientId()).getName()+Constant.TASK_ACCEPTED);
+        taskDynamicMapper.insert(dynamic);
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg taskInvalidChecking() {
+        List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().ne("state", 7));
+        LocalDateTime now = LocalDateTime.now();
+        String format = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
+        for (Task task : taskList) {
+            if(task.getState()==6){
+//                if(){
+//
+//                }
+            }else{
+
+            }
+            
+        }
+        return null;
+    }
+
+    public static void main(String[] args) {
+        LocalDateTime now = LocalDateTime.now();
+        String format = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
+        System.out.println(format);
+    }
 }

+ 13 - 10
pcbms/src/main/resources/mapper/TaskMapper.xml

@@ -35,24 +35,27 @@
         <result column="delay_time" property="delayTime" />
         <result column="state" property="state" />
         <result column="publish_id" property="publishId" />
-        <result column="publishName" property="publishName" />
-        <result column="tag_name" property="tagName" />
-        <result column="recipient" property="recipient" />
+        <result column="publishName" property="publisherName" />
+        <result column="tagname" property="tagName" />
+        <result column="recipient" property="recipientName" />
+        <result column="pHedaPic" property="publisherHedaPic" />
+        <result column="rHedaPic" property="recipientHedaPic" />
         <result column="content" property="content" />
+        <result column="indate" property="indate" />
         <collection property="participantsVOS" select="selectPaticaterByTaskId" column="id"
                     ofType="com.hssx.pcbms.entity.vo.TaskParticipantsVO"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, name, code, plan_time, work_load, recipient_id, payer, payee, fee, tag_id, delay_time, state, publish_id
+        id, name, code, plan_time, work_load, recipient_id, payer, payee, fee, tag_id, delay_time, state, publish_id,content
     </sql>
 
     <select id="selectListByCondition" resultMap="BaseResultMapVO">
         select
-        t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,
+        t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,t.content,t.indate,
         t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id,
-        u.name publishName,tt.name tag_name,ru.name recipient,t.content
+        u.name publishName,tt.name tagname,ru.name recipient,t.content,u.head_url pHedaPic,ru.head_url rHedaPic
         from
         task t
         left join user u
@@ -82,9 +85,9 @@
     </select>
     <select id="selectListByTaskIds" resultMap="BaseResultMapVO">
         select
-        t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,
+        t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,t.content,t.indate,
         t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id,
-        u.name publishName,tt.name tag_name,ru.name recipient
+        u.name publishName,tt.name tagname,ru.name recipient,u.head_url pHedaPic,ru.head_url rHedaPic
         from
         task t
         left join user u
@@ -133,9 +136,9 @@
 
     <select id="getDetailById" resultMap="BaseResultMapVO">
         select
-        t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,
+        t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,t.indate,
         t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id,
-        u.name publishName,tt.name tag_name,ru.name recipient,t.content
+        u.name publishName,tt.name tag_name,ru.name recipient,t.content,u.head_url pHedaPic,ru.head_url rHedaPic
         from
         task t
         left join user u