邱宇豪
2023-11-01 9100d3fa53c50ba5c5ca3972724a9f8ad905eea0
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
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.TBigOverhaul;
import com.thhy.engineering.modules.biz.device.entity.TBigOverhaulPath;
import com.thhy.engineering.modules.biz.device.mapper.TBigOverhaulMapper;
import com.thhy.engineering.modules.biz.device.service.TBigOverhaulService;
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 TBigOverhaulServiceImpl implements TBigOverhaulService {
 
    @Resource
    private TBigOverhaulMapper overhaulMapper;
 
 
    @Override
    public BasicResult overhaulInsert(Map<String, Object> values) {
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        String userId = sysUserInfo.getUserId();
        values.put("createUser",userId);
        values.put("bigOverhaulId","");
        overhaulMapper.overhaulInsert(values);
        List<String> files  = (List<String>) values.get("files");
 
        if(files!=null && files.size()>0){
            for (String file :files){
                HashMap<String, Object> hashMap = new HashMap<>();
                hashMap.put("overhaulPathId","");
                hashMap.put("bigOverhaulId",values.get("bigOverhaulId").toString());
                hashMap.put("overhaulPath",file);
                overhaulMapper.overhaulPathInsert(hashMap);
            }
        }
        return BasicResult.success("添加成功");
    }
 
    @Override
    public BasicResult overhaulList(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<TBigOverhaul> bigOverhauls = overhaulMapper.overhaulList(values);
        PageInfo<TBigOverhaul> tBigOverhaulPageInfo = new PageInfo<>(bigOverhauls);
        return BasicResult.success(tBigOverhaulPageInfo);
    }
 
    @Override
    public BasicResult overhaulInfo(String bigOverhaulId) {
        TBigOverhaul bigOverhaul = overhaulMapper.overhaulInfo(bigOverhaulId);
        List<TBigOverhaulPath> overhaulPaths= overhaulMapper.overhaulPath(bigOverhaulId);
        bigOverhaul.setOverhaulPaths(overhaulPaths);
        return BasicResult.success(bigOverhaul);
    }
 
    @Override
    @Transactional
    public BasicResult overhaulDel(String bigOverhaulId) {
        overhaulMapper.overhaulDel(bigOverhaulId);
        overhaulMapper.overhaulPathDel(bigOverhaulId);
        return BasicResult.success("删除成功");
    }
 
    @Override
    public BasicResult overhaulUpdate(Map<String, Object> values) {
        String bigOverhaulId = values.get("bigOverhaulId").toString();
        overhaulMapper.overhaulPathDel(bigOverhaulId);
 
 
        List<String> files  = (List<String>) values.get("files");
        if(files!=null && files.size()>0){
            for (String file :files){
                HashMap<String, Object> hashMap = new HashMap<>();
                hashMap.put("overhaulPathId","");
                hashMap.put("bigOverhaulId",values.get("bigOverhaulId").toString());
                hashMap.put("overhaulPath",file);
                overhaulMapper.overhaulPathInsert(hashMap);
            }
        }
        overhaulMapper.overhaulUpdate(values);
        return BasicResult.success("修改成功");
    }
}