|  |  |  | @ -8,10 +8,11 @@ import com.github.pagehelper.PageHelper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.Constant; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inv.InvPlaceOrderDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inv.InvPlaceOrderDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvPlaceOrderDetailEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.InvPlaceOrderEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.ConstantStatus; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.auth.InvWarehouseDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inv.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inv.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.AddInvPlaceOrderRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.FilterInvPlaceOrderRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inv.FilterInvPlaceRequest; | 
			
		
	
	
		
			
				
					|  |  |  | @ -20,6 +21,7 @@ import com.glxp.api.res.inv.BindInvSpaceRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.InvPlaceOrderDetailResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.InvPlaceOrderResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.auth.CustomerService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inv.InvPlaceOrderService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.GennerOrderUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.OrderNoTypeBean; | 
			
		
	
	
		
			
				
					|  |  |  | @ -45,6 +47,15 @@ public class InvPlaceOrderServiceImpl implements InvPlaceOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |     private CustomerService customerService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private GennerOrderUtils gennerOrderUtils; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private InvWarehouseDao invWarehouseDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private InvProductDetailDao invProductDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private InvPreProductDetailDao invPreProductDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private InvPreInProductDetailDao invPreInProductDetailDao; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public List<InvPlaceOrderResponse> filterList(FilterInvPlaceOrderRequest filterInvPlaceOrderRequest) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -106,11 +117,57 @@ public class InvPlaceOrderServiceImpl implements InvPlaceOrderService { | 
			
		
	
		
			
				
					|  |  |  |  | //        ew.isNull("invSpaceCode");
 | 
			
		
	
		
			
				
					|  |  |  |  | //        ew.
 | 
			
		
	
		
			
				
					|  |  |  |  | //        invPreInProductDetailDao.selectOne()
 | 
			
		
	
		
			
				
					|  |  |  |  |         Long relId = null; | 
			
		
	
		
			
				
					|  |  |  |  |         String batchNo = null; | 
			
		
	
		
			
				
					|  |  |  |  |         String nameCode = null; | 
			
		
	
		
			
				
					|  |  |  |  |         String supId = null; | 
			
		
	
		
			
				
					|  |  |  |  |         String produceDate = null; | 
			
		
	
		
			
				
					|  |  |  |  |         String expireDate = null; | 
			
		
	
		
			
				
					|  |  |  |  |         String serialNo = null; | 
			
		
	
		
			
				
					|  |  |  |  |         InvWarehouseEntity invWarehouseEntity = invWarehouseDao.selectOne(new QueryWrapper<InvWarehouseEntity>().eq("code", bindInvSpaceRequest.getInvCode())); | 
			
		
	
		
			
				
					|  |  |  |  |         if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_PREIN) { | 
			
		
	
		
			
				
					|  |  |  |  |             QueryWrapper<InvPreInProductDetailEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.eq("code", bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.last("limit 1"); | 
			
		
	
		
			
				
					|  |  |  |  |             InvPreInProductDetailEntity invPreInProductDetailEntity = invPreInProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |             relId = invPreInProductDetailEntity.getRelId(); | 
			
		
	
		
			
				
					|  |  |  |  |             batchNo = invPreInProductDetailEntity.getBatchNo(); | 
			
		
	
		
			
				
					|  |  |  |  |             nameCode = invPreInProductDetailEntity.getNameCode(); | 
			
		
	
		
			
				
					|  |  |  |  |             supId = invPreInProductDetailEntity.getSupId(); | 
			
		
	
		
			
				
					|  |  |  |  |             produceDate = invPreInProductDetailEntity.getProduceDate(); | 
			
		
	
		
			
				
					|  |  |  |  |             expireDate = invPreInProductDetailEntity.getExpireDate(); | 
			
		
	
		
			
				
					|  |  |  |  |             serialNo = invPreInProductDetailEntity.getSerialNo(); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_ADVANCE) { | 
			
		
	
		
			
				
					|  |  |  |  |             QueryWrapper<InvPreProductDetailEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.eq("code", bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.last("limit 1"); | 
			
		
	
		
			
				
					|  |  |  |  |             InvPreProductDetailEntity invPreInProductDetailEntity = invPreProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |             relId = invPreInProductDetailEntity.getRelId(); | 
			
		
	
		
			
				
					|  |  |  |  |             batchNo = invPreInProductDetailEntity.getBatchNo(); | 
			
		
	
		
			
				
					|  |  |  |  |             nameCode = invPreInProductDetailEntity.getNameCode(); | 
			
		
	
		
			
				
					|  |  |  |  |             supId = invPreInProductDetailEntity.getSupId(); | 
			
		
	
		
			
				
					|  |  |  |  |             produceDate = invPreInProductDetailEntity.getProduceDate(); | 
			
		
	
		
			
				
					|  |  |  |  |             expireDate = invPreInProductDetailEntity.getExpireDate(); | 
			
		
	
		
			
				
					|  |  |  |  |             serialNo = invPreInProductDetailEntity.getSerialNo(); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_NORMAL) { | 
			
		
	
		
			
				
					|  |  |  |  |             QueryWrapper<InvProductDetailEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.eq("code", bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.last("limit 1"); | 
			
		
	
		
			
				
					|  |  |  |  |             InvProductDetailEntity invPreInProductDetailEntity = invProductDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |             relId = invPreInProductDetailEntity.getRelId(); | 
			
		
	
		
			
				
					|  |  |  |  |             batchNo = invPreInProductDetailEntity.getBatchNo(); | 
			
		
	
		
			
				
					|  |  |  |  |             nameCode = invPreInProductDetailEntity.getNameCode(); | 
			
		
	
		
			
				
					|  |  |  |  |             supId = invPreInProductDetailEntity.getSupId(); | 
			
		
	
		
			
				
					|  |  |  |  |             produceDate = invPreInProductDetailEntity.getProduceDate(); | 
			
		
	
		
			
				
					|  |  |  |  |             expireDate = invPreInProductDetailEntity.getExpireDate(); | 
			
		
	
		
			
				
					|  |  |  |  |             serialNo = invPreInProductDetailEntity.getSerialNo(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //判断是不是第一次进行添加 是就插入一条主表
 | 
			
		
	
		
			
				
					|  |  |  |  |         String recordId = ""; | 
			
		
	
		
			
				
					|  |  |  |  |         if(StrUtil.isEmpty(bindInvSpaceRequest.getOrderId())){ | 
			
		
	
		
			
				
					|  |  |  |  |             InvPlaceOrderEntity invPlaceOrderEntity=new InvPlaceOrderEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (StrUtil.isEmpty(bindInvSpaceRequest.getOrderId())) { | 
			
		
	
		
			
				
					|  |  |  |  |             InvPlaceOrderEntity invPlaceOrderEntity = new InvPlaceOrderEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             //操作人ID
 | 
			
		
	
		
			
				
					|  |  |  |  |             String userId = customerService.getUserIdStr(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -126,39 +183,52 @@ public class InvPlaceOrderServiceImpl implements InvPlaceOrderService { | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDao.insert(orderEntity); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             //插入附表
 | 
			
		
	
		
			
				
					|  |  |  |  |             InvPlaceOrderDetailEntity invPlaceOrderDetailEntity=new InvPlaceOrderDetailEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setRecordId(recordId); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setBatchNo(batchNo); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setRelId(relId+""); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setNameCode(nameCode); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setExpireDate(expireDate); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setProduceDate(produceDate); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setSupId(supId); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setInvCode(bindInvSpaceRequest.getInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setInvSpaceCode(bindInvSpaceRequest.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setCode(bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setSerialNo(serialNo); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailEntity.setCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |             invPlaceOrderDetailDao.insert(invPlaceOrderDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |  |             recordId=bindInvSpaceRequest.getOrderId(); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             recordId = bindInvSpaceRequest.getOrderId(); | 
			
		
	
		
			
				
					|  |  |  |  |             //查询有没有存在一样的code有就加数量没有新增
 | 
			
		
	
		
			
				
					|  |  |  |  |             QueryWrapper<InvPlaceOrderDetailEntity> ew=new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.eq("recordId",bindInvSpaceRequest.getOrderId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.eq("code",bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             InvPlaceOrderDetailEntity invPlaceOrderDetailEntity=invPlaceOrderDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |             if(invPlaceOrderDetailEntity!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setCount(invPlaceOrderDetailEntity.getCount()+1); | 
			
		
	
		
			
				
					|  |  |  |  |             QueryWrapper<InvPlaceOrderDetailEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.eq("recordId", bindInvSpaceRequest.getOrderId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ew.eq("code", bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             InvPlaceOrderDetailEntity invPlaceOrderDetailEntity = invPlaceOrderDetailDao.selectOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |             if (invPlaceOrderDetailEntity != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setCount(invPlaceOrderDetailEntity.getCount() + 1); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailDao.updateById(invPlaceOrderDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |             }else{ | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 //插入附表
 | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity=new InvPlaceOrderDetailEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity = new InvPlaceOrderDetailEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setRecordId(bindInvSpaceRequest.getOrderId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setInvCode(bindInvSpaceRequest.getInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setBatchNo(batchNo); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setRelId(relId+""); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setNameCode(nameCode); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setExpireDate(expireDate); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setProduceDate(produceDate); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setSupId(supId); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setInvSpaceCode(bindInvSpaceRequest.getInvSpaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setCode(bindInvSpaceRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setCount(1); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailEntity.setSerialNo(serialNo); | 
			
		
	
		
			
				
					|  |  |  |  |                 invPlaceOrderDetailDao.insert(invPlaceOrderDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(recordId); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |