完成考核细则

This commit is contained in:
TS-QD1 2023-05-14 00:28:14 +08:00
parent 12217c5eb9
commit cb9847a2da
16 changed files with 121 additions and 33 deletions

View File

@ -86,6 +86,11 @@ public class KpiController extends AbstractController {
return departmentService.list(); return departmentService.list();
} }
@GetMapping("list-znbm")
public List<DepartmentDTO> listZnbm() {
return departmentService.listZnbm();
}
@GetMapping("list-community-case-count") @GetMapping("list-community-case-count")
public List<CommunityCaseCountDTO> listCommunityCaseCount(@RequestParam(name = "areaId", required = false) String areaId, public List<CommunityCaseCountDTO> listCommunityCaseCount(@RequestParam(name = "areaId", required = false) String areaId,
@RequestParam(name = "communityId", required = false) String communityId, @RequestParam(name = "communityId", required = false) String communityId,

View File

@ -36,7 +36,7 @@ public class KpiKhxzController extends AbstractController {
return new SuccessResult(); return new SuccessResult();
} }
@GetMapping("update/kh-year/{khYear}/kh-month/{khMonth}") @GetMapping("reset-update-process")
public void resetUpdateProcess() { public void resetUpdateProcess() {
KpiUpdateMonitor.getInstance().setTaskCount(0); KpiUpdateMonitor.getInstance().setTaskCount(0);
} }
@ -112,8 +112,6 @@ public class KpiKhxzController extends AbstractController {
kpiKhxzService.exportWgz(httpServletResponse, queryMap); kpiKhxzService.exportWgz(httpServletResponse, queryMap);
} }
@PutMapping("update-wgz") @PutMapping("update-wgz")
public synchronized SuccessResult updateWgz(@RequestBody KpiUpdateVO kpiUpdateVO) { public synchronized SuccessResult updateWgz(@RequestBody KpiUpdateVO kpiUpdateVO) {
kpiKhxzService.updateWgz(kpiUpdateVO); kpiKhxzService.updateWgz(kpiUpdateVO);
@ -132,4 +130,10 @@ public class KpiKhxzController extends AbstractController {
kpiKhxzService.exportZnbm(httpServletResponse, queryMap); kpiKhxzService.exportZnbm(httpServletResponse, queryMap);
} }
@PutMapping("update-znbm")
public synchronized SuccessResult updateZnbm(@RequestBody KpiUpdateVO kpiUpdateVO) {
kpiKhxzService.updateZnbm(kpiUpdateVO);
return new SuccessResult();
}
} }

View File

@ -21,4 +21,7 @@ public interface IKpiKhxzZnbmDao {
void updateIJ(Map<String, Object> updateParams); void updateIJ(Map<String, Object> updateParams);
List<KpiKhxzZnbmDTO> list(Map<String, Object> params); List<KpiKhxzZnbmDTO> list(Map<String, Object> params);
void update(Map<String, Object> params);
} }

View File

@ -9,6 +9,7 @@ public class NPersonDayCountPO {
private Integer isSigninLate; private Integer isSigninLate;
private Integer isSignout; private Integer isSignout;
private Integer isSignoutEarly; private Integer isSignoutEarly;
private Double workDistance;
private Integer isHoliday; private Integer isHoliday;
private Double dayScore; private Double dayScore;
@ -68,6 +69,14 @@ public class NPersonDayCountPO {
this.isSignoutEarly = isSignoutEarly; this.isSignoutEarly = isSignoutEarly;
} }
public Double getWorkDistance() {
return workDistance;
}
public void setWorkDistance(Double workDistance) {
this.workDistance = workDistance;
}
public Integer getIsHoliday() { public Integer getIsHoliday() {
return isHoliday; return isHoliday;
} }

View File

@ -14,5 +14,7 @@ public interface IDepartmentService {
List<DepartmentDTO> list(); List<DepartmentDTO> list();
List<DepartmentDTO> listZnbm();
} }

View File

@ -42,6 +42,5 @@ public interface IKpiKhxzService {
void exportZnbm(HttpServletResponse httpServletResponse, Map<String, Object> queryMap) throws IOException; void exportZnbm(HttpServletResponse httpServletResponse, Map<String, Object> queryMap) throws IOException;
void updateZnbm(KpiUpdateVO kpiUpdateVO);
} }

View File

