bingbo
2023-11-24 ace7066780453a7a70dbaa3700de9a761f38ca87
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
139
140
141
142
package com.thhy.mobile.modules.biz.pipeinfo.controller;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.utils.StringUtils;
import com.github.pagehelper.PageInfo;
import com.thhy.general.common.BasicResult;
import com.thhy.general.common.BasicStatus;
import com.thhy.general.config.GlobalConfig;
import com.thhy.general.exception.BasicException;
import com.thhy.general.utils.ExcelUtils;
import com.thhy.general.utils.PagingUtils;
import com.thhy.mobile.modules.biz.pipeinfo.entity.*;
import com.thhy.mobile.modules.biz.pipeinfo.service.PipeInfoService;
import com.thhy.mobile.modules.biz.steelproduce.entity.ProduceDto;
import com.thhy.mobile.modules.biz.steelproduce.entity.ProduceMonthVo;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
 
/**
 * @author zhang_xiao_bo
 * @since 2023-05-08 15:28:37
 */
@RestController
@RequestMapping("pipeInfo")
public class PipeInfoController {
 
 
    @Autowired
    private PipeInfoService pipeInfoService;
 
    @Autowired
    private RedissonClient redissonClient;
 
    @Autowired
    private GlobalConfig globalConfig;
 
    @RequestMapping("findList")
    public BasicResult findList(@RequestBody(required = false) PipeDto pipeDto, HttpServletRequest req){
        PagingUtils.setPageParam(req);
        List<PipeListVo> pipeInfoList = pipeInfoService.pipelist(pipeDto);
        PageInfo<PipeListVo> pageInfo = new PageInfo<>(pipeInfoList);
        return BasicResult.success(pageInfo);
    }
 
    @RequestMapping("checkHistory")
    public BasicResult checkHistory(@RequestBody PipeDto pipeDto, HttpServletRequest req){
        PipeInfoVo pipeInfoVo = pipeInfoService.checkHistory(pipeDto);
        return BasicResult.success(pipeInfoVo);
    }
 
    @RequestMapping("addPipeInfo")
    public BasicResult addPipeInfo(@RequestBody PipeInfo pipeInfo){
        pipeInfoService.addPipeInfo(pipeInfo);
        return BasicResult.success();
    }
 
    /**
    @RequestMapping("update")
    public BasicResult update(@RequestBody PipeInfo pipeInfo){
        pipeInfoService.update(pipeInfo);
        return BasicResult.success();
    }**/
 
    @RequestMapping("delete")
    public BasicResult delete(@RequestBody PipeInfo pipeInfo){
        pipeInfoService.delete(pipeInfo.getPipeId());
        return BasicResult.success();
    }
 
    @RequestMapping("problemInfo")
    public BasicResult problemInfo(@RequestBody PipeDto pipeDto){
        ProblemInfoVo problemInfoVo = pipeInfoService.problemInfo(pipeDto);
        return BasicResult.success(problemInfoVo);
    }
 
    @RequestMapping("setscrap")
    public BasicResult setscrap(@RequestBody ProblemInfoVo problemInfoVo){
        pipeInfoService.setscrap(problemInfoVo);
        return BasicResult.success();
    }
 
    @RequestMapping("export")
    public void export(String authcode, HttpServletResponse response){
        RBucket<String> rBucket = redissonClient.getBucket(globalConfig.getFilePreKey()+":authcode:"+authcode);
        String param = rBucket.getAndDelete();
        if(StringUtils.isEmpty(param)){
            throw new BasicException(BasicStatus.TOKEN_IS_NULL);
        }
        JSONObject jsonObject = JSON.parseObject(param);
        PipeDto pipeDto = JSON.toJavaObject(jsonObject,PipeDto.class);
        List<PipeListVo> pipeInfoList = pipeInfoService.pipelist(pipeDto, jsonObject.getString("token"));
        String fileName = "管片列表";
 
        ExcelUtils.downExcel(pipeInfoList,PipeListVo.class,response,fileName);
    }
 
    @RequestMapping("pipeMonth")
    public BasicResult pipeMonth(@RequestBody ProduceDto produceDto, HttpServletRequest req){
        List<ProduceMonthVo> pipeInfoList = pipeInfoService.pipeMonth(produceDto);
        return BasicResult.success(pipeInfoList);
    }
 
    @RequestMapping("pipeComparePlan")
    public BasicResult pipeComparePlan(@RequestBody ProduceDto produceDto, HttpServletRequest req){
        List<ProduceMonthVo> pipeInfoList = pipeInfoService.pipeComparePlan(produceDto);
        return BasicResult.success(pipeInfoList);
    }
 
    @RequestMapping("h5PipeList")
    public BasicResult pipeComparePlan(@RequestBody(required = false) PipeDto pipeDto){
        return BasicResult.success(pipeInfoService.h5Pipelist(pipeDto));
    }
 
    @RequestMapping("updateRingNum")
    public BasicResult updateRingNum(@RequestBody PipeInfo pipeInfo){
        pipeInfoService.updateRingNum(pipeInfo);
        return BasicResult.success();
    }
 
    @RequestMapping("updateDateInfo")
    public BasicResult updateDateInfo(@RequestBody PipeInfo pipeInfo){
        Map<String, Object> map = pipeInfoService.updateDateInfo(pipeInfo);
        return BasicResult.success(map);
    }
 
    @RequestMapping("updatePipeDate")
    public BasicResult updatePipeDate(@RequestBody PipeDateDto pipeDateDto){
        pipeInfoService.updatePipeDate(pipeDateDto);
        return BasicResult.success();
    }
 
}