春风项目四线(合箱线、总装线)
yyt
2024-05-22 696fd55ecc1243bce1d421d95cb9fba4b0a598b1
提交 | 用户 | 时间
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      */
696fd5 84     @PreAuthorize("@ss.hasPermi('om:productionOrde:query')")
Y 85     @GetMapping(value = "/{id}")
86     public AjaxResult getInfo(@PathVariable("id") Long id)
87     {
88         return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id));
89     }
d4f437 90
Y 91     /**
92      * 获取生产工单详细信息
93      */
fd2207 94     @PreAuthorize("@ss.hasPermi('om:productionOrde:query')")
696fd5 95     @GetMapping("/ids/{ids}")
d4f437 96     public AjaxResult getInfo(@PathVariable Long[] ids)
fd2207 97     {
d4f437 98         return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoByIds(ids));
fd2207 99     }
100
101     /**
102      * 新增生产工单
103      */
104     @PreAuthorize("@ss.hasPermi('om:productionOrde:add')")
105     @Log(title = "生产工单", businessType = BusinessType.INSERT)
106     @PostMapping
107     public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
108     {
109         return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo));
110     }
111
112     /**
e0a2b8 113      * 生成按钮
05d425 114      */
C 115     @PostMapping("/orderSchedulingForBoxCode")
116     public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
117     {
696fd5 118
64e175 119         //获取当前时间
120         LocalDateTime date= LocalDateTime.now();
121         //创建日期时间对象格式化器,日期格式类似: 2023-05-23 22:18:38
122         DateTimeFormatter formatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
123         //将时间转化为对应格式的字符串
124         String fomateDate=date.format(formatter).toString();
749044 125
05d425 126         Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//开始编号
696fd5 127
05d425 128         String dateTimeRule = omProductionOrdeInfo.getDateTimeRule();
C 129
696fd5 130         Long[] id=omProductionOrdeInfo.getIdNums();
Y 131         OmProductionOrdeInfo ProductionOrde;
132         for (int a=0;a<id.length;a++){
133             ProductionOrde=omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id[a]);
134             Integer planQty = Math.toIntExact(ProductionOrde.getPlanQty());//计划数量
135             String engineNo = "";
136             if(planQty>0) {
137                 for (int i = 0; i < planQty; i++) {
138                     engineNo = omProductionOrdeInfo.getTypeZ() + " " + dateTimeRule + StringUtils.leftPad(String.valueOf(startCode), 3, "0");
139                     BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
140                     bsOrderScheduling.setOrderNo(ProductionOrde.getWorkOrderNo());
141                     bsOrderScheduling.setModel(ProductionOrde.getTypeZ());
142                     bsOrderScheduling.setEngineNo(engineNo);
143                     bsOrderScheduling.setProductionStatus("1");
144                     bsOrderScheduling.setOperator(getUserName());
145                     bsOrderScheduling.setOperateTime(fomateDate);
146                     bsOrderScheduling.setProductType(ProductionOrde.getTypeL());//产品类型
147                     bsOrderScheduling.setWhetherOrPrint("0");
148                     bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
149                     startCode++;
150                 }
749044 151             }
696fd5 152             //更新工单状态
Y 153             ProductionOrde.setOrderStatus("2");
154             omProductionOrdeInfoService.updateOmProductionOrdeInfo(ProductionOrde);
749044 155         }
696fd5 156         //新增机型序号
Y 157         BsModelNumber bsModelNumber = new BsModelNumber();
158         bsModelNumber.setModel(omProductionOrdeInfo.getTypeZ());
159         bsModelNumber.setModelDate(dateTimeRule);
160         bsModelNumber.setMaxnumValue((startCode - 1) + "");
161         bsModelNumber.setSaveTime(fomateDate);
162         bsModelNumber.setLastNumber((startCode - 1) + "");
163         bsModelNumberService.insertBsModelNumber(bsModelNumber);
164         return toAjax(1);
05d425 165     }
C 166
167     /**
fd2207 168      * 修改生产工单
169      */
170     @PreAuthorize("@ss.hasPermi('om:productionOrde:edit')")
171     @Log(title = "生产工单", businessType = BusinessType.UPDATE)
172     @PutMapping
173     public AjaxResult edit(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
174     {
175         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
176     }
177
178     /**
179      * 删除生产工单
180      */
181     @PreAuthorize("@ss.hasPermi('om:productionOrde:remove')")
182     @Log(title = "生产工单", businessType = BusinessType.DELETE)
183     @DeleteMapping("/{ids}")
184     public AjaxResult remove(@PathVariable Long[] ids)
185     {
186         return toAjax(omProductionOrdeInfoService.deleteOmProductionOrdeInfoByIds(ids));
187     }
188
189     /**
190      * table列上移下移
191      */
192     @Log(title = "生产工单", businessType = BusinessType.DELETE)
193     @GetMapping("/upDownMove")
194     public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo)
195     {
196         return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo);
197     }
df1f2b 198
199     /**
1391b3 200      * 接收工单
df1f2b 201      */
1391b3 202     @PreAuthorize("@ss.hasPermi('om:productionOrde:receive')")
df1f2b 203     @GetMapping("/getProductionNotice")
204     public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo)
205     {
5f7e70 206         String productionNotice = omProductionOrdeInfo.getProductionNotice();
207         List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
208         if(omProductionOrdeInfos.size() == 0){
209             try {
210                 ReceivingServices.insertWebserviceData(productionNotice);
211             } catch (Exception e) {
212                 return error("接收失败!请检查通知单号");
213             }
1de44b 214         }else {
e4f64a 215             return warn("该通知单已经接收完毕,不能重复接收!");
5f7e70 216         }
1de44b 217         return AjaxResult.success("接收成功!");
df1f2b 218     }
fd2207 219 }