增加4-5级网格员日统计功能和相关代码
This commit is contained in:
parent
3c912e13ba
commit
cd2e2c9308
6
pom.xml
6
pom.xml
@ -170,6 +170,12 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.cm.systemcity.controller.apis.kpi;
|
||||
|
||||
import com.cm.common.base.AbstractController;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultData;
|
||||
import com.cm.systemcity.service.kpi.IKpiService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "网格员接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/kpi")
|
||||
public class KpiController extends AbstractController {
|
||||
|
||||
@Autowired
|
||||
private IKpiService kpiService;
|
||||
|
||||
@GetMapping("update-community-boss-day-count/{level}")
|
||||
public SuccessResultData<String> updateCommunityBossDayCount(@PathVariable("level") Integer level,
|
||||
@RequestParam("dayDate") String dayDate) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
kpiService.updateCommunityBossDayCount(dayDate, level);
|
||||
long endTime = System.currentTimeMillis();
|
||||
return new SuccessResultData<>("used "+ (endTime - startTime) +" ms");
|
||||
}
|
||||
|
||||
}
|
19
src/main/java/com/cm/systemcity/dao/kpi/IKpiDao.java
Normal file
19
src/main/java/com/cm/systemcity/dao/kpi/IKpiDao.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.cm.systemcity.dao.kpi;
|
||||
|
||||
import com.cm.systemcity.pojo.pos.kpi.CommunityBossDayCountPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Repository
|
||||
public interface IKpiDao {
|
||||
|
||||
void saveCommunityBossDayCount(Map<String, Object> params);
|
||||
|
||||
void deleteCommunityBossDayCount(Map<String, Object> params);
|
||||
|
||||
void updateCommunityBossDayCount(Map<String, Object> params);
|
||||
|
||||
CommunityBossDayCountPO getCommunityBossDayCountPO(Map<String, Object> params);
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.exception.UpdateException;
|
||||
import com.cm.systemcity.pojo.bos.userlocation.BaiduOffsetBO;
|
||||
import com.cm.systemcity.pojo.dtos.userlocation.UserLocationDTO;
|
||||
import com.cm.systemcity.pojo.pos.userlocation.UserLocationPO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -118,4 +119,7 @@ public interface IUserLocationDao {
|
||||
Map<String, Object> getUserInfoById(String userId);
|
||||
|
||||
List<Map<String, Object>> listUserByIds(Map<String, Object> params);
|
||||
|
||||
List<UserLocationPO> listUserLocationPO(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.cm.systemcity.pojo.pos.kpi;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class CommunityBossDayCountPO {
|
||||
|
||||
private Long id;
|
||||
private String userId;
|
||||
private String dayDate;
|
||||
private Integer isSignin;
|
||||
private Integer isSigninLate;
|
||||
private Integer isSignout;
|
||||
private Integer isSignoutEarly;
|
||||
private Double workDistance;
|
||||
private Integer savePopulationCount;
|
||||
private Integer updatePopulationCount;
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.cm.systemcity.pojo.pos.userlocation;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class UserLocationPO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
private String userLocationId;
|
||||
private String userLongitude;
|
||||
private String userLatitude;
|
||||
private String userLocation;
|
||||
private String isOverstep;
|
||||
private String userName;
|
||||
private String creator;
|
||||
private String gmtCreate;
|
||||
|
||||
}
|
@ -228,4 +228,6 @@ public interface ICommunityBossService {
|
||||
List<Map<String, Object>> listNPeopleByRoleId(String roleId);
|
||||
|
||||
List<CommunityBossDTO> listGridUser(Map<String, Object> params);
|
||||
|
||||
List<CommunityBossDTO> listCommunityBossByLevel(int level);
|
||||
}
|
||||
|
@ -432,6 +432,13 @@ public class CommunityBossServiceImpl extends AbstractService implements ICommun
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommunityBossDTO> listCommunityBossByLevel(int level) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("communityBossLevel", level);
|
||||
return listCommunityBoss(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultData<Integer> countCommunityBoss(Map<String, Object> params) throws SearchException {
|
||||
int count = communityBossDao.countCommunityBoss(params);
|
||||
|
15
src/main/java/com/cm/systemcity/service/kpi/IKpiService.java
Normal file
15
src/main/java/com/cm/systemcity/service/kpi/IKpiService.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.cm.systemcity.service.kpi;
|
||||
|
||||
/**
|
||||
* 绩效考核
|
||||
*/
|
||||
public interface IKpiService {
|
||||
|
||||
/**
|
||||
* 更新4、5级网格员日统计
|
||||
* @param date
|
||||
*/
|
||||
void updateCommunityBossDayCount(String date, int level);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.cm.systemcity.service.kpi.impl;
|
||||
|
||||
import com.cm.systemcity.dao.kpi.IKpiDao;
|
||||
import com.cm.systemcity.pojo.dtos.communityboss.CommunityBossDTO;
|
||||
import com.cm.systemcity.pojo.dtos.usersignin.UserSigninDTO;
|
||||
import com.cm.systemcity.pojo.dtos.usersignout.UserSignoutDTO;
|
||||
import com.cm.systemcity.pojo.pos.kpi.CommunityBossDayCountPO;
|
||||
import com.cm.systemcity.pojo.pos.userlocation.UserLocationPO;
|
||||
import com.cm.systemcity.service.communityboss.ICommunityBossService;
|
||||
import com.cm.systemcity.service.kpi.IKpiService;
|
||||
import com.cm.systemcity.service.userlocation.IUserLocationService;
|
||||
import com.cm.systemcity.service.usersignin.IUserSigninService;
|
||||
import com.cm.systemcity.service.usersignout.IUserSignoutService;
|
||||
import com.cm.systemcity.utils.KpiUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class KpiServiceImpl implements IKpiService {
|
||||
|
||||
@Autowired
|
||||
private IKpiDao kpiDao;
|
||||
@Autowired
|
||||
private ICommunityBossService communityBossService;
|
||||
@Autowired
|
||||
private IUserSigninService userSigninService;
|
||||
@Autowired
|
||||
private IUserSignoutService userSignoutService;
|
||||
@Autowired
|
||||
private IUserLocationService userLocationService;
|
||||
|
||||
@Override
|
||||
public void updateCommunityBossDayCount(String date, int level) {
|
||||
// communityBoss表中的level位1-4,对应的是2-5级网格员
|
||||
final int communityBossLevel = level - 1;
|
||||
List<CommunityBossDTO> communityBoss4DTOList = communityBossService.listCommunityBossByLevel(communityBossLevel);
|
||||
List<String> userIds = communityBoss4DTOList.stream().map(CommunityBossDTO::getCommunityBossUserId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||
Map<String, List<UserSigninDTO>> userSigninMap = KpiUtil.mapSignIn(userSigninService, userIds, date);
|
||||
Map<String, List<UserSignoutDTO>> userSignoutMap = KpiUtil.mapSignOut(userSignoutService, userIds, date);
|
||||
// 删除当日数据
|
||||
deleteCommunityBossDayCount(date, communityBossLevel);
|
||||
communityBoss4DTOList.forEach(communityBossDTO -> {
|
||||
String userId = communityBossDTO.getCommunityBossUserId();
|
||||
List<UserSigninDTO> userSigninDTOS = userSigninMap.get(userId);
|
||||
int isSignin = userSigninDTOS == null || userSigninDTOS.size() == 0 ? 0 : 1;
|
||||
int isSigninLate = userSigninDTOS == null || userSigninDTOS.size() == 0 ? 0 : Integer.parseInt(userSigninDTOS.get(0).getIsLate());
|
||||
List<UserSignoutDTO> userSignoutDTOS = userSignoutMap.get(userId);
|
||||
int isSignout = userSignoutDTOS == null || userSignoutDTOS.size() == 0 ? 0 : 1;
|
||||
int isSignoutEarly = userSignoutDTOS == null || userSignoutDTOS.size() == 0 ? 0 : Integer.parseInt(userSignoutDTOS.get(0).getIsEarly());
|
||||
double workDistance = KpiUtil.calculateWorkDistance(userLocationService, userId, date);
|
||||
double savePopulationCount = 0;
|
||||
double updatePopulationCount = 0;
|
||||
// 新增
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("userId", userId);
|
||||
params.put("dayDate", date);
|
||||
params.put("isSignin", isSignin);
|
||||
params.put("isSigninLate", isSigninLate);
|
||||
params.put("isSignout", isSignout);
|
||||
params.put("isSignoutEarly", isSignoutEarly);
|
||||
params.put("workDistance", workDistance);
|
||||
params.put("savePopulationCount", savePopulationCount);
|
||||
params.put("updatePopulationCount", updatePopulationCount);
|
||||
params.put("level", communityBossLevel);
|
||||
kpiDao.saveCommunityBossDayCount(params);
|
||||
});
|
||||
}
|
||||
|
||||
private void deleteCommunityBossDayCount(String date, int level) {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("dayDate", date);
|
||||
params.put("level", level);
|
||||
kpiDao.deleteCommunityBossDayCount(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 网格员日统计
|
||||
*
|
||||
* @param userId
|
||||
* @param date
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
private CommunityBossDayCountPO getCommunityBossDayCountPO(String userId, String date, int level) {
|
||||
Map<String, Object> params = new HashMap<>(8);
|
||||
params.put("userId", userId);
|
||||
params.put("dayDate", date);
|
||||
params.put("level", level);
|
||||
return kpiDao.getCommunityBossDayCountPO(params);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -10,6 +10,7 @@ import com.cm.plugin.map.pojo.dto.GridDTO;
|
||||
import com.cm.systemcity.pojo.dtos.userlocation.UserLocationDTO;
|
||||
import com.cm.systemcity.pojo.dtos.userlocation.UserSignLocationDTO;
|
||||
import com.cm.systemcity.pojo.dtos.userpoints.UserAndPointsDTO;
|
||||
import com.cm.systemcity.pojo.pos.userlocation.UserLocationPO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -290,4 +291,6 @@ public interface IUserLocationService {
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> listUserByIds(Map<String, Object> params);
|
||||
|
||||
List<UserLocationPO> listUserLocationPOByUserIdAndDate(String communityBossUserId, String date);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.cm.systemcity.service.userlocation.impl;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.component.SecurityComponent;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.exception.*;
|
||||
import com.cm.common.plugin.oauth.service.user.IUserService;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
@ -36,6 +37,7 @@ import com.cm.systemcity.pojo.dtos.userpoints.UserDTO;
|
||||
import com.cm.systemcity.pojo.dtos.usersignin.UserSigninDTO;
|
||||
import com.cm.systemcity.pojo.dtos.usersignout.UserSignoutDTO;
|
||||
import com.cm.systemcity.pojo.pos.communityboss.CommunityBossPO;
|
||||
import com.cm.systemcity.pojo.pos.userlocation.UserLocationPO;
|
||||
import com.cm.systemcity.service.BaseService;
|
||||
import com.cm.systemcity.service.bossleader.IBossLeaderService;
|
||||
import com.cm.systemcity.service.community.ICommunityService;
|
||||
@ -49,6 +51,7 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -257,7 +260,7 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
Map<String, Object> config = CacheManager.getInstance().getConfig();
|
||||
String startTime = Objects.isNull(params.get("startTime")) ? String.format("%s %s", today, "09:00:00") : params.get("startTime").toString();
|
||||
String endTime = Objects.isNull(params.get("endTime")) ? String.format("%s %s", today, "18:00:00") : params.get("endTime").toString();
|
||||
if(today.equals(startTime.substring(0, 10))){
|
||||
if (today.equals(startTime.substring(0, 10))) {
|
||||
params.put("today", null);
|
||||
}
|
||||
if (!isStartAndEndTimeParams(startTime, endTime, params)) {
|
||||
@ -500,15 +503,15 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
List<String> userIds = new ArrayList<>();
|
||||
String roleId = "bc405346-8714-4ded-89ac-9cc4d755f66a";
|
||||
List<Map<String, Object>> nPeopleList = communityBossService.listNPeopleByRoleId(roleId);
|
||||
if(nPeopleList != null && nPeopleList.size() > 0){
|
||||
for (Map<String, Object> item : nPeopleList){
|
||||
if (nPeopleList != null && nPeopleList.size() > 0) {
|
||||
for (Map<String, Object> item : nPeopleList) {
|
||||
userIds.add(item.get("userId").toString());
|
||||
}
|
||||
}
|
||||
params.put("communityBossLevel", "4");
|
||||
List<CommunityBossDTO> communityBossDTOS = communityBossService.listCommunityBossV2(params);
|
||||
if(communityBossDTOS != null && communityBossDTOS.size() > 0){
|
||||
for (CommunityBossDTO item : communityBossDTOS){
|
||||
if (communityBossDTOS != null && communityBossDTOS.size() > 0) {
|
||||
for (CommunityBossDTO item : communityBossDTOS) {
|
||||
userIds.add(item.getCommunityBossUserId());
|
||||
}
|
||||
}
|
||||
@ -519,7 +522,7 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
params.put("startTime", DateUtil.getDay()); // "2022-09-22"
|
||||
List<UserSigninDTO> userSigninDTOS = userSigninService.listUserSignin(params);
|
||||
List<UserDTO> signInUserList = new ArrayList<>();
|
||||
for(UserSigninDTO item : userSigninDTOS){
|
||||
for (UserSigninDTO item : userSigninDTOS) {
|
||||
UserDTO user = new UserDTO();
|
||||
user.setUserId(item.getCreator());
|
||||
user.setUserName(item.getUserName());
|
||||
@ -529,15 +532,15 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
res.setUnSignInUsers(signInUserList);
|
||||
// 未签到人员列表
|
||||
List<UserDTO> unSignInUserList = new ArrayList<>();
|
||||
for(String userId : userIds){
|
||||
for (String userId : userIds) {
|
||||
String flag = "0";
|
||||
for(UserDTO item : signInUserList){
|
||||
if(userId.equals(item.getUserId())){
|
||||
for (UserDTO item : signInUserList) {
|
||||
if (userId.equals(item.getUserId())) {
|
||||
flag = "1";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if("0".equals(flag)){
|
||||
if ("0".equals(flag)) {
|
||||
Map<String, Object> userInfo = userLocationDao.getUserInfoById(userId);
|
||||
UserDTO user = new UserDTO();
|
||||
user.setUserId(userId);
|
||||
@ -547,7 +550,7 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
params.put("userId", user.getUserId());
|
||||
params.put("nowTime", DateUtil.getTime());
|
||||
LeaveDTO leave = leaveService.getLeave(params);
|
||||
if(leave != null && leave.getLeaveState() == 1){
|
||||
if (leave != null && leave.getLeaveState() == 1) {
|
||||
user.setUserName(user.getUserName() + "【已请假】");
|
||||
}
|
||||
unSignInUserList.add(user);
|
||||
@ -556,7 +559,7 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
res.setUnSignOutUsers(unSignInUserList);
|
||||
// 人员定位列表
|
||||
List<UserLocationDTO> workingUserList = new ArrayList<>();
|
||||
for(UserSigninDTO item : userSigninDTOS){
|
||||
for (UserSigninDTO item : userSigninDTOS) {
|
||||
UserLocationDTO userLocationDTO = new UserLocationDTO();
|
||||
userLocationDTO.setCreator(item.getCreator());
|
||||
userLocationDTO.setUserName(item.getUserName());
|
||||
@ -576,9 +579,7 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
@Deprecated
|
||||
public List<UserLocationDTO> listOnlineUserLastLocationOld(Map<String, Object> params) throws SearchException {
|
||||
// 如果有关键字检索
|
||||
if (params.get("keywords") != null && !StringUtils.isBlank(params.get("keywords").toString()) ||
|
||||
params.get("startTime") != null && !StringUtils.isBlank(params.get("startTime").toString()) ||
|
||||
params.get("endTime") != null && !StringUtils.isBlank(params.get("endTime").toString())) {
|
||||
if (params.get("keywords") != null && !StringUtils.isBlank(params.get("keywords").toString()) || params.get("startTime") != null && !StringUtils.isBlank(params.get("startTime").toString()) || params.get("endTime") != null && !StringUtils.isBlank(params.get("endTime").toString())) {
|
||||
return listUserLastLocation(params);
|
||||
}
|
||||
List<AppTokenUser> appTokenUsers = AppTokenManager.getInstance().listCurrentUsers();
|
||||
@ -805,7 +806,7 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
}
|
||||
// 得到用户列表
|
||||
List<String> userIds = listGridUserIds(relationIdList);
|
||||
if(userIds == null || userIds.size() == 0){
|
||||
if (userIds == null || userIds.size() == 0) {
|
||||
return new HashMap<>(0);
|
||||
}
|
||||
String currentUserId = userIds.get(0);
|
||||
@ -818,13 +819,13 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
userCardInfo.put("userAvatar", sysUserInfo.get("user_avatar") == null ? "" : sysUserInfo.get("user_avatar").toString());
|
||||
CommunityBossDTO communityBoss = communityBossService.getCommunityBoss(params);
|
||||
// 专管员
|
||||
if(communityBoss == null){
|
||||
if (communityBoss == null) {
|
||||
userCardInfo.put("userType", "1");
|
||||
List<Map<String, Object>> deptList = bindDao.getDepartmentInfoByUserId(sysUserInfo.get("user_id").toString());
|
||||
String departmentNames = "";
|
||||
userCardInfo.put("departmentName", departmentNames);
|
||||
for(Map<String, Object> deptItem : deptList){
|
||||
if("".equals(departmentNames)){
|
||||
for (Map<String, Object> deptItem : deptList) {
|
||||
if ("".equals(departmentNames)) {
|
||||
departmentNames += deptItem.get("department_name").toString();
|
||||
} else {
|
||||
departmentNames += "," + deptItem.get("department_name").toString();
|
||||
@ -836,14 +837,14 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
userCardInfo.put("roleSummary", roleInfo.get("role_summary").toString());
|
||||
}
|
||||
// 网格员
|
||||
if(communityBoss != null){
|
||||
if (communityBoss != null) {
|
||||
userCardInfo.put("userType", "2");
|
||||
userCardInfo.put("areaName", communityBoss.getAreaName());
|
||||
userCardInfo.put("communityName", "");
|
||||
List<CommunityDTO> communities = communityBoss.getCommunities();
|
||||
String communityNames = "";
|
||||
for(CommunityDTO community : communities){
|
||||
if("".equals(communityNames)){
|
||||
for (CommunityDTO community : communities) {
|
||||
if ("".equals(communityNames)) {
|
||||
communityNames += community.getCommunityName();
|
||||
} else {
|
||||
communityNames += "," + community.getCommunityName();
|
||||
@ -938,12 +939,12 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
List<String> relationArray = new ArrayList<>();
|
||||
relationArray.add(userId);
|
||||
List<GridDTO> gridDTOS = gridDao.listGridByRelationIds(relationArray);
|
||||
for(GridDTO item : gridDTOS){
|
||||
for (GridDTO item : gridDTOS) {
|
||||
List<GridPointDTO> gridPointArray = new ArrayList<>();
|
||||
queryMap.clear();
|
||||
queryMap.put("gridId", item.getGridId());
|
||||
List<AreaPointsDTO> areaPointsList = userPointsDao.listPointByGridId(queryMap);
|
||||
for(AreaPointsDTO point : areaPointsList){
|
||||
for (AreaPointsDTO point : areaPointsList) {
|
||||
GridPointDTO gridPointDTO = new GridPointDTO();
|
||||
gridPointDTO.setGridId(item.getGridId());
|
||||
gridPointDTO.setLat(point.getLatitude());
|
||||
@ -1067,18 +1068,25 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio
|
||||
LOG.debug("无百度地图定位可处理偏移数据");
|
||||
return new double[]{lng, lat};
|
||||
}
|
||||
return new double[]{
|
||||
(lngFor6Accuracy * 1000000 + baiduOffsetBO.getLngOffset()) / 1000000,
|
||||
(latFor6Accuracy * 1000000 + baiduOffsetBO.getLatOffset()) / 1000000
|
||||
};
|
||||
return new double[]{(lngFor6Accuracy * 1000000 + baiduOffsetBO.getLngOffset()) / 1000000, (latFor6Accuracy * 1000000 + baiduOffsetBO.getLatOffset()) / 1000000};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listUserByIds(Map<String, Object> params) {
|
||||
if(params.get("userIds") == null || params.get("userIds").toString().length() == 0){
|
||||
if (params.get("userIds") == null || params.get("userIds").toString().length() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Map<String, Object>> list = userLocationDao.listUserByIds(params);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserLocationPO> listUserLocationPOByUserIdAndDate(String userId, String date) {
|
||||
String currentDate = LocalDateTime.now().toString(DateTimeFormat.forPattern(ISystemConstant.DATE_FORMATTER_YYYY_MM_DD));
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userId", userId);
|
||||
params.put("dayDate", date);
|
||||
params.put("tableSuffix", StringUtils.equals(currentDate, date) ? "" : "_history");
|
||||
return userLocationDao.listUserLocationPO(params);
|
||||
}
|
||||
}
|
@ -177,4 +177,6 @@ public interface IUserSigninService {
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<Map<String, Object>>> listPageGridUserSignIn(ListPage page);
|
||||
|
||||
List<UserSigninDTO> listUserSignInByUserIdsAndDay(List<String> userIds, String day);
|
||||
}
|
||||
|
@ -191,6 +191,14 @@ public class UserSigninServiceImpl extends BaseService implements IUserSigninSer
|
||||
return new SuccessResultList<>(new ArrayList<>(), 0, 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserSigninDTO> listUserSignInByUserIdsAndDay(List<String> userIds, String day) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
params.put("signTime", day);
|
||||
return listUserSignin(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultData<UserSigninStatusDTO> getCheckUserSignin(String token, Map<String, Object> params) throws SearchException {
|
||||
UserSigninStatusDTO userSigninStatusDTO = new UserSigninStatusDTO();
|
||||
|
@ -154,4 +154,6 @@ public interface IUserSignoutService {
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countUserSignout(Map<String, Object> params) throws SearchException;
|
||||
|
||||
List<UserSignoutDTO> listUserSignOutByUserIdsAndDay(List<String> userIds, String day);
|
||||
}
|
||||
|
@ -257,6 +257,14 @@ public class UserSignoutServiceImpl extends BaseService implements IUserSignoutS
|
||||
return userSignoutDao.countUserSignout(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserSignoutDTO> listUserSignOutByUserIdsAndDay(List<String> userIds, String day) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userIds", userIds);
|
||||
params.put("signTime", day);
|
||||
return listUserSignout(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否签到
|
||||
*
|
||||
|
89
src/main/java/com/cm/systemcity/utils/KpiUtil.java
Normal file
89
src/main/java/com/cm/systemcity/utils/KpiUtil.java
Normal file
@ -0,0 +1,89 @@
|
||||
package com.cm.systemcity.utils;
|
||||
|
||||
import com.cm.common.utils.point.Point;
|
||||
import com.cm.common.utils.point.PointUtil;
|
||||
import com.cm.systemcity.pojo.dtos.usersignin.UserSigninDTO;
|
||||
import com.cm.systemcity.pojo.dtos.usersignout.UserSignoutDTO;
|
||||
import com.cm.systemcity.pojo.pos.userlocation.UserLocationPO;
|
||||
import com.cm.systemcity.service.userlocation.IUserLocationService;
|
||||
import com.cm.systemcity.service.usersignin.IUserSigninService;
|
||||
import com.cm.systemcity.service.usersignout.IUserSignoutService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KpiUtil {
|
||||
|
||||
/**
|
||||
* 签到map
|
||||
*
|
||||
* @param userSigninService
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, List<UserSigninDTO>> mapSignIn(IUserSigninService userSigninService, List<String> userIds, String day) {
|
||||
List<UserSigninDTO> userSigninDTOS = userSigninService.listUserSignInByUserIdsAndDay(userIds, day);
|
||||
Map<String, List<UserSigninDTO>> userSigninMap = new HashMap<>();
|
||||
userSigninDTOS.forEach(userSigninDTO -> {
|
||||
List<UserSigninDTO> userSigninDTOList = userSigninMap.get(userSigninDTO.getUserId());
|
||||
if (userSigninDTOList == null) {
|
||||
userSigninDTOList = new ArrayList<>();
|
||||
}
|
||||
userSigninDTOList.add(userSigninDTO);
|
||||
userSigninMap.put(userSigninDTO.getCreator(), userSigninDTOList);
|
||||
});
|
||||
return userSigninMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签退map
|
||||
*
|
||||
* @param userSignoutService
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, List<UserSignoutDTO>> mapSignOut(IUserSignoutService userSignoutService, List<String> userIds, String day) {
|
||||
List<UserSignoutDTO> userSignoutDTOS = userSignoutService.listUserSignOutByUserIdsAndDay(userIds, day);
|
||||
Map<String, List<UserSignoutDTO>> userSigninMap = new HashMap<>();
|
||||
userSignoutDTOS.forEach(userSignoutDTO -> {
|
||||
List<UserSignoutDTO> userSignoutDTOList = userSigninMap.get(userSignoutDTO.getUserId());
|
||||
if (userSignoutDTOList == null) {
|
||||
userSignoutDTOList = new ArrayList<>();
|
||||
}
|
||||
userSignoutDTOList.add(userSignoutDTO);
|
||||
userSigninMap.put(userSignoutDTO.getCreator(), userSignoutDTOList);
|
||||
});
|
||||
return userSigninMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算工作距离
|
||||
*
|
||||
* @param userLocationService
|
||||
* @param userId
|
||||
* @param day af535c78-f0ba-4ccf-891b-cf7c6e42e9e8
|
||||
* @return
|
||||
*/
|
||||
public static Double calculateWorkDistance(IUserLocationService userLocationService, String userId, String day) {
|
||||
double workDistance = 0D;
|
||||
if(!StringUtils.equals(userId, "af535c78-f0ba-4ccf-891b-cf7c6e42e9e8")) {
|
||||
return workDistance;
|
||||
}
|
||||
List<UserLocationPO> userLocationPOS = userLocationService.listUserLocationPOByUserIdAndDate(userId, day);
|
||||
Point tempPoint = null;
|
||||
for (UserLocationPO userLocationPO : userLocationPOS) {
|
||||
Point point = new Point(Double.parseDouble(userLocationPO.getUserLatitude()), Double.parseDouble(userLocationPO.getUserLongitude()));
|
||||
if (tempPoint == null) {
|
||||
tempPoint = point;
|
||||
continue;
|
||||
}
|
||||
workDistance += PointUtil.getDistance(tempPoint, point);
|
||||
tempPoint = point;
|
||||
}
|
||||
return workDistance;
|
||||
}
|
||||
|
||||
}
|
90
src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml
Normal file
90
src/main/resources/mybatis/mapper/kpi/kpi-mapper.xml
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cm.systemcity.dao.kpi.IKpiDao">
|
||||
|
||||
<resultMap id="communityBossDayCountPO" type="com.cm.systemcity.pojo.pos.kpi.CommunityBossDayCountPO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="day_date" property="dayDate"/>
|
||||
<result column="is_signin" property="isSignin"/>
|
||||
<result column="is_signin_late" property="isSigninLate"/>
|
||||
<result column="is_signout" property="isSignout"/>
|
||||
<result column="is_signout_early" property="isSignoutEarly"/>
|
||||
<result column="work_distance" property="workDistance"/>
|
||||
<result column="save_population_count" property="savePopulationCount"/>
|
||||
<result column="update_population_count" property="updatePopulationCount"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 保存网格员日统计 -->
|
||||
<insert id="saveCommunityBossDayCount" parameterType="map">
|
||||
INSERT INTO kpi_community_boss_${level}_day_count(
|
||||
user_id,
|
||||
day_date,
|
||||
is_signin,
|
||||
is_signin_late,
|
||||
is_signout,
|
||||
is_signout_early,
|
||||
work_distance,
|
||||
save_population_count,
|
||||
update_population_count
|
||||
) VALUES (
|
||||
#{userId},
|
||||
#{dayDate},
|
||||
#{isSignin},
|
||||
#{isSigninLate},
|
||||
#{isSignout},
|
||||
#{isSignoutEarly},
|
||||
#{workDistance},
|
||||
#{savePopulationCount},
|
||||
#{updatePopulationCount}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除网格员日统计 -->
|
||||
<delete id="deleteCommunityBossDayCount" parameterType="map">
|
||||
DELETE FROM
|
||||
kpi_community_boss_${level}_day_count
|
||||
WHERE
|
||||
day_date = #{dayDate}
|
||||
</delete>
|
||||
|
||||
<!-- 修改网格员日统计 -->
|
||||
<update id="updateCommunityBossDayCount" parameterType="map">
|
||||
UPDATE
|
||||
kpi_community_boss_${level}_day_count
|
||||
SET
|
||||
is_signin = #{isSignin},
|
||||
is_signin_late = #{isSigninLate},
|
||||
is_signout = #{isSignout},
|
||||
is_signout_early = #{isSignoutEarly},
|
||||
work_distance = #{workDistance},
|
||||
save_population_count = #{savePopulationCount},
|
||||
update_population_count = #{updatePopulationCount}
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
AND
|
||||
day_date = #{dayDate}
|
||||
</update>
|
||||
|
||||
<!-- 详情 -->
|
||||
<select id="getCommunityBossDayCountPO" parameterType="map" resultMap="communityBossDayCountPO">
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
day_date,
|
||||
is_signin,
|
||||
is_signin_late,
|
||||
is_signout,
|
||||
is_signout_early,
|
||||
work_distance,
|
||||
save_population_count,
|
||||
update_population_count
|
||||
FROM
|
||||
kpi_community_boss_${level}_day_count
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
AND
|
||||
day_date = #{dayDate}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -15,6 +15,18 @@
|
||||
<result property="gmtCreate" column="gmt_create"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="userLocationPO" type="com.cm.systemcity.pojo.pos.userlocation.UserLocationPO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="userLocationId" column="user_location_id"/>
|
||||
<result property="userLongitude" column="user_longitude"/>
|
||||
<result property="userLatitude" column="user_latitude"/>
|
||||
<result property="userLocation" column="user_location"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="isOverstep" column="is_overstep"/>
|
||||
<result property="creator" column="creator"/>
|
||||
<result property="gmtCreate" column="gmt_create"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="baiduOffsetBO" type="com.cm.systemcity.pojo.bos.userlocation.BaiduOffsetBO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="lng" column="lng"/>
|
||||
@ -429,4 +441,30 @@
|
||||
FIND_IN_SET(user_id, #{userIds})
|
||||
</select>
|
||||
|
||||
<!-- 列表 -->
|
||||
<select id="listUserLocationPO" parameterType="map" resultMap="userLocationPO">
|
||||
SELECT
|
||||
id,
|
||||
user_location_id,
|
||||
user_longitude,
|
||||
user_latitude,
|
||||
user_location,
|
||||
user_name,
|
||||
is_overstep,
|
||||
creator,
|
||||
gmt_create
|
||||
FROM
|
||||
city_user_location${tableSuffix}
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="dayDate != null and dayDate != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 10) = #{dayDate}
|
||||
</if>
|
||||
<if test="userId != null and userId != ''">
|
||||
AND
|
||||
creator = #{userId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -169,6 +169,13 @@
|
||||
#{userSignoutIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
t1.creator IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY
|
||||
t1.gmt_create DESC
|
||||
</select>
|
||||
|
Loading…
Reference in New Issue
Block a user