TaskDetailServiceImpl.java
7.02 KB
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
package com.huaheng.pc.task.taskDetail.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.pc.config.FilterConfigDetail.domain.FilterConfigDetail;
import com.huaheng.pc.config.FilterConfigDetail.service.FilterConfigDetailService;
import com.huaheng.pc.config.cycleCountPreference.domain.CycleCountPreference;
import com.huaheng.pc.config.cycleCountPreference.service.CycleCountPreferenceService;
import com.huaheng.pc.config.receiptPreference.domain.ReceiptPreference;
import com.huaheng.pc.config.receiptPreference.service.ReceiptPreferenceService;
import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceService;
import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.task.taskDetail.mapper.TaskDetailMapper;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import org.springframework.transaction.annotation.Transactional;
@Service
public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDetail> implements TaskDetailService{
@Resource
private CycleCountDetailService cycleCountDetailService;
@Resource
private CycleCountPreferenceService cycleCountPreferenceService;
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private ReceiptPreferenceService receiptPreferenceService;
@Resource
private ShipmentPreferenceService shipmentPreferenceService;
@Resource
private FilterConfigDetailService filterConfigDetailService;
/**
* 盘点任务首选项
* @param taskDetailList
* @return
*/
@Transactional
@Override
public List<TaskDetail> preferenceRealize(List<TaskDetail> taskDetailList) {
/*查出盘点明细,找出盘点首选项,根据首选项显示字段*/
List<TaskDetail> taskDetails = new ArrayList<>();
for (TaskDetail item:taskDetailList){
//盘点明细
CycleCountDetail cycleCountDetailtemp = new CycleCountDetail();
cycleCountDetailtemp.setCycleCountHeadCode(item.getBillCode());
cycleCountDetailtemp.setId(item.getBillDetailId());
LambdaQueryWrapper<CycleCountDetail> detailLambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountDetailtemp);
CycleCountDetail cycleCountDetail = cycleCountDetailService.getOne(detailLambdaQueryWrapper);
if(cycleCountDetail == null){
throw new SecurityException("没有找到子任务对应的盘点明细!");
}
//找盘点首选项
CycleCountPreference cycleCountPreferenceTemp = new CycleCountPreference();
cycleCountPreferenceTemp.setCode(cycleCountDetail.getPreferenceCode());
cycleCountPreferenceTemp.setWarehouseCode(cycleCountDetail.getWarehouseCode());
LambdaQueryWrapper<CycleCountPreference> preferenceLambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountPreferenceTemp);
CycleCountPreference cycleCountPreference = cycleCountPreferenceService.getOne(preferenceLambdaQueryWrapper);
if(cycleCountPreference == null){
throw new SecurityException("没有找到盘点首选项!");
}
//根据首选项判断数据
if(cycleCountPreference.getPromptLocation() == false){
//库位
item.setFromLocation("");
item.setToLocation("");
}
if(cycleCountPreference.getPromptLpn() == false){
//容器
item.setContainerCode("");
}
if(cycleCountPreference.getPromptItem() == false){
//物料
item.setMaterialCode("");
item.setMaterialName("");
item.setMaterialUnit("");
item.setMaterialSpec("");
}
if(cycleCountPreference.getPromptQuantity() == false){
//系统数量
item.setQty(null);
}
taskDetails.add(item);
}
return taskDetails;
}
/**
* 任务位置拣货单打印
* 根据任务头表id查询任务明细,根据上架或拣货货规则排序
* @param ids 头表id数组
* @return
*/
@Override
public List<TaskDetail> findByTaskId(Integer[] ids) {
Integer taskType = taskHeaderService.getById(ids[0]).getTaskType();
String filterConfigCode = "";
if (taskType.equals(QuantityConstant.TASK_TYPE_WHOLERECEIPT) || taskType.equals(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)) {
ReceiptPreference receiptPreference = receiptPreferenceService.list().get(0);
filterConfigCode = receiptPreference.getListingRules();
}
if (taskType.equals(QuantityConstant.TASK_TYPE_WHOLESHIPMENT) || taskType.equals(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT)) {
ShipmentPreference shipmentPreference = shipmentPreferenceService.list().get(0);
filterConfigCode = shipmentPreference.getShipmentPickingRule();
}
FilterConfigDetail filterConfigDetail = new FilterConfigDetail();
if (StringUtils.isNotEmpty(filterConfigCode)) {
LambdaQueryWrapper<FilterConfigDetail> detailQueryWrapper = Wrappers.lambdaQuery();
detailQueryWrapper.eq(FilterConfigDetail::getCode, filterConfigCode);
filterConfigDetail = filterConfigDetailService.getOne(detailQueryWrapper);
}
//Integer数组转object数组
Object[] objects = new Object[ids.length];
try{
for(int i = 0; i < ids.length ; i++){
Object a = (ids[i]);
objects[i] = a;
}
}catch (Exception e){
throw new ServiceException(e.toString());
}
LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery();
queryWrapper
.in(TaskDetail::getTaskId, objects)
.last(StringUtils.isNotEmpty(filterConfigDetail.getStatement()), filterConfigDetail.getStatement());
return this.list(queryWrapper);
}
/**
* 根据任务头表id查询任务明细
* @param id
* @return
*/
@Override
public List<TaskDetail> findByTaskId(Integer id) {
LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(TaskDetail::getTaskId, id);
return this.list(queryWrapper);
}
}