k94314517
2025-04-18 478b26d76795e44d3745a2afa08a247c7d529212
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package com.doumee.api.business;
 
import com.doumee.api.BaseController;
import com.doumee.config.annotation.EncryptionReq;
import com.doumee.config.annotation.EncryptionResp;
import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.constants.Constants;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageWrap;
import com.doumee.core.model.PageData;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.model.Workorder;
import com.doumee.dao.business.vo.*;
import com.doumee.dao.web.dto.OrderDataDTO;
import com.doumee.dao.web.vo.WorkOrderDataVO;
import com.doumee.service.business.WorkorderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * @author 江蹄蹄
 * @since 2025/04/02 17:49
 */
@Api(tags = "工单信息表")
@RestController
@RequestMapping("/business/workorder")
public class WorkorderController extends BaseController {
 
    @Autowired
    private WorkorderService workorderService;
 
    @PreventRepeat
    @ApiOperation("新建")
    @EncryptionReq
    @EncryptionResp
    @PostMapping("/create")
    @RequiresPermissions("business:workorder:create")
    public ApiResponse create(@RequestBody Workorder workorder) {
        return ApiResponse.success(workorderService.create(workorder));
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("business:workorder:delete")
    public ApiResponse deleteById(@PathVariable Integer id) {
        workorderService.deleteById(id);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("business:workorder:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
        workorderService.deleteByIdInBatch(this.getIdList(ids));
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("business:workorder:update")
    public ApiResponse updateById(@RequestBody Workorder workorder) {
        workorderService.updateById(workorder);
        return ApiResponse.success(null);
    }
    @ApiOperation("工作台统计数据")
    @PostMapping("/getIndexData")
    @EncryptionReq
    @EncryptionResp
    public ApiResponse<WorkorderIndexNumVO> getIndexData(@RequestBody Workorder workorder) {
        return ApiResponse.success( workorderService.getIndexData(workorder));
    }
    @ApiOperation("工作台统计报表数据")
    @PostMapping("/getWorkOrderData")
    @EncryptionReq
    @EncryptionResp
    public ApiResponse<List<WorkOrderDataVO>> getWorkOrderData(@RequestBody OrderDataDTO workorder) {
        return ApiResponse.success( workorderService.getWorkOrderData(workorder));
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @EncryptionReq
    @EncryptionResp
    @RequiresPermissions("business:workorder:query")
    public ApiResponse<PageData<Workorder>> findPage (@RequestBody PageWrap<Workorder> pageWrap) {
        return ApiResponse.success(workorderService.findPage(pageWrap));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @EncryptionReq
    @RequiresPermissions("business:workorder:exportExcel")
    public void exportExcel (@RequestBody PageWrap<Workorder> pageWrap, HttpServletResponse response) {
        //0SHE事件 1DCA事件提交记录 2DCA工单 3跌绊滑事件
        long index = 1;
        if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.ZERO)){
            List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
            List<WorkorderSheDto> list = new ArrayList<>();
            if(records!=null){
                for(Workorder model : records){
                    WorkorderSheDto t = new WorkorderSheDto();
                    t.setIndex(index++);
                    BeanUtils.copyProperties(model,t);
                    if(Constants.equalsInteger(model.getOutJiuyi(),Constants.ONE)){
                        t.setJiuyiInfo("外部就医");
                    }else{
                        t.setJiuyiInfo("非外部就医");
                        if(Constants.equalsInteger(model.getIsYiwushi(),Constants.ONE)){
                            t.setJiuyiInfo(t.getJiuyiInfo() + "-医务室");
                        }else{
                            t.setJiuyiInfo(t.getJiuyiInfo() + "-非医务室");
                            if(Constants.equalsInteger(model.getIsHurted(),Constants.ONE)){
                                t.setJiuyiInfo(t.getJiuyiInfo() + "-受伤");
                            }else{
                                t.setJiuyiInfo(t.getJiuyiInfo() + "-未受伤");
                            }
                        }
                    }
                    t.setMemberNames("本人");
                    if(Constants.equalsInteger(model.getMemberType(),Constants.ONE)){
                        t.setMemberNames( "同事-"+StringUtils.defaultString(model.getMemberNames(),""));
                    }else  if(Constants.equalsInteger(model.getMemberType(),Constants.TWO)){
                        t.setMemberNames("供应商");
                        t.setMemberNames( "供应商-"+StringUtils.defaultString(model.getMemberNames(),""));
                    }
                    list.add(t);
                }
            }
            ExcelExporter.build(WorkorderSheDto.class).export(list, "SHE事件工单报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
        }else if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.ONE)){
            List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
            List<WorkorderDcaDto> list = new ArrayList<>();
            if(records!=null){
                for(Workorder model : records){
                    WorkorderDcaDto t = new WorkorderDcaDto();
                    t.setIndex(index++);
                    BeanUtils.copyProperties(model,t);
                    list.add(t);
                }
            }
            ExcelExporter.build(WorkorderDcaDto.class).export(list, "DCA事件工单提交记录报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
          }else if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.TWO)){
            List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
            List<WorkorderDcaChildDto> list = new ArrayList<>();
            if(records!=null){
                for(Workorder model : records){
                    WorkorderDcaChildDto t = new WorkorderDcaChildDto();
                    t.setIndex(index++);
                    BeanUtils.copyProperties(model,t);
                    list.add(t);
                }
            }
            ExcelExporter.build(WorkorderDcaChildDto.class).export(list, "DCA事件工单报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
        }else if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.THREE)){
            List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
            List<WorkorderDbhDto> list = new ArrayList<>();
            if(records!=null){
                for(Workorder model : records){
                    WorkorderDbhDto t = new WorkorderDbhDto();
                    t.setIndex(index++);
                    BeanUtils.copyProperties(model,t);
                    list.add(t);
                }
            }
            ExcelExporter.build(WorkorderDbhDto.class).export(list, "跌绊滑事件工单报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
        }else{
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:workorder:query")
    @EncryptionResp
    @EncryptionReq
    public ApiResponse findById(@PathVariable Integer id) {
        return ApiResponse.success(workorderService.getDetail(id,null));
    }
}