111
k94314517
2023-08-28 c5c6fa800cedd37cea0e3cc3e68df78b47ee2813
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 doumeemes.api.ext;
 
import doumeemes.api.BaseController;
import doumeemes.core.annotation.excel.ExcelExporter;
import doumeemes.core.annotation.pr.PreventRepeat;
import doumeemes.core.model.ApiResponse;
import doumeemes.core.model.PageData;
import doumeemes.core.model.PageWrap;
import doumeemes.dao.business.model.WorkorderCheck;
import doumeemes.dao.ext.dto.QueryWorkorderCheckExtDTO;
import doumeemes.dao.ext.vo.WorkorderCheckExtListVO;
//import doumeemes.dao.ext.vo.WorkorderCheckGroupListVO;
import doumeemes.dao.ext.vo.WorkorderCheckGroupListVO;
import doumeemes.service.business.WorkorderCheckService;
import doumeemes.service.ext.WorkorderCheckExtService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
 
/**
 * 检验信息接口
 * @author 江蹄蹄
 * @date 2022/04/20 10:56
 */
@RestController
@RequestMapping("/ext/workorderCheckExt")
@Api(tags = "检验信息接口")
public class WorkorderCheckExtController extends BaseController {
 
    @Autowired
    private WorkorderCheckExtService workorderCheckExtService;
    
    @Autowired
    private WorkorderCheckService workorderCheckService;
 
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @RequiresPermissions("ext:workordercheckext:create")
    public ApiResponse create(@RequestBody WorkorderCheck workorderCheck) {
        return workorderCheckService.insertData(workorderCheck);
    }
 
 
    @PreventRepeat
    @ApiOperation("新建 - 标准版")
    @PostMapping("/createStandard")
    @RequiresPermissions("ext:workordercheckext:create")
    public ApiResponse createStandard(@RequestBody WorkorderCheck workorderCheck) {
        return workorderCheckService.insertDataStandard(workorderCheck);
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("ext:workordercheckext:delete")
    public ApiResponse deleteById(@PathVariable Integer id) {
 
        return  workorderCheckService.deleteById(id);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("ext:workordercheckext:delete")
    public ApiResponse deleteByIds(@RequestParam String ids) {
        String [] idArray = ids.split(",");
        List<Integer> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(Integer.valueOf(id));
        }
        workorderCheckService.deleteByIdInBatch(idList);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("ext:workordercheckext:update")
    public ApiResponse updateById(@RequestBody WorkorderCheck workorderCheck) {
        workorderCheckService.updateById(workorderCheck);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("ext:workordercheckext:query")
    public ApiResponse<PageData<WorkorderCheckExtListVO>> findPage (@RequestBody PageWrap<QueryWorkorderCheckExtDTO> pageWrap) {
        return ApiResponse.success(workorderCheckExtService.findPage(pageWrap));
    }
    @ApiOperation("根据篮筐分组统计报废和不良数量")
    @PostMapping("/listGroupByAppliance")
    @RequiresPermissions("ext:workordercheckext:query")
    public ApiResponse<List<WorkorderCheckGroupListVO>> listGroupByAppliace (@RequestBody QueryWorkorderCheckExtDTO  pageWrap) {
        return ApiResponse.success(workorderCheckExtService.listGroupByAppliance(pageWrap));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
   // @RequiresPermissions("ext:workordercheckext:exportExcel")
    public void exportExcel (@RequestBody PageWrap<QueryWorkorderCheckExtDTO> pageWrap, HttpServletResponse response) {
        List<WorkorderCheckExtListVO> list=workorderCheckExtService.findPage(pageWrap).getRecords();
        for(int i=0;i<list.size();i++){
            WorkorderCheckExtListVO  w=list.get(i);
            w.setSmodelRealName(w.getSmodelRealName()+" "+ w.getSmodelMobile());
            w.setAmodelcode(w.getAmodel()!=null?w.getAmodel().getCode():"");
            w.setCheckTypename(w.getCheckType()+"");
            w.setMmodelcode(w.getMmodel()!=null?w.getMmodel().getCode():"");
            w.setMmodelname(w.getMmodel()!=null?w.getMmodel().getName():"");
            w.setPmodelname(w.getPmodel()!=null?w.getPmodel().getName():"");
            String  devcode= w.getDevmodel()!=null?w.getDevmodel().getCode():"";
            String  devname= w.getDevmodel()!=null?w.getDevmodel().getName():"";
            w.setDevmodelname("【"+devcode+"】"+devname);
 
            String unitname="";
            if( w.getUmodel()!=null){
                unitname=w.getUmodel().getName();
            }
            if(w.getQualifiedNum()!=null){
                w.setQualifiedNumname(w.getQualifiedNum()+ unitname);
            }
            if(w.getUnqualifiedNum()!=null){
                w.setUnqualifiedNumname(w.getUnqualifiedNum()+unitname);
            }
 
           if(w.getNum()!=null){
               w.setNumname(w.getNum()+unitname);
           }
        }
        ExcelExporter.build(WorkorderCheckExtListVO.class).export(list, "工单检验记录"+System.currentTimeMillis(), response);
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("ext:workordercheckext:query")
    public ApiResponse<WorkorderCheckExtListVO> findById(@PathVariable Integer id) {
        return ApiResponse.success(workorderCheckExtService.findDetailById(id));
    }
}