@ -5,11 +5,13 @@ import com.cm.bigdata.pojo.dtos.kpi.DepartmentDTO;
import com.cm.bigdata.pojo.pos.kpi.DepartmentPO; import com.cm.bigdata.pojo.pos.kpi.DepartmentPO;
import com.cm.bigdata.pojo.pos.kpi.DepartmentUserPO; import com.cm.bigdata.pojo.pos.kpi.DepartmentUserPO;
import com.cm.bigdata.service.kpi.IDepartmentService; import com.cm.bigdata.service.kpi.IDepartmentService;
import com.cm.bigdata.utils.KpiUtil;
import com.mchange.v2.beans.BeansUtils; import com.mchange.v2.beans.BeansUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -41,4 +43,16 @@ public class DepartmentServiceImpl implements IDepartmentService {
return departmentDTO; return departmentDTO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override
public List<DepartmentDTO> listZnbm() {
Map<String, Object> params = new HashMap<>();
params.put("departmentParentId", "0");
params.put("excludeDepartmentIds", Arrays.asList(KpiUtil.ZF_DEPARTMENT_ID, KpiUtil.GA_DEPARTMENT_ID));
return listPO(params).stream().map(departmentPO -> {
DepartmentDTO departmentDTO = new DepartmentDTO();
BeanUtils.copyProperties(departmentPO, departmentDTO);
return departmentDTO;
}).collect(Collectors.toList());
}
} }

View File

