Commit 8328f1eed6df5d4be6608a20d53d4577071794b9

Authored by 周鸿
1 parent 5145b9c8

入库组盘生成任务时,有一个显示新建任务状态,实际生成了任务

src/main/java/com/huaheng/pc/task/taskHeader/service/ReceiptTaskService.java
@@ -138,16 +138,36 @@ public class ReceiptTaskService { @@ -138,16 +138,36 @@ public class ReceiptTaskService {
138 if (!receiptContainerHeader.getWarehouseCode().equals(ShiroUtils.getWarehouseCode())) { 138 if (!receiptContainerHeader.getWarehouseCode().equals(ShiroUtils.getWarehouseCode())) {
139 throw new ServiceException("id:" + id + "的入库组盘不能在" + ShiroUtils.getWarehouseCode() + "仓库操作"); 139 throw new ServiceException("id:" + id + "的入库组盘不能在" + ShiroUtils.getWarehouseCode() + "仓库操作");
140 } 140 }
141 - Container container = containerService.getContainerByCode(receiptContainerHeader.getContainerCode());  
142 - if(container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {  
143 - throw new ServiceException("托盘已经锁定,不能生成任务");  
144 - }  
145 - //锁定容器  
146 - containerService.updateStatus(receiptContainerHeader.getContainerCode(), QuantityConstant.STATUS_CONTAINER_LOCK, container.getWarehouseCode()); 141 +
  142 +
147 //查询入库组盘明细 143 //查询入库组盘明细
148 - List<ReceiptContainerDetail> list = receiptContainerDetailService.list(new LambdaQueryWrapper<ReceiptContainerDetail>().eq(ReceiptContainerDetail::getReceiptContainerId, id)); 144 + LambdaQueryWrapper<ReceiptContainerDetail> lam = Wrappers.lambdaQuery();
  145 + lam.eq(ReceiptContainerDetail::getReceiptContainerId,id);
  146 + lam.lt(ReceiptContainerDetail::getStatus,QuantityConstant.RECEIPT_CONTAINER_TASK);
  147 + List<ReceiptContainerDetail> list = receiptContainerDetailService.list(lam);
  148 +
  149 +// List<ReceiptContainerDetail> list = receiptContainerDetailService.list(new LambdaQueryWrapper<ReceiptContainerDetail>().eq(ReceiptContainerDetail::getReceiptContainerId, id));
149 if (list.isEmpty()) { 150 if (list.isEmpty()) {
150 - throw new ServiceException("id:" + id + "的入库组盘,没有组盘明细,请先组盘!"); 151 + throw new ServiceException("id:" + id + "的入库组盘,没有未生成任务的组盘明细!");
  152 + }
  153 + Container container = containerService.getContainerByCode(receiptContainerHeader.getContainerCode());
  154 + if(container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
  155 + //一般只有一个异常数据
  156 + ReceiptContainerDetail itemReceiptContainerDetail = list.get(0);
  157 + if (itemReceiptContainerDetail!=null) {
  158 + LambdaQueryWrapper<TaskDetail> detaillam = Wrappers.lambdaQuery();
  159 + detaillam.eq(TaskDetail::getAllocationId,itemReceiptContainerDetail.getId());
  160 + detaillam.last("limit 1");
  161 + TaskDetail taskDetail=taskDetailService.getOne(detaillam);
  162 + if(taskDetail!=null){
  163 + //更新入库组盘明细状态
  164 + itemReceiptContainerDetail.setStatus(QuantityConstant.RECEIPT_CONTAINER_TASK);
  165 + receiptContainerDetailService.updateById(itemReceiptContainerDetail);
  166 + return AjaxResult.success("生成任务成功").setData(taskDetail.getTaskId());
  167 + }
  168 + }else{
  169 + throw new ServiceException("托盘已经锁定,不能生成任务");
  170 + }
151 } 171 }
152 if(StringUtils.isNotEmpty(receiptContainerHeader.getFromLocation())) { 172 if(StringUtils.isNotEmpty(receiptContainerHeader.getFromLocation())) {
153 locationService.updateStatus(receiptContainerHeader.getFromLocation(), QuantityConstant.STATUS_LOCATION_LOCK); 173 locationService.updateStatus(receiptContainerHeader.getFromLocation(), QuantityConstant.STATUS_LOCATION_LOCK);
@@ -157,11 +177,11 @@ public class ReceiptTaskService { @@ -157,11 +177,11 @@ public class ReceiptTaskService {
157 locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK); 177 locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK);
158 Location desLocation = locationService.getLocationByCode(locationCode); 178 Location desLocation = locationService.getLocationByCode(locationCode);
159 if (desLocation==null){ 179 if (desLocation==null){
160 - return AjaxResult.error(receiptContainerHeader.getContainerCode()+",该托盘没有这个库位,"+locationCode); 180 + throw new ServiceException(receiptContainerHeader.getContainerCode()+",该托盘没有这个库位,"+locationCode);
161 } 181 }
162 String loginWarehouse = ShiroUtils.getWarehouseCode(); 182 String loginWarehouse = ShiroUtils.getWarehouseCode();
163 if(!desLocation.getWarehouseCode().equals(loginWarehouse)) { 183 if(!desLocation.getWarehouseCode().equals(loginWarehouse)) {
164 - return AjaxResult.error("库位对应仓库不对"); 184 + throw new ServiceException("库位对应仓库不对");
165 } 185 }
166 //if (taskHeaderService.getUncompleteTaskInNear(desLocation) > 0) { 186 //if (taskHeaderService.getUncompleteTaskInNear(desLocation) > 0) {
167 // return AjaxResult.error("目标库位:" + desLocation + "旁边存在任务,请完成任务以后再分配"); 187 // return AjaxResult.error("目标库位:" + desLocation + "旁边存在任务,请完成任务以后再分配");
@@ -174,109 +194,24 @@ public class ReceiptTaskService { @@ -174,109 +194,24 @@ public class ReceiptTaskService {
174 throw new ServiceException("组盘状态更新失败"); 194 throw new ServiceException("组盘状态更新失败");
175 } 195 }
176 } 196 }
177 - //添加任务主表  
178 - TaskHeader task = new TaskHeader();  
179 - //成品入库任务将typeid改成1  
180 - if(StringUtils.isNotEmpty(receiptContainerHeader.getBarCodeHeaderCode())){  
181 - task.setTypeId(1);  
182 - }  
183 - task.setAllocationHeadId(receiptContainerHeader.getId());  
184 - task.setElectricQuantity(receiptContainerHeader.getElectricQuantity());  
185 - task.setAllocationHeadId(receiptContainerHeader.getId());  
186 - task.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_RECEIPT);  
187 - task.setWarehouseCode(receiptContainerHeader.getWarehouseCode());  
188 - task.setCompanyCode(receiptContainerHeader.getCompanyCode());  
189 - task.setStatus(QuantityConstant.TASK_STATUS_BUILD);  
190 - task.setTaskType(receiptContainerHeader.getTaskType());  
191 - task.setFromLocation(receiptContainerHeader.getFromLocation());  
192 - if(StringUtils.isNotEmpty(receiptContainerHeader.getToLocation())){  
193 - task.setToLocation(receiptContainerHeader.getToLocation());  
194 - Location location = locationService.getLocationByCode(task.getToLocation(), ShiroUtils.getWarehouseCode());  
195 - if(location != null) {  
196 - task.setZoneCode(location.getZoneCode());  
197 - }  
198 - }  
199 - if(StringUtils.isNotEmpty(receiptContainerHeader.getBarCodeHeaderCode())){  
200 - task.setBarCodeHeaderCode(receiptContainerHeader.getBarCodeHeaderCode());  
201 - task.setBarCodeHeaderId(receiptContainerHeader.getBarCodeHeaderId());  
202 - }  
203 - task.setContainerCode(receiptContainerHeader.getContainerCode());  
204 - task.setRecvDock(receiptContainerHeader.getRecvDock());  
205 - task.setPort(receiptContainerHeader.getPort());  
206 - //是否需要检测放电 197 + //锁定容器
  198 + containerService.updateStatus(receiptContainerHeader.getContainerCode(), QuantityConstant.STATUS_CONTAINER_LOCK, container.getWarehouseCode());
  199 + //是否需要检测放电
207 int isBatteryFlag=1; 200 int isBatteryFlag=1;
  201 + TaskHeader task=createTask(receiptContainerHeader);
  202 +
208 if (taskHeaderService.save(task)) { 203 if (taskHeaderService.save(task)) {
209 //添加任务明细表 204 //添加任务明细表
210 for (ReceiptContainerDetail item : list) { 205 for (ReceiptContainerDetail item : list) {
211 - TaskDetail taskDetail = new TaskDetail();  
212 - taskDetail.setTaskId(task.getId());  
213 - taskDetail.setTaskType(task.getTaskType());  
214 - taskDetail.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_RECEIPT);  
215 - taskDetail.setWarehouseCode(task.getWarehouseCode());  
216 - taskDetail.setAllocationId(item.getId());  
217 - taskDetail.setCompanyCode(task.getCompanyCode());  
218 - taskDetail.setBatteryPackTwoCode(item.getBatteryPackTwoCode());  
219 - taskDetail.setMaterialCode(item.getMaterialCode());  
220 - taskDetail.setMaterialName(item.getMaterialName());  
221 - taskDetail.setMaterialSpec(item.getMaterialSpec());  
222 - taskDetail.setMaterialUnit(item.getMaterialUnit());  
223 - taskDetail.setMaterialIsBattery(item.getMaterialIsBattery());  
224 - taskDetail.setInventorySts(item.getInventorySts());  
225 - taskDetail.setBillCode(item.getReceiptCode());  
226 - taskDetail.setBillDetailId(item.getReceiptDetailId());  
227 - //成品入库任务将typeid改成1  
228 - if(StringUtils.isNotEmpty(receiptContainerHeader.getBarCodeHeaderCode())){  
229 - taskDetail.setTypeId(1);  
230 - //taskDetail.setBillDetailId(item.getBarcodeDetailsId());  
231 - taskDetail.setBarcodeDetailsCode(item.getBarcodeDetailsCode());  
232 - taskDetail.setBarcodeDetailsId(item.getBarcodeDetailsId());  
233 - //taskDetail.setBillDetailId(rec);  
234 - }  
235 - taskDetail.setQty(item.getQty());  
236 - taskDetail.setWeights(item.getWeights());  
237 - taskDetail.setContainerCode(task.getContainerCode());  
238 - taskDetail.setFromLocation(task.getFromLocation());  
239 - taskDetail.setElectricQuantity(item.getElectricQuantity());  
240 - taskDetail.setMaterialNetWeight(item.getMaterialNetWeight());  
241 - taskDetail.setMaterialGrossWeight(item.getMaterialGrossWeight());  
242 - taskDetail.setMaterialNetWeight(item.getMaterialNetWeight());  
243 - taskDetail.setMaterialTareWeight(item.getMaterialTareWeight());  
244 - taskDetail.setMaterialBatch(item.getMaterialBatch());  
245 - if(StringUtils.isNotEmpty(task.getToLocation() )) {  
246 - taskDetail.setToLocation(task.getToLocation());  
247 - }  
248 - if(StringUtils.isNotEmpty(item.getSn() )){  
249 - taskDetail.setSn(item.getSn());  
250 - }  
251 - taskDetail.setBatch(item.getBatch());  
252 - taskDetail.setProjectNo(item.getProjectNo());  
253 - taskDetail.setBatteryQty(item.getBatteryQty());  
254 - taskDetail.setBatteryPackType(item.getBatteryPackType());  
255 - taskDetail.setBatteryTypes(item.getBatteryTypes());  
256 - taskDetail.setCompleteness(item.getCompleteness());  
257 - taskDetail.setRemark(item.getRemark());  
258 - taskDetail.setCountryCode(item.getCountryCode());  
259 - taskDetail.setRecycler(item.getRecycler());  
260 - /* System.out.println("id=="+item.getId());  
261 - System.out.println("taskDetail.getMaterialIsBattery()=="+taskDetail.getMaterialIsBattery());  
262 - System.out.println("taskDetail.getBatteryTypes()=="+taskDetail.getBatteryTypes());*/  
263 - if(taskDetail.getMaterialIsBattery()==1&&StringUtils.isNotEmpty(taskDetail.getBatteryTypes())&&taskDetail.getBatteryTypes().equals("1")){  
264 - taskDetail.setDischargeReview(2);  
265 - isBatteryFlag=2;  
266 - }else{  
267 - taskDetail.setDischargeReview(1); 206 + TaskDetail taskDetail=createTaskDetail(task,isBatteryFlag,item,receiptContainerHeader);
  207 + if (!taskDetailService.save(taskDetail)) {
  208 + throw new ServiceException("生成任务明细失败");
268 } 209 }
269 //更新入库组盘明细状态 210 //更新入库组盘明细状态
270 item.setStatus(QuantityConstant.RECEIPT_CONTAINER_TASK); 211 item.setStatus(QuantityConstant.RECEIPT_CONTAINER_TASK);
271 if (!receiptContainerDetailService.updateById(item)) { 212 if (!receiptContainerDetailService.updateById(item)) {
272 throw new ServiceException("更新入库组盘明细状态出错"); 213 throw new ServiceException("更新入库组盘明细状态出错");
273 } 214 }
274 - taskDetail.setPoundCode(item.getPoundCode());  
275 - taskDetail.setSupplierCode(item.getSupplierCode());  
276 - if (!taskDetailService.save(taskDetail)) {  
277 - throw new ServiceException("生成任务明细失败");  
278 - }  
279 -  
280 215
281 /* 修改明细状态为上架*/ 216 /* 修改明细状态为上架*/
282 ReceiptDetail receiptDetail = receiptDetailService.getById(item.getReceiptDetailId()); 217 ReceiptDetail receiptDetail = receiptDetailService.getById(item.getReceiptDetailId());
@@ -315,6 +250,106 @@ public class ReceiptTaskService { @@ -315,6 +250,106 @@ public class ReceiptTaskService {
315 250
316 } 251 }
317 252
  253 +
  254 + public TaskHeader createTask(ReceiptContainerHeader receiptContainerHeader){
  255 + //添加任务主表
  256 + TaskHeader task = new TaskHeader();
  257 + //成品入库任务将typeid改成1
  258 + if(StringUtils.isNotEmpty(receiptContainerHeader.getBarCodeHeaderCode())){
  259 + task.setTypeId(1);
  260 + }
  261 + task.setAllocationHeadId(receiptContainerHeader.getId());
  262 + task.setElectricQuantity(receiptContainerHeader.getElectricQuantity());
  263 + task.setAllocationHeadId(receiptContainerHeader.getId());
  264 + task.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_RECEIPT);
  265 + task.setWarehouseCode(receiptContainerHeader.getWarehouseCode());
  266 + task.setCompanyCode(receiptContainerHeader.getCompanyCode());
  267 + task.setStatus(QuantityConstant.TASK_STATUS_BUILD);
  268 + task.setTaskType(receiptContainerHeader.getTaskType());
  269 + task.setFromLocation(receiptContainerHeader.getFromLocation());
  270 + if(StringUtils.isNotEmpty(receiptContainerHeader.getToLocation())){
  271 + task.setToLocation(receiptContainerHeader.getToLocation());
  272 + Location location = locationService.getLocationByCode(task.getToLocation(), ShiroUtils.getWarehouseCode());
  273 + if(location != null) {
  274 + task.setZoneCode(location.getZoneCode());
  275 + }
  276 + }
  277 + if(StringUtils.isNotEmpty(receiptContainerHeader.getBarCodeHeaderCode())){
  278 + task.setBarCodeHeaderCode(receiptContainerHeader.getBarCodeHeaderCode());
  279 + task.setBarCodeHeaderId(receiptContainerHeader.getBarCodeHeaderId());
  280 + }
  281 + task.setContainerCode(receiptContainerHeader.getContainerCode());
  282 + task.setRecvDock(receiptContainerHeader.getRecvDock());
  283 + task.setPort(receiptContainerHeader.getPort());
  284 +
  285 + return task;
  286 + }
  287 +
  288 +
  289 + public TaskDetail createTaskDetail(TaskHeader task,int isBatteryFlag,ReceiptContainerDetail item,ReceiptContainerHeader receiptContainerHeader){
  290 + TaskDetail taskDetail = new TaskDetail();
  291 + taskDetail.setTaskId(task.getId());
  292 + taskDetail.setTaskType(task.getTaskType());
  293 + taskDetail.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_RECEIPT);
  294 + taskDetail.setWarehouseCode(task.getWarehouseCode());
  295 + taskDetail.setAllocationId(item.getId());
  296 + taskDetail.setCompanyCode(task.getCompanyCode());
  297 + taskDetail.setBatteryPackTwoCode(item.getBatteryPackTwoCode());
  298 + taskDetail.setMaterialCode(item.getMaterialCode());
  299 + taskDetail.setMaterialName(item.getMaterialName());
  300 + taskDetail.setMaterialSpec(item.getMaterialSpec());
  301 + taskDetail.setMaterialUnit(item.getMaterialUnit());
  302 + taskDetail.setMaterialIsBattery(item.getMaterialIsBattery());
  303 + taskDetail.setInventorySts(item.getInventorySts());
  304 + taskDetail.setBillCode(item.getReceiptCode());
  305 + taskDetail.setBillDetailId(item.getReceiptDetailId());
  306 + //成品入库任务将typeid改成1
  307 + if(StringUtils.isNotEmpty(receiptContainerHeader.getBarCodeHeaderCode())){
  308 + taskDetail.setTypeId(1);
  309 + //taskDetail.setBillDetailId(item.getBarcodeDetailsId());
  310 + taskDetail.setBarcodeDetailsCode(item.getBarcodeDetailsCode());
  311 + taskDetail.setBarcodeDetailsId(item.getBarcodeDetailsId());
  312 + //taskDetail.setBillDetailId(rec);
  313 + }
  314 + taskDetail.setQty(item.getQty());
  315 + taskDetail.setWeights(item.getWeights());
  316 + taskDetail.setContainerCode(task.getContainerCode());
  317 + taskDetail.setFromLocation(task.getFromLocation());
  318 + taskDetail.setElectricQuantity(item.getElectricQuantity());
  319 + taskDetail.setMaterialNetWeight(item.getMaterialNetWeight());
  320 + taskDetail.setMaterialGrossWeight(item.getMaterialGrossWeight());
  321 + taskDetail.setMaterialNetWeight(item.getMaterialNetWeight());
  322 + taskDetail.setMaterialTareWeight(item.getMaterialTareWeight());
  323 + taskDetail.setMaterialBatch(item.getMaterialBatch());
  324 + if(StringUtils.isNotEmpty(task.getToLocation() )) {
  325 + taskDetail.setToLocation(task.getToLocation());
  326 + }
  327 + if(StringUtils.isNotEmpty(item.getSn() )){
  328 + taskDetail.setSn(item.getSn());
  329 + }
  330 + taskDetail.setBatch(item.getBatch());
  331 + taskDetail.setProjectNo(item.getProjectNo());
  332 + taskDetail.setBatteryQty(item.getBatteryQty());
  333 + taskDetail.setBatteryPackType(item.getBatteryPackType());
  334 + taskDetail.setBatteryTypes(item.getBatteryTypes());
  335 + taskDetail.setCompleteness(item.getCompleteness());
  336 + taskDetail.setRemark(item.getRemark());
  337 + taskDetail.setCountryCode(item.getCountryCode());
  338 + taskDetail.setRecycler(item.getRecycler());
  339 + /* System.out.println("id=="+item.getId());
  340 + System.out.println("taskDetail.getMaterialIsBattery()=="+taskDetail.getMaterialIsBattery());
  341 + System.out.println("taskDetail.getBatteryTypes()=="+taskDetail.getBatteryTypes());*/
  342 + if(taskDetail.getMaterialIsBattery()==1&&StringUtils.isNotEmpty(taskDetail.getBatteryTypes())&&taskDetail.getBatteryTypes().equals("1")){
  343 + taskDetail.setDischargeReview(2);
  344 + isBatteryFlag=2;
  345 + }else{
  346 + taskDetail.setDischargeReview(1);
  347 + }
  348 + taskDetail.setPoundCode(item.getPoundCode());
  349 + taskDetail.setSupplierCode(item.getSupplierCode());
  350 + return taskDetail;
  351 + }
  352 +
318 public WcsTask createWcsTask(TaskHeader task){ 353 public WcsTask createWcsTask(TaskHeader task){
319 WcsTask wcsTask=new WcsTask(); 354 WcsTask wcsTask=new WcsTask();
320 wcsTask.setTaskNo(task.getId().toString()); 355 wcsTask.setTaskNo(task.getId().toString());