春风项目四线(合箱线、总装线)
懒羊羊
2024-01-17 1de44b26c41de44548684bfb475d40fc52af9b71
提交 | 用户 | 时间
fd2207 1 package com.jcdm.main.om.productionOrde.controller;
2
64e175 3 import java.text.SimpleDateFormat;
4 import java.time.LocalDateTime;
5 import java.time.format.DateTimeFormatter;
f11989 6 import java.util.Date;
fd2207 7 import java.util.List;
8 import javax.servlet.http.HttpServletResponse;
05d425 9
749044 10 import com.jcdm.main.bs.modelNumber.domain.BsModelNumber;
C 11 import com.jcdm.main.bs.modelNumber.service.IBsModelNumberService;
05d425 12 import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
C 13 import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
fd2207 14 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
15 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
df1f2b 16 import com.jcdm.main.webservice.service.ReceivingServices;
05d425 17 import org.apache.commons.lang3.StringUtils;
fd2207 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;
f11989 34
35 import static org.apache.commons.lang3.SystemUtils.getUserName;
fd2207 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;
05d425 49
C 50     @Autowired
51     private IBsOrderSchedulingService bsOrderSchedulingService;
749044 52
C 53     @Autowired
54     private IBsModelNumberService bsModelNumberService;
fd2207 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     /**
05d425 103      * 新增生产工单
C 104      */
105     @PostMapping("/orderSchedulingForBoxCode")
106     public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
107     {
64e175 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();
749044 114
C 115
05d425 116         Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//开始编号
C 117         Integer planQty = Math.toIntExact(omProductionOrdeInfo.getPlanQty());//计划数量
118         String dateTimeRule = omProductionOrdeInfo.getDateTimeRule();
119
749044 120         String engineNo = "";
C 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                 bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
132                 startCode++;
133             }
05d425 134
749044 135             //新增机型序号
C 136             BsModelNumber bsModelNumber = new BsModelNumber();
137             bsModelNumber.setModel(omProductionOrdeInfo.getTypeZ());
138             bsModelNumber.setModelDate(dateTimeRule);
139             bsModelNumber.setMaxnumValue((startCode - 1) + "");
140             bsModelNumber.setSaveTime(fomateDate);
141             bsModelNumberService.insertBsModelNumber(bsModelNumber);
142         }
143         //更新工单状态
144         omProductionOrdeInfo.setOrderStatus("2");
05d425 145         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
749044 146
C 147
05d425 148     }
C 149
150     /**
fd2207 151      * 修改生产工单
152      */
153     @PreAuthorize("@ss.hasPermi('om:productionOrde:edit')")
154     @Log(title = "生产工单", businessType = BusinessType.UPDATE)
155     @PutMapping
156     public AjaxResult edit(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
157     {
158         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
159     }
160
161     /**
162      * 删除生产工单
163      */
164     @PreAuthorize("@ss.hasPermi('om:productionOrde:remove')")
165     @Log(title = "生产工单", businessType = BusinessType.DELETE)
166     @DeleteMapping("/{ids}")
167     public AjaxResult remove(@PathVariable Long[] ids)
168     {
169         return toAjax(omProductionOrdeInfoService.deleteOmProductionOrdeInfoByIds(ids));
170     }
171
172     /**
173      * table列上移下移
174      */
175     @Log(title = "生产工单", businessType = BusinessType.DELETE)
176     @GetMapping("/upDownMove")
177     public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo)
178     {
179         return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo);
180     }
df1f2b 181
182     /**
1391b3 183      * 接收工单
df1f2b 184      */
1391b3 185     @PreAuthorize("@ss.hasPermi('om:productionOrde:receive')")
df1f2b 186     @GetMapping("/getProductionNotice")
187     public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo)
188     {
5f7e70 189         String productionNotice = omProductionOrdeInfo.getProductionNotice();
190         List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
191         if(omProductionOrdeInfos.size() == 0){
192             try {
193                 ReceivingServices.insertWebserviceData(productionNotice);
194             } catch (Exception e) {
195                 return error("接收失败!请检查通知单号");
196             }
1de44b 197         }else {
198             return warn("该订单已接收完毕,不能重复接收!");
5f7e70 199         }
1de44b 200         return AjaxResult.success("接收成功!");
df1f2b 201     }
fd2207 202 }