Merge branch 'develop_3' into 'develop_master'
Develop 3 See merge request LiuChao/foton-slrs-system-rest!275
This commit is contained in:
+5
-4
@@ -71,16 +71,17 @@ public class QualityEvaluationController extends BaseController<QualityEvaluatio
|
||||
|
||||
|
||||
@ApiOperation("查询评分表")
|
||||
@PostMapping("getEvaluationForm")
|
||||
public ResponseMessage getEvaluationForm(@RequestBody FormVO form){
|
||||
@GetMapping("getEvaluationForm")
|
||||
public ResponseMessage<List<QualityEvaluation>> getEvaluationForm(FormVO form){
|
||||
|
||||
QualityEvaluation qualityEvaluation = new QualityEvaluation();
|
||||
qualityEvaluation.setLawId(form.getLawId()) ;
|
||||
qualityEvaluation.setUserId(form.getUserId()) ;
|
||||
qualityEvaluation.setEvaluationType(form.getEvaluationType());
|
||||
|
||||
iQualityEvaluationService.getEvaluationForm(qualityEvaluation);
|
||||
List<QualityEvaluation> evaluationForm = iQualityEvaluationService.getEvaluationForm(qualityEvaluation);
|
||||
|
||||
return null;
|
||||
return Result.success(evaluationForm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
@@ -23,4 +23,7 @@ public interface QualityEvaluationDao extends BaseMapper<QualityEvaluation> {
|
||||
|
||||
|
||||
public IPage<QualityEvaluation> getHistory(IPage<QualityEvaluation> page,@Param(Constants.WRAPPER) QueryWrapper<QualityEvaluation> queryWrapper);
|
||||
|
||||
public List<QualityEvaluation> getEvaluationForm(@Param(Constants.WRAPPER) QueryWrapper<QualityEvaluation> queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
+7
-2
@@ -77,13 +77,18 @@ public class QualityEvaluation extends BaseEntity {
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime modifyTime;
|
||||
private Date modifyTime;
|
||||
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "指标名称")
|
||||
private String indexTitle;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer page;
|
||||
|
||||
|
||||
+28
-24
@@ -58,6 +58,7 @@ public class QualityEvaluationServiceImpl extends ServiceImpl<QualityEvaluationD
|
||||
List<QualityEvaluation> tableData = form.getTableData();
|
||||
tableData.forEach(item->{
|
||||
|
||||
item.setModifyTime(new Date());
|
||||
item.setId( UUIDUtils.randomUUID20());
|
||||
if ("number".equals(item.getValueType()) ){
|
||||
item.setScore(String.valueOf (Double.valueOf(item.getScore()) * 2) );
|
||||
@@ -83,6 +84,7 @@ public class QualityEvaluationServiceImpl extends ServiceImpl<QualityEvaluationD
|
||||
queryWrapper.eq("evaluation_type",query.getEvaluationType());
|
||||
}
|
||||
|
||||
queryWrapper.eq("`index`.value_type","number");
|
||||
//sql计算每个用户的评分
|
||||
return qualityEvaluationDao.getHistory(page,queryWrapper);
|
||||
|
||||
@@ -95,9 +97,6 @@ public class QualityEvaluationServiceImpl extends ServiceImpl<QualityEvaluationD
|
||||
public List<QualityEvaluation> getEvaluationForm(QualityEvaluation query) {
|
||||
QueryWrapper<QualityEvaluation> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.select("UNAME as userName","score","reason","create_time as createTime","modify_time as modifyTime","idx.value_type as valueType")
|
||||
.last("JOIN ts_user user ON quality_evaluation.user_id = user.USID" +
|
||||
"LEFT JOIN evaluation_index as idx on iex.id=quality_evaluation.evaluation_index");
|
||||
|
||||
|
||||
if (query.getLawId()!=null){
|
||||
@@ -113,8 +112,7 @@ public class QualityEvaluationServiceImpl extends ServiceImpl<QualityEvaluationD
|
||||
queryWrapper.eq("evaluation_type",query.getEvaluationType());
|
||||
}
|
||||
|
||||
|
||||
return this.baseMapper.selectList(queryWrapper);
|
||||
return qualityEvaluationDao.getEvaluationForm(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,33 +122,39 @@ public class QualityEvaluationServiceImpl extends ServiceImpl<QualityEvaluationD
|
||||
@Override
|
||||
public Map<String, Double> getScore(String lawId) {
|
||||
|
||||
|
||||
QueryWrapper<QualityEvaluation> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("law_id",lawId);
|
||||
List<QualityEvaluation> list = this.list(queryWrapper);
|
||||
queryWrapper.eq("law_id",lawId)
|
||||
.eq("`index`.value_type","number");
|
||||
|
||||
// List<QualityEvaluation> list = this.list(queryWrapper);
|
||||
|
||||
Page<QualityEvaluation> page = new Page<>(1, 1000);
|
||||
|
||||
List<QualityEvaluation> list = qualityEvaluationDao.getHistory(page, queryWrapper).getRecords();
|
||||
|
||||
return list.stream()
|
||||
.collect(Collectors.groupingBy(QualityEvaluation::getEvaluationType,
|
||||
Collectors.averagingDouble(item -> getScoreSingle(item))));
|
||||
Collectors.averagingDouble(item ->Double.valueOf(item.getScore()) )));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Double getScoreSingle(QualityEvaluation item){
|
||||
|
||||
QueryWrapper<EvaluationIndex> indexQuery = new QueryWrapper<>();
|
||||
indexQuery.select("code","weight");
|
||||
|
||||
List<EvaluationIndex> indexList = iEvaluationIndexService.list(indexQuery);
|
||||
|
||||
Map<String, Float> weightMap = indexList.stream()
|
||||
.collect(Collectors.toMap(EvaluationIndex::getCode, obj -> Float.valueOf(obj.getWeight())));
|
||||
|
||||
|
||||
|
||||
String score = item.getScore();
|
||||
return ((score == null || (Float.valueOf(item.getScore()) < 0.0)) ? 0.0 : Float.valueOf(score) * weightMap.get(item.getEvaluationIndex()));
|
||||
}
|
||||
// private Double getScoreSingle(QualityEvaluation item){
|
||||
//
|
||||
// QueryWrapper<EvaluationIndex> indexQuery = new QueryWrapper<>();
|
||||
// indexQuery.select("code","weight")
|
||||
// .eq("value_type","number");
|
||||
//
|
||||
// List<EvaluationIndex> indexList = iEvaluationIndexService.list(indexQuery);
|
||||
//
|
||||
// Map<String, Float> weightMap = indexList.stream()
|
||||
// .collect(Collectors.toMap(EvaluationIndex::getCode, obj -> Float.valueOf(obj.getWeight())));
|
||||
//
|
||||
//
|
||||
//
|
||||
// String score = item.getScore();
|
||||
// return (score == null && !weightMap.containsKey(item.getEvaluationIndex()) ) ? 0.0 : Float.valueOf(score) * weightMap.get(item.getEvaluationIndex());
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public class FieldConvertUtil {
|
||||
List<String> timeList = Arrays.asList(timeStr.split(","));
|
||||
|
||||
List<String> collect = timeList.stream()
|
||||
.map(item -> "str_to_date('" + item + "','%Y-%m-%d %H:%i:%s')")
|
||||
.map(item -> "str_to_date('" + item + "','%Y-%m-%d')")
|
||||
.collect(Collectors.toList());
|
||||
timeStr ="concat(" + String.join(", \',\' ,", collect) + ")";
|
||||
} else {
|
||||
@@ -143,7 +143,7 @@ public class FieldConvertUtil {
|
||||
String mustValue = "'"+ UUIDUtils.randomUUID20() + "','" + id + "','0','"
|
||||
+ LoginUserUtil.getUserId() + "'";
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String nowTime = sf.format(date);
|
||||
String timeValue = "," + changeTimeValue(nowTime);
|
||||
mustValue += timeValue + timeValue;
|
||||
|
||||
+34
-5
@@ -8,17 +8,46 @@
|
||||
SELECT
|
||||
`user`.UNAME AS userName,
|
||||
eva.user_id,
|
||||
avg(eva.score * iex.weight) AS score,
|
||||
iex.index_type as valueType
|
||||
`index`.value_type as valueType,
|
||||
eva.evaluation_type as evaluationType,
|
||||
avg(eva.score * `index`.weight) AS score,
|
||||
min(eva.create_time) as createTiem,
|
||||
max(eva.modify_time) as modifyTime
|
||||
FROM
|
||||
quality_evaluation AS eva
|
||||
LEFT JOIN ts_user `user` ON eva.user_id = `user`.USID
|
||||
LEFT JOIN evaluation_index AS iex ON eva.evaluation_index = iex.id
|
||||
LEFT JOIN evaluation_index AS `index` ON eva.evaluation_index = `index`.id
|
||||
${ew.customSqlSegment}
|
||||
GROUP BY
|
||||
userName,
|
||||
eva.user_id,
|
||||
index_type
|
||||
index_type,
|
||||
valueType,
|
||||
evaluationType
|
||||
ORDER BY modifyTime DESC
|
||||
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="getEvaluationForm"
|
||||
resultType="com.adc.da.slrs.sarEnterpriseStandardEvaluation.entity.QualityEvaluation">
|
||||
|
||||
SELECT
|
||||
UNAME AS userName,
|
||||
score,
|
||||
reason,
|
||||
evaluation_index as evaluationIndex,
|
||||
quality_evaluation.create_time AS createTime,
|
||||
quality_evaluation.modify_time AS modifyTime,
|
||||
`index`.value_type AS valueType,
|
||||
`index`.three_index_title as indexTitle
|
||||
FROM
|
||||
quality_evaluation
|
||||
LEFT JOIN ts_user `user` ON quality_evaluation.user_id = `user` .USID
|
||||
LEFT JOIN evaluation_index AS `index` ON `index`.id = quality_evaluation.evaluation_index
|
||||
${ew.customSqlSegment}
|
||||
|
||||
ORDER BY `index`.index_sort
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user