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