提交 | 用户 | 时间
|
d9cf6b
|
1 |
package com.jcdm.main.bs.orderScheduling.controller; |
J |
2 |
|
c74dcb
|
3 |
import java.io.IOException; |
766c03
|
4 |
import java.util.ArrayList; |
d9cf6b
|
5 |
import java.util.List; |
c74dcb
|
6 |
import java.util.stream.Collectors; |
W |
7 |
import javax.annotation.Resource; |
d9cf6b
|
8 |
import javax.servlet.http.HttpServletResponse; |
766c03
|
9 |
|
c74dcb
|
10 |
import cn.hutool.core.collection.CollUtil; |
W |
11 |
import com.alibaba.excel.EasyExcel; |
|
12 |
import com.alibaba.excel.ExcelWriter; |
|
13 |
import com.alibaba.excel.write.metadata.WriteSheet; |
|
14 |
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
|
15 |
import com.jcdm.common.annotation.Excel; |
c6e069
|
16 |
import com.jcdm.common.core.domain.R; |
c74dcb
|
17 |
import com.jcdm.common.core.domain.entity.SysDictData; |
W |
18 |
import com.jcdm.common.utils.DictUtils; |
766c03
|
19 |
import com.jcdm.common.utils.StringUtils; |
c74dcb
|
20 |
import com.jcdm.main.bs.orderScheduling.vo.FollowReportVO; |
c6e069
|
21 |
import com.jcdm.main.bs.orderScheduling.vo.LineChartVO; |
c74dcb
|
22 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
W |
23 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
|
24 |
import com.jcdm.system.service.ISysDictDataService; |
d9cf6b
|
25 |
import org.springframework.security.access.prepost.PreAuthorize; |
J |
26 |
import org.springframework.beans.factory.annotation.Autowired; |
|
27 |
import org.springframework.web.bind.annotation.GetMapping; |
|
28 |
import org.springframework.web.bind.annotation.PostMapping; |
|
29 |
import org.springframework.web.bind.annotation.PutMapping; |
|
30 |
import org.springframework.web.bind.annotation.DeleteMapping; |
|
31 |
import org.springframework.web.bind.annotation.PathVariable; |
|
32 |
import org.springframework.web.bind.annotation.RequestBody; |
|
33 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
34 |
import org.springframework.web.bind.annotation.RestController; |
|
35 |
import com.jcdm.common.annotation.Log; |
|
36 |
import com.jcdm.common.core.controller.BaseController; |
|
37 |
import com.jcdm.common.core.domain.AjaxResult; |
|
38 |
import com.jcdm.common.enums.BusinessType; |
|
39 |
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling; |
|
40 |
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService; |
|
41 |
import com.jcdm.common.utils.poi.ExcelUtil; |
|
42 |
import com.jcdm.common.core.page.TableDataInfo; |
|
43 |
|
|
44 |
/** |
|
45 |
* 订单排产Controller |
|
46 |
* |
|
47 |
* @author jiang |
2aea64
|
48 |
* @date 2024-01-13 |
d9cf6b
|
49 |
*/ |
J |
50 |
@RestController |
|
51 |
@RequestMapping("/bs/orderScheduling") |
|
52 |
public class BsOrderSchedulingController extends BaseController |
|
53 |
{ |
|
54 |
@Autowired |
|
55 |
private IBsOrderSchedulingService bsOrderSchedulingService; |
|
56 |
|
c74dcb
|
57 |
|
W |
58 |
@Resource |
|
59 |
private ISysDictDataService iSysDictDataService; |
|
60 |
|
d9cf6b
|
61 |
/** |
J |
62 |
* 查询订单排产列表 |
|
63 |
*/ |
|
64 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')") |
|
65 |
@GetMapping("/list") |
|
66 |
public TableDataInfo list(BsOrderScheduling bsOrderScheduling) |
|
67 |
{ |
29d394
|
68 |
startPage(); |
d9cf6b
|
69 |
List<BsOrderScheduling> list = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
J |
70 |
return getDataTable(list); |
|
71 |
} |
|
72 |
|
c6e069
|
73 |
/** |
8aafc5
|
74 |
* 查询追溯列表 |
c74dcb
|
75 |
*/ |
W |
76 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')") |
|
77 |
@GetMapping("/getFollowReportList") |
|
78 |
public R getFollowReportList(BsOrderScheduling bsOrderScheduling) |
|
79 |
{ |
|
80 |
FollowReportVO followReportList = bsOrderSchedulingService.getFollowReportList(bsOrderScheduling); |
|
81 |
return R.ok(followReportList); |
|
82 |
} |
|
83 |
|
|
84 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:export')") |
|
85 |
@Log(title = "追溯报表导出", businessType = BusinessType.EXPORT) |
|
86 |
@PostMapping("/exportFollow") |
|
87 |
public void exportFollow(HttpServletResponse response, BsOrderScheduling bsOrderScheduling) |
|
88 |
{ |
|
89 |
FollowReportVO followReportList = bsOrderSchedulingService.getFollowReportList(bsOrderScheduling); |
|
90 |
List<SysDictData> allDict = iSysDictDataService.selectDictDataList(null); |
|
91 |
if (CollUtil.isNotEmpty(followReportList.getMainList())){ |
|
92 |
List<SysDictData> dict1 = allDict.stream().filter(x -> "material_type".equals(x.getDictType())).collect(Collectors.toList()); |
|
93 |
List<SysDictData> dict2 = allDict.stream().filter(x -> "order_scheduling_produce_status".equals(x.getDictType())).collect(Collectors.toList()); |
|
94 |
for (BsOrderScheduling orderScheduling : followReportList.getMainList()) { |
|
95 |
if (CollUtil.isNotEmpty(dict1)){ |
|
96 |
List<SysDictData> collect = dict1.stream().filter(x -> x.getDictValue().equals(orderScheduling.getProductType())).collect(Collectors.toList()); |
|
97 |
if (CollUtil.isNotEmpty(collect)){ |
|
98 |
SysDictData sysDictData1 = collect.get(0); |
|
99 |
orderScheduling.setProductTypeString(sysDictData1.getDictLabel()); |
|
100 |
} |
|
101 |
} |
|
102 |
if (CollUtil.isNotEmpty(dict2)){ |
|
103 |
List<SysDictData> collect = dict2.stream().filter(x -> x.getDictValue().equals(orderScheduling.getProductionStatus())).collect(Collectors.toList()); |
|
104 |
if (CollUtil.isNotEmpty(collect)){ |
|
105 |
SysDictData sysDictData1 = collect.get(0); |
|
106 |
orderScheduling.setProductionStatusString(sysDictData1.getDictLabel()); |
|
107 |
} |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
String fileName = "追溯报表"; |
|
112 |
try { |
|
113 |
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); |
|
114 |
WriteSheet mainSheet = EasyExcel.writerSheet(0, "订单排产") |
|
115 |
.head(BsOrderScheduling.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
116 |
.build(); |
|
117 |
WriteSheet sheet1 = EasyExcel.writerSheet(1, "拧紧数据") |
|
118 |
.head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
119 |
.build(); |
|
120 |
WriteSheet sheet2 = EasyExcel.writerSheet(2, "相机检测") |
|
121 |
.head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
122 |
.build(); |
|
123 |
WriteSheet sheet3 = EasyExcel.writerSheet(3, "外漏检测") |
|
124 |
.head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
125 |
.build(); |
|
126 |
WriteSheet sheet4 = EasyExcel.writerSheet(4, "机油加注") |
|
127 |
.head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
128 |
.build(); |
|
129 |
WriteSheet sheet5 = EasyExcel.writerSheet(5, "工位结果") |
|
130 |
.head(DaPassingStationCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
131 |
.build(); |
|
132 |
excelWriter.write(followReportList.getMainList(),mainSheet); |
|
133 |
excelWriter.write(followReportList.getList1(),sheet1); |
|
134 |
excelWriter.write(followReportList.getList2(),sheet2); |
|
135 |
excelWriter.write(followReportList.getList3(),sheet3); |
|
136 |
excelWriter.write(followReportList.getList4(),sheet4); |
|
137 |
excelWriter.write(followReportList.getList5(),sheet5); |
|
138 |
response.setContentType("application/vnd.ms-excel;charset=utf-8"); |
|
139 |
response.setCharacterEncoding("UTF-8"); |
|
140 |
response.setHeader("Content-Disposition","attachment;filename="+fileName+".xlsx"); |
|
141 |
excelWriter.finish(); |
|
142 |
} catch (IOException e) { |
|
143 |
throw new RuntimeException(e); |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
/** |
c6e069
|
148 |
* 查询下线数量 |
W |
149 |
*/ |
|
150 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')") |
|
151 |
@GetMapping("/getOffLineNum") |
|
152 |
public TableDataInfo getOffLineNum(BsOrderScheduling bsOrderScheduling) |
|
153 |
{ |
|
154 |
|
|
155 |
List<LineChartVO> vo = bsOrderSchedulingService.getOffLineNum(); |
|
156 |
return getDataTable(vo); |
|
157 |
} |
|
158 |
|
6eaf05
|
159 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')") |
W |
160 |
@GetMapping("/list2") |
|
161 |
public TableDataInfo list2(BsOrderScheduling bsOrderScheduling) |
|
162 |
{ |
b849f1
|
163 |
// startPage(); |
766c03
|
164 |
List<BsOrderScheduling> list = new ArrayList<>(); |
C |
165 |
if (StringUtils.isNotEmpty(bsOrderScheduling.getOrderNo())){ |
|
166 |
list = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
|
167 |
} |
d9cf6b
|
168 |
return getDataTable(list); |
J |
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* 导出订单排产列表 |
|
173 |
*/ |
|
174 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:export')") |
|
175 |
@Log(title = "订单排产", businessType = BusinessType.EXPORT) |
|
176 |
@PostMapping("/export") |
|
177 |
public void export(HttpServletResponse response, BsOrderScheduling bsOrderScheduling) |
|
178 |
{ |
|
179 |
List<BsOrderScheduling> list = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
|
180 |
ExcelUtil<BsOrderScheduling> util = new ExcelUtil<BsOrderScheduling>(BsOrderScheduling.class); |
|
181 |
util.exportExcel(response, list, "订单排产数据"); |
|
182 |
} |
|
183 |
|
|
184 |
/** |
|
185 |
* 获取订单排产详细信息 |
|
186 |
*/ |
|
187 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:query')") |
2aea64
|
188 |
@GetMapping(value = "/{id}") |
J |
189 |
public AjaxResult getInfo(@PathVariable("id") Long id) |
d9cf6b
|
190 |
{ |
2aea64
|
191 |
return success(bsOrderSchedulingService.selectBsOrderSchedulingById(id)); |
d9cf6b
|
192 |
} |
J |
193 |
|
|
194 |
/** |
|
195 |
* 新增订单排产 |
|
196 |
*/ |
|
197 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:add')") |
|
198 |
@Log(title = "订单排产", businessType = BusinessType.INSERT) |
|
199 |
@PostMapping |
|
200 |
public AjaxResult add(@RequestBody BsOrderScheduling bsOrderScheduling) |
|
201 |
{ |
|
202 |
return toAjax(bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling)); |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* 修改订单排产 |
|
207 |
*/ |
|
208 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:edit')") |
|
209 |
@Log(title = "订单排产", businessType = BusinessType.UPDATE) |
|
210 |
@PutMapping |
|
211 |
public AjaxResult edit(@RequestBody BsOrderScheduling bsOrderScheduling) |
|
212 |
{ |
|
213 |
return toAjax(bsOrderSchedulingService.updateBsOrderScheduling(bsOrderScheduling)); |
|
214 |
} |
|
215 |
|
|
216 |
/** |
|
217 |
* 删除订单排产 |
|
218 |
*/ |
|
219 |
@PreAuthorize("@ss.hasPermi('bs:orderScheduling:remove')") |
|
220 |
@Log(title = "订单排产", businessType = BusinessType.DELETE) |
2aea64
|
221 |
@DeleteMapping("/{ids}") |
J |
222 |
public AjaxResult remove(@PathVariable Long[] ids) |
d9cf6b
|
223 |
{ |
2aea64
|
224 |
return toAjax(bsOrderSchedulingService.deleteBsOrderSchedulingByIds(ids)); |
d9cf6b
|
225 |
} |
J |
226 |
} |