邱宇豪
2023-11-01 21db563b4f218e04cdf07ee442af76d929e8da3a
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
package com.thhy.engineering.modules.biz.device.service.impl;
 
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.thhy.engineering.modules.biz.device.entity.TBigInspect;
import com.thhy.engineering.modules.biz.device.entity.TBigInspectType;
import com.thhy.engineering.modules.biz.device.mapper.TBigInspectMapper;
import com.thhy.engineering.modules.biz.device.service.TBigInspectService;
import com.thhy.general.common.BasicResult;
import com.thhy.general.config.SysUserInfo;
import com.thhy.general.utils.UserInfoUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class TBigInspectServiceImpl implements TBigInspectService {
 
    @Resource
    private TBigInspectMapper bigInspectMapper;
 
 
    @Override
    @Transactional
    public BasicResult bigInspectInsert(Map<String, Object> values) {
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        String userId = sysUserInfo.getUserId();
 
        values.put("bigInspectId","");
        values.put("createUser",userId);
        bigInspectMapper.bigInspectInsert(values);
        String bigInspectId = values.get("bigInspectId").toString();
        List<String> typeIds = (List<String>) values.get("typeIds");
        for (String typeId :typeIds){
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("bigInspectId",bigInspectId);
            hashMap.put("typeId",typeId);
            hashMap.put("inspectTypeId","");
            bigInspectMapper.bigInspectTypeInsert(hashMap);
        }
        return BasicResult.success("添加成功");
    }
 
    @Override
    public BasicResult bigInspectList(Map<String, Object> values) {
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        String companyId = sysUserInfo.getCompanyId();
        values.put("companyId",companyId);
        Integer pageSize = Integer.valueOf(values.get("pageSize").toString());
        Integer pageNum = Integer.valueOf(values.get("pageNum").toString());
        PageHelper.startPage(pageNum,pageSize);
        List<TBigInspect> bigInspects = bigInspectMapper.bigInspectList(values);
        if(bigInspects!=null&&bigInspects.size()>0){
            for (TBigInspect bigInspect:bigInspects){
                List<TBigInspectType> inspectTypes = bigInspectMapper.inspectTypes(bigInspect.getBigInspectId());
                bigInspect.setInspectTypes(inspectTypes);
            }
        }
        PageInfo<TBigInspect> tBigInspectPageInfo = new PageInfo<>(bigInspects);
        return BasicResult.success(tBigInspectPageInfo);
    }
 
    @Override
    public BasicResult bigInspectInfo(String bigInspectId) {
      TBigInspect bigInspects = bigInspectMapper.bigInspectInfo(bigInspectId);
      List<TBigInspectType> inspectTypes = bigInspectMapper.inspectTypes(bigInspects.getBigInspectId());
      bigInspects.setInspectTypes(inspectTypes);
      return BasicResult.success(bigInspects);
    }
 
    @Override
    @Transactional
    public BasicResult bigInspectDel(String bigInspectId) {
 
        bigInspectMapper.bigTypeDel(bigInspectId);
        //缺少 更改 设备检查 状态
        bigInspectMapper.bigInspectDel(bigInspectId);
 
        return BasicResult.success("删除成功");
    }
 
    @Override
    public BasicResult bigInspectUpdate(Map<String, Object> values) {
 
        String bigInspectId = values.get("bigInspectId").toString();
        bigInspectMapper.bigTypeDel(bigInspectId);
        List<String> typeIds = (List<String>) values.get("typeIds");
        for (String typeId :typeIds){
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("bigInspectId",bigInspectId);
            hashMap.put("typeId",typeId);
            hashMap.put("inspectTypeId","");
            bigInspectMapper.bigInspectTypeInsert(hashMap);
        }
        bigInspectMapper.bigInspectUpdate(values);
        return BasicResult.success("修改成功");
    }
}