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