处理调度员、执法公安的案件和请假签到分值超过40的问题

This commit is contained in:
TS-QD1 2023-10-24 10:58:26 +08:00
parent 90ee454b5c
commit a3d4714ccb
11 changed files with 106 additions and 74 deletions

View File

@ -33,7 +33,7 @@ public class KpiKhxzController extends AbstractController {
if (percent > 0 && percent < 100) {
throw new UpdateException("正在有任务运行");
}
kpiKhxzService.update(khYear, khMonth);
kpiKhxzService.sync(khYear, khMonth);
return new SuccessResult();
}
@ -79,7 +79,7 @@ public class KpiKhxzController extends AbstractController {
@PutMapping("update-ddy")
public synchronized SuccessResult updateDdy(@RequestBody KpiUpdateVO kpiUpdateVO) {
kpiKhxzService.updateDdy(kpiUpdateVO);
kpiKhxzService.syncDdy(kpiUpdateVO);
return new SuccessResult();
}
@ -139,67 +139,67 @@ public class KpiKhxzController extends AbstractController {
@GetMapping("sync-case")
public void syncCase() throws IOException {
kpiKhxzService.updateCase();
kpiKhxzService.syncCase();
}
@GetMapping("sync-wgy3/{year}/{month}")
public void syncWgy3(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy3(year, month);
kpiKhxzService.syncWgy3(year, month);
}
@GetMapping("sync-wgy4/{year}/{month}")
public void syncWgy4(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy4(year, month);
kpiKhxzService.syncWgy4(year, month);
}
@GetMapping("sync-wgy4/{year}/{month}/{userId}")
public void syncWgy4(@PathVariable("year") Integer year, @PathVariable("month") Integer month, @PathVariable("userId") String userId) {
kpiKhxzService.updateWgy4(year, month, userId);
kpiKhxzService.syncWgy4(year, month, userId);
}
@GetMapping("sync-ddy/{year}/{month}")
public void syncDdy(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateDdy(year, month);
kpiKhxzService.syncDdy(year, month);
}
@GetMapping("sync-zgy/{year}/{month}")
public void syncZgy(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateZgy(year, month);
kpiKhxzService.syncZgy(year, month);
}
@GetMapping("sync-wgy3-task/{year}/{month}")
public void syncWgy3Task(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy3Task(year, month);
kpiKhxzService.syncWgy3Task(year, month);
}
@GetMapping("sync-wgy4-task/{year}/{month}")
public void syncWgy4Task(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgy4Task(year, month);
kpiKhxzService.syncWgy4Task(year, month);
}
@GetMapping("sync-wgy4-task/{year}/{month}/{userId}")
public void syncWgy4Task(@PathVariable("year") Integer year, @PathVariable("month") Integer month, @PathVariable("userId") String userId) throws IOException {
kpiKhxzService.updateWgy4Task(year, month, userId);
kpiKhxzService.syncWgy4Task(year, month, userId);
}
@GetMapping("sync-ddy-task/{year}/{month}")
public void syncDdyTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateDdyTask(year, month);
kpiKhxzService.syncDdyTask(year, month);
}
@GetMapping("sync-zf-ga-task/{year}/{month}")
public void syncZfGaTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateZfGaTask(year, month);
kpiKhxzService.syncZfGaTask(year, month);
}
@GetMapping("sync-znbm-task/{year}/{month}")
public void syncZnbmTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateZnbmTask(year, month);
kpiKhxzService.syncZnbmTask(year, month);
}
@GetMapping("sync-wgz-tazk/{year}/{month}")
public void syncWgzTask(@PathVariable("year") Integer year, @PathVariable("month") Integer month) throws IOException {
kpiKhxzService.updateWgzTask(year, month);
kpiKhxzService.syncWgzTask(year, month);
}

View File

