5 年之前
父节点
当前提交
d8ad2c3883

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

@@ -9,5 +9,6 @@ package com.hssx.pcbms.constant;
 public class Constant {
     public static final String HANDLE_CONTENT = "将状态 oldState 改为 newState ";//处理资产类容前缀
     public static final String APP_ID = "";//appid
+    public static final String SCORING_DEADLINE_CODE = "scoringDeadline";//打分日期截止
 
 }

+ 1 - 1
pcbms/src/main/java/com/hssx/pcbms/controller/GoodsController.java

@@ -168,7 +168,7 @@ public class GoodsController {
      * 处置资产
      * 参数:
      * id:对应编号的id,state:资产状态0-空闲 1-在用 3-报废
-     * userId :对应人员的id(不选传0)
+     * userId :对应人员的id(不选传0),currentUserId:当前人id
      *
      * @return
      */

+ 23 - 0
pcbms/src/main/java/com/hssx/pcbms/controller/IdeaController.java

@@ -4,6 +4,7 @@ package com.hssx.pcbms.controller;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.hssx.pcbms.entity.Idea;
 import com.hssx.pcbms.entity.vo.GoodsVO;
+import com.hssx.pcbms.entity.vo.IdeaVO;
 import com.hssx.pcbms.service.IdeaService;
 import com.hssx.pcbms.util.HttpRespMsg;
 import com.hssx.pcbms.util.PageUtil;
@@ -15,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.ParseException;
+
 /**
  * @author 吴涛涛
  * @since 2019-11-02
@@ -81,6 +84,26 @@ public class IdeaController {
         return msg;
     }
 
+    /**
+     * 获取建议得分
+     * 有两种情况
+     * 参数:
+     * 1.打分:time:建议时间如:2019-11 ,uid:发表建议人的id
+     * 2.修改打分:scoreId:打分的数据的id,time:建议时间如:2019-11,uid:发表建议人的id
+     * @return
+     */
+    @ApiOperation(value = "获取建议得分", notes = "获取建议得分方法")
+    @RequestMapping("/getAdviceScore")
+    @ResponseBody
+    public HttpRespMsg getAdviceScore(IdeaVO ideaVO) {
+        HttpRespMsg msg = new HttpRespMsg();
+        try {
+            msg = ideaService.getAdviceScore(ideaVO);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return msg;
+    }
 
 }
 

+ 12 - 3
pcbms/src/main/java/com/hssx/pcbms/controller/ScoreController.java

@@ -3,6 +3,7 @@ package com.hssx.pcbms.controller;
 
 import com.hssx.pcbms.entity.Idea;
 import com.hssx.pcbms.entity.Score;
+import com.hssx.pcbms.entity.vo.IdeaVO;
 import com.hssx.pcbms.service.ScoreService;
 import com.hssx.pcbms.util.HttpRespMsg;
 import io.swagger.annotations.ApiOperation;
@@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.ParseException;
+
 /**
  * <p>
  *  前端控制器
@@ -30,15 +33,21 @@ public class ScoreController {
     /**
      * 打分/修改打分
      * 参数:
-     * uid :当前发表人的id,personalScore:个人分,ideaScore:建议分
-     * 注:修改时传 id:建议的id(以上参数isDraft也需要传)
+     * 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 = scoreService.add(score);
+        HttpRespMsg msg = new HttpRespMsg();
+        try {
+             msg = scoreService.add(score);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
         return msg;
     }
 

+ 8 - 8
pcbms/src/main/java/com/hssx/pcbms/entity/Score.java

@@ -12,7 +12,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author 吴涛涛
- * @since 2019-11-02
+ * @since 2019-11-04
  */
 public class Score extends Model<Score> {
 
@@ -69,8 +69,8 @@ public class Score extends Model<Score> {
     /**
      * 年-月份如:2019-10
      */
-    @TableField("year_month")
-    private String yearMonth;
+    @TableField("scoring_year_month")
+    private String scoringYearMonth;
 
 
     public Integer getScoreId() {
@@ -137,12 +137,12 @@ public class Score extends Model<Score> {
         this.uid = uid;
     }
 
-    public String getYearMonth() {
-        return yearMonth;
+    public String getScoringYearMonth() {
+        return scoringYearMonth;
     }
 
-    public void setYearMonth(String yearMonth) {
-        this.yearMonth = yearMonth;
+    public void setScoringYearMonth(String scoringYearMonth) {
+        this.scoringYearMonth = scoringYearMonth;
     }
 
     @Override
@@ -161,7 +161,7 @@ public class Score extends Model<Score> {
         ", raterId=" + raterId +
         ", rater=" + rater +
         ", uid=" + uid +
-        ", yearMonth=" + yearMonth +
+        ", scoringYearMonth=" + scoringYearMonth +
         "}";
     }
 }

+ 1 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/vo/IdeaVO.java

@@ -15,4 +15,5 @@ import java.util.List;
 @Data
 public class IdeaVO extends Idea {
     private IdeaComment ideaComment;
+    private String time;
 }

+ 16 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/vo/ScoreVO.java

@@ -0,0 +1,16 @@
+package com.hssx.pcbms.entity.vo;
+
+import com.hssx.pcbms.entity.Score;
+import lombok.Data;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 11 - 04 10:07
+ * Description:<描述>
+ * Version: 1.0
+ */
+@Data
+public class ScoreVO extends Score {
+    private String time;
+
+}

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/mapper/IdeaMapper.java

@@ -18,4 +18,6 @@ import java.util.List;
 public interface IdeaMapper extends BaseMapper<Idea> {
 
     List<IdeaVO> getIdeaListByUid(@Param("idea") Idea idea,@Param("time") String time);
+
+    List<Idea> getIdeaScoreLists(@Param("ideaVO")IdeaVO ideaVO);
 }

+ 3 - 0
pcbms/src/main/java/com/hssx/pcbms/service/IdeaService.java

@@ -2,6 +2,7 @@ package com.hssx.pcbms.service;
 
 import com.hssx.pcbms.entity.Idea;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.pcbms.entity.vo.IdeaVO;
 import com.hssx.pcbms.util.HttpRespMsg;
 import com.hssx.pcbms.util.PageUtil;
 
@@ -22,4 +23,6 @@ public interface IdeaService extends IService<Idea> {
     HttpRespMsg ideaList(Idea idea,PageUtil page);
 
     HttpRespMsg ideaListByTime(Idea idea,String time);
+
+    HttpRespMsg getAdviceScore(IdeaVO ideaVO);
 }

+ 3 - 1
pcbms/src/main/java/com/hssx/pcbms/service/ScoreService.java

@@ -4,6 +4,8 @@ import com.hssx.pcbms.entity.Score;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.hssx.pcbms.util.HttpRespMsg;
 
+import java.text.ParseException;
+
 /**
  * <p>
  *  服务类
@@ -14,5 +16,5 @@ import com.hssx.pcbms.util.HttpRespMsg;
  */
 public interface ScoreService extends IService<Score> {
 
-    HttpRespMsg add(Score score);
+    HttpRespMsg add(Score score) throws ParseException;
 }

+ 4 - 4
pcbms/src/main/java/com/hssx/pcbms/service/impl/GoodsServiceImpl.java

@@ -146,17 +146,17 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         String nowState = "";
         if (no.getState() == 0) {
             oldState = "未用";
-        } else if (no.getState() == 1) {
-            oldState = "在用";
+        } else if (no.getState() == 1)
+            oldState = "在用";{
             User usering = userMapper.selectById(no.getUserId());
-            oldState = oldState + (usering.getName() + "/" + usering.getPhone());
+            oldState = oldState + ("("+usering.getName() + "/" + usering.getPhone()+")");
         }
         if (goodsNo.getState() == 0) {
             nowState = "未用";
         } else if (goodsNo.getState() == 1) {
             nowState = "在用";
             User usering = userMapper.selectById(goodsNo.getUserId());
-            nowState = nowState + (usering.getName() + "/" + usering.getPhone());
+            nowState = nowState + ("("+usering.getName() + "/" + usering.getPhone()+")");
         } else if (goodsNo.getState() == 3) {
             nowState = "报废";
         }

+ 1 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/IdeaCommentServiceImpl.java

@@ -32,6 +32,7 @@ public class IdeaCommentServiceImpl extends ServiceImpl<IdeaCommentMapper, IdeaC
             Idea idea = new Idea();
             idea.setId(ideaComment.getId());
             idea.setScore(score);
+            idea.setIsEvaluated(1);
             ideaMapper.update(idea,new QueryWrapper<Idea>().eq("id",ideaComment.getIdeaId()));
         } else {
             Idea idea = ideaMapper.selectOne(new QueryWrapper<Idea>().eq("id", ideaComment.getIdeaId()));

+ 13 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/IdeaServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author 吴涛涛
@@ -76,4 +77,16 @@ public class IdeaServiceImpl extends ServiceImpl<IdeaMapper, Idea> implements Id
         return msg;
     }
 
+    @Override
+    public HttpRespMsg getAdviceScore(IdeaVO ideaVO) {
+        HttpRespMsg msg = new HttpRespMsg();
+        List<Idea> list = ideaMapper.getIdeaScoreLists(ideaVO);
+        double sum = 0.0;
+        if(list.size()>0){
+             sum = list.stream().mapToDouble(Idea::getScore).sum();
+        }
+        msg.data = sum;
+        return msg;
+    }
+
 }

+ 111 - 6
pcbms/src/main/java/com/hssx/pcbms/service/impl/ScoreServiceImpl.java

@@ -1,25 +1,130 @@
 package com.hssx.pcbms.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.hssx.pcbms.constant.Constant;
+import com.hssx.pcbms.entity.Parameter;
 import com.hssx.pcbms.entity.Score;
+import com.hssx.pcbms.entity.User;
+import com.hssx.pcbms.mapper.ParameterMapper;
 import com.hssx.pcbms.mapper.ScoreMapper;
+import com.hssx.pcbms.mapper.UserMapper;
 import com.hssx.pcbms.service.ScoreService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hssx.pcbms.util.HttpRespMsg;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.annotation.Resource;
+import javax.xml.crypto.Data;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
 
 /**
- * <p>
- *  服务实现类
- * </p>
- *
  * @author 吴涛涛
  * @since 2019-11-02
  */
 @Service
 public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements ScoreService {
+    @Resource
+    private ScoreMapper scoreMapper;
+    @Resource
+    private ParameterMapper parameterMapper;
+    @Resource
+    private UserMapper userMapper;
 
     @Override
-    public HttpRespMsg add(Score score) {
-        return null;
+    public HttpRespMsg add(Score score) throws ParseException {
+        HttpRespMsg msg = new HttpRespMsg();
+//        SimpleDateFormat sdfymd = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat sdfym = new SimpleDateFormat("yyyy-MM");
+        Parameter parameter = parameterMapper.selectOne(new QueryWrapper<Parameter>().eq("param_key", Constant.SCORING_DEADLINE_CODE));
+        if (parameter != null) {
+            User Rater = userMapper.selectById(score.getRaterId());
+            score.setRater(Rater.getName());
+            if(Rater != null){
+                msg.setError("当前打分人身份异常。");
+                return msg;
+            }
+            Score oldScore = scoreMapper.selectOne(new QueryWrapper<Score>().eq("scoring_year_month", score.getScoringYearMonth()));
+            if (score.getScoreId() != null) {
+                //修改打分
+                scoreMapper.updateById(score);
+            } else {
+                Date now = new Date();
+                now.setDate(Integer.parseInt(parameter.getParamValue()));
+                String thisMonth5 = sdfym.format(now);
+                now.setMonth(now.getMonth() - 1);
+                String lastMonth5 = sdfym.format(now);
+                now.setMonth(now.getMonth() + 2);
+                String nextMonth5 = sdfym.format(now);
+                Date nowDate = new Date();
+                String currentDateStr = sdfym.format(nowDate);
+                //打分日期
+                Date yearMonth = sdfym.parse(score.getScoringYearMonth());
+                if (currentDateStr.compareTo(lastMonth5) >= 0 && currentDateStr.compareTo(thisMonth5) <= 0) {
+                    //上个月五号到本月五号之间(可评上月的分)
+                    msg = addScore(yearMonth, nowDate, 0, score,oldScore);
+                } else if (currentDateStr.compareTo(thisMonth5) >= 0 && currentDateStr.compareTo(nextMonth5) <= 0) {
+                    //本月五号到下月五号之间(可评本月的分)
+                    msg = addScore(yearMonth, nowDate, 1, score,oldScore);
+                }
+            }
+        }
+        return msg;
+    }
+
+    private HttpRespMsg addScore(Date yearMonth, Date nowDate, Integer type, Score score,Score oldScore) {
+        HttpRespMsg msg = new HttpRespMsg();
+        //评分上个月
+        if (type == 0) {
+            if (yearMonth.getMonth() == (nowDate.getMonth() - 1)) {
+                if (oldScore != null) {
+                    msg.setError("本月已打分,请勿重复打分");
+                    return msg;
+                } else {
+                    scoreMapper.insert(score);
+                }
+            } else {
+                msg.setError("评分日期不和法,请切换日期后重试");
+                return msg;
+            }
+        } else if (type == 1) {
+            if (yearMonth.getMonth() == (nowDate.getMonth())) {
+                if (oldScore != null) {
+                    msg.setError("本月已打分,请勿重复打分");
+                    return msg;
+                } else {
+                    scoreMapper.insert(score);
+                }
+            } else {
+                msg.setError("评分日期不和法,请切换日期后重试");
+                return msg;
+            }
+        }
+        return msg;
+    }
+
+    public static void main(String[] args) {
+        System.out.println("2019-11-07".compareTo("2019-11-07"));
+        SimpleDateFormat sdfym = new SimpleDateFormat("yyyy-MM");
+        Date now = new Date();
+        now.setDate(Integer.parseInt("5"));
+        String thisMonth5 = sdfym.format(now);
+        now.setMonth(now.getMonth() - 1);
+        String lastMonth5 = sdfym.format(now);
+        now.setMonth(now.getMonth() + 2);
+        String nextMonth5 = sdfym.format(now);
+        System.out.println(thisMonth5 + "  " + lastMonth5 + "  " + nextMonth5);
+        Date nowDate = new Date();
+        String currentDateStr = "2019-11-06";
+        if (currentDateStr.compareTo(lastMonth5) > 0 && currentDateStr.compareTo(thisMonth5) < 0) {
+            System.out.println("上月五号到这月五号之间");
+
+        } else if (currentDateStr.compareTo(thisMonth5) > 0) {
+            System.out.println("超过本月五号了");
+
+        }
     }
 }

+ 17 - 0
pcbms/src/main/resources/mapper/IdeaMapper.xml

@@ -55,5 +55,22 @@
         </where>
         order by i.indate desc
     </select>
+    <select id="getIdeaScoreLists" resultMap="BaseResultMap">
+        select
+        id, uid, indate, score, is_draft, is_evaluated, score_id
+        from
+            idea i
+        <where>
+            i.uid = #{ideaVO.uid,jdbcType=INTEGER}
+            and is_evaluated = 1
+            <if test="ideaVO.time != null">
+               and date_format(i.indate,'%Y-%m') = #{time}
+            </if>
+            <if test="ideaVO.scoreId != null">
+               and date_format(i.indate,'%Y-%m') = #{time}
+            </if>
+        </where>
+        order by i.indate desc
+    </select>
 
 </mapper>

+ 2 - 2
pcbms/src/main/resources/mapper/ScoreMapper.xml

@@ -12,12 +12,12 @@
         <result column="rater_id" property="raterId" />
         <result column="rater" property="rater" />
         <result column="uid" property="uid" />
-        <result column="year_month" property="yearMonth" />
+        <result column="scoring_year_month" property="scoringYearMonth" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        score_id, personal_score, idea_score, total, reason, rater_id, rater, uid, year_month
+        score_id, personal_score, idea_score, total, reason, rater_id, rater, uid, scoring_year_month
     </sql>
 
 </mapper>