-
admin
2024-04-18 e70fb4b691d0411cb6de676256160255a153cada
提交 | 用户 | 时间
e57a89 1 package com.jcdm.main.om.productionOrde.service.impl;
2
3 import java.util.List;
4 import java.util.stream.Collectors;
5
0ce25f 6 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
e57a89 7 import com.jcdm.common.core.domain.AjaxResult;
8 import com.jcdm.common.utils.DateUtils;
9 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
10 import com.jcdm.main.om.productionOrde.mapper.OmProductionOrdeInfoMapper;
11 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
e70fb4 12 import com.jcdm.main.restful.factoryMes.service.RestfulService;
e57a89 13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.stereotype.Service;
15
16 /**
17  * 生产工单Service业务层处理
18  * 
19  * @author ruimin
20  * @date 2023-12-11
21  */
22 @Service
0ce25f 23 public class OmProductionOrdeInfoServiceImpl extends ServiceImpl<OmProductionOrdeInfoMapper,OmProductionOrdeInfo> implements IOmProductionOrdeInfoService
e57a89 24 {
25     @Autowired
26     private OmProductionOrdeInfoMapper omProductionOrdeInfoMapper;
27
28     @Autowired
29     private IOmProductionOrdeInfoService omProductionOrdeInfoService;
30
31     /**
32      * 查询生产工单
33      * 
34      * @param id 生产工单主键
35      * @return 生产工单
36      */
37     @Override
38     public OmProductionOrdeInfo selectOmProductionOrdeInfoById(Long id)
39     {
40         return omProductionOrdeInfoMapper.selectOmProductionOrdeInfoById(id);
41     }
42
43     /**
44      * 查询生产工单列表
45      * 
46      * @param omProductionOrdeInfo 生产工单
47      * @return 生产工单
48      */
49     @Override
50     public List<OmProductionOrdeInfo> selectOmProductionOrdeInfoList(OmProductionOrdeInfo omProductionOrdeInfo)
51     {
52         return omProductionOrdeInfoMapper.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
53     }
54
55     /**
56      * 新增生产工单
57      * 
58      * @param omProductionOrdeInfo 生产工单
59      * @return 结果
60      */
61     @Override
62     public int insertOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo)
63     {
64         omProductionOrdeInfo.setCreateTime(DateUtils.getNowDate());
65         Integer streamNumber = omProductionOrdeInfoMapper.getMaxStreamNumber();
66         omProductionOrdeInfo.setStreamNumber(String.valueOf(streamNumber+1));
67         return omProductionOrdeInfoMapper.insertOmProductionOrdeInfo(omProductionOrdeInfo);
68     }
69
70     /**
71      * 修改生产工单
72      * 
73      * @param omProductionOrdeInfo 生产工单
74      * @return 结果
75      */
76     @Override
77     public int updateOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo)
78     {
79         omProductionOrdeInfo.setUpdateTime(DateUtils.getNowDate());
80         return omProductionOrdeInfoMapper.updateOmProductionOrdeInfo(omProductionOrdeInfo);
81     }
82
83     /**
84      * 批量删除生产工单
85      * 
86      * @param ids 需要删除的生产工单主键
87      * @return 结果
88      */
89     @Override
90     public int deleteOmProductionOrdeInfoByIds(Long[] ids)
91     {
92         return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoByIds(ids);
93     }
94
95     /**
96      * 删除生产工单信息
97      * 
98      * @param id 生产工单主键
99      * @return 结果
100      */
101     @Override
102     public int deleteOmProductionOrdeInfoById(Long id)
103     {
104         return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoById(id);
105     }
106
107     @Override
108     public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo) {
109         long currentId = omProductionOrdeInfo.getFrontEndId();
110         List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
111         List<Long> idList = omProductionOrdeInfos.stream()
112                 .map(OmProductionOrdeInfo::getId) // 提取id属性
113                 .collect(Collectors.toList());
114         int index = idList.indexOf(currentId);
115         long moveId = 0L;
116         try {
117             if(omProductionOrdeInfo.getFlag().equals("up")){
118                 moveId = idList.get(index - 1);
119             }else {
120                 moveId = idList.get(index + 1);
121             }
122         }catch (Exception e){
123             return AjaxResult.error("当前工单为最后一个或第一个,无法移动");
124         }
125         OmProductionOrdeInfo  currentInfo = new OmProductionOrdeInfo();
126         currentInfo.setId(currentId);
127         List<OmProductionOrdeInfo> currentOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(currentInfo);
128         String currentStreamNumber = currentOrdeInfos.get(0).getStreamNumber();
129         OmProductionOrdeInfo  moveInfo = new OmProductionOrdeInfo();
130         moveInfo.setId(moveId);
131         List<OmProductionOrdeInfo> moveOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(moveInfo);
132         String moveStreamNumber = moveOrdeInfos.get(0).getStreamNumber();
133         moveOrdeInfos.get(0).setStreamNumber(currentStreamNumber);
134         omProductionOrdeInfoService.updateOmProductionOrdeInfo(moveOrdeInfos.get(0));
135         currentOrdeInfos.get(0).setStreamNumber(moveStreamNumber);
136         omProductionOrdeInfoService.updateOmProductionOrdeInfo(currentOrdeInfos.get(0));
137         return AjaxResult.success("移动成功");
138     }
42cfe3 139
140     @Override
141     public void overrideSaveBatch(List<OmProductionOrdeInfo> omProductionOrdeInfoList) {
142         try {
143             this.saveBatch(omProductionOrdeInfoList);
144         }catch (Exception e){
145             return;
146         }
147     }
e70fb4 148
A 149     @Override
150     public AjaxResult receivingWorkOrders() {
151         return null;
152     }
e57a89 153 }