yyt
2024-06-26 0cceb649e1dc443c2a91d26d81eacb0867c96db3
提交 | 用户 | 时间
0cceb6 1 package com.jcdm.main.om.productionOrde.controller;
Y 2
3 import java.text.SimpleDateFormat;
4 import java.time.LocalDateTime;
5 import java.time.format.DateTimeFormatter;
6 import java.util.Date;
7 import java.util.List;
8 import javax.servlet.http.HttpServletResponse;
9
10 import com.jcdm.main.bs.modelNumber.domain.BsModelNumber;
11 import com.jcdm.main.bs.modelNumber.service.IBsModelNumberService;
12 import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
13 import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
14 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
15 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
16 import com.jcdm.main.webservice.service.ReceivingServices;
17 import org.apache.commons.lang3.StringUtils;
18 import org.springframework.security.access.prepost.PreAuthorize;
19 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.web.bind.annotation.GetMapping;
21 import org.springframework.web.bind.annotation.PostMapping;
22 import org.springframework.web.bind.annotation.PutMapping;
23 import org.springframework.web.bind.annotation.DeleteMapping;
24 import org.springframework.web.bind.annotation.PathVariable;
25 import org.springframework.web.bind.annotation.RequestBody;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.bind.annotation.RestController;
28 import com.jcdm.common.annotation.Log;
29 import com.jcdm.common.core.controller.BaseController;
30 import com.jcdm.common.core.domain.AjaxResult;
31 import com.jcdm.common.enums.BusinessType;
32 import com.jcdm.common.utils.poi.ExcelUtil;
33 import com.jcdm.common.core.page.TableDataInfo;
34
35 import static org.apache.commons.lang3.SystemUtils.getUserName;
36
37 /**
38  * 生产工单Controller
39  * 
40  * @author ruimin
41  * @date 2023-12-11
42  */
43 @RestController
44 @RequestMapping("/om/productionOrde")
45 public class OmProductionOrdeInfoController extends BaseController
46 {
47     @Autowired
48     private IOmProductionOrdeInfoService omProductionOrdeInfoService;
49
50     @Autowired
51     private IBsOrderSchedulingService bsOrderSchedulingService;
52
53     @Autowired
54     private IBsModelNumberService bsModelNumberService;
55
56     /**
57      * 查询生产工单列表
58      */
59     @PreAuthorize("@ss.hasPermi('om:productionOrde:list')")
60     @GetMapping("/list")
61     public TableDataInfo list(OmProductionOrdeInfo omProductionOrdeInfo)
62     {
63         startPage();
64         List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
65         return getDataTable(list);
66     }
67
68     /**
69      * 导出生产工单列表
70      */
71     @PreAuthorize("@ss.hasPermi('om:productionOrde:export')")
72     @Log(title = "生产工单", businessType = BusinessType.EXPORT)
73     @PostMapping("/export")
74     public void export(HttpServletResponse response, OmProductionOrdeInfo omProductionOrdeInfo)
75     {
76         List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
77         ExcelUtil<OmProductionOrdeInfo> util = new ExcelUtil<OmProductionOrdeInfo>(OmProductionOrdeInfo.class);
78         util.exportExcel(response, list, "生产工单数据");
79     }
80
81     /**
82      * 获取生产工单详细信息
83      */
84     @PreAuthorize("@ss.hasPermi('om:productionOrde:query')")
85     @GetMapping(value = "/{id}")
86     public AjaxResult getInfo(@PathVariable("id") Long id)
87     {
88         return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id));
89     }
90
91     /**
92      * 新增生产工单
93      */
94     @PreAuthorize("@ss.hasPermi('om:productionOrde:add')")
95     @Log(title = "生产工单", businessType = BusinessType.INSERT)
96     @PostMapping
97     public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
98     {
99         return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo));
100     }
101
102     /**
103      * 生成按钮
104      */
105     @PostMapping("/orderSchedulingForBoxCode")
106     public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
107     {
108         //获取当前时间
109         LocalDateTime date= LocalDateTime.now();
110         //创建日期时间对象格式化器,日期格式类似: 2023-05-23 22:18:38
111         DateTimeFormatter formatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
112         //将时间转化为对应格式的字符串
113         String fomateDate=date.format(formatter).toString();
114
115
116         Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//开始编号
117         Integer planQty = Math.toIntExact(omProductionOrdeInfo.getPlanQty());//计划数量
118         String dateTimeRule = omProductionOrdeInfo.getDateTimeRule();
119
120         String engineNo = "";
121         if(planQty>0) {
122             for (int i = 0; i < planQty; i++) {
123                 engineNo = omProductionOrdeInfo.getTypeZ() + " " + dateTimeRule + StringUtils.leftPad(String.valueOf(startCode), 3, "0");
124                 BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
125                 bsOrderScheduling.setOrderNo(omProductionOrdeInfo.getWorkOrderNo());
126                 bsOrderScheduling.setModel(omProductionOrdeInfo.getTypeZ());
127                 bsOrderScheduling.setEngineNo(engineNo);
128                 bsOrderScheduling.setProductionStatus("1");
129                 bsOrderScheduling.setOperator(getUserName());
130                 bsOrderScheduling.setOperateTime(fomateDate);
131                 bsOrderScheduling.setProductType(omProductionOrdeInfo.getTypeL());//产品类型
132                 bsOrderScheduling.setWhetherOrPrint("0");
133                 bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
134                 startCode++;
135             }
136
137             //新增机型序号
138             BsModelNumber bsModelNumber = new BsModelNumber();
139             bsModelNumber.setModel(omProductionOrdeInfo.getTypeZ());
140             bsModelNumber.setModelDate(dateTimeRule);
141             bsModelNumber.setMaxnumValue((startCode - 1) + "");
142             bsModelNumber.setSaveTime(fomateDate);
143             bsModelNumber.setLastNumber((startCode - 1) + "");
144             bsModelNumberService.insertBsModelNumber(bsModelNumber);
145         }
146         //更新工单状态
147         omProductionOrdeInfo.setOrderStatus("2");
148         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
149
150
151     }
152
153     /**
154      * 修改生产工单
155      */
156     @PreAuthorize("@ss.hasPermi('om:productionOrde:edit')")
157     @Log(title = "生产工单", businessType = BusinessType.UPDATE)
158     @PutMapping
159     public AjaxResult edit(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
160     {
161         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
162     }
163
164     /**
165      * 删除生产工单
166      */
167     @PreAuthorize("@ss.hasPermi('om:productionOrde:remove')")
168     @Log(title = "生产工单", businessType = BusinessType.DELETE)
169     @DeleteMapping("/{ids}")
170     public AjaxResult remove(@PathVariable Long[] ids)
171     {
172         return toAjax(omProductionOrdeInfoService.deleteOmProductionOrdeInfoByIds(ids));
173     }
174
175     /**
176      * table列上移下移
177      */
178     @Log(title = "生产工单", businessType = BusinessType.DELETE)
179     @GetMapping("/upDownMove")
180     public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo)
181     {
182         return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo);
183     }
184
185     /**
186      * 接收工单
187      */
188     @PreAuthorize("@ss.hasPermi('om:productionOrde:receive')")
189     @GetMapping("/getProductionNotice")
190     public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo)
191     {
192         String productionNotice = omProductionOrdeInfo.getProductionNotice();
193         List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
194         if(omProductionOrdeInfos.size() == 0){
195             try {
196                 ReceivingServices.insertWebserviceData(productionNotice);
197             } catch (Exception e) {
198                 return error("接收失败!请检查通知单号");
199             }
200         }else {
201             return warn("该通知单已经接收完毕,不能重复接收!");
202         }
203         return AjaxResult.success("接收成功!");
204     }
205 }