@ -49,61 +49,56 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
@Override @Override
public void update(Integer khYear, Integer khMonth) { public void update(Integer khYear, Integer khMonth) {
// KpiUpdateMonitor.getInstance().setTaskCount(0);
// kpiService.updateCommunityBossDayCount(khYear, khMonth, 4);
// kpiKhxzWgyTask.update(khYear, khMonth, 4);
// kpiService.updateNPersonDayCount(KpiUtil.ZGY_ROLE_ID, khYear, khMonth);
// kpiKhxzDdyTask.update(khYear, khMonth);
// khKhxzZfGaTask.update(khYear, khMonth);
// kpiKhxzWgzTask.update(khYear, khMonth);
// kpiKhxzZnbmTask.update(khYear, khMonth);
// 这个数要和下面的任务数之和一致 // 这个数要和下面的任务数之和一致
KpiUpdateMonitor.getInstance().setTaskCount(28); KpiUpdateMonitor.getInstance().setTaskCount(29);
// 开始更新 // 开始更新
Executors.newSingleThreadExecutor().execute(() -> { Executors.newSingleThreadExecutor().execute(() -> {
// 更新案件1任务 // 更新案件1任务
kpiService.updateCaseCount(); kpiService.updateCaseCount();
KpiUpdateMonitor.getInstance().complete(); KpiUpdateMonitor.getInstance().complete();
// 更新4级网格员日统计1任务 // 更新4级网格员日统计1任务
kpiService.updateCommunityBossDayCount(khYear, khMonth, 3); kpiService.updateCommunityBossDayCount(khYear, khMonth, 3);
KpiUpdateMonitor.getInstance().complete(); KpiUpdateMonitor.getInstance().complete();
// 更新5级网格员日统计1任务 // 更新5级网格员日统计1任务
kpiService.updateCommunityBossDayCount(khYear, khMonth, 4); kpiService.updateCommunityBossDayCount(khYear, khMonth, 4);
KpiUpdateMonitor.getInstance().complete(); KpiUpdateMonitor.getInstance().complete();
// 更新调度员日统计1任务 // 更新调度员日统计1任务
kpiService.updateNPersonDayCount(KpiUtil.DDY_ROLE_ID, khYear, khMonth); kpiService.updateNPersonDayCount(KpiUtil.DDY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete(); KpiUpdateMonitor.getInstance().complete();
// 更新专管员1任务 // 更新专管员1任务
kpiService.updateNPersonDayCount(KpiUtil.ZGY_ROLE_ID, khYear, khMonth); kpiService.updateNPersonDayCount(KpiUtil.ZGY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete(); KpiUpdateMonitor.getInstance().complete();
// kpiKhxzWgyTask.update(khYear, khMonth, 3);
// kpiKhxzWgyTask.update(khYear, khMonth, 4);
// kpiKhxzDdyTask.update(khYear, khMonth);
// khKhxzZfGaTask.update(khYear, khMonth);
// kpiKhxzWgzTask.update(khYear, khMonth);
// kpiKhxzZnbmTask.update(khYear, khMonth);
executorService.execute(() -> { executorService.execute(() -> {
// 更新4级网格员4任务 // 更新4级网格员4任务
kpiKhxzWgyTask.update(khYear, khMonth, 3); kpiKhxzWgyTask.update(khYear, khMonth, 3);
}); });
executorService.execute(() -> { executorService.execute(() -> {
// 更新5级网格员4个任务 // 更新5级网格员4个任务
kpiKhxzWgyTask.update(khYear, khMonth, 4); kpiKhxzWgyTask.update(khYear, khMonth, 4);
}); });
executorService.execute(() -> { executorService.execute(() -> {
// 调度员4任务 // 调度员4任务
kpiKhxzDdyTask.update(khYear, khMonth); kpiKhxzDdyTask.update(khYear, khMonth);
}); });
executorService.execute(() -> { executorService.execute(() -> {
// 执法公安4任务 // 执法公安5任务
khKhxzZfGaTask.update(khYear, khMonth); khKhxzZfGaTask.update(khYear, khMonth);
}); });
executorService.execute(() -> { executorService.execute(() -> {
// 网格长3任务 // 网格长3任务
kpiKhxzWgzTask.update(khYear, khMonth); kpiKhxzWgzTask.update(khYear, khMonth);
}); });
executorService.execute(() -> { executorService.execute(() -> {
// 职能部门4任务 // 职能部门4任务
kpiKhxzZnbmTask.update(khYear, khMonth); kpiKhxzZnbmTask.update(khYear, khMonth);
@ -190,4 +185,11 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
public void exportZnbm(HttpServletResponse httpServletResponse, Map<String, Object> queryMap) throws IOException { public void exportZnbm(HttpServletResponse httpServletResponse, Map<String, Object> queryMap) throws IOException {
ExcelExportUtil.simple(httpServletResponse, "职能部门考核细则", listZnbm(queryMap), KpiKhxzZnbmDTO.class); ExcelExportUtil.simple(httpServletResponse, "职能部门考核细则", listZnbm(queryMap), KpiKhxzZnbmDTO.class);
} }
@Override
public void updateZnbm(KpiUpdateVO kpiUpdateVO) {
kpiUpdateVO.getDatas().forEach(params -> {
kpiKhxzZnbmDao.update(params);
});
}
} }

View File

@ -92,6 +92,7 @@ public class KpiServiceImpl implements IKpiService {
queryParams.put("isSigninLate", isSigninLate); queryParams.put("isSigninLate", isSigninLate);
queryParams.put("isSignout", isSignout); queryParams.put("isSignout", isSignout);
queryParams.put("isSignoutEarly", isSignoutEarly); queryParams.put("isSignoutEarly", isSignoutEarly);
queryParams.put("workDistance", workDistance); queryParams.put("workDistance", workDistance);
queryParams.put("populationCount", populationCount); queryParams.put("populationCount", populationCount);
queryParams.put("savePopulationCount", savePopulationCount); queryParams.put("savePopulationCount", savePopulationCount);
@ -157,7 +158,7 @@ public class KpiServiceImpl implements IKpiService {
queryParams.put("dayScore", KpiScoreUtil.getDdyDayScore(isSignin, isSigninLate, isSignout, isSignoutEarly, isHoliday)); queryParams.put("dayScore", KpiScoreUtil.getDdyDayScore(isSignin, isSigninLate, isSignout, isSignoutEarly, isHoliday));
} }
if (StringUtils.equals(roleId, KpiUtil.ZGY_ROLE_ID)) { if (StringUtils.equals(roleId, KpiUtil.ZGY_ROLE_ID)) {
queryParams.put("dayScore", KpiScoreUtil.getZgyDayScore(isSignin, isSigninLate, isSignout, isSignoutEarly, isHoliday)); queryParams.put("dayScore", KpiScoreUtil.getZgyDayScore(isSignin, isSigninLate, isSignout, isSignoutEarly, workDistance, isHoliday));
} }
queryParams.put("isHoliday", isHoliday); queryParams.put("isHoliday", isHoliday);
kpiDao.saveNPersonDayCount(queryParams); kpiDao.saveNPersonDayCount(queryParams);

View File

@ -48,6 +48,7 @@ public class KpiKhxzZfGaTask {
params.put("khYear", khYear); params.put("khYear", khYear);
params.put("khMonth", khMonth); params.put("khMonth", khMonth);
kpiKhxzZfGaDao.delete(params); kpiKhxzZfGaDao.delete(params);
KpiUpdateMonitor.getInstance().complete();
} }
private void updateBase(String departmentId, int khYear, int khMonth) { private void updateBase(String departmentId, int khYear, int khMonth) {
@ -65,6 +66,7 @@ public class KpiKhxzZfGaTask {
saveParams.put("khMonth", khMonth); saveParams.put("khMonth", khMonth);
kpiKhxzZfGaDao.save(saveParams); kpiKhxzZfGaDao.save(saveParams);
}); });
KpiUpdateMonitor.getInstance().complete();
} }
private List<String> listUserId(int khYear, int khMonth) { private List<String> listUserId(int khYear, int khMonth) {

View File

@ -54,7 +54,7 @@ public class KpiKhxzZnbmCDEFGRunnable implements Runnable {
updateParams.put("D", inspectCount); updateParams.put("D", inspectCount);
updateParams.put("E", unInspectCount); updateParams.put("E", unInspectCount);
updateParams.put("F", inspectCount * 200D); updateParams.put("F", inspectCount * 200D);
updateParams.put("G", 60D / handleCount * inspectCount); updateParams.put("G", handleCount == 0 ? 0 : 60D / handleCount * inspectCount);
updateParams.put("khYear", khYear); updateParams.put("khYear", khYear);
updateParams.put("khMonth", khMonth); updateParams.put("khMonth", khMonth);
updateParams.put("userId", userId); updateParams.put("userId", userId);

View File

@ -9,6 +9,7 @@ public class KpiScoreUtil {
private static double DDY_SIGNOUT_SCORE = 15D; private static double DDY_SIGNOUT_SCORE = 15D;
private static double ZGY_SIGNIN_SCORE = 25D; private static double ZGY_SIGNIN_SCORE = 25D;
private static double ZGY_SIGNOUT_SCORE = 25D; private static double ZGY_SIGNOUT_SCORE = 25D;
private static double ZGY_DISTANCE_SCORE = 50D;
public static double getWgyDayScore(int isSignin, int isSigninLate, int isSignout, int isSignoutEarly, double workDistance, int isHoliday) { public static double getWgyDayScore(int isSignin, int isSigninLate, int isSignout, int isSignoutEarly, double workDistance, int isHoliday) {
@ -24,7 +25,8 @@ public class KpiScoreUtil {
if (isSignout == 1) { if (isSignout == 1) {
signoutScore += isSignoutEarly == 1 ? WGY_SIGNOUT_SCORE / 2 : WGY_SIGNOUT_SCORE; signoutScore += isSignoutEarly == 1 ? WGY_SIGNOUT_SCORE / 2 : WGY_SIGNOUT_SCORE;
} }
if (workDistance > 0) { // 有签到签退或轨迹的都算有轨迹
if (isSignin == 1 || isSignout == 1 || workDistance > 0) {
distanceScore = WGY_DISTANCE_SCORE; distanceScore = WGY_DISTANCE_SCORE;
} }
return signinScore + signoutScore + distanceScore; return signinScore + signoutScore + distanceScore;
@ -45,19 +47,24 @@ public class KpiScoreUtil {
return signinScore + signoutScore; return signinScore + signoutScore;
} }
public static double getZgyDayScore(int isSignin, int isSigninLate, int isSignout, int isSignoutEarly, int isHoliday) { public static double getZgyDayScore(int isSignin, int isSigninLate, int isSignout, int isSignoutEarly, double workDistance, int isHoliday) {
if (isHoliday == 1) { if (isHoliday == 1) {
return 0; return 0;
} }
double signinScore = 0D; double signinScore = 0D;
double signoutScore = 0D; double signoutScore = 0D;
double distanceScore = 0D;
if (isSignin == 1) { if (isSignin == 1) {
signinScore += isSigninLate == 1 ? ZGY_SIGNIN_SCORE / 2 : ZGY_SIGNIN_SCORE; signinScore += isSigninLate == 1 ? ZGY_SIGNIN_SCORE / 2 : ZGY_SIGNIN_SCORE;
} }
if (isSignout == 1) { if (isSignout == 1) {
signoutScore += isSignoutEarly == 1 ? ZGY_SIGNOUT_SCORE / 2 : ZGY_SIGNOUT_SCORE; signoutScore += isSignoutEarly == 1 ? ZGY_SIGNOUT_SCORE / 2 : ZGY_SIGNOUT_SCORE;
} }
return signinScore + signoutScore; // 有签到签退或轨迹的都算有轨迹
if (isSignin == 1 || isSignout == 1 || workDistance > 0) {
distanceScore = ZGY_DISTANCE_SCORE;
}
return signinScore + signoutScore + distanceScore;
} }

View File

@ -125,15 +125,15 @@ public class KpiUtil {
* *
* @param userLocationService * @param userLocationService
* @param userId * @param userId
* @param day af535c78-f0ba-4ccf-891b-cf7c6e42e9e8 * @param day
* @return * @return
*/ */
public static Double calculateWorkDistance(IUserLocationService userLocationService, String userId, String day) { public static Double calculateWorkDistance(IUserLocationService userLocationService, String userId, String day) {
double workDistance = 0D; double workDistance = 0D;
if (!StringUtils.equals(userId, "af535c78-f0ba-4ccf-891b-cf7c6e42e9e8")) {
return workDistance;
}
List<UserLocationPO> userLocationPOS = userLocationService.listPOByUserIdAndDate(userId, day); List<UserLocationPO> userLocationPOS = userLocationService.listPOByUserIdAndDate(userId, day);
// 由于轨迹不好统计为了方便只要有定位记录就算有轨迹返回数量后期在根据情况调整
return (double) userLocationPOS.size();
/**
Point tempPoint = null; Point tempPoint = null;
for (UserLocationPO userLocationPO : userLocationPOS) { for (UserLocationPO userLocationPO : userLocationPOS) {
Point point = new Point(Double.parseDouble(userLocationPO.getUserLatitude()), Double.parseDouble(userLocationPO.getUserLongitude())); Point point = new Point(Double.parseDouble(userLocationPO.getUserLatitude()), Double.parseDouble(userLocationPO.getUserLongitude()));
@ -145,6 +145,7 @@ public class KpiUtil {
tempPoint = point; tempPoint = point;
} }
return workDistance; return workDistance;
**/
} }
public static Map<String, Integer> mapPopulationCount(IBasePopulationInfoService basePopulationInfoService, List<String> userIds) { public static Map<String, Integer> mapPopulationCount(IBasePopulationInfoService basePopulationInfoService, List<String> userIds) {

View File

@ -88,6 +88,14 @@
kh_year = #{khYear} kh_year = #{khYear}
AND AND
kh_month = #{khMonth} kh_month = #{khMonth}
<if test="areaId != null and areaId != ''">
AND
area_id = #{areaId}
</if>
<if test="communityId != null and communityId != ''">
AND
community_id = #{communityId}
</if>
<if test="keywords != null and keywords != ''"> <if test="keywords != null and keywords != ''">
AND ( AND (
B LIKE CONCAT('%', #{keywords}, '%') B LIKE CONCAT('%', #{keywords}, '%')
@ -114,9 +122,9 @@
P = #{P} P = #{P}
WHERE WHERE
kh_year = #{khYear} kh_year = #{khYear}
AND AND
kh_month = #{khMonth} kh_month = #{khMonth}
AND AND
user_id = #{userId} user_id = #{userId}
</update> </update>

View File

@ -109,6 +109,10 @@
kh_year = #{khYear} kh_year = #{khYear}
AND AND
kh_month = #{khMonth} kh_month = #{khMonth}
<if test="departmentId != null and departmentId != ''">
AND
department_id = #{departmentId}
</if>
<if test="keywords != null and keywords != ''"> <if test="keywords != null and keywords != ''">
AND ( AND (
B LIKE CONCAT('%', #{keywords}, '%') B LIKE CONCAT('%', #{keywords}, '%')
@ -118,4 +122,28 @@
</if> </if>
</select> </select>
<update id="update" parameterType="map">
UPDATE
kpi_khxz_znbm
SET
H = #{H},
reasonH = #{reasonH},
K = #{K},
reasonK = #{reasonK},
L = #{L},
reasonL = #{reasonL},
M = #{M},
reasonM = #{reasonM},
N = #{N},
O = #{O},
P = #{P}
WHERE
kh_year = #{khYear}
AND
kh_month = #{khMonth}
AND
user_id = #{userId}
</update>
</mapper> </mapper>

View File

@ -25,6 +25,7 @@
<result column="is_signin_late" property="isSigninLate"/> <result column="is_signin_late" property="isSigninLate"/>
<result column="is_signout" property="isSignout"/> <result column="is_signout" property="isSignout"/>
<result column="is_signout_early" property="isSignoutEarly"/> <result column="is_signout_early" property="isSignoutEarly"/>
<result column="work_distance" property="workDistance"/>
<result column="is_holiday" property="isHoliday"/> <result column="is_holiday" property="isHoliday"/>
<result column="day_score" property="dayScore"/> <result column="day_score" property="dayScore"/>
</resultMap> </resultMap>
@ -156,6 +157,7 @@
is_signin_late, is_signin_late,
is_signout, is_signout,
is_signout_early, is_signout_early,
work_distance,
is_holiday, is_holiday,
day_score day_score
) VALUES ( ) VALUES (
@ -165,6 +167,7 @@
#{isSigninLate}, #{isSigninLate},
#{isSignout}, #{isSignout},
#{isSignoutEarly}, #{isSignoutEarly},
#{workDistance},
#{isHoliday}, #{isHoliday},
#{dayScore} #{dayScore}
) )