张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.thhy.secure.modules.biz.inspect.service.impl;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.thhy.general.common.BasicResult;
import com.thhy.general.config.SysUserInfo;
import com.thhy.general.utils.UserInfoUtils;
import com.thhy.secure.modules.biz.file.service.FileService;
import com.thhy.secure.modules.biz.inspect.entity.TSecureInspect;
import com.thhy.secure.modules.biz.inspect.entity.TSecureInspectPath;
import com.thhy.secure.modules.biz.inspect.entity.dto.SecureInspectDto;
import com.thhy.secure.modules.biz.inspect.entity.dto.SecureInspectInfoDto;
import com.thhy.secure.modules.biz.inspect.mapper.TSecureInspectMapper;
import com.thhy.secure.modules.biz.inspect.service.TSecureInspectService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class TSecureInspectServiceImpl implements TSecureInspectService {
    @Resource
    private TSecureInspectMapper inspectMapper;
    @Resource
    private FileService fileService;
 
    @Override
    public BasicResult inspectInsert(Map<String, Object> values) {
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        //分公司id
        String companyId = sysUserInfo.getCompanyId();
        //用户id
        String userId = sysUserInfo.getUserId();
        values.put("companyId",companyId);
        values.put("createUser",userId);
        values.put("secureInspectId","");
        inspectMapper.inspectInsert(values);
        //添加的主键
        String secureInspectId = values.get("secureInspectId").toString();
        Integer isType = Integer.valueOf(values.get("isType").toString());
        List<String> files = (List<String>) values.get("files");
        for (String file:files){
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("inspectPathId","");
            hashMap.put("secureInspectId",secureInspectId);
            hashMap.put("imgPath",file);
            hashMap.put("isType",isType);
            inspectMapper.inspectPathInsert(hashMap);
        }
        return BasicResult.success("添加成功");
    }
 
    @Override
    public BasicResult inspectList(Map<String, Object> values) {
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        //分公司id
        String companyId = sysUserInfo.getCompanyId();
        values.put("companyId",companyId);
        List<SecureInspectDto> secureInspectDtos = inspectMapper.inspectList(values);
        return BasicResult.success(secureInspectDtos);
    }
 
    @Override
    public BasicResult inspectInfo(Map<String, Object> values) {
        String secureInspectId = values.get("secureInspectId").toString();
 
        SecureInspectInfoDto secureInspectInfoDto = inspectMapper.inspectInfo(secureInspectId);
        List<TSecureInspectPath> secureInspectPaths = inspectMapper.secureInspectPath(secureInspectId);
        secureInspectPaths.stream().forEach(fl->{
            JSONObject json = new JSONObject();
            json.put("fullpath",fl.getImgPath());
            BasicResult basicResult = fileService.fileinfo(json.toJSONString());
            if(basicResult.isSuccess()){
                JSONArray jsonArray = JSONArray.parseArray(basicResult.getData().toString());
                for(Object obj : jsonArray){
                    JSONObject j = JSON.parseObject(obj.toString());
                    if(j.containsKey("name")&&"name".equals(j.getString("name"))){
                        fl.setImgPathName(j.getString("value"));
                    }
                }
            }
        });
        secureInspectInfoDto.setTSecureInspectPaths(secureInspectPaths);
        return BasicResult.success(secureInspectInfoDto);
    }
 
    @Override
    @Transactional
    public BasicResult inspectFeedbackInfo(Map<String, Object> values) {
        //SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        //登录人
       // String userId = sysUserInfo.getUserId();
        //values.put("userId",userId);
        values.put("isState",2);
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format1 = format.format(date);
        values.put("feedbackTime",format1);
        inspectMapper.inspectFeedbackInfo(values);
        ///反馈的照片
        String secureInspectId = values.get("secureInspectId").toString();
        Integer isType = Integer.valueOf(values.get("isType").toString());
        List<String> files = (List<String>) values.get("files");
        for (String file:files){
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("inspectPathId","");
            hashMap.put("secureInspectId",secureInspectId);
            hashMap.put("imgPath",file);
            hashMap.put("isType",isType);
            inspectMapper.inspectPathInsert(hashMap);
        }
        return BasicResult.success("已反馈");
    }
 
    @Override
    public BasicResult rectificationNotice(Map<String, Object> values) {
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        if(sysUserInfo.getUserType()==2){
        //登录人
        String userId = sysUserInfo.getUserId();
        values.put("userId",userId);
        List<TSecureInspect> secureInspects = inspectMapper.rectificationNotice(values);
        return BasicResult.success(secureInspects);
        }else if(sysUserInfo.getUserType()==1){
            String companyId = sysUserInfo.getCompanyId();
            values.put("companyId",companyId);
            List<TSecureInspect> secureInspects = inspectMapper.rectificationNoticeGuan(values);
            return BasicResult.success(secureInspects);
        }
        return BasicResult.faild("11111","error","类型错误");
    }
}