@ -4,6 +4,7 @@ public class NPersonDayCountPO {
private Long id;
private String userId;
private String roleId;
private String dayDate;
private Integer isSignin;
private Integer isSigninLate;
@ -29,6 +30,14 @@ public class NPersonDayCountPO {
this.userId = userId;
}
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getDayDate() {
return dayDate;
}

View File

@ -10,34 +10,34 @@ import java.util.Map;
public interface IKpiKhxzService {
void update(Integer khYear, Integer khMonth);
void sync(Integer khYear, Integer khMonth);
void updateCase();
void syncCase();
void updateWgy3(Integer khYear, Integer khMonth);
void syncWgy3(Integer khYear, Integer khMonth);
void updateWgy4(Integer khYear, Integer khMonth);
void syncWgy4(Integer khYear, Integer khMonth);
void updateWgy4(Integer year, Integer month, String userId);
void syncWgy4(Integer year, Integer month, String userId);
void updateDdy(Integer khYear, Integer khMonth);
void syncDdy(Integer khYear, Integer khMonth);
void updateZgy(Integer khYear, Integer khMonth);
void syncZgy(Integer khYear, Integer khMonth);
void updateWgy3Task(Integer khYear, Integer khMonth);
void syncWgy3Task(Integer khYear, Integer khMonth);
void updateWgy4Task(Integer khYear, Integer khMonth);
void syncWgy4Task(Integer khYear, Integer khMonth);
void updateWgy4Task(Integer year, Integer month, String userId);
void syncWgy4Task(Integer year, Integer month, String userId);
void updateDdyTask(Integer khYear, Integer khMonth);
void syncDdyTask(Integer khYear, Integer khMonth);
void updateZfGaTask(Integer khYear, Integer khMonth);
void syncZfGaTask(Integer khYear, Integer khMonth);
void updateZnbmTask(Integer khYear, Integer khMonth);
void syncZnbmTask(Integer khYear, Integer khMonth);
void updateWgzTask(Integer khYear, Integer khMonth);
void syncWgzTask(Integer khYear, Integer khMonth);
List<KpiKhxzWgyDTO> listWgy(Map<String, Object> queryMap);
@ -50,7 +50,7 @@ public interface IKpiKhxzService {
void exportDdy(HttpServletResponse httpServletResponse, Map<String, Object> queryMap) throws IOException;
void updateDdy(KpiUpdateVO kpiUpdateVO);
void syncDdy(KpiUpdateVO kpiUpdateVO);
List<KpiKhxzZfGaDTO> listZfGa(Map<String, Object> queryMap);

View File

@ -48,49 +48,50 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
private ExecutorService executorService = Executors.newFixedThreadPool(10);
@Override
public void update(Integer khYear, Integer khMonth) {
public void sync(Integer khYear, Integer khMonth) {
// 这个数要和下面的任务数之和一致
KpiUpdateMonitor.getInstance().setTaskCount(29);
// KpiUpdateMonitor.getInstance().setTaskCount(15);
// 开始更新
Executors.newSingleThreadExecutor().execute(() -> {
// 更新案件1任务
updateCase();
syncCase();
// 更新4级网格员日统计1任务
updateWgy3(khYear, khMonth);
syncWgy3(khYear, khMonth);
// 更新5级网格员日统计1任务
updateWgy4(khYear, khMonth);
syncWgy4(khYear, khMonth);
// 更新调度员日统计1任务
updateDdy(khYear, khMonth);
syncDdy(khYear, khMonth);
// 更新专管员1任务
updateZgy(khYear, khMonth);
syncZgy(khYear, khMonth);
executorService.execute(() -> {
// 更新4级网格员4任务
updateWgy3Task(khYear, khMonth);
syncWgy3Task(khYear, khMonth);
});
executorService.execute(() -> {
// 更新5级网格员4个任务
updateWgy4Task(khYear, khMonth);
syncWgy4Task(khYear, khMonth);
});
executorService.execute(() -> {
// 调度员4任务
updateDdyTask(khYear, khMonth);
syncDdyTask(khYear, khMonth);
});
executorService.execute(() -> {
// 执法公安5任务
updateZfGaTask(khYear, khMonth);
syncZfGaTask(khYear, khMonth);
});
executorService.execute(() -> {
// 职能部门4任务
updateZnbmTask(khYear, khMonth);
syncZnbmTask(khYear, khMonth);
});
executorService.execute(() -> {
@ -103,78 +104,78 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
}
}
// 网格长3任务
updateWgzTask(khYear, khMonth);
syncWgzTask(khYear, khMonth);
});
});
}
@Override
public void updateCase() {
public void syncCase() {
kpiService.updateCaseCount();
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateWgy3(Integer khYear, Integer khMonth) {
public void syncWgy3(Integer khYear, Integer khMonth) {
kpiService.updateCommunityBossDayCount(khYear, khMonth, 3);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateWgy4(Integer khYear, Integer khMonth) {
public void syncWgy4(Integer khYear, Integer khMonth) {
kpiService.updateCommunityBossDayCount(khYear, khMonth, 4);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateWgy4(Integer year, Integer month, String userId) {
public void syncWgy4(Integer year, Integer month, String userId) {
kpiService.updateCommunityBossDayCount(year, month, 4, userId);
}
@Override
public void updateDdy(Integer khYear, Integer khMonth) {
public void syncDdy(Integer khYear, Integer khMonth) {
kpiService.updateNPersonDayCount(KpiUtil.DDY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateZgy(Integer khYear, Integer khMonth) {
public void syncZgy(Integer khYear, Integer khMonth) {
kpiService.updateNPersonDayCount(KpiUtil.ZGY_ROLE_ID, khYear, khMonth);
KpiUpdateMonitor.getInstance().complete();
}
@Override
public void updateWgy3Task(Integer khYear, Integer khMonth) {
public void syncWgy3Task(Integer khYear, Integer khMonth) {
kpiKhxzWgyTask.update(khYear, khMonth, 3);
}
@Override
public void updateWgy4Task(Integer khYear, Integer khMonth) {
public void syncWgy4Task(Integer khYear, Integer khMonth) {
kpiKhxzWgyTask.update(khYear, khMonth, 4);
}
@Override
public void updateWgy4Task(Integer year, Integer month, String userId) {
public void syncWgy4Task(Integer year, Integer month, String userId) {
kpiKhxzWgyTask.update(year, month, 4, userId);
}
@Override
public void updateDdyTask(Integer khYear, Integer khMonth) {
public void syncDdyTask(Integer khYear, Integer khMonth) {
kpiKhxzDdyTask.update(khYear, khMonth);
}
@Override
public void updateZfGaTask(Integer khYear, Integer khMonth) {
public void syncZfGaTask(Integer khYear, Integer khMonth) {
khKhxzZfGaTask.update(khYear, khMonth);
}
@Override
public void updateZnbmTask(Integer khYear, Integer khMonth) {
public void syncZnbmTask(Integer khYear, Integer khMonth) {
kpiKhxzZnbmTask.update(khYear, khMonth);
}
@Override
public void updateWgzTask(Integer khYear, Integer khMonth) {
public void syncWgzTask(Integer khYear, Integer khMonth) {
kpiKhxzWgzTask.update(khYear, khMonth);
}
@ -223,7 +224,7 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi
}
@Override
public void updateDdy(KpiUpdateVO kpiUpdateVO) {
public void syncDdy(KpiUpdateVO kpiUpdateVO) {
kpiUpdateVO.getDatas().forEach(params -> {
kpiKhxzDdyDao.update(params);
});

View File

@ -333,7 +333,7 @@ public class KpiServiceImpl implements IKpiService {
Map<String, List<UserSigninPO>> userSigninMap = KpiUtil.mapSignin(userSignService, userIds, date);
Map<String, List<UserSignoutPO>> userSignoutMap = KpiUtil.mapSignout(userSignService, userIds, date);
// 删除当日数据
deleteNPersonDayCount(date);
deleteNPersonDayCount(roleId, date);
userPOS.forEach(userPO -> {
String userId = userPO.getUserId();
List<UserSigninPO> userSigninPO = userSigninMap.get(userId);
@ -346,6 +346,7 @@ public class KpiServiceImpl implements IKpiService {
// 新增
Map<String, Object> queryParams = new HashMap<>();
queryParams.put("userId", userId);
queryParams.put("roleId", roleId);
queryParams.put("dayDate", date);
queryParams.put("isSignin", isSignin);
queryParams.put("isSigninLate", isSigninLate);
@ -391,8 +392,9 @@ public class KpiServiceImpl implements IKpiService {
return dates;
}
private void deleteNPersonDayCount(String date) {
private void deleteNPersonDayCount(String roleId, String date) {
Map<String, Object> params = new HashMap<>(4);
params.put("roleId", roleId);
params.put("dayDate", date);
kpiDao.deleteNPersonDayCount(params);
}

View File

@ -32,6 +32,7 @@ public class KpiKhxzDdyCRunnable implements Runnable{
Map<String, Object> params = new HashMap<>();
userIds.forEach(userId -> {
params.put("userId", userId);
params.put("roleId", KpiUtil.DDY_ROLE_ID);
params.put("startTime", dates.get(0));
params.put("endTime", dates.get(dates.size() - 1));
List<NPersonDayCountPO> nPersonDayCountPOS = kpiDao.listNPersonDayCountPO(params);

View File

@ -10,7 +10,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class KpiKhxzZfGaCRunnable implements Runnable{
public class KpiKhxzZfGaCRunnable implements Runnable {
private IKpiKhxzZfGaDao kpiKhxzZfGaDao;
private IKpiDao kpiDao;
@ -32,18 +32,25 @@ public class KpiKhxzZfGaCRunnable implements Runnable{
Map<String, Object> params = new HashMap<>();
userIds.forEach(userId -> {
params.put("userId", userId);
params.put("roleId", KpiUtil.ZGY_ROLE_ID);
params.put("startTime", dates.get(0));
params.put("endTime", dates.get(dates.size() - 1));
List<NPersonDayCountPO> nPersonDayCountPOS = kpiDao.listNPersonDayCountPO(params);
int workDay = 0;
double totalDayScore = 0D;
for (NPersonDayCountPO nPersonDayCountPO : nPersonDayCountPOS) {
totalDayScore += nPersonDayCountPO.getDayScore();
int isHoliday = nPersonDayCountPO.getIsHoliday();
if (isHoliday == 1) {
double dayScore = nPersonDayCountPO.getDayScore();
// 如果是假期有签到签退就算工作日
if (isHoliday == 1 && dayScore > 0D) {
totalDayScore += nPersonDayCountPO.getDayScore();
workDay++;
continue;
}
workDay++;
if (isHoliday == 0) {
totalDayScore += nPersonDayCountPO.getDayScore();
workDay++;
}
}
double totalScore = workDay == 0 ? 0D : totalDayScore / workDay;
// 保存总分

View File

@ -30,7 +30,7 @@ public class KpiKhxzZfGaDEFRunnable implements Runnable {
Map<String, Object> params = new HashMap<>();
params.put("handleYearMonth", String.format("%04d-%02d", khYear, khMonth));
userIds.forEach(userId -> {
params.put("handleUserId", userId);
params.put("reportOrHandleUserId", userId);
int unInspectCount = 0;
int inspectCount = 0;
List<CasePO> casePOS = kpiDao.listCase(params);

View File

@ -17,10 +17,10 @@ public class KpiScoreUtil {
double signoutScore = 0D;
double distanceScore = 0D;
if (isSignin == 1) {
signinScore += isSigninLate == 1 ? WGY_SIGNIN_SCORE / 2 : WGY_SIGNIN_SCORE;
signinScore = isSigninLate == 1 ? WGY_SIGNIN_SCORE / 2 : WGY_SIGNIN_SCORE;
}
if (isSignout == 1) {
signoutScore += isSignoutEarly == 1 ? WGY_SIGNOUT_SCORE / 2 : WGY_SIGNOUT_SCORE;
signoutScore = isSignoutEarly == 1 ? WGY_SIGNOUT_SCORE / 2 : WGY_SIGNOUT_SCORE;
}
// 有签到签退或轨迹的都算有轨迹
if (isSignin == 1 || isSignout == 1 || workDistance > 0) {
@ -30,14 +30,14 @@ public class KpiScoreUtil {
if (isLeave == 1) {
if (isLeaveSelf == 0) {
// 公假不算矿工
signinScore += WGY_SIGNIN_SCORE;
signoutScore += WGY_SIGNOUT_SCORE;
distanceScore += WGY_DISTANCE_SCORE;
signinScore = WGY_SIGNIN_SCORE;
signoutScore = WGY_SIGNOUT_SCORE;
distanceScore = WGY_DISTANCE_SCORE;
} else {
// 私假并且未超过上限
if (isLeaveSelfOverLimitInQuarter == 0) {
signinScore += isSigninLate == 1 ? WGY_SIGNIN_SCORE / 2 : WGY_SIGNIN_SCORE;
signoutScore += isSignoutEarly == 1 ? WGY_SIGNOUT_SCORE / 2 : WGY_SIGNOUT_SCORE;
signinScore = isSigninLate == 1 ? WGY_SIGNIN_SCORE / 2 : WGY_SIGNIN_SCORE;
signoutScore = isSignoutEarly == 1 ? WGY_SIGNOUT_SCORE / 2 : WGY_SIGNOUT_SCORE;
}
}
}

View File

@ -21,14 +21,14 @@ spring:
datasource:
druid:
db1:
url: jdbc:mysql://127.0.0.1:3306/db_btgxq_bigdata?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
url: jdbc:mysql://192.168.0.151:3306/db_btgxq_bigdata?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
db-type: mysql
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
mapper-locations: classpath*:mybatis/mapper/**/*.xml
db2:
url: jdbc:mysql://127.0.0.1:3306/db_btgxq_city?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
url: jdbc:mysql://192.168.0.151:3306/db_btgxq_city?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
db-type: mysql
driver-class-name: com.mysql.jdbc.Driver
username: root

View File

@ -24,6 +24,7 @@
<resultMap id="nPersonDayCountPO" type="com.cm.bigdata.pojo.pos.kpi.NPersonDayCountPO">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="role_id" property="roleId"/>
<result column="day_date" property="dayDate"/>
<result column="is_signin" property="isSignin"/>
<result column="is_signin_late" property="isSigninLate"/>
@ -290,12 +291,15 @@
DELETE FROM
kpi_n_person
WHERE
role_id = #{roleId}
AND
day_date = #{dayDate}
</delete>
<insert id="saveNPersonDayCount" parameterType="map">
INSERT INTO kpi_n_person(
user_id,
role_id,
day_date,
is_signin,
is_signin_late,
@ -306,6 +310,7 @@
day_score
) VALUES (
#{userId},
#{roleId},
#{dayDate},
#{isSignin},
#{isSigninLate},
@ -319,7 +324,7 @@
<select id="listCommunityBossDayCountPO" parameterType="map" resultMap="communityBossDayCountPO">
SELECT
*
*
FROM
kpi_community_boss_${level}_day_count
<where>
@ -628,9 +633,16 @@
LEFT(gmt_assign, 7) = #{assignYearMonth}
</if>
<if test="handleUserId != null and handleUserId != ''">
AND
AND
handle_user_id = #{handleUserId}
</if>
<if test="reportOrHandleUserId != null and reportOrHandleUserId != ''">
AND (
report_user_id = #{reportOrHandleUserId}
OR
handle_user_id = #{reportOrHandleUserId}
)
</if>
<if test="handleYearMonth != null and handleYearMonth != ''">
AND
LEFT(gmt_handle, 7) = #{handleYearMonth}