|
@@ -26,11 +26,15 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanChangeLineBo; |
|
@@ -26,11 +26,15 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanChangeLineBo; |
|
26
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
|
26
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
|
|
27
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChange;
|
27
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChange;
|
|
28
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChangeLine;
|
28
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChangeLine;
|
|
|
|
29
|
+import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine;
|
|
29
|
import com.lframework.xingyun.sc.procurement.mappers.change.ProcurementPlanChangeLineMapper;
|
30
|
import com.lframework.xingyun.sc.procurement.mappers.change.ProcurementPlanChangeLineMapper;
|
|
30
|
import com.lframework.xingyun.sc.procurement.mappers.change.ProcurementPlanChangeMapper;
|
31
|
import com.lframework.xingyun.sc.procurement.mappers.change.ProcurementPlanChangeMapper;
|
|
|
|
32
|
+import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService;
|
|
31
|
import com.lframework.xingyun.sc.procurement.service.change.ProcurementPlanChangeLineService;
|
33
|
import com.lframework.xingyun.sc.procurement.service.change.ProcurementPlanChangeLineService;
|
|
32
|
import com.lframework.xingyun.sc.procurement.service.change.ProcurementPlanChangeService;
|
34
|
import com.lframework.xingyun.sc.procurement.service.change.ProcurementPlanChangeService;
|
|
|
|
35
|
+import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService;
|
|
33
|
import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
|
36
|
import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
|
|
|
|
37
|
+import com.lframework.xingyun.sc.procurement.vo.buyout.CreateProcurementBuyoutApplyVo;
|
|
34
|
import com.lframework.xingyun.sc.procurement.vo.change.CreateProcurementPlanChangeLineVo;
|
38
|
import com.lframework.xingyun.sc.procurement.vo.change.CreateProcurementPlanChangeLineVo;
|
|
35
|
import com.lframework.xingyun.sc.procurement.vo.change.CreateProcurementPlanChangeVo;
|
39
|
import com.lframework.xingyun.sc.procurement.vo.change.CreateProcurementPlanChangeVo;
|
|
36
|
import com.lframework.xingyun.sc.procurement.vo.change.QueryProcurementPlanChangeVo;
|
40
|
import com.lframework.xingyun.sc.procurement.vo.change.QueryProcurementPlanChangeVo;
|
|
@@ -59,6 +63,10 @@ public class ProcurementPlanChangeServiceImpl extends |
|
@@ -59,6 +63,10 @@ public class ProcurementPlanChangeServiceImpl extends |
|
59
|
private SysRoleService sysRoleService;
|
63
|
private SysRoleService sysRoleService;
|
|
60
|
@Resource
|
64
|
@Resource
|
|
61
|
private FlowInstanceWrapperService flowInstanceWrapperService;
|
65
|
private FlowInstanceWrapperService flowInstanceWrapperService;
|
|
|
|
66
|
+ @Resource
|
|
|
|
67
|
+ private ProcurementPlanLineService procurementPlanLineService;
|
|
|
|
68
|
+ @Resource
|
|
|
|
69
|
+ private ProcurementBuyoutApplyService procurementBuyoutApplyService;
|
|
62
|
|
70
|
|
|
63
|
|
71
|
|
|
64
|
private static final List<String> PROCESS_STATUSES = Arrays.asList(
|
72
|
private static final List<String> PROCESS_STATUSES = Arrays.asList(
|
|
@@ -81,54 +89,155 @@ public class ProcurementPlanChangeServiceImpl extends |
|
@@ -81,54 +89,155 @@ public class ProcurementPlanChangeServiceImpl extends |
|
81
|
throw new DefaultClientException("原采购计划不存在!");
|
89
|
throw new DefaultClientException("原采购计划不存在!");
|
|
82
|
}
|
90
|
}
|
|
83
|
|
91
|
|
|
84
|
- if (StringUtil.isNotBlank(plan.getParentId())) {
|
|
|
|
85
|
- throw new DefaultClientException("只能选择主计划进行变更!");
|
|
|
|
86
|
- }
|
|
|
|
87
|
-
|
|
|
|
88
|
if (StringUtil.isBlank(plan.getProcessStatus())
|
92
|
if (StringUtil.isBlank(plan.getProcessStatus())
|
|
89
|
|| !PROCESS_STATUSES.contains(plan.getProcessStatus())) {
|
93
|
|| !PROCESS_STATUSES.contains(plan.getProcessStatus())) {
|
|
90
|
throw new DefaultClientException("原采购计划状态不允许变更,请确认计划已中止/完成");
|
94
|
throw new DefaultClientException("原采购计划状态不允许变更,请确认计划已中止/完成");
|
|
91
|
}
|
95
|
}
|
|
92
|
- String currentUserId = SecurityUtil.getCurrentUser().getId();
|
|
|
|
93
|
- List<SysRole> roles = sysRoleService.getByUserId(currentUserId);
|
|
|
|
94
|
- List<String> roleCodes = CollectionUtil.isEmpty(roles) ? new java.util.ArrayList<>()
|
|
|
|
95
|
- : roles.stream().map(SysRole::getCode).collect(Collectors.toList());
|
|
|
|
96
|
- ProcurementPlanChange planChange = new ProcurementPlanChange();
|
|
|
|
97
|
- BeanUtil.copyProperties(vo, planChange);
|
|
|
|
98
|
- planChange.setId(IdUtil.getId());
|
|
|
|
99
|
- if (roleCodes.contains("ltcgczg") || roleCodes.contains("ztcgczg")
|
|
|
|
100
|
- || roleCodes.contains("htcgeczg") || roleCodes.contains("htcgyczg")) {
|
|
|
|
101
|
- planChange.setProcessNode("CGCZG");
|
|
|
|
102
|
- } else if (roleCodes.contains("qyjl")) {
|
|
|
|
103
|
- planChange.setProcessNode("QYJL");
|
|
|
|
104
|
- } else if (roleCodes.contains("nmcgkywy")) {
|
|
|
|
105
|
- planChange.setProcessNode("YWY");
|
|
|
|
106
|
- }
|
96
|
+ if ("FAST".equals(vo.getChangeType())) {
|
|
|
|
97
|
+ ProcurementPlanChange planChange = new ProcurementPlanChange();
|
|
|
|
98
|
+ BeanUtil.copyProperties(vo, planChange);
|
|
|
|
99
|
+ planChange.setId(IdUtil.getId());
|
|
|
|
100
|
+ planChange.setCode("K" + vo.getCode());
|
|
|
|
101
|
+ this.save(planChange);
|
|
|
|
102
|
+
|
|
|
|
103
|
+ List<ProcurementPlanChangeLine> lines = new ArrayList<>();
|
|
|
|
104
|
+ if (!CollectionUtil.isEmpty(vo.getLines())) {
|
|
|
|
105
|
+ for (CreateProcurementPlanChangeLineVo lineVo : vo.getLines()) {
|
|
|
|
106
|
+ ProcurementPlanChangeLine line = new ProcurementPlanChangeLine();
|
|
|
|
107
|
+ BeanUtil.copyProperties(lineVo, line);
|
|
|
|
108
|
+ line.setId(IdUtil.getId());
|
|
|
|
109
|
+ line.setProcurementPlanChangeId(planChange.getId());
|
|
|
|
110
|
+ lines.add(line);
|
|
|
|
111
|
+ }
|
|
|
|
112
|
+ }
|
|
107
|
|
113
|
|
|
|
|
114
|
+ if (!CollectionUtil.isEmpty(lines)) {
|
|
|
|
115
|
+ procurementPlanChangeLineService.saveBatch(lines);
|
|
|
|
116
|
+ }
|
|
108
|
|
117
|
|
|
109
|
- this.save(planChange);
|
118
|
+ //变更的是子计划 直接修改(开票品名 公司名称 另付运费 分厂)子计划的数据(无需修改主计划、合同数据),需重新生成买断操作申请单(如有买断)
|
|
|
|
119
|
+ if (StringUtil.isNotEmpty(plan.getParentId())) {
|
|
|
|
120
|
+ //修改 开票品名 公司名称 另付运费
|
|
|
|
121
|
+ Wrapper<ProcurementPlan> parentWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class)
|
|
|
|
122
|
+ .set(ProcurementPlan::getInvoiceProductName, vo.getInvoiceProductName())
|
|
|
|
123
|
+ .set(ProcurementPlan::getCompanyShortId, vo.getCompanyShortId())
|
|
|
|
124
|
+ .set(ProcurementPlan::getShippingCost, vo.getShippingCost())
|
|
|
|
125
|
+ .set(ProcurementPlan::getWorkshopId, vo.getLines().get(0).getWorkshopId())
|
|
|
|
126
|
+ .set(ProcurementPlan::getProcessStatus, "COMPLETED")
|
|
|
|
127
|
+ .set(ProcurementPlan::getProcessNode, null)
|
|
|
|
128
|
+ .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
|
|
|
|
129
|
+ procurementPlanService.update(parentWrapper);
|
|
|
|
130
|
+ //修改分厂
|
|
|
|
131
|
+ Wrapper<ProcurementPlanLine> lineWrapper = Wrappers.lambdaUpdate(ProcurementPlanLine.class)
|
|
|
|
132
|
+ .set(ProcurementPlanLine::getWorkshopId, vo.getLines().get(0).getWorkshopId())
|
|
|
|
133
|
+ .eq(ProcurementPlanLine::getProcurementPlanId, vo.getProcurementPlanId());
|
|
|
|
134
|
+ procurementPlanLineService.update(lineWrapper);
|
|
|
|
135
|
+ //先删除买断操作申请单
|
|
|
|
136
|
+ procurementBuyoutApplyService.deleteByPlanId(vo.getProcurementPlanId());
|
|
|
|
137
|
+ //重新生成买断操作申请单
|
|
|
|
138
|
+ CreateProcurementBuyoutApplyVo vo1 = new CreateProcurementBuyoutApplyVo();
|
|
|
|
139
|
+ vo1.setProcurementPlanId(vo.getProcurementPlanId());
|
|
|
|
140
|
+ procurementBuyoutApplyService.create(vo1);
|
|
|
|
141
|
+ } else {
|
|
|
|
142
|
+ //变更的是主计划(开票品名 公司名称 另付运费) 直接修改主计划的数据、合同数据、子计划数据,子计划买断操作申请单(如果只有主计划就只生成主计划的买断操作申请单)
|
|
|
|
143
|
+ Wrapper<ProcurementPlan> queryWrapper = Wrappers.lambdaQuery(ProcurementPlan.class)
|
|
|
|
144
|
+ .eq(ProcurementPlan::getFrozen, false)
|
|
|
|
145
|
+ .eq(ProcurementPlan::getParentId, vo.getProcurementPlanId());
|
|
|
|
146
|
+ List<ProcurementPlan> list = procurementPlanService.list(queryWrapper);
|
|
|
|
147
|
+ //有子计划
|
|
|
|
148
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
149
|
+ //修改主计划 开票品名 公司名称 另付运费
|
|
|
|
150
|
+ Wrapper<ProcurementPlan> parentWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class)
|
|
|
|
151
|
+ .set(ProcurementPlan::getInvoiceProductName, vo.getInvoiceProductName())
|
|
|
|
152
|
+ .set(ProcurementPlan::getCompanyShortId, vo.getCompanyShortId())
|
|
|
|
153
|
+ .set(ProcurementPlan::getShippingCost, vo.getShippingCost())
|
|
|
|
154
|
+ .set(ProcurementPlan::getProcessStatus, "COMPLETED")
|
|
|
|
155
|
+ .set(ProcurementPlan::getProcessNode, null)
|
|
|
|
156
|
+ .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
|
|
|
|
157
|
+ procurementPlanService.update(parentWrapper);
|
|
|
|
158
|
+
|
|
|
|
159
|
+ //修改子计划 开票品名 公司名称 另付运费
|
|
|
|
160
|
+ Wrapper<ProcurementPlan> sonWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class)
|
|
|
|
161
|
+ .set(ProcurementPlan::getInvoiceProductName, vo.getInvoiceProductName())
|
|
|
|
162
|
+ .set(ProcurementPlan::getCompanyShortId, vo.getCompanyShortId())
|
|
|
|
163
|
+ .set(ProcurementPlan::getShippingCost, vo.getShippingCost())
|
|
|
|
164
|
+ .set(ProcurementPlan::getProcessStatus, "COMPLETED")
|
|
|
|
165
|
+ .set(ProcurementPlan::getProcessNode, null)
|
|
|
|
166
|
+ .eq(ProcurementPlan::getParentId, vo.getProcurementPlanId());
|
|
|
|
167
|
+ procurementPlanService.update(sonWrapper);
|
|
|
|
168
|
+
|
|
|
|
169
|
+ for (ProcurementPlan procurementPlan : list) {
|
|
|
|
170
|
+ //先删除子计划买断操作申请单
|
|
|
|
171
|
+ procurementBuyoutApplyService.deleteByPlanId(procurementPlan.getId());
|
|
|
|
172
|
+ //重新生成子计划买断操作申请单
|
|
|
|
173
|
+ CreateProcurementBuyoutApplyVo vo1 = new CreateProcurementBuyoutApplyVo();
|
|
|
|
174
|
+ vo1.setProcurementPlanId(procurementPlan.getId());
|
|
|
|
175
|
+ procurementBuyoutApplyService.create(vo1);
|
|
|
|
176
|
+ }
|
|
|
|
177
|
+ //todo 作废合同,生成新合同
|
|
|
|
178
|
+ } else {
|
|
|
|
179
|
+ //没有子计划
|
|
|
|
180
|
+ //修改 开票品名 公司名称 另付运费
|
|
|
|
181
|
+ Wrapper<ProcurementPlan> parentWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class)
|
|
|
|
182
|
+ .set(ProcurementPlan::getInvoiceProductName, vo.getInvoiceProductName())
|
|
|
|
183
|
+ .set(ProcurementPlan::getCompanyShortId, vo.getCompanyShortId())
|
|
|
|
184
|
+ .set(ProcurementPlan::getShippingCost, vo.getShippingCost())
|
|
|
|
185
|
+ .set(ProcurementPlan::getWorkshopId, vo.getLines().get(0).getWorkshopId())
|
|
|
|
186
|
+ .set(ProcurementPlan::getProcessStatus, "COMPLETED")
|
|
|
|
187
|
+ .set(ProcurementPlan::getProcessNode, null)
|
|
|
|
188
|
+ .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
|
|
|
|
189
|
+ procurementPlanService.update(parentWrapper);
|
|
|
|
190
|
+ //先删除买断操作申请单
|
|
|
|
191
|
+ procurementBuyoutApplyService.deleteByPlanId(vo.getProcurementPlanId());
|
|
|
|
192
|
+ //重新生成买断操作申请单
|
|
|
|
193
|
+ CreateProcurementBuyoutApplyVo vo1 = new CreateProcurementBuyoutApplyVo();
|
|
|
|
194
|
+ vo1.setProcurementPlanId(vo.getProcurementPlanId());
|
|
|
|
195
|
+ procurementBuyoutApplyService.create(vo1);
|
|
|
|
196
|
+ }
|
|
|
|
197
|
+ }
|
|
|
|
198
|
+ return planChange.getId();
|
|
|
|
199
|
+ } else {
|
|
|
|
200
|
+ String currentUserId = SecurityUtil.getCurrentUser().getId();
|
|
|
|
201
|
+ List<SysRole> roles = sysRoleService.getByUserId(currentUserId);
|
|
|
|
202
|
+ List<String> roleCodes = CollectionUtil.isEmpty(roles) ? new java.util.ArrayList<>()
|
|
|
|
203
|
+ : roles.stream().map(SysRole::getCode).collect(Collectors.toList());
|
|
|
|
204
|
+ ProcurementPlanChange planChange = new ProcurementPlanChange();
|
|
|
|
205
|
+ BeanUtil.copyProperties(vo, planChange);
|
|
|
|
206
|
+ planChange.setId(IdUtil.getId());
|
|
|
|
207
|
+ if (roleCodes.contains("ltcgczg") || roleCodes.contains("ztcgczg")
|
|
|
|
208
|
+ || roleCodes.contains("htcgeczg") || roleCodes.contains("htcgyczg")) {
|
|
|
|
209
|
+ planChange.setProcessNode("CGCZG");
|
|
|
|
210
|
+ } else if (roleCodes.contains("qyjl")) {
|
|
|
|
211
|
+ planChange.setProcessNode("QYJL");
|
|
|
|
212
|
+ } else if (roleCodes.contains("nmcgkywy")) {
|
|
|
|
213
|
+ planChange.setProcessNode("YWY");
|
|
|
|
214
|
+ }
|
|
|
|
215
|
+
|
|
|
|
216
|
+
|
|
|
|
217
|
+ this.save(planChange);
|
|
|
|
218
|
+
|
|
|
|
219
|
+ List<ProcurementPlanChangeLine> lines = new ArrayList<>();
|
|
|
|
220
|
+ if (!CollectionUtil.isEmpty(vo.getLines())) {
|
|
|
|
221
|
+ for (CreateProcurementPlanChangeLineVo lineVo : vo.getLines()) {
|
|
|
|
222
|
+ ProcurementPlanChangeLine line = new ProcurementPlanChangeLine();
|
|
|
|
223
|
+ BeanUtil.copyProperties(lineVo, line);
|
|
|
|
224
|
+ line.setId(IdUtil.getId());
|
|
|
|
225
|
+ line.setProcurementPlanChangeId(planChange.getId());
|
|
|
|
226
|
+ lines.add(line);
|
|
|
|
227
|
+ }
|
|
|
|
228
|
+ }
|
|
110
|
|
229
|
|
|
111
|
- List<ProcurementPlanChangeLine> lines = new ArrayList<>();
|
|
|
|
112
|
- if (!CollectionUtil.isEmpty(vo.getLines())) {
|
|
|
|
113
|
- for (CreateProcurementPlanChangeLineVo lineVo : vo.getLines()) {
|
|
|
|
114
|
- ProcurementPlanChangeLine line = new ProcurementPlanChangeLine();
|
|
|
|
115
|
- BeanUtil.copyProperties(lineVo, line);
|
|
|
|
116
|
- line.setId(IdUtil.getId());
|
|
|
|
117
|
- line.setProcurementPlanChangeId(planChange.getId());
|
|
|
|
118
|
- lines.add(line);
|
230
|
+ if (!CollectionUtil.isEmpty(lines)) {
|
|
|
|
231
|
+ procurementPlanChangeLineService.saveBatch(lines);
|
|
119
|
}
|
232
|
}
|
|
120
|
- }
|
233
|
+ //更新采购计划变更状态为 变更中
|
|
|
|
234
|
+ Wrapper<ProcurementPlan> parentWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class)
|
|
|
|
235
|
+ .set(ProcurementPlan::getChangeStatus, "CHANGING")
|
|
|
|
236
|
+ .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
|
|
|
|
237
|
+ procurementPlanService.update(parentWrapper);
|
|
121
|
|
238
|
|
|
122
|
- if (!CollectionUtil.isEmpty(lines)) {
|
|
|
|
123
|
- procurementPlanChangeLineService.saveBatch(lines);
|
239
|
+ return planChange.getId();
|
|
124
|
}
|
240
|
}
|
|
125
|
- //更新采购计划变更状态为 变更中
|
|
|
|
126
|
- Wrapper<ProcurementPlan> parentWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class)
|
|
|
|
127
|
- .set(ProcurementPlan::getChangeStatus, "CHANGING")
|
|
|
|
128
|
- .eq(ProcurementPlan::getId, vo.getProcurementPlanId());
|
|
|
|
129
|
- procurementPlanService.update(parentWrapper);
|
|
|
|
130
|
-
|
|
|
|
131
|
- return planChange.getId();
|
|
|
|
132
|
}
|
241
|
}
|
|
133
|
|
242
|
|
|
134
|
@Override
|
243
|
@Override
|