Browse Source

fix: 完善问题赋分

main
wxc 1 year ago
parent
commit
1a3d9f4eb8
  1. 3
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfileDepartController.java
  2. 3
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java
  3. 2
      src/main/java/com/biutag/supervision/mapper/ProfileDepartMapper.java
  4. 2
      src/main/java/com/biutag/supervision/mapper/ProfilePoliceMapper.java
  5. 2
      src/main/java/com/biutag/supervision/pojo/entity/NegativeScoreDepart.java
  6. 2
      src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java
  7. 2
      src/main/java/com/biutag/supervision/pojo/param/DepartNegativeQueryParam.java
  8. 2
      src/main/java/com/biutag/supervision/pojo/param/DepartPoliceQueryParam.java
  9. 4
      src/main/java/com/biutag/supervision/service/NegativeProblemRelationService.java
  10. 4
      src/main/java/com/biutag/supervision/service/NegativeScoreDepartService.java
  11. 4
      src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java
  12. 26
      src/main/java/com/biutag/supervision/service/NegativeScoreService.java
  13. 2
      src/main/resources/mapper/ProfileDepartMapper.xml
  14. 1
      src/main/resources/mapper/ProfilePoliceMapper.xml

3
src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfileDepartController.java

@ -58,7 +58,8 @@ public class ProfileDepartController {
beginTime = param.getCrtTime().get(0);
endTime = param.getCrtTime().get(1);
}
Page<DepartNegativeModel> page = profileDepartMapper.queryDepartNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime, param.getDepartName(), param.getDepartId());
Page<DepartNegativeModel> page = profileDepartMapper.queryDepartNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime,
param.getDepartName(), param.getDepartId(), param.getDepartGroupId());
long l = System.currentTimeMillis();
for (DepartNegativeModel item : page.getRecords()) {
List<Object> result = negativeScoreService.calculateDepartScore(beginTime, endTime, item.getDepartId());

3
src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java

@ -62,7 +62,8 @@ public class ProfilePoliceController {
beginTime = param.getCrtTime().get(0);
endTime = param.getCrtTime().get(1);
}
Page<PoliceNegativeModel> page = profilePoliceMapper.queryPoliceNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime, param.getName(),param.getEmpNo(), param.getDepartId());
Page<PoliceNegativeModel> page = profilePoliceMapper.queryPoliceNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime,
param.getName(),param.getEmpNo(), param.getDepartId(), param.getDepartGroupId());
long l = System.currentTimeMillis();
for (PoliceNegativeModel item : page.getRecords()) {
List<Object> result = negativeScoreService.calculatePoliceScore(beginTime, endTime, item.getIdCode());

2
src/main/java/com/biutag/supervision/mapper/ProfileDepartMapper.java

@ -14,7 +14,7 @@ import java.util.List;
*/
public interface ProfileDepartMapper {
Page<DepartNegativeModel> queryDepartNegative(Page<DepartNegativeModel> page, Date beginTime, Date endTime, String departName, String departId);
Page<DepartNegativeModel> queryDepartNegative(Page<DepartNegativeModel> page, Date beginTime, Date endTime, String departName, String departId, String departGroupId);
List<BarItem> selectPoliceNegativeCount(String departId, Date beginTime, Date endTime);

2
src/main/java/com/biutag/supervision/mapper/ProfilePoliceMapper.java

@ -14,7 +14,7 @@ import java.util.List;
*/
public interface ProfilePoliceMapper {
Page<PoliceNegativeModel> queryPoliceNegative(Page<PoliceNegativeModel> page, Date beginTime, Date endTime, String name, String empNo, String departId);
Page<PoliceNegativeModel> queryPoliceNegative(Page<PoliceNegativeModel> page, Date beginTime, Date endTime, String name, String empNo, String departId, String departGroupId);
List<BarItem> selectProblemType(String idCode, Date beginTime, Date endTime);

2
src/main/java/com/biutag/supervision/pojo/entity/NegativeScoreDepart.java

@ -37,4 +37,6 @@ public class NegativeScoreDepart {
@TableField("expression")
private String expression;
private String departGroupId;
}

2
src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java

@ -33,4 +33,6 @@ public class NegativeScorePolice {
private String businessTypeCode;
private String departGroupId;
}

2
src/main/java/com/biutag/supervision/pojo/param/DepartNegativeQueryParam.java

@ -20,4 +20,6 @@ public class DepartNegativeQueryParam extends BasePage {
private List<Date> crtTime = new ArrayList<>();
private String departName;
private String departId;
private String departGroupId;
}

2
src/main/java/com/biutag/supervision/pojo/param/DepartPoliceQueryParam.java

@ -21,4 +21,6 @@ public class DepartPoliceQueryParam extends BasePage {
private String name;
private String empNo;
private String departId;
private String departGroupId;
}

4
src/main/java/com/biutag/supervision/service/NegativeProblemRelationService.java

@ -7,11 +7,15 @@ import com.biutag.supervision.pojo.entity.NegativeProblemRelation;
import com.biutag.supervision.mapper.NegativeProblemRelationMapper;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
@Service
public class NegativeProblemRelationService extends ServiceImpl<NegativeProblemRelationMapper, NegativeProblemRelation> {
public List<NegativeProblemRelation> list(Collection<String> negativeIds) {
return list(new LambdaQueryWrapper<NegativeProblemRelation>().in(NegativeProblemRelation::getNegativeId, negativeIds));
}
public List<NegativeProblemRelation> list(String negativeId, String blameId) {
return list(new LambdaQueryWrapper<NegativeProblemRelation>().eq(NegativeProblemRelation::getNegativeId, negativeId).eq(NegativeProblemRelation::getBlameId, blameId));
}

4
src/main/java/com/biutag/supervision/service/NegativeScoreDepartService.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.mapper.NegativeScoreDepartMapper;
import com.biutag.supervision.pojo.entity.NegativeScoreDepart;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import org.springframework.stereotype.Service;
import java.util.Date;
@ -12,8 +13,9 @@ import java.util.List;
@Service
public class NegativeScoreDepartService extends ServiceImpl<NegativeScoreDepartMapper, NegativeScoreDepart> {
public List<NegativeScoreDepart> list(Date beginTime, Date endTime) {
public List<NegativeScoreDepart> list(Date beginTime, Date endTime, String departGroupId) {
return list(new LambdaQueryWrapper<NegativeScoreDepart>()
.eq(NegativeScoreDepart::getDepartGroupId, departGroupId)
.between(NegativeScoreDepart::getDiscoveryTime, beginTime, endTime));
}

4
src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java

@ -16,9 +16,9 @@ public class NegativeScorePoliceService extends ServiceImpl<NegativeScorePoliceM
return list(new LambdaQueryWrapper<NegativeScorePolice>().eq(NegativeScorePolice::getNegativeId, negativeId));
}
public List<NegativeScorePolice> list(Date beginTime, Date endTime) {
public List<NegativeScorePolice> list(Date beginTime, Date endTime, String departGroupId) {
return list(new LambdaQueryWrapper<NegativeScorePolice>()
.eq(NegativeScorePolice::getDepartGroupId, departGroupId)
.between(NegativeScorePolice::getDiscoveryTime, beginTime, endTime));
}

26
src/main/java/com/biutag/supervision/service/NegativeScoreService.java

@ -50,20 +50,30 @@ public class NegativeScoreService {
flag.set(true);
System.out.println("calculateScore-------------------------------------------------");
List<NegativeBlame> negativeBlames = blameMapper.selectVerifyTrue();
if (negativeBlames.isEmpty()) {
flag.set(false);
return;
}
String formula = "%s + (%s * %s) + (%s * %s)";
List<NegativeScoreDepart> scoreDeparts = new ArrayList<>();
negativeScorePoliceService.remove(new LambdaQueryWrapper<>());
negativeScoreDepartService.remove(new LambdaQueryWrapper<>());
Set<String> negativeIds = negativeBlames.stream().map(NegativeBlame::getNegativeId).collect(Collectors.toSet());
List<NegativeProblemRelation> problemsAll = problemRelationService.list(negativeIds);
List<Negative> negatives = negativeService.listByIds(negativeIds);
negativeBlames.forEach(blame -> {
Negative negative = negativeService.getById(blame.getNegativeId());
Negative negative = negatives.stream().filter(item -> item.getId().equals(blame.getNegativeId())).findFirst().get();
SupDepart depart = departService.getById(negative.getInvolveDepartId());
NegativeScorePolice negativeScorePolice = new NegativeScorePolice()
.setNegativeId(blame.getNegativeId())
.setIdCode(blame.getBlameIdCode())
.setDiscoveryTime(negative.getDiscoveryTime())
.setIdCode(blame.getBlameIdCode())
.setBusinessTypeCode(negative.getBusinessTypeCode())
.setDepartGroupId(depart.getStatisticsGroupId())
.setCreateTime(LocalDateTime.now());
List<NegativeProblemRelation> problems = problemRelationService.list(blame.getNegativeId(), blame.getBlameId());
List<NegativeProblemRelation> problems = problemsAll.stream().filter(item -> item.getNegativeId().equals(blame.getNegativeId()) &&
item.getBlameId().equals(blame.getBlameId())).toList();
List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList();
if (codes.isEmpty()) {
return;
@ -83,6 +93,7 @@ public class NegativeScoreService {
double score = NumberUtil.roundHalfEven(calculate, 2).doubleValue();
negativeScorePolice.setScore(score)
.setExpression(expression);
negativeScorePoliceService.save(negativeScorePolice);
NegativeScoreDepart scoreDepart = scoreDeparts.stream().filter(item -> item.getNegativeId().equals(negative.getId())).findFirst().orElse(null);
if (Objects.isNull(scoreDepart)) {
@ -187,6 +198,8 @@ public class NegativeScoreService {
return 50 + (diff * 15);
}
private final SupDepartService departService;
// 平均问题数 = 单个业务问题数 / 业务涉及人数
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
@ -203,9 +216,11 @@ public class NegativeScoreService {
* @return
*/
public List<Object> calculatePoliceScore(Date beginTime, Date endTime, String idCode) {
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(beginTime, endTime);
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum();
SupPolice police = policeService.getByIdCode(idCode);
SupDepart depart = departService.getById(police.getOrgId());
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(beginTime, endTime, depart.getStatisticsGroupId());
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum();
List<String> expressionArr = new ArrayList<>();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {
List<NegativeScorePolice> businessScorePolice = scorePolices.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList();
@ -251,7 +266,8 @@ public class NegativeScoreService {
*/
public List<Object> calculateDepartScore(Date beginTime, Date endTime, String departId) {
List<NegativeScoreDepart> scoreDeparts = negativeScoreDepartService.list(beginTime, endTime);
SupDepart depart = departService.getById(departId);
List<NegativeScoreDepart> scoreDeparts = negativeScoreDepartService.list(beginTime, endTime, depart.getStatisticsGroupId());
Double totalScore = scoreDeparts.stream().mapToDouble(NegativeScoreDepart::getScore).sum();
List<String> expressionArr = new ArrayList<>();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {

2
src/main/resources/mapper/ProfileDepartMapper.xml

@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND n.discoveryTime BETWEEN #{beginTime} AND #{endTime}
LEFT JOIN negative_blame nb ON n.id = nb.negativeId
WHERE
1 = 1
d.statistics_group_id = #{departGroupId}
<if test="departName != null and departName != ''">
AND d.short_name like concat('%', #{departName}, '%')
</if>

1
src/main/resources/mapper/ProfilePoliceMapper.xml

@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE
n.id_code is not null
AND n.discovery_time BETWEEN #{beginTime} AND #{endTime}
AND d.statistics_group_id = #{departGroupId}
<if test="name != null and name != ''">
AND p.name like concat('%', #{name}, '%')
</if>

Loading…
Cancel
Save