春风项目四线(合箱线、总装线)
hdy
2024-01-16 9562e6b8a5d1b703681074927efbd602b9f48108
提交 | 用户 | 时间
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
C 10 import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
11 import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
fd2207 12 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
13 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
df1f2b 14 import com.jcdm.main.webservice.service.ReceivingServices;
05d425 15 import org.apache.commons.lang3.StringUtils;
fd2207 16 import org.springframework.security.access.prepost.PreAuthorize;
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.web.bind.annotation.GetMapping;
19 import org.springframework.web.bind.annotation.PostMapping;
20 import org.springframework.web.bind.annotation.PutMapping;
21 import org.springframework.web.bind.annotation.DeleteMapping;
22 import org.springframework.web.bind.annotation.PathVariable;
23 import org.springframework.web.bind.annotation.RequestBody;
24 import org.springframework.web.bind.annotation.RequestMapping;
25 import org.springframework.web.bind.annotation.RestController;
26 import com.jcdm.common.annotation.Log;
27 import com.jcdm.common.core.controller.BaseController;
28 import com.jcdm.common.core.domain.AjaxResult;
29 import com.jcdm.common.enums.BusinessType;
30 import com.jcdm.common.utils.poi.ExcelUtil;
31 import com.jcdm.common.core.page.TableDataInfo;
f11989 32
33 import static org.apache.commons.lang3.SystemUtils.getUserName;
fd2207 34
35 /**
36  * 生产工单Controller
37  * 
38  * @author ruimin
39  * @date 2023-12-11
40  */
41 @RestController
42 @RequestMapping("/om/productionOrde")
43 public class OmProductionOrdeInfoController extends BaseController
44 {
45     @Autowired
46     private IOmProductionOrdeInfoService omProductionOrdeInfoService;
05d425 47
C 48     @Autowired
49     private IBsOrderSchedulingService bsOrderSchedulingService;
fd2207 50
51     /**
52      * 查询生产工单列表
53      */
54     @PreAuthorize("@ss.hasPermi('om:productionOrde:list')")
55     @GetMapping("/list")
56     public TableDataInfo list(OmProductionOrdeInfo omProductionOrdeInfo)
57     {
58         startPage();
59         List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
60         return getDataTable(list);
61     }
62
63     /**
64      * 导出生产工单列表
65      */
66     @PreAuthorize("@ss.hasPermi('om:productionOrde:export')")
67     @Log(title = "生产工单", businessType = BusinessType.EXPORT)
68     @PostMapping("/export")
69     public void export(HttpServletResponse response, OmProductionOrdeInfo omProductionOrdeInfo)
70     {
71         List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
72         ExcelUtil<OmProductionOrdeInfo> util = new ExcelUtil<OmProductionOrdeInfo>(OmProductionOrdeInfo.class);
73         util.exportExcel(response, list, "生产工单数据");
74     }
75
76     /**
77      * 获取生产工单详细信息
78      */
79     @PreAuthorize("@ss.hasPermi('om:productionOrde:query')")
80     @GetMapping(value = "/{id}")
81     public AjaxResult getInfo(@PathVariable("id") Long id)
82     {
83         return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id));
84     }
85
86     /**
87      * 新增生产工单
88      */
89     @PreAuthorize("@ss.hasPermi('om:productionOrde:add')")
90     @Log(title = "生产工单", businessType = BusinessType.INSERT)
91     @PostMapping
92     public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
93     {
94         return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo));
95     }
96
97     /**
05d425 98      * 新增生产工单
C 99      */
100     @PostMapping("/orderSchedulingForBoxCode")
101     public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
102     {
64e175 103         //获取当前时间
104         LocalDateTime date= LocalDateTime.now();
105         //创建日期时间对象格式化器,日期格式类似: 2023-05-23 22:18:38
106         DateTimeFormatter formatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
107         //将时间转化为对应格式的字符串
108         String fomateDate=date.format(formatter).toString();
05d425 109         Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//开始编号
C 110         Integer planQty = Math.toIntExact(omProductionOrdeInfo.getPlanQty());//计划数量
111         String dateTimeRule = omProductionOrdeInfo.getDateTimeRule();
112
113         for(int i=0;i<planQty;i++){
114             BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
115             bsOrderScheduling.setOrderNo(omProductionOrdeInfo.getWorkOrderNo());
116             bsOrderScheduling.setModel(omProductionOrdeInfo.getTypeZ());
117             bsOrderScheduling.setEngineNo(omProductionOrdeInfo.getTypeZ() + " "+dateTimeRule+ StringUtils.leftPad(String.valueOf(startCode),3, "0"));
f11989 118             bsOrderScheduling.setProductionStatus("1");
119             bsOrderScheduling.setOperator(getUserName());
64e175 120             bsOrderScheduling.setOperateTime(fomateDate);
05d425 121             bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
C 122             startCode ++;
123         }
124
125         omProductionOrdeInfo.setOrderStatus("2");//更新工单状态
126         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
127     }
128
129     /**
fd2207 130      * 修改生产工单
131      */
132     @PreAuthorize("@ss.hasPermi('om:productionOrde:edit')")
133     @Log(title = "生产工单", businessType = BusinessType.UPDATE)
134     @PutMapping
135     public AjaxResult edit(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
136     {
137         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
138     }
139
140     /**
141      * 删除生产工单
142      */
143     @PreAuthorize("@ss.hasPermi('om:productionOrde:remove')")
144     @Log(title = "生产工单", businessType = BusinessType.DELETE)
145     @DeleteMapping("/{ids}")
146     public AjaxResult remove(@PathVariable Long[] ids)
147     {
148         return toAjax(omProductionOrdeInfoService.deleteOmProductionOrdeInfoByIds(ids));
149     }
150
151     /**
152      * table列上移下移
153      */
154     @Log(title = "生产工单", businessType = BusinessType.DELETE)
155     @GetMapping("/upDownMove")
156     public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo)
157     {
158         return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo);
159     }
df1f2b 160
161     /**
162      * table列上移下移
163      */
164     @GetMapping("/getProductionNotice")
165     public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo)
166     {
167         ReceivingServices.insertWebserviceData(omProductionOrdeInfo.getProductionNotice());
168         return AjaxResult.success();
169     }
fd2207 170 }