单据校验相关修改
							parent
							
								
									c2472cb5e6
								
							
						
					
					
						commit
						0f3d83a854
					
				| @ -0,0 +1,261 @@ | |||||||
|  | package com.glxp.api.service.inout; | ||||||
|  | 
 | ||||||
|  | import cn.hutool.core.collection.CollUtil; | ||||||
|  | import cn.hutool.core.util.StrUtil; | ||||||
|  | import com.glxp.api.constant.ConstantStatus; | ||||||
|  | import com.glxp.api.entity.basic.BasicBussinessTypeEntity; | ||||||
|  | import com.glxp.api.entity.inout.*; | ||||||
|  | import com.glxp.api.res.basic.UdiRelevanceResponse; | ||||||
|  | import com.glxp.api.service.basic.IBasicBussinessTypeService; | ||||||
|  | import org.springframework.beans.BeanUtils; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 校验出入库服务 | ||||||
|  |  */ | ||||||
|  | @Service | ||||||
|  | public class IoCheckInoutService { | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     IoOrderService orderService; | ||||||
|  |     @Resource | ||||||
|  |     IoCodeService codeService; | ||||||
|  |     @Resource | ||||||
|  |     IoCodeTempService codeTempService; | ||||||
|  |     @Resource | ||||||
|  |     IBasicBussinessTypeService basicBussinessTypeService; | ||||||
|  |     @Resource | ||||||
|  |     IoOrderDetailCodeService orderDetailCodeService; | ||||||
|  |     @Resource | ||||||
|  |     IoOrderDetailBizService orderDetailBizService; | ||||||
|  |     @Resource | ||||||
|  |     IoOrderDetailResultService orderDetailResultService; | ||||||
|  | 
 | ||||||
|  |     public void check(String orderId) { | ||||||
|  |         IoOrderEntity orderEntity = orderService.findByBillNo(orderId); | ||||||
|  |         BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction()); | ||||||
|  |         if (!bussinessTypeEntity.isCheckEnable()) { | ||||||
|  |             unCheckFinish(orderEntity); | ||||||
|  |         } else { | ||||||
|  |             if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_UDIMS) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckUdims()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_WEBNEW) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckWebNew()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_PDAED) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckPdaEd()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_PDAUN) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckPdaUn()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_PC) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckPc()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_CHANGE) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckChange()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_PEACE_CHANGE) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckBalance()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_UDISP) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckSp()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } else if (orderEntity.getFromType().intValue() == ConstantStatus.FROM_COPY) { | ||||||
|  |                 if (!bussinessTypeEntity.isCheckCopy()) { | ||||||
|  |                     unCheckFinish(orderEntity); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             checkFinish(orderEntity); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void unCheckFinish(IoOrderEntity orderEntity) { | ||||||
|  | 
 | ||||||
|  |         List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderEntity.getBillNo()); | ||||||
|  | 
 | ||||||
|  |         if (CollUtil.isEmpty(orderDetailCodeEntities)) { | ||||||
|  |             orderEntity.setStatus(ConstantStatus.ORDER_STATUS_FAIL); | ||||||
|  |             orderEntity.setUpdateTime(new Date()); | ||||||
|  |             orderEntity.setErrMsg("校验失败,扫码详情为空!"); | ||||||
|  |             orderService.update(orderEntity); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         orderDetailCodeEntities.forEach(orderDetailCodeEntity -> | ||||||
|  |         { | ||||||
|  |             //生成业务单据
 | ||||||
|  |             IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity(); | ||||||
|  |             BeanUtils.copyProperties(orderDetailCodeEntity, orderDetailBizEntity); | ||||||
|  |             orderDetailBizService.insert(orderDetailBizEntity); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |             //生成单据结果
 | ||||||
|  |             IoOrderDetailResultEntity orderDetailResultEntity = new IoOrderDetailResultEntity(); | ||||||
|  |             BeanUtils.copyProperties(orderDetailCodeEntity, orderDetailResultEntity); | ||||||
|  |             orderDetailResultService.insert(orderDetailResultEntity); | ||||||
|  | 
 | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|  |         orderEntity.setStatus(ConstantStatus.ORDER_STATUS_RECEIVEED); | ||||||
|  |         orderEntity.setUpdateTime(new Date()); | ||||||
|  |         orderService.update(orderEntity); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void checkFinish(IoOrderEntity orderEntity) { | ||||||
|  |         List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderEntity.getBillNo()); | ||||||
|  |         List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(orderEntity.getBillNo()); | ||||||
|  | 
 | ||||||
|  |         if (CollUtil.isEmpty(orderDetailCodeEntities)) { | ||||||
|  |             orderEntity.setStatus(ConstantStatus.ORDER_STATUS_FAIL); | ||||||
|  |             orderEntity.setUpdateTime(new Date()); | ||||||
|  |             orderEntity.setErrMsg("校验失败,扫码详情为空!"); | ||||||
|  |             orderService.update(orderEntity); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (CollUtil.isEmpty(orderDetailBizEntities)) { | ||||||
|  |             orderEntity.setStatus(ConstantStatus.ORDER_STATUS_FAIL); | ||||||
|  |             orderEntity.setUpdateTime(new Date()); | ||||||
|  |             orderEntity.setErrMsg("校验失败,业务详情为空!"); | ||||||
|  |             orderService.update(orderEntity); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         String errMsg = ""; | ||||||
|  |         //正向校验
 | ||||||
|  |         for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) { | ||||||
|  |             for (IoOrderDetailCodeEntity codeEntity : orderDetailCodeEntities) { | ||||||
|  |                 if (!bizEntity.isCheckSuccess() && !codeEntity.isCheckSuccess() && checkId(bizEntity, codeEntity) == null | ||||||
|  |                         && checkBatchNo(bizEntity, codeEntity) == null | ||||||
|  |                         && checkProductDate(bizEntity, codeEntity) == null | ||||||
|  |                         && checkExpireDate(bizEntity, codeEntity) == null | ||||||
|  |                 ) { | ||||||
|  | 
 | ||||||
|  |                     if (checkCount(bizEntity, codeEntity) == null) { | ||||||
|  |                         bizEntity.setCheckSuccess(true); | ||||||
|  |                         codeEntity.setCheckSuccess(true); | ||||||
|  |                     } | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) { | ||||||
|  |             if (!bizEntity.isCheckSuccess()) { | ||||||
|  |                 errMsg = errMsg + bizEntity.getCoName() + ";"; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         //反向校验
 | ||||||
|  |         for (IoOrderDetailCodeEntity codeEntity : orderDetailCodeEntities) { | ||||||
|  |             for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) { | ||||||
|  |                 if (!bizEntity.isCheckSuccess() && !codeEntity.isCheckSuccess() && checkId(bizEntity, codeEntity) == null | ||||||
|  |                         && checkBatchNo(bizEntity, codeEntity) == null | ||||||
|  |                         && checkProductDate(bizEntity, codeEntity) == null | ||||||
|  |                         && checkExpireDate(bizEntity, codeEntity) == null | ||||||
|  |                 ) { | ||||||
|  | 
 | ||||||
|  |                     if (checkCount(bizEntity, codeEntity) == null) { | ||||||
|  |                         bizEntity.setCheckSuccess(true); | ||||||
|  |                         codeEntity.setCheckSuccess(true); | ||||||
|  |                     } | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         for (IoOrderDetailCodeEntity codeEntity : orderDetailCodeEntities) { | ||||||
|  |             if (!codeEntity.isCheckSuccess()) { | ||||||
|  |                 errMsg = errMsg + codeEntity.getCoName() + ";"; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (StrUtil.isEmpty(errMsg)) { | ||||||
|  |             orderEntity.setErrMsg(errMsg + "校验失败"); | ||||||
|  |             orderEntity.setStatus(ConstantStatus.ORDER_STATUS_FAIL); | ||||||
|  |             orderEntity.setUpdateTime(new Date()); | ||||||
|  |             orderService.update(orderEntity); | ||||||
|  |         } else { | ||||||
|  |             //生成单据结果
 | ||||||
|  |             for (IoOrderDetailBizEntity orderDetailBizEntity : orderDetailBizEntities) { | ||||||
|  |                 IoOrderDetailResultEntity orderDetailResultEntity = new IoOrderDetailResultEntity(); | ||||||
|  |                 BeanUtils.copyProperties(orderDetailBizEntity, orderDetailResultEntity); | ||||||
|  |                 orderDetailResultService.insert(orderDetailResultEntity); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             //临时表转正式表
 | ||||||
|  |             List<IoCodeTempEntity> codeTempEntities = codeTempService.findByOrderId(orderEntity.getBillNo()); | ||||||
|  |             for (IoCodeTempEntity codeTempEntity : codeTempEntities) { | ||||||
|  |                 IoCodeEnttity codeEnttity = new IoCodeEnttity(); | ||||||
|  |                 BeanUtils.copyProperties(codeTempEntity, codeEnttity); | ||||||
|  |                 codeService.insert(codeEnttity); | ||||||
|  |             } | ||||||
|  |             codeTempService.deleteByBillNo(orderEntity.getBillNo()); | ||||||
|  |             orderEntity.setErrMsg("校验成功!"); | ||||||
|  |             orderEntity.setStatus(ConstantStatus.ORDER_STATUS_SUCCESS); | ||||||
|  |             orderEntity.setUpdateTime(new Date()); | ||||||
|  |             orderService.update(orderEntity); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String checkId(IoOrderDetailBizEntity bizEntity, IoOrderDetailCodeEntity codeEntity) { | ||||||
|  | 
 | ||||||
|  |         if (bizEntity.getBindRlFk() == codeEntity.getBindRlFk()) { | ||||||
|  |             return null; | ||||||
|  |         } else { | ||||||
|  |             return "产品ID不匹配"; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String checkBatchNo(IoOrderDetailBizEntity bizEntity, IoOrderDetailCodeEntity codeEntity) { | ||||||
|  | 
 | ||||||
|  |         if (StrUtil.nullToEmpty(bizEntity.getBatchNo()).equals(StrUtil.nullToEmpty(codeEntity.getBatchNo()))) { | ||||||
|  |             return null; | ||||||
|  |         } else { | ||||||
|  |             return bizEntity.getCoName() + "批次号不匹配"; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String checkProductDate(IoOrderDetailBizEntity bizEntity, IoOrderDetailCodeEntity codeEntity) { | ||||||
|  |         if (StrUtil.nullToEmpty(bizEntity.getBatchNo()).equals(StrUtil.nullToEmpty(codeEntity.getBatchNo()))) { | ||||||
|  |             return null; | ||||||
|  |         } else { | ||||||
|  |             return bizEntity.getCoName() + "批次号不匹配"; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String checkExpireDate(IoOrderDetailBizEntity bizEntity, IoOrderDetailCodeEntity codeEntity) { | ||||||
|  |         if (StrUtil.nullToEmpty(bizEntity.getBatchNo()).equals(StrUtil.nullToEmpty(codeEntity.getBatchNo()))) { | ||||||
|  |             return null; | ||||||
|  |         } else { | ||||||
|  |             return bizEntity.getCoName() + "批次号不匹配"; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String checkCount(IoOrderDetailBizEntity bizEntity, IoOrderDetailCodeEntity codeEntity) { | ||||||
|  |         if (bizEntity.getReCount() == codeEntity.getReCount()) { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |         return bizEntity.getCoName() + "数量不匹配!"; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,10 @@ | |||||||
|  | package com.glxp.api.service.inout; | ||||||
|  | 
 | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  | public class IoGenInvService { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,5 @@ | |||||||
|  | package com.glxp.api.service.inv; | ||||||
|  | 
 | ||||||
|  | public interface InvPreinOrderService { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,5 @@ | |||||||
|  | package com.glxp.api.service.inv; | ||||||
|  | 
 | ||||||
|  | public interface InvProductService { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,8 @@ | |||||||
|  | package com.glxp.api.service.inv.impl; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.service.inv.InvPreinOrderService; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  | public class InvPreinOrderServiceImpl implements InvPreinOrderService { | ||||||
|  | } | ||||||
| @ -0,0 +1,8 @@ | |||||||
|  | package com.glxp.api.service.inv.impl; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.service.inv.InvProductService; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  | public class InvProductServiceImpl implements InvProductService { | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in New Issue