提交 | 用户 | 时间
|
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 |
|
8876c2
|
53 |
|
W |
54 |
@Override |
|
55 |
public List<OmProductionOrdeInfo> selectOmProductionOrderListById(Long[] ids) |
|
56 |
{ |
|
57 |
return omProductionOrdeInfoMapper.selectOmProductionOrderListById(ids); |
|
58 |
} |
|
59 |
|
d4f437
|
60 |
/** |
fd2207
|
61 |
* 查询生产工单列表 |
懒 |
62 |
* |
|
63 |
* @param omProductionOrdeInfo 生产工单 |
|
64 |
* @return 生产工单 |
|
65 |
*/ |
|
66 |
@Override |
|
67 |
public List<OmProductionOrdeInfo> selectOmProductionOrdeInfoList(OmProductionOrdeInfo omProductionOrdeInfo) |
|
68 |
{ |
162d0b
|
69 |
if(omProductionOrdeInfo.getDateConditions()!=null){ |
懒 |
70 |
String[] conditions = omProductionOrdeInfo.getDateConditions(); |
|
71 |
omProductionOrdeInfo.setStartTime(conditions[0]); |
|
72 |
omProductionOrdeInfo.setEndTime(conditions[1]); |
|
73 |
} |
fd2207
|
74 |
return omProductionOrdeInfoMapper.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
懒 |
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* 新增生产工单 |
|
79 |
* |
|
80 |
* @param omProductionOrdeInfo 生产工单 |
|
81 |
* @return 结果 |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public int insertOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo) |
|
85 |
{ |
|
86 |
omProductionOrdeInfo.setCreateTime(DateUtils.getNowDate()); |
|
87 |
return omProductionOrdeInfoMapper.insertOmProductionOrdeInfo(omProductionOrdeInfo); |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* 修改生产工单 |
|
92 |
* |
|
93 |
* @param omProductionOrdeInfo 生产工单 |
|
94 |
* @return 结果 |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
public int updateOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo) |
|
98 |
{ |
|
99 |
omProductionOrdeInfo.setUpdateTime(DateUtils.getNowDate()); |
|
100 |
return omProductionOrdeInfoMapper.updateOmProductionOrdeInfo(omProductionOrdeInfo); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* 批量删除生产工单 |
|
105 |
* |
|
106 |
* @param ids 需要删除的生产工单主键 |
|
107 |
* @return 结果 |
|
108 |
*/ |
|
109 |
@Override |
|
110 |
public int deleteOmProductionOrdeInfoByIds(Long[] ids) |
|
111 |
{ |
|
112 |
return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoByIds(ids); |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* 删除生产工单信息 |
|
117 |
* |
|
118 |
* @param id 生产工单主键 |
|
119 |
* @return 结果 |
|
120 |
*/ |
|
121 |
@Override |
|
122 |
public int deleteOmProductionOrdeInfoById(Long id) |
|
123 |
{ |
|
124 |
return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoById(id); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo) { |
|
129 |
long currentId = omProductionOrdeInfo.getFrontEndId(); |
|
130 |
List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
|
131 |
List<Long> idList = omProductionOrdeInfos.stream() |
|
132 |
.map(OmProductionOrdeInfo::getId) // 提取id属性 |
|
133 |
.collect(Collectors.toList()); |
|
134 |
int index = idList.indexOf(currentId); |
|
135 |
long moveId = 0L; |
|
136 |
try { |
|
137 |
if(omProductionOrdeInfo.getFlag().equals("up")){ |
|
138 |
moveId = idList.get(index - 1); |
|
139 |
}else { |
|
140 |
moveId = idList.get(index + 1); |
|
141 |
} |
|
142 |
}catch (Exception e){ |
|
143 |
return AjaxResult.error("当前工单为最后一个或第一个,无法移动"); |
|
144 |
} |
|
145 |
OmProductionOrdeInfo currentInfo = new OmProductionOrdeInfo(); |
|
146 |
currentInfo.setId(currentId); |
|
147 |
List<OmProductionOrdeInfo> currentOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(currentInfo); |
|
148 |
String currentStreamNumber = currentOrdeInfos.get(0).getStreamNumber(); |
|
149 |
OmProductionOrdeInfo moveInfo = new OmProductionOrdeInfo(); |
|
150 |
moveInfo.setId(moveId); |
|
151 |
List<OmProductionOrdeInfo> moveOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(moveInfo); |
|
152 |
String moveStreamNumber = moveOrdeInfos.get(0).getStreamNumber(); |
|
153 |
moveOrdeInfos.get(0).setStreamNumber(currentStreamNumber); |
|
154 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(moveOrdeInfos.get(0)); |
|
155 |
currentOrdeInfos.get(0).setStreamNumber(moveStreamNumber); |
|
156 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(currentOrdeInfos.get(0)); |
|
157 |
return AjaxResult.success("移动成功"); |
|
158 |
} |
|
159 |
} |