jiazx0107@163.com
2023-06-08 08cea428e888b6fdd2a3c3783e87e4f828385783
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.ld.igds.phone.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.file.CoreFileService;
import com.ld.igds.phone.constant.PhoneConstant;
import com.ld.igds.phone.dto.AuthUser;
import com.ld.igds.phone.dto.DtoPatrolRecord;
import com.ld.igds.phone.dto.PhoneResponse;
import com.ld.igds.phone.mapper.PhoneCommonMapper;
import com.ld.igds.phone.param.ParamPatrolRecord;
import com.ld.igds.phone.param.PhoneRequest;
import com.ld.igds.phone.service.PhoneService;
import com.ld.igds.phone.util.PhoneRespUtil;
import com.ld.igds.util.DateUtil;
import com.ld.igds.util.FfmpegUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
 
/**
 * 电子巡更---打卡记录
 * @author chen
 */
@Slf4j
@Service
public class ServiceImpl5802 implements PhoneService {
 
    @Autowired
    private PhoneCommonMapper phoneCommonMapper;
    @Autowired
    private CoreFileService fileService;
 
    @Override
    public String getInterfaceId() {
        return PhoneConstant.API_PHONE_5802;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public PhoneResponse<Object> execute(PhoneRequest<JSONObject> req, AuthUser authUser)
            throws Exception {
 
        //转化为对象
        ParamPatrolRecord param = JSONObject.parseObject(req.getData().toString(), ParamPatrolRecord.class);
 
        //设置查询参数
        if(null == param){
            return PhoneRespUtil.error(RespCodeEnum.CODE_1007, "参数不完整,请重试!");
        }
 
        //设置查询参数
        if(null == param.getDate()){
            return PhoneRespUtil.error(RespCodeEnum.CODE_1007, "请选择日期进行查询!");
        }
        param.setDate(DateUtil.getCurZero(param.getDate()));
        param.setEnd(DateUtil.getNextZero(param.getDate()));
        param.setCompanyId(authUser.getCompanyId());
        param.setDeptId(authUser.getDeptId());
        param.setUserName(authUser.getCname());
 
        List<DtoPatrolRecord> list = phoneCommonMapper.phoneListPatrolRecord(param);
        if(list != null && list.size()>0){
            //设置图片
            String bathPath;
            String imgData;
            for (DtoPatrolRecord patrol : list) {
                if(StringUtils.isNotEmpty(patrol.getImgName())){
                    bathPath = fileService.getInoutFilePath(patrol.getCreateTime());
                    imgData = FfmpegUtil.getImgStr(bathPath + patrol.getImgName());
                    if (null == imgData) {
                        log.error("没有获取到巡更图片信息:{}", patrol.getImgName());
                        patrol.setImgTag("N");
                        continue;
                    }
                    patrol.setImgTag("Y");
                }
            }
        }
 
        return PhoneRespUtil.success(list, req);
    }
}