瀏覽代碼

定时任务处理维护资产(0)

5 年之前
父節點
當前提交
a4ff8705f7

+ 18 - 20
pcbms/src/main/java/com/hssx/pcbms/controller/ScoreController.java

@@ -54,26 +54,24 @@ public class ScoreController {
         }
         return msg;
     }
-//    /**
-//     * 打分/修改打分
-//     * 参数:
-//     * uid :被打分人的id,personalScore:个人分,ideaScore:建议分,reason:评分原因,
-//     * total:总得分,scoringYearMonth:打分日期如:2019-10,raterId:打分人id
-//     * 注:修改时传 scoreId:打分数据的id(以上参数修改的传,没修改的不传)
-//     * @return
-//     */
-//    @ApiOperation(value = "打分/修改打分", notes = "打分/修改打分方法")
-//    @RequestMapping("/addOrUpdate")
-//    @ResponseBody
-//    public HttpRespMsg addOrUpdate(Score score) {
-//        HttpRespMsg msg = new HttpRespMsg();
-//        try {
-//             msg = scoreService.add(score);
-//        } catch (ParseException e) {
-//            e.printStackTrace();
-//        }
-//        return msg;
-//    }
+    /**
+     * 删除打分
+     * 参数:
+     * scoreId:打分数据的id
+     * @return
+     */
+    @ApiOperation(value = "删除打分", notes = "删除打分方法")
+    @RequestMapping("/del")
+    @ResponseBody
+    public HttpRespMsg del(Score score) {
+        HttpRespMsg msg = new HttpRespMsg();
+        try {
+             msg = scoreService.del(score);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return msg;
+    }
     /**
      * 我的评分
      * 参数:

+ 16 - 12
pcbms/src/main/java/com/hssx/pcbms/entity/Idea.java

@@ -1,9 +1,12 @@
 package com.hssx.pcbms.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
+
 import java.time.LocalDateTime;
+
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
@@ -11,7 +14,7 @@ import java.io.Serializable;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author 吴涛涛
@@ -19,7 +22,7 @@ import java.io.Serializable;
  */
 public class Idea extends Model<Idea> {
 
-    private static final long serialVersionUID=1L;
+    private static final long serialVersionUID = 1L;
 
     /**
      * 建议表主键
@@ -66,8 +69,9 @@ public class Idea extends Model<Idea> {
 
     /**
      * 评分外键
+     * strategy = FieldStrategy.IGNORED,忽略全局配置策略,可以忽略全局配置的非null更新
      */
-    @TableField("score_id")
+    @TableField(value = "score_id", strategy = FieldStrategy.IGNORED)
     private Integer scoreId;
 
 
@@ -143,14 +147,14 @@ public class Idea extends Model<Idea> {
     @Override
     public String toString() {
         return "Idea{" +
-        "id=" + id +
-        ", uid=" + uid +
-        ", indate=" + indate +
-        ", content=" + content +
-        ", score=" + score +
-        ", isDraft=" + isDraft +
-        ", isEvaluated=" + isEvaluated +
-        ", scoreId=" + scoreId +
-        "}";
+                "id=" + id +
+                ", uid=" + uid +
+                ", indate=" + indate +
+                ", content=" + content +
+                ", score=" + score +
+                ", isDraft=" + isDraft +
+                ", isEvaluated=" + isEvaluated +
+                ", scoreId=" + scoreId +
+                "}";
     }
 }

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/service/ScoreService.java

@@ -26,4 +26,6 @@ public interface ScoreService extends IService<Score> {
     HttpRespMsg getDetailByTimeAndUid(Score score,String time);
 
     HttpRespMsg scoringTaskNotice();
+
+    HttpRespMsg del(Score score);
 }

+ 34 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/ScoreServiceImpl.java

@@ -1,6 +1,7 @@
 package com.hssx.pcbms.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.hssx.pcbms.constant.Constant;
@@ -15,6 +16,7 @@ import com.hssx.pcbms.util.PageUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.expression.spel.ast.Operator;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.annotation.Resource;
@@ -24,6 +26,7 @@ import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author 吴涛涛
@@ -170,6 +173,37 @@ public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements
         return msg;
     }
 
+    @Override
+    public HttpRespMsg del(Score score) {
+        HttpRespMsg msg = new HttpRespMsg();
+        Score Oldscore = scoreMapper.selectOne(new QueryWrapper<Score>().eq("score_id", score.getScoreId()));
+        //清空该建议的评分
+        List<Idea> ideas = ideaMapper.selectList(new QueryWrapper<Idea>().eq("score_id", Oldscore.getScoreId()));
+        //删除建议的评论
+        if(!CollectionUtils.isEmpty(ideas)){
+            ideaCommentMapper.delete(new QueryWrapper<IdeaComment>().in("idea_id",ideas.stream().map(Idea::getId).collect(Collectors.toList())));
+        }
+        //将之前的建议打分全部修改为0
+        Idea idea = new Idea();
+        idea.setScore(0.0);
+        idea.setScoreId(null);//这里是null没法更新
+        ideaMapper.update(idea,new QueryWrapper<Idea>().eq("score_id", Oldscore.getScoreId()));
+        //添加删除打分记录
+        User uidUser = userMapper.selectById(Oldscore.getUid());
+        User operator = userMapper.selectById(Oldscore.getRaterId());
+        ScoringOperateRecord record = new ScoringOperateRecord();
+        record.setContent(Constant.DELETE_SCORE);
+        record.setDeptId(Oldscore.getDeptId());
+        record.setOperatorId(operator.getId());
+        record.setUid(uidUser.getId());
+        record.setUname(uidUser.getName());
+        record.setOperator(operator.getName());
+        record.setScoreId(Oldscore.getScoreId());
+        scoringOperateRecordMapper.insert(record);
+        scoreMapper.delete(new QueryWrapper<Score>().eq("score_id",score.getScoreId()));
+        return msg;
+    }
+
     private HttpRespMsg addScore(Date yearMonth, Date nowDate, Integer type, Score score,Score oldScore) {
         HttpRespMsg msg = new HttpRespMsg();
         //评分上个月