Fixiaobai
2023-11-16 d8d129a2e41f7099968cb4f4dc1b028ab985135f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
package com.chinaztt.mes.plan.controller;
 
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
import com.chinaztt.mes.plan.dto.CustomerOrderDTO;
import com.chinaztt.mes.plan.dto.MasterProductionScheduleDTO;
import com.chinaztt.mes.plan.dto.MpsStructureComponentDTO;
import com.chinaztt.mes.plan.dto.MpsStructureComponentTreeNode;
import com.chinaztt.mes.plan.entity.MasterProductionSchedule;
import com.chinaztt.mes.plan.entity.OperationTaskProduce;
import com.chinaztt.mes.plan.service.MasterProductionScheduleService;
import com.chinaztt.mes.technology.dto.StructureTree;
import com.chinaztt.mes.technology.service.StructureService;
import com.chinaztt.ztt.common.core.util.R;
import com.chinaztt.ztt.common.log.annotation.SysLog;
import com.chinaztt.ztt.common.security.annotation.Inner;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
 
 
/**
 * 主生产计划
 *
 * @author cxf
 * @date 2020-09-23 14:42:39
 */
@RestController
@AllArgsConstructor
@RequestMapping("/masterProductionSchedule")
@Api(value = "masterProductionSchedule", tags = "主生产计划")
public class MasterProductionScheduleController {
    private final StructureService structureService;
    private final MasterProductionScheduleService masterProductionScheduleService;
 
    /**
     * 分页查询
     *
     * @param page                        分页对象
     * @param masterProductionScheduleDTO 计划
     * @return R
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')")
    public R getMasterProductionSchedulePage(Page page, MasterProductionScheduleDTO masterProductionScheduleDTO) {
        return R.ok(masterProductionScheduleService.getMasterProductionSchedulePage(page, QueryWrapperUtil.gen(masterProductionScheduleDTO)));
    }
 
    /**
     * 通过id查询计划
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')")
    public R getById(@PathVariable("id") Long id) {
        return R.ok(masterProductionScheduleService.getById(id));
    }
 
    /**
     * 通过id查询计划
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/getByIdExt/{id}")
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')")
    public R getByIdExt(@PathVariable("id") Long id) {
        return R.ok(masterProductionScheduleService.getByIdExt(id));
    }
 
    /**
     * 新增计划
     *
     * @param masterProductionSchedule 计划
     * @return R
     */
    @ApiOperation(value = "新增计划", notes = "新增计划")
    @SysLog("新增计划")
    @PostMapping
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_add')")
    public R save(@RequestBody MasterProductionSchedule masterProductionSchedule) {
        return masterProductionScheduleService.doAdd(masterProductionSchedule);
    }
 
    /**
     * 修改计划
     *
     * @param masterProductionSchedule 计划
     * @return R
     */
    @ApiOperation(value = "修改计划", notes = "修改计划")
    @SysLog("修改计划")
    @PutMapping
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_edit')")
    public R updateById(@RequestBody MasterProductionSchedule masterProductionSchedule) {
        return R.ok(masterProductionScheduleService.updateById(masterProductionSchedule));
    }
 
