修改下发班组任务信息
This commit is contained in:
parent
aa2828252e
commit
b6cceb3004
|
|
@ -101,8 +101,13 @@ public class RedisService
|
|||
*/
|
||||
public <T> T getCacheObject(final String key)
|
||||
{
|
||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||
return operation.get(key);
|
||||
try{
|
||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||
return operation.get(key);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,32 +36,32 @@
|
|||
SELECT
|
||||
psc.id AS sub_com_id,
|
||||
psc.sub_company_name,
|
||||
COUNT(distinct IF(pp.pro_status = '0', pp.id, NULL)) AS buildProNum,
|
||||
COUNT(distinct IF(pp.pro_status = '2', pp.id, NULL)) AS preProNum,
|
||||
COUNT(distinct IF(pp.pro_status = '4', pp.id, NULL)) AS completedProNum,
|
||||
SUM(CASE WHEN pp.pro_status = '0' THEN 1 ELSE 0 END) AS buildProNum,
|
||||
SUM(CASE WHEN pp.pro_status = '2' THEN 1 ELSE 0 END) AS preProNum,
|
||||
SUM(CASE WHEN pp.pro_status = '4' THEN 1 ELSE 0 END) AS completedProNum,
|
||||
COUNT(DISTINCT bsc.sub_id) AS subNum,
|
||||
COUNT(DISTINCT bstc.team_id) AS teamNum,
|
||||
COUNT(DISTINCT bwem.worker_id) AS einNum,
|
||||
COUNT(DISTINCT bap.worker_id) AS attNum
|
||||
FROM
|
||||
FROM
|
||||
pm_sub_company psc
|
||||
LEFT JOIN pm_project pp ON psc.id = pp.sub_com_id
|
||||
AND pp.is_active = 1
|
||||
LEFT JOIN bm_sub_contract bsc ON bsc.pro_id = pp.id
|
||||
AND bsc.is_active = 1
|
||||
LEFT JOIN pm_sub_team_contract bstc ON bstc.sub_id = bsc.sub_id
|
||||
AND bsc.pro_id = bstc.pro_id
|
||||
AND bstc.is_active = 1
|
||||
<!-- LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id-->
|
||||
LEFT JOIN bm_worker_ein_day_record bwem ON pp.id = bwem.pro_id and bwem.ein_day = #{startDate}
|
||||
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{startDate}
|
||||
WHERE
|
||||
LEFT JOIN pm_project pp ON psc.id = pp.sub_com_id AND pp.is_active = 1
|
||||
LEFT JOIN bm_sub_contract bsc ON bsc.pro_id = pp.id AND bsc.is_active = 1
|
||||
LEFT JOIN pm_sub_team_contract bstc ON bstc.sub_id = bsc.sub_id AND bstc.pro_id = pp.id AND bstc.is_active = 1
|
||||
LEFT JOIN bm_worker_ein_day_record bwem ON pp.id = bwem.pro_id AND bwem.ein_day = #{startDate}
|
||||
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{startDate}
|
||||
WHERE
|
||||
psc.is_active = 1
|
||||
<if test="subComId != null and subComId != ''">
|
||||
AND psc.id = #{subComId}
|
||||
</if>
|
||||
GROUP BY
|
||||
psc.id
|
||||
-- 将pp的过滤条件移到WHERE,减少关联数据(LEFT JOIN不影响主表)
|
||||
|
||||
GROUP BY
|
||||
psc.id, psc.sub_company_name -- 分组字段补全,避免语法警告
|
||||
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getProAttList" resultMap="BaseResultMap">
|
||||
|
|
|
|||
|
|
@ -22,30 +22,21 @@
|
|||
pp.pro_address,
|
||||
pp.start_time as einTime,
|
||||
pp.end_time as exitTime,
|
||||
count(DISTINCT ps.id) AS subNum,
|
||||
count(DISTINCT pstc.id) AS teamNum,
|
||||
count(DISTINCT bwem.worker_id) AS einNum
|
||||
FROM
|
||||
pm_project pp
|
||||
COUNT(DISTINCT ps.id) AS subNum,
|
||||
COUNT(DISTINCT pstc.id) AS teamNum,
|
||||
COUNT(DISTINCT bwem.worker_id) AS einNum
|
||||
FROM pm_project pp
|
||||
LEFT JOIN pm_sub_company psc ON pp.sub_com_id = psc.id
|
||||
LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id
|
||||
AND bwem.is_active = 1
|
||||
LEFT JOIN bm_sub_contract bsc ON pp.id = bsc.pro_id
|
||||
AND bsc.is_active = 1
|
||||
AND bsc.sub_ein_status = 1
|
||||
LEFT JOIN pm_sub ps ON ps.id = bsc.sub_id
|
||||
AND bsc.is_active = 1
|
||||
LEFT JOIN pm_sub_team_contract pstc ON pp.id = pstc.pro_id
|
||||
AND pstc.is_active = 1
|
||||
AND pstc.team_ein_status = 1
|
||||
LEFT JOIN pm_sub_team pst ON pst.id = pstc.team_id
|
||||
AND pst.is_active = 1
|
||||
left join sys_dict_data sdd on sdd.dict_value = pp.pro_type and sdd.dict_type = 'project_type'
|
||||
left join sys_dict_data sdd2 on sdd2.dict_value = pp.pro_status and sdd2.dict_type = 'project_status'
|
||||
WHERE
|
||||
pp.is_active = 1
|
||||
LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id AND bwem.is_active = 1
|
||||
LEFT JOIN bm_sub_contract bsc ON pp.id = bsc.pro_id AND bsc.is_active = 1 AND bsc.sub_ein_status = 1
|
||||
LEFT JOIN pm_sub ps ON ps.id = bsc.sub_id AND ps.is_active = 1
|
||||
LEFT JOIN pm_sub_team_contract pstc ON pp.id = pstc.pro_id AND pstc.is_active = 1 AND pstc.team_ein_status = 1
|
||||
-- LEFT JOIN pm_sub_team pst ON pst.id = pstc.team_id AND pst.is_active = 1
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = pp.pro_type AND sdd.dict_type = 'project_type'
|
||||
LEFT JOIN sys_dict_data sdd2 ON sdd2.dict_value = pp.pro_status AND sdd2.dict_type = 'project_status'
|
||||
WHERE pp.is_active = 1
|
||||
<if test="proName != null">
|
||||
AND locate(#{proName},pp.pro_name)
|
||||
AND LOCATE(#{proName},pp.pro_name) > 0 -- 补全locate返回值判断,避免语法隐患
|
||||
</if>
|
||||
<if test="proStatus != null">
|
||||
AND pp.pro_status = #{proStatus}
|
||||
|
|
@ -56,10 +47,8 @@
|
|||
<if test="subComId != null">
|
||||
AND pp.sub_com_id = #{subComId}
|
||||
</if>
|
||||
GROUP BY
|
||||
pp.id
|
||||
GROUP BY pp.id
|
||||
</select>
|
||||
|
||||
<select id="getEinNumByHis" resultType="com.bonus.bmw.domain.vo.ProStatisticsPo">
|
||||
SELECT
|
||||
count(DISTINCT pp.worker_id) AS einNumHis,
|
||||
|
|
|
|||
|
|
@ -113,8 +113,6 @@ public class ReceiveCmd {
|
|||
service.updateById(task);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
log.error(e.toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bonus.common.core.urk.CommonUtils;
|
|||
import com.bonus.common.core.urk.Constant;
|
||||
import com.bonus.common.core.urk.TaskStatusEnum;
|
||||
import com.bonus.urk.service.ResultService;
|
||||
import com.bonus.urk.vo.DeviceVo;
|
||||
import com.bonus.urk.vo.KqCmdTaskVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -30,7 +31,7 @@ public class ResultHandle {
|
|||
* @param req
|
||||
* @param resp
|
||||
*/
|
||||
public void dealTrans(HttpServletRequest req, HttpServletResponse resp) {
|
||||
public void dealTrans(DeviceVo deviceVo, HttpServletRequest req, HttpServletResponse resp) {
|
||||
//任务识别号
|
||||
String asTransId = req.getHeader(Constant.DEVICE_HEADER_TRANS_ID);
|
||||
String isok = req.getHeader("cmd_return_code");
|
||||
|
|
@ -109,6 +110,19 @@ public class ResultHandle {
|
|||
}
|
||||
|
||||
|
||||
}else{
|
||||
//没有任务
|
||||
//如果是默认 1的任务
|
||||
if("default".equals(asTransId)){
|
||||
taskVo=new KqCmdTaskVo();
|
||||
taskVo.setId(asTransId);
|
||||
taskVo.setDeviceCode(deviceVo.getDevCode());
|
||||
service.insertUserInfo(taskVo, req, resp);
|
||||
}else{
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID,asTransId);
|
||||
resp.getWriter().write("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -181,37 +181,29 @@ public class ResultService {
|
|||
List<DevUserVo> list=new ArrayList<>();
|
||||
JSONArray users=json.getJSONArray("users");
|
||||
packageId=json.getString("packageId");
|
||||
if("1".equals(packageId)){
|
||||
List<String> faceList=mapper.getFaceList(taskVo.getDeviceCode());
|
||||
if(faceList!=null&& !faceList.isEmpty()){
|
||||
for (String face : faceList) {
|
||||
if(StringUtils.isNotBlank(face)) {
|
||||
fileService.remoteFile(face);
|
||||
if (users!=null) {
|
||||
for (int i=0;i<users.size();i++) {
|
||||
String deviceCode=taskVo.getDeviceCode();
|
||||
String userId=users.getJSONObject(i).getString("userId");
|
||||
DevUserVo dto=new DevUserVo();
|
||||
String face=users.getJSONObject(i).getString("photo");
|
||||
String id=deviceCode+"-"+userId;
|
||||
if(StringUtils.isNotBlank(face)){
|
||||
UploadFileVo uploadFileVo=fileService.upload("kq_user_list",id,"考勤机照片","face",face,null);
|
||||
if(uploadFileVo!=null){
|
||||
dto.setImagePath(uploadFileVo.getPath());
|
||||
}
|
||||
}
|
||||
String name=users.getJSONObject(i).getString("name");
|
||||
dto.setUserId(userId);
|
||||
dto.setName(name);
|
||||
dto.setDeviceCode(deviceCode);
|
||||
dto.setId(id);
|
||||
list.add(dto);
|
||||
}
|
||||
mapper.delAllDeviceUserId(taskVo.getDeviceCode());
|
||||
mapper.addDeviceUserInfo(list);
|
||||
}
|
||||
for (int i=0;i<users.size();i++) {
|
||||
String deviceCode=taskVo.getDeviceCode();
|
||||
String userId=users.getJSONObject(i).getString("userId");
|
||||
DevUserVo dto=new DevUserVo();
|
||||
String face=users.getJSONObject(i).getString("photo");
|
||||
String id=deviceCode+"-"+userId;
|
||||
if(StringUtils.isNotBlank(face)){
|
||||
UploadFileVo uploadFileVo=fileService.upload("kq_user_list",id,"考勤机照片","face",face,null);
|
||||
if(uploadFileVo!=null){
|
||||
dto.setImagePath(uploadFileVo.getPath());
|
||||
}
|
||||
}
|
||||
String name=users.getJSONObject(i).getString("name");
|
||||
dto.setUserId(userId);
|
||||
dto.setName(name);
|
||||
dto.setDeviceCode(deviceCode);
|
||||
dto.setId(id);
|
||||
list.add(dto);
|
||||
}
|
||||
mapper.addDeviceUserInfo(list);
|
||||
|
||||
}
|
||||
if("0".equals(packageId)){
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import com.alibaba.fastjson.JSONArray;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.redis.service.RedisService;
|
||||
import com.bonus.system.api.model.UploadFileVo;
|
||||
import com.bonus.common.core.urk.Constant;
|
||||
import com.bonus.urk.mapper.ResultMapper;
|
||||
import com.bonus.urk.vo.DeviceUserDto;
|
||||
import com.bonus.common.core.urk.ImageResizer;
|
||||
import com.bonus.common.core.urk.TaskStatusEnum;
|
||||
|
|
@ -33,6 +35,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
|
|
@ -48,10 +51,18 @@ public class TaskService {
|
|||
@Autowired
|
||||
private TaskMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private ResultMapper resultMapper;
|
||||
|
||||
@Resource
|
||||
private UrkMinioService fileService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisService redisUtils;
|
||||
|
||||
|
||||
|
||||
public static SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
|
||||
public void updateTime(DeviceTaskVo taskVo, HttpServletRequest req, HttpServletResponse resp) {
|
||||
String body = "";
|
||||
|
|
@ -135,6 +146,7 @@ public class TaskService {
|
|||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
redisUtils.setCacheObject("att_dev:get_user:"+task.getDeviceCode(),"0",600L, TimeUnit.SECONDS);
|
||||
service.logServerResponseLog(task, resp, body);
|
||||
log.info("设备:{}, 删除人员指令下达", task.getDeviceCode());
|
||||
}
|
||||
|
|
@ -374,14 +386,14 @@ public class TaskService {
|
|||
user.setVaildEnd(sdf.format(userVo.getEndTime()));
|
||||
user.setVaildTimeEnd(sdf.format(userVo.getEndTime()));
|
||||
}
|
||||
|
||||
user.setPrivilege(0);
|
||||
List<UploadFileVo> fileList=fileService.getFileBast64List(null,user.getUserId(),"pm_worker","1");
|
||||
if(fileList!=null && !fileList.isEmpty()) {
|
||||
String bast64=fileList.get(0).getBast64();
|
||||
if(StringUtils.isNotBlank(bast64)) {
|
||||
if(noZip){
|
||||
user.setPhoto_base64(ImageResizer.transImageByJpg(bast64));
|
||||
String face=ImageResizer.transImageByJpg(bast64);
|
||||
user.setPhoto_base64(face);
|
||||
}else{
|
||||
user.setPhoto_base64(bast64);
|
||||
}
|
||||
|
|
@ -416,20 +428,35 @@ public class TaskService {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//下发人员成功后 会去更新
|
||||
redisUtils.setCacheObject("att_dev:get_user:"+task.getDeviceCode(),"0",600L, TimeUnit.SECONDS);
|
||||
service.logServerResponseLog(task, resp, body);
|
||||
log.info("设备:{}, 写入用户指令下达", task.getDeviceCode());
|
||||
}
|
||||
|
||||
|
||||
public void getUserInfo(DeviceTaskVo task, HttpServletRequest req, HttpServletResponse resp) {
|
||||
public void getUserInfo(DeviceTaskVo task, HttpServletRequest req, HttpServletResponse resp) throws Exception {
|
||||
String body = "";
|
||||
// body
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
List<String> userSends = mapper.getTaskUserList(task.getId());
|
||||
if(!CollUtil.isEmpty(userSends)) {
|
||||
String[] userIds = userSends.toArray(new String[0]);
|
||||
jsonObject.put("usersId", userIds);
|
||||
}
|
||||
//执行前先删除
|
||||
List<String> faceList=resultMapper.getFaceList(task.getDeviceCode());
|
||||
if(faceList!=null&& !faceList.isEmpty()){
|
||||
for (String face : faceList) {
|
||||
if(StringUtils.isNotBlank(face)) {
|
||||
fileService.remoteFile(face);
|
||||
}
|
||||
}
|
||||
}
|
||||
resultMapper.delAllDeviceUserId(task.getDeviceCode());
|
||||
|
||||
|
||||
body = jsonObject.toString();
|
||||
try {
|
||||
// head
|
||||
|
|
@ -506,8 +533,39 @@ public class TaskService {
|
|||
list= mapper.selectCmdBlockTask(devCode);
|
||||
}
|
||||
}
|
||||
//如果再次为空的话-设置一个默认的查询用户数据
|
||||
if(list==null || list.isEmpty()){
|
||||
String getUser=redisUtils.getCacheObject("att_dev:get_user:"+devCode);
|
||||
if(StringUtils.isNotEmpty(getUser) && "0".equals(getUser)){
|
||||
list=new ArrayList<>();
|
||||
DeviceTaskVo vo=new DeviceTaskVo();
|
||||
vo.setCmdCode(devCode);
|
||||
vo.setId("default");
|
||||
vo.setCmdCode("GET_USER_INFO");
|
||||
vo.setCmdParam("{}");
|
||||
list.add(vo);
|
||||
redisUtils.setCacheObject("att_dev:get_user:"+devCode,"1",600L, TimeUnit.SECONDS);
|
||||
try{
|
||||
//执行前先删除
|
||||
List<String> faceList=resultMapper.getFaceList(devCode);
|
||||
if(faceList!=null&& !faceList.isEmpty()){
|
||||
for (String face : faceList) {
|
||||
if(StringUtils.isNotBlank(face)) {
|
||||
fileService.remoteFile(face);
|
||||
}
|
||||
}
|
||||
}
|
||||
resultMapper.delAllDeviceUserId(devCode);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.codec.Base64;
|
|||
import cn.hutool.core.io.FileUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.redis.service.RedisService;
|
||||
import com.bonus.common.core.urk.Constant;
|
||||
import com.bonus.urk.vo.DeviceUserDto;
|
||||
|
|
@ -73,6 +74,10 @@ public class DeviceServlet extends HttpServlet {
|
|||
return;
|
||||
}
|
||||
redisUtils.setCacheObject("att_dev:status:"+deviceVo.getDevCode(),"1",600L, TimeUnit.SECONDS);
|
||||
String getUser=redisUtils.getCacheObject("att_dev:get_user:"+deviceVo.getDevCode());
|
||||
if(StringUtils.isEmpty(getUser)){
|
||||
redisUtils.setCacheObject("att_dev:get_user:"+deviceVo.getDevCode(),"0",600L, TimeUnit.SECONDS);
|
||||
}
|
||||
String asTransId = req.getHeader(Constant.DEVICE_HEADER_TRANS_ID);
|
||||
String requestCode = req.getHeader(Constant.DEVICE_HEADER_REQUEST_CODE);
|
||||
// zSetOperations.add(CacheConstant.DEVICE_ONLINE_SET_CACHE, deviceVo.getDevCode(), System.currentTimeMillis());
|
||||
|
|
@ -93,7 +98,7 @@ public class DeviceServlet extends HttpServlet {
|
|||
if(StringHelper.isNullOrEmptyString(asTransId)){
|
||||
log.info("设备:{}, 请求未能识别的request_code:{}",deviceVo.getDevCode(), requestCode);
|
||||
}else{
|
||||
resultHandle.dealTrans(req,resp);
|
||||
resultHandle.dealTrans(deviceVo,req,resp);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ public class DeviceTaskVo {
|
|||
*/
|
||||
private String msg;
|
||||
|
||||
private String param;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ spring:
|
|||
name: bonus-urk
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: prod
|
||||
task:
|
||||
scheduling:
|
||||
pool:
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
update_state
|
||||
from kq_cmd_task
|
||||
where device_code=#{devCode} and trans_status in (1)
|
||||
and trans_status_update_time is not null and trans_status_update_time < NOW() - INTERVAL 1 HOUR
|
||||
and trans_status_update_time is not null
|
||||
</select>
|
||||
|
||||
<!--更新任务状态-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue