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