    /**
     * 通过id删除计划
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除计划", notes = "通过id删除计划")
    @SysLog("通过id删除计划")
    @DeleteMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_del')")
    public R removeById(@PathVariable Long id) {
        return R.ok(masterProductionScheduleService.removeById(id));
    }
 
    /**
     * 通过id加载主生产计划来源
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "通过id加载主生产计划来源", notes = "通过id加载主生产计划来源")
    @GetMapping("/loadMasterPlanSource/{id}")
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')")
    public R loadMasterPlanSource(@PathVariable Long id) {
        return R.ok(masterProductionScheduleService.loadMasterPlanSourceById(id));
    }
 
    /**
     * 通过id加载主生产计划来源(客户订单)
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "通过id加载主生产计划来源(客户订单)", notes = "通过id加载主生产计划来源(客户订单)")
    @GetMapping("/loadMasterPlanSourceByCustomer/{id}")
    public R loadMasterPlanSourceByCustomer(@PathVariable Long id) {
        return R.ok(masterProductionScheduleService.loadMasterPlanSourceByCustomer(id));
    }
 
    /**
     * 通过id加载下发的订单
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "通过id加载下发的订单", notes = "通过id加载下发的订单")
    @GetMapping("/loadOrder/{id}")
    @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')")
    public R loadOrder(@PathVariable Long id) {
        return R.ok(masterProductionScheduleService.loadOrder(id));
    }
 
    /**
     * 修改来源的计划数量
     *
     * @param customerOrderDTO
     * @return
     */
    @ApiOperation(value = "修改来源的计划数量", notes = "修改来源的计划数量")
    @PostMapping("/updateQtyPlaned")
    public R updateQtyPlaned(@RequestBody CustomerOrderDTO customerOrderDTO) {
        return R.ok(masterProductionScheduleService.updateQtyPlaned(customerOrderDTO));
    }
 
    /**
     * 通过id查询bom结构
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "通过id查询bom结构", notes = "通过id查询bom结构")
    @GetMapping("/getMpsStructureComponent/{id}/{partId}")
    public R getMpsStructureComponentByMpsId(@PathVariable("id") Long id, @PathVariable("partId") Long partId) {
        List<MpsStructureComponentTreeNode> mpsStructureComponentTree = masterProductionScheduleService.getMpsStructureComponentByMpsId(id);
        if (CollectionUtil.isNotEmpty(mpsStructureComponentTree)) {
            return R.ok(mpsStructureComponentTree);
        } else {
            List<StructureTree> structureTreeList = null;
            StructureTree structureTree = structureService.getMasterTreeByPartId(partId);
            if (structureTree != null) {
                structureTreeList = new ArrayList<StructureTree>();
                structureTreeList.add(structureTree);
            }
            return R.ok(structureTreeList);
        }
    }
 
    /**
     * 保存bom结构
     *
     * @param list
     * @param mpsId
     * @return
     */
    @ApiOperation(value = "保存bom结构", notes = "保存bom结构")
    @PostMapping("/saveMpsStructureComponent/{mpsId}")
    public R saveMpsStructureComponent(@RequestBody List<MpsStructureComponentDTO> list, @PathVariable Long mpsId) {
        return R.ok(masterProductionScheduleService.saveMpsStructureComponent(list, mpsId));
    }
 
    /**
     * 通过id删除bom结构
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除bom结构", notes = "通过id删除bom结构")
    @SysLog("通过id删除bom结构")
    @DeleteMapping("deleteMpsStructureComponent/{id}")
    public R deleteMpsStructureComponentById(@PathVariable Long id) {
        return R.ok(masterProductionScheduleService.deleteMpsStructureComponentById(id));
    }
 
    /**
     * 新增bom结构
     *
     * @param mpsStructureComponentDTO
     * @param mpsId
     * @return
     */
    @ApiOperation(value = "新增bom结构", notes = "新增bom结构")
    @PostMapping("/insertMpsStructureComponent/{mpsId}")
    public R insertMpsStructureComponent(@RequestBody MpsStructureComponentDTO mpsStructureComponentDTO, @PathVariable Long mpsId) {
        return R.ok(masterProductionScheduleService.insertMpsStructureComponent(mpsStructureComponentDTO, mpsId));
    }
 
    /**
     * 修改bom结构
     *
     * @param mpsStructureComponentDTO
     * @return
     */
    @ApiOperation(value = "修改bom结构", notes = "修改bom结构")
    @PostMapping("/updateMpsStructureComponent")
    public R updateMpsStructureComponent(@RequestBody MpsStructureComponentDTO mpsStructureComponentDTO) {
        return R.ok(masterProductionScheduleService.updateMpsStructureComponent(mpsStructureComponentDTO));
    }
 
