%!s(int64=5) %!d(string=hai) anos
pai
achega
ad55b1cebd

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

@@ -84,7 +84,7 @@ public class TaskController {
 
     /**
      * 任务详情
-     * 参数:pageNum:当前页,pageSize:每页多少条,id: 任务id
+     * 参数:id: 任务id
      */
     @ApiOperation(value = "任务详情", notes = "任务详情方法")
     @RequestMapping("/detail")
@@ -97,7 +97,7 @@ public class TaskController {
      * 任务删除
      * 参数:id:任务id
      */
-    @ApiOperation(value = "任务详情", notes = "任务详情方法")
+    @ApiOperation(value = "任务删除", notes = "任务删除方法")
     @RequestMapping("/del")
     @ResponseBody
     public HttpRespMsg del(Task task) {

+ 39 - 36
pcbms/src/main/java/com/hssx/pcbms/service/impl/TaskServiceImpl.java

@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author 吴涛涛
@@ -49,20 +49,24 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     private NewsNoticeUserMapper newsNoticeUserMapper;
 
     @Override
-    public HttpRespMsg addOrUpdate(Task task,String participantsIdes) {
+    public HttpRespMsg addOrUpdate(Task task, String participantsIdes) {
         HttpRespMsg msg = new HttpRespMsg();
         List<TaskParticipants> taskParticipants = new ArrayList<>();
-        if(null == task.getId()){
+        if (null == task.getId()) {
             TaskDynamic taskDynamic = new TaskDynamic();
-            if(task.getRecipientId() != null){
+            if (task.getRecipientId() != null) {
                 task.setState(1);//已派发
+                taskMapper.insert(task);
                 taskDynamic.setTaskState(1);//已派发
                 taskDynamic.setStateContent(Constant.ALREADY_DISTRIBUTED);
-                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DISTRIBUTE+userMapper.selectById(task.getRecipientId()).getName());
+                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName() + Constant.TASK_DISTRIBUTE + userMapper.selectById(task.getRecipientId()).getName());
+                taskDynamic.setTaskId(task.getId());
+                taskDynamicMapper.insert(taskDynamic);
                 //给接收人发送消息
                 NewsNotice newsNotice = new NewsNotice();
                 newsNotice.setNoticeType(2);
-                newsNotice.setRefId(Integer.parseInt(task.getId()));
+//                Integer rafId = Integer.valueOf(task.getId());
+//                newsNotice.setRefId(rafId);
                 newsNotice.setRafName(task.getName());
                 newsNotice.setContent("有新的任务待您接受");
                 newsNoticeMapper.insert(newsNotice);
@@ -71,16 +75,16 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 noticeUser.setUserId(task.getRecipientId());
                 noticeUser.setNewsId(newsNotice.getId());
                 newsNoticeUserMapper.insert(noticeUser);
-            }else{
+            } else {
                 task.setState(0);//待派发
+                taskMapper.insert(task);
                 taskDynamic.setTaskState(0);//待派发
                 taskDynamic.setStateContent(Constant.TO_BE_DISTRIBUTE);
-                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_PULISH);
+                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName() + Constant.TASK_PULISH);
+                taskDynamic.setTaskId(task.getId());
+                taskDynamicMapper.insert(taskDynamic);
             }
-            taskMapper.insert(task);
-            taskDynamic.setTaskId(task.getId());
-            taskDynamicMapper.insert(taskDynamic);
-            if(participantsIdes != null && participantsIdes != ""){
+            if (participantsIdes != null && participantsIdes != "") {
                 List<Integer> ids = ListUtil.convertIntegerIdsArrayToList(participantsIdes);
                 for (Integer id : ids) {
                     TaskParticipants participants = new TaskParticipants();
@@ -90,27 +94,26 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 }
                 taskParticipantsService.saveBatch(taskParticipants);
             }
-        }else{
+        } else {
             Task oldTask = taskMapper.selectById(task.getId());
             TaskDynamic taskDynamic = new TaskDynamic();
             taskDynamic.setTaskId(task.getId());
-            if(task.getDelayTime()!=null && oldTask.getDelayTime() == null){
+            if (task.getDelayTime() != null && oldTask.getDelayTime() == null) {
                 //添加动态
                 taskDynamic.setTaskState(6);//已延期
                 taskDynamic.setStateContent(Constant.ALREADY_DELAY);
-                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName()+Constant.TASK_DELAY+task.getDelayTime());
+                taskDynamic.setContent(userMapper.selectById(task.getPublishId()).getName() + Constant.TASK_DELAY + task.getDelayTime());
                 taskDynamicMapper.insert(taskDynamic);
             }
-            if(task.getRecipientId() != null && oldTask.getRecipientId() == null){
+            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());
+                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);
@@ -121,8 +124,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 newsNoticeUserMapper.insert(noticeUser);
             }
             taskMapper.updateById(task);
-            if(participantsIdes != null && participantsIdes != ""){
-                taskParticipantsService.remove(new QueryWrapper<TaskParticipants>().eq("task_id",task.getId()));
+            if (participantsIdes != null && participantsIdes != "") {
+                taskParticipantsService.remove(new QueryWrapper<TaskParticipants>().eq("task_id", task.getId()));
                 List<Integer> ids = ListUtil.convertIntegerIdsArrayToList(participantsIdes);
                 for (Integer id : ids) {
                     TaskParticipants participants = new TaskParticipants();
@@ -139,24 +142,24 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     @Override
     public HttpRespMsg getListByCondition(TaskVO taskVO, PageUtil page) {
         HttpRespMsg msg = new HttpRespMsg();
-        PageHelper.startPage(page.getPageNum(),page.getPageSize());
-        if(taskVO.getType()==0){
+        PageHelper.startPage(page.getPageNum(), page.getPageSize());
+        if (taskVO.getType() == 0) {
             //我的任务
-            List<Task> tasks= taskMapper.selectList(new QueryWrapper<Task>().eq("recipient_id", taskVO.getUid()));
+            List<Task> tasks = taskMapper.selectList(new QueryWrapper<Task>().eq("recipient_id", taskVO.getUid()));
             List<TaskParticipants> participants = taskParticipantsService.list(new QueryWrapper<TaskParticipants>().eq("user_id", taskVO.getUid()));
             List<String> taskIds = new ArrayList<>();
-            if(tasks.size()>0){
+            if (tasks.size() > 0) {
                 taskIds.addAll(tasks.stream().map(Task::getId).collect(Collectors.toList()));
             }
-            if(participants.size()>0){
+            if (participants.size() > 0) {
                 taskIds.addAll(participants.stream().map(TaskParticipants::getTaskId).collect(Collectors.toList()));
             }
-            if(taskIds .size()>0){
-                List<TaskDTO> taskDTOList = taskMapper.selectListByTaskIds(taskIds,taskVO);
+            if (taskIds.size() > 0) {
+                List<TaskDTO> taskDTOList = taskMapper.selectListByTaskIds(taskIds, taskVO);
                 PageInfo<TaskDTO> pageInfo = new PageInfo<>(taskDTOList);
                 msg.data = pageInfo;
             }
-        }else if(taskVO.getType()==1){
+        } else if (taskVO.getType() == 1) {
             //我发布的
             List<TaskDTO> taskDTOList = taskMapper.selectListByCondition(taskVO);
             PageInfo<TaskDTO> pageInfo = new PageInfo<>(taskDTOList);
@@ -175,13 +178,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
 
     @Override
     public HttpRespMsg acceptTask(Task task) {
-        HttpRespMsg msg= new HttpRespMsg();
+        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);
+        dynamic.setContent(userMapper.selectById(task.getRecipientId()).getName() + Constant.TASK_ACCEPTED);
         taskDynamicMapper.insert(dynamic);
         return msg;
     }
@@ -192,22 +195,22 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         LocalDateTime now = LocalDateTime.now();
         String format = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
         for (Task task : taskList) {
-            if(task.getState()==6){
-                if(format.compareTo(task.getDelayTime())>=0){
+            if (task.getState() == 6) {
+                if (format.compareTo(task.getDelayTime()) >= 0) {
                     task.setState(7);
                     TaskDynamic taskDynamic = new TaskDynamic();
                     taskDynamic.setTaskState(7);//已失效
                     taskDynamic.setStateContent(Constant.ALREADY_INVALID);
-                    taskDynamic.setContent("["+task.getName()+"] "+Constant.ALREADY_INVALID);
+                    taskDynamic.setContent("[" + task.getName() + "] " + Constant.ALREADY_INVALID);
                     taskDynamicMapper.insert(taskDynamic);
                 }
-            }else{
-                if(format.compareTo(task.getPlanTime())>=0){
+            } else {
+                if (format.compareTo(task.getPlanTime()) >= 0) {
                     task.setState(7);
                     TaskDynamic taskDynamic = new TaskDynamic();
                     taskDynamic.setTaskState(7);//已失效
                     taskDynamic.setStateContent(Constant.ALREADY_INVALID);
-                    taskDynamic.setContent("["+task.getName()+"] "+Constant.ALREADY_INVALID);
+                    taskDynamic.setContent("[" + task.getName() + "] " + Constant.ALREADY_INVALID);
                     taskDynamicMapper.insert(taskDynamic);
                 }
             }

+ 6 - 6
pcbms/src/main/resources/mapper/TaskMapper.xml

@@ -67,13 +67,13 @@
         <where>
             t.state !=8
             <if test="taskVO.keyName != null and taskVO.keyName != ''">
-                and name like concat('%',#{taskVO.keyName},'%')
+                and t.name like concat('%',#{taskVO.keyName},'%')
             </if>
             <if test="taskVO.startTime != null and taskVO.startTime != ''and taskVO.endTime != null and taskVO.endTime != ''">
-                and plan_time between #{taskVO.startTime} and #{taskVO.endTime}
+                and t.plan_time between #{taskVO.startTime} and #{taskVO.endTime}
             </if>
             <if test="taskVO.uid != null">
-                and publish_id =#{taskVO.uid}
+                and t.publish_id =#{taskVO.uid}
             </if>
             <if test="taskVO.tagId != null and taskVO.tagId != ''">
                 and t.tag_id = #{taskVO.tagId}
@@ -103,13 +103,13 @@
             </foreach>
             and t.state !=8
             <if test="taskVO.keyName != null and taskVO.keyName != ''">
-                and name like concat('%',#{taskVO.keyName},'%')
+                and t.name like concat('%',#{taskVO.keyName},'%')
             </if>
             <if test="taskVO.startTime != null and taskVO.startTime != ''and taskVO.endTime != null and taskVO.endTime != ''">
-                and plan_time between #{taskVO.startTime} and #{taskVO.endTime}
+                and t.plan_time between #{taskVO.startTime} and #{taskVO.endTime}
             </if>
             <if test="taskVO.uid != null">
-                and publish_id =#{taskVO.uid}
+                and t.publish_id =#{taskVO.uid}
             </if>
             <if test="taskVO.tagId != null and taskVO.tagId != ''">
                 and t.tag_id = #{taskVO.tagId}