    /**
     * 状态变更
     *
     * @param ids
     * @return R
     */
    @ApiOperation(value = "状态变更", notes = "状态变更")
    @SysLog("状态变更")
    @PostMapping("/changeState/{event}")
    public R changeMarkPlanned(@RequestBody List<Long> ids, @PathVariable String event) {
        return R.ok(masterProductionScheduleService.changeState(ids, event));
    }
 
    /**
     * Description: 绑定工艺文件
     *
     * @param: mpsRequirementsDTOList
     * @return: R
     */
    @ApiOperation(value = "绑定工艺文件", notes = "绑定工艺文件")
    @PostMapping("/handleDocument/{docId}")
    public R handleDocument(@RequestBody List<Long> ids, @PathVariable Long docId) {
        return masterProductionScheduleService.handleDocument(ids, docId);
    }
 
    /**
     * Description: 取消关联工艺文件
     *
     * @param: mpsRequirementsDTOList
     * @return: R
     */
    @ApiOperation(value = "取消绑定工艺文件", notes = "取消绑定工艺文件")
    @PostMapping("/rejectHandleDocument")
    public R rejectHandleDocument(@RequestBody List<Long> ids) {
        return masterProductionScheduleService.rejectHandleDocument(ids);
    }
 
    /**
     * OA对接
     *
     * @param id
     */
    @GetMapping("/oa/{id}")
    public R oa(@PathVariable("id") Long id) {
        return masterProductionScheduleService.oa(id);
    }
 
    /**
     * 手动修改审核状态
     *
     * @param id     id
     * @param status 状态
     * @return
     */
    @GetMapping("/changeAudit/{id}/{status}")
    public R oa(@PathVariable("id") Long id, @PathVariable("status") String status) {
        return masterProductionScheduleService.changeAudit(id, status);
    }
 
    /**
     * 根据零件号查询库存可用性计划
     *
     * @param partNo 零件号
     * @return
     */
    @GetMapping("/queryInventUseablePlanStd")
    public R queryInventUseablePlanStd(String partNo) {
        return masterProductionScheduleService.queryInventUseablePlanStd(partNo);
    }
 
    /**
     * 根据工艺文件id查看工艺文件是否对接到ifs
     *
     * @param id
     * @return
     */
    @GetMapping("/checkIfsSync/{id}")
    public R checkIfsSync(@PathVariable("id") Long id) {
        return masterProductionScheduleService.checkIfsSync(id);
    }
 
 
    /**
     * 查询计划半成品数据
     *
     * @param id                       主计划的id
     * @param operationTaskProduceList 选择的段长数据
     * @return
     */
    @PostMapping("/getTheoryQuantity/{id}")
    public R getTheoryQuantity(@PathVariable("id") Long id, @RequestBody List<OperationTaskProduce> operationTaskProduceList) {
        return masterProductionScheduleService.getTheoryQuantity(id, operationTaskProduceList);
    }
 
 
 
    /**
     * 通过主计划号查询
     * @param mpsNo
     * @return
     */
    @ApiOperation(value = "通过主计划号查询", notes = "通过主计划号查询")
    @GetMapping("/getByMpsNo")
    public R getByCustomerOrderNo (@RequestParam("mpsNo") String mpsNo){
        return R.ok(masterProductionScheduleService.getOne(Wrappers.<MasterProductionSchedule>lambdaQuery()
                .eq(MasterProductionSchedule::getMpsNo, mpsNo)));
    }
 
    @ApiOperation(value = "通过主计划查询ifs库存生产采购计划", notes = "通过主计划查询ifs库存生产采购计划")
    @PostMapping("/addPlanPurchasing")
    @Inner(value = false)
    public R addPlanPurchasing(@RequestParam(required = false) List<MasterProductionSchedule>masterProductionSchedules){
        return R.ok(masterProductionScheduleService.addPlanPurchasing(masterProductionSchedules));
    }
 
}