|  |  |  | @ -0,0 +1,379 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package com.glxp.api.controller.inout; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.util.IdUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.github.pagehelper.PageInfo; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.Constant; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.ConstantStatus; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.constant.ConstantType; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.auth.AuthAdmin; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.auth.InvWarehouseEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.BasicBussinessTypeEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.UdiEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.UdiProductEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inout.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inout.IoOrderMutiRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inout.IoOrderMutiResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inout.IoOrderMutiSetResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.auth.CustomerService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.auth.InvWarehouseService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.IBasicBussinessTypeService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.UdiProductService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.inout.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.GennerOrderUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.OrderNoTypeBean; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.RedisUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.udi.FilterUdiUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.web.bind.annotation.RestController; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import java.lang.reflect.InvocationTargetException; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @RestController | 
			
		
	
		
			
				
					|  |  |  |  | public class IoOrderMutiController { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IoOrderMutiService ioOrderMutiService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private UdiProductService udiProductService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IoOrderMutiUseService ioOrderMutiUseService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IoOrderMutiSetService ioOrderMutiSetService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     RedisUtil redisUtil; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     CustomerService customerService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     GennerOrderUtils gennerOrderUtils; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IoOrderService orderService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCodeTempService codeTempService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IBasicBussinessTypeService basicBussinessTypeService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     InvWarehouseService invWarehouseService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/checkUdi") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse checkUdi(@RequestBody IoOrderMutiEntity ioOrderMutiEntity) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (StrUtil.isNotBlank(ioOrderMutiEntity.getUdiCode())) { | 
			
		
	
		
			
				
					|  |  |  |  |             //查询码是否包含序列号
 | 
			
		
	
		
			
				
					|  |  |  |  |             UdiEntity udiEntity = FilterUdiUtils.getUdi(ioOrderMutiEntity.getUdiCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isNotBlank(udiEntity.getSerialNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 //包含
 | 
			
		
	
		
			
				
					|  |  |  |  |                 QueryWrapper<IoOrderMutiEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                 ew.eq("udiCode", ioOrderMutiEntity.getUdiCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 IoOrderMutiEntity ioOrderMutiEntityOne = ioOrderMutiService.getOne(ew); | 
			
		
	
		
			
				
					|  |  |  |  |                 //查询是否被使用过
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (ioOrderMutiEntityOne != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     if (ioOrderMutiEntityOne.getReCount() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                         return ResultVOUtils.error(999, "该产品库存不足!"); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.success(ioOrderMutiEntityOne.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     //查询物资信息
 | 
			
		
	
		
			
				
					|  |  |  |  |                     UdiProductEntity udiProductEntity = udiProductService.selectUdiByName(udiEntity.getUdi()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne = new IoOrderMutiEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setRelIdFk(udiProductEntity.getRelId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setMark(ioOrderMutiEntity.getMark()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setUdiCode(ioOrderMutiEntity.getUdiCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setBatchNo(udiEntity.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setExpireDate(udiEntity.getExpireDate()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setProduceDate(udiEntity.getProduceDate()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setTotalCount(20); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setStatus(0); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setCreateUser(customerService.getUserId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setUseCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setReCount(20); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setNameCode(udiProductEntity.getNameCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setSerialNo(udiEntity.getSerialNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiEntityOne.setSupId(udiProductEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ioOrderMutiService.save(ioOrderMutiEntityOne); | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.success(ioOrderMutiEntityOne.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 //不包含
 | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(888, ""); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(999, "请选填写UDI码!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @GetMapping("/udiwms/inout/order/muti/filterMutiList") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse filterMutiList(IoOrderMutiEntity ioOrderMutiEntity) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity = ioOrderMutiService.getById(ioOrderMutiEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         UdiProductEntity udiProductEntity = udiProductService.findByNameCode(ioOrderMutiEntity.getNameCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         IoOrderMutiResponse ioOrderMutiResponse = new IoOrderMutiResponse(); | 
			
		
	
		
			
				
					|  |  |  |  |         BeanUtils.copyProperties(ioOrderMutiEntity, ioOrderMutiResponse); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiResponse.setCpmctymc(udiProductEntity.getCpmctymc()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiResponse.setGgxh(udiProductEntity.getGgxh()); | 
			
		
	
		
			
				
					|  |  |  |  |         QueryWrapper<IoOrderMutiUseEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         ew.eq("mutiIdFk", ioOrderMutiEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         ew.select("io_order_muti_use.*,(SELECT userName FROM auth_user WHERE auth_user.id=io_order_muti_use.useUser) as createUserName"); | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderMutiUseEntity> ioOrderMutiUseEntityList = ioOrderMutiUseService.list(ew); | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, Object> map = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("data", ioOrderMutiResponse); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("detailList", ioOrderMutiUseEntityList); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(map); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/addOrderMuti") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse addOrderMuti(@RequestBody IoOrderMutiEntity ioOrderMutiEntity) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (StrUtil.isNotBlank(ioOrderMutiEntity.getUdiCode())) { | 
			
		
	
		
			
				
					|  |  |  |  |             UdiEntity udiEntity = FilterUdiUtils.getUdi(ioOrderMutiEntity.getUdiCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             //查询物资信息
 | 
			
		
	
		
			
				
					|  |  |  |  |             UdiProductEntity udiProductEntity = udiProductService.selectUdiByName(udiEntity.getUdi()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             IoOrderMutiEntity ioOrderMutiEntity1 = new IoOrderMutiEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setRelIdFk(udiProductEntity.getRelId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setMark(ioOrderMutiEntity.getMark()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setUdiCode(ioOrderMutiEntity.getUdiCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setBatchNo(udiEntity.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setExpireDate(udiEntity.getExpireDate()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setProduceDate(udiEntity.getProduceDate()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setTotalCount(20); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setStatus(0); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setUseCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setReCount(20); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setCreateUser(customerService.getUserId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setNameCode(udiProductEntity.getNameCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setSerialNo(udiEntity.getSerialNo()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiEntity1.setSupId(udiProductEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiService.save(ioOrderMutiEntity1); | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.success(ioOrderMutiEntity1.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(999, "请选填写UDI码!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/updateOrderMuti") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse updateOrderMuti(@RequestBody IoOrderMutiEntity ioOrderMutiEntity) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         String orderNo =ioOrderMutiEntity.getOrderIdFk(); | 
			
		
	
		
			
				
					|  |  |  |  |         //如果是第一次的话就插入
 | 
			
		
	
		
			
				
					|  |  |  |  |         String mark=ioOrderMutiEntity.getMark(); | 
			
		
	
		
			
				
					|  |  |  |  |         int totalCount=ioOrderMutiEntity.getTotalCount(); | 
			
		
	
		
			
				
					|  |  |  |  |         int useCount=ioOrderMutiEntity.getUseCount(); | 
			
		
	
		
			
				
					|  |  |  |  |         int status=ioOrderMutiEntity.getStatus(); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity= ioOrderMutiService.getById(ioOrderMutiEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setMark(mark); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setTotalCount(totalCount); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setUseCount(useCount); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setStatus(status); | 
			
		
	
		
			
				
					|  |  |  |  |         if (StrUtil.isBlank(ioOrderMutiEntity.getOrderIdFk())) { | 
			
		
	
		
			
				
					|  |  |  |  |             IoOrderEntity orderEntity = new IoOrderEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             //查询补单条件
 | 
			
		
	
		
			
				
					|  |  |  |  |             AuthAdmin authAdmin = customerService.getUserBean(); | 
			
		
	
		
			
				
					|  |  |  |  |             QueryWrapper<IoOrderMutiSetEntity> setEw = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |             setEw.eq("curInv", authAdmin.getLocInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             IoOrderMutiSetEntity ioOrderMutiSetEntity = ioOrderMutiSetService.getOne(setEw); | 
			
		
	
		
			
				
					|  |  |  |  |             if (ioOrderMutiSetEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(999, "请设置补单条件!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(ioOrderMutiSetEntity.getTargetAction()); | 
			
		
	
		
			
				
					|  |  |  |  |             InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(ioOrderMutiSetEntity.getCurInv()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd")); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setBillNo(orderNo); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setMainAction(ConstantType.TYPE_OUT); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setCreateUser(authAdmin.getId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setUpdateUser(authAdmin.getId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setCustomerId(authAdmin.getCustomerId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setFromCorp(ioOrderMutiSetEntity.getFromCorp()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setAction(bussinessTypeEntity.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setMainAction(bussinessTypeEntity.getMainAction()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setDeptCode(invWarehouseEntity.getParentId()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setInvCode(invWarehouseEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setFromType(ConstantStatus.FROM_Muti); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setOrderType(ConstantStatus.ORDER_TYPE_NORMAL); | 
			
		
	
		
			
				
					|  |  |  |  |             orderEntity.setBusType(bussinessTypeEntity.getBusType()); | 
			
		
	
		
			
				
					|  |  |  |  |             //插入单据
 | 
			
		
	
		
			
				
					|  |  |  |  |             orderService.insertOrder(orderEntity); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             IoCodeTempEntity ioCodeTempEntity = new IoCodeTempEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setCode(ioOrderMutiEntity.getUdiCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setMainAction(ConstantType.TYPE_OUT); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setAction(bussinessTypeEntity.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setOrderId(orderNo); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setNameCode(ioOrderMutiEntity.getNameCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setBatchNo(ioOrderMutiEntity.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setProduceDate(ioOrderMutiEntity.getProduceDate()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setExpireDate(ioOrderMutiEntity.getExpireDate()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setSerialNo(ioOrderMutiEntity.getSerialNo()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setSupId(ioOrderMutiEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setRelId(Long.valueOf(ioOrderMutiEntity.getRelIdFk())); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setCount(ioOrderMutiEntity.getTotalCount()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setReCount(ioOrderMutiEntity.getTotalCount() - ioOrderMutiEntity.getUseCount()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setDeptCode(invWarehouseEntity.getParentId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ioCodeTempEntity.setInvCode(invWarehouseEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             codeTempService.insert(ioCodeTempEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setReCount(ioOrderMutiEntity.getTotalCount() - ioOrderMutiEntity.getUseCount()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setOrderIdFk(orderNo); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setCreateUser(customerService.getUserId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setUpdateUser(customerService.getUserId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |         boolean falg = ioOrderMutiService.updateById(ioOrderMutiEntity); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         QueryWrapper<IoOrderMutiUseEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         ew.eq("mutiIdFk", ioOrderMutiEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderMutiUseEntity> ioOrderMutiUseEntityList = ioOrderMutiUseService.list(ew); | 
			
		
	
		
			
				
					|  |  |  |  |         for (IoOrderMutiUseEntity ioOrderMutiUseEntity : ioOrderMutiUseEntityList) { | 
			
		
	
		
			
				
					|  |  |  |  |             ioOrderMutiUseEntity.setStatus(1); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiUseService.updateBatchById(ioOrderMutiUseEntityList); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (falg) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.success(); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(999, "更新失败"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/filterMutiDetailList") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse filterMutiDetailList(@RequestBody IoOrderMutiRequest ioOrderMutiRequest) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //判断是不是个人使用
 | 
			
		
	
		
			
				
					|  |  |  |  |         AuthAdmin authAdmin = customerService.getUserBean(); | 
			
		
	
		
			
				
					|  |  |  |  |         QueryWrapper<IoOrderMutiSetEntity> setEw=new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         setEw.eq("curInv",authAdmin.getLocInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         IoOrderMutiSetEntity ioOrderMutiSetEntity=ioOrderMutiSetService.getOne(setEw); | 
			
		
	
		
			
				
					|  |  |  |  |         if(ioOrderMutiSetEntity!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |             if(ioOrderMutiSetEntity.getCheckUse()==1){ | 
			
		
	
		
			
				
					|  |  |  |  |                 ioOrderMutiRequest.setCreateUser(authAdmin.getId()+""); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(999,"请先设置多次出库单据类型!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiRequest.setStatus(0); | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderMutiResponse> ioOrderMutiEntityList = ioOrderMutiService.filterList(ioOrderMutiRequest); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(ioOrderMutiEntityList); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/selectMutiDetailList") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse selectMutiDetailList(@RequestBody IoOrderMutiUseEntity ioOrderMutiUseEntity) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         QueryWrapper<IoOrderMutiUseEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         ew.eq("mutiIdFk", ioOrderMutiUseEntity.getMutiIdFk()); | 
			
		
	
		
			
				
					|  |  |  |  |         ew.select("io_order_muti_use.*,(SELECT userName FROM auth_user WHERE auth_user.id=io_order_muti_use.useUser) as createUserName"); | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderMutiUseEntity> ioOrderMutiEntityList = ioOrderMutiUseService.list(ew); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(ioOrderMutiEntityList); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/selectMutiList") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse selectMutiList(@RequestBody IoOrderMutiRequest ioOrderMutiRequest) { | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoOrderMutiResponse> list = ioOrderMutiService.filterList(ioOrderMutiRequest); | 
			
		
	
		
			
				
					|  |  |  |  |         PageInfo<IoOrderMutiResponse> pageInfo = new PageInfo<>(list); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.page(pageInfo); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/addMutiDetail") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse addMutiDetail(@RequestBody IoOrderMutiUseEntity ioOrderMutiUseEntity) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //判断是不是个人使用
 | 
			
		
	
		
			
				
					|  |  |  |  |         AuthAdmin authAdmin = customerService.getUserBean(); | 
			
		
	
		
			
				
					|  |  |  |  |         QueryWrapper<IoOrderMutiSetEntity> setEw=new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         setEw.eq("curInv",authAdmin.getLocInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         IoOrderMutiSetEntity ioOrderMutiSetEntity=ioOrderMutiSetService.getOne(setEw); | 
			
		
	
		
			
				
					|  |  |  |  |         if(ioOrderMutiSetEntity!=null){ | 
			
		
	
		
			
				
					|  |  |  |  |             if(ioOrderMutiSetEntity.getCheckUse()==1){ | 
			
		
	
		
			
				
					|  |  |  |  |                 IoOrderMutiEntity ioOrderMutiEntity=ioOrderMutiService.getById(ioOrderMutiUseEntity.getMutiIdFk()); | 
			
		
	
		
			
				
					|  |  |  |  |                 if(!ioOrderMutiEntity.getCreateUser().equals(authAdmin.getId()+"")){ | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(999,"该单设置了个人使用,添加失败!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         }else{ | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(999,"请先设置多次出库单据类型!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         int sum = 0; | 
			
		
	
		
			
				
					|  |  |  |  |         QueryWrapper<IoOrderMutiUseEntity> ew = new QueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         ew.eq("mutiIdFk", ioOrderMutiUseEntity.getMutiIdFk()); | 
			
		
	
		
			
				
					|  |  |  |  |         Long count = ioOrderMutiUseService.count(ew); | 
			
		
	
		
			
				
					|  |  |  |  |         if (count == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             sum = 0; | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             sum = count.intValue(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         IoOrderMutiEntity ioOrderMutiEntity = ioOrderMutiService.getById(ioOrderMutiUseEntity.getMutiIdFk()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (ioOrderMutiEntity.getTotalCount() - count == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(999, "该产品数量不足!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiUseEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiUseEntity.setCurIndex(sum + 1); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiUseEntity.setUseUser(customerService.getUserId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiUseEntity.setUseTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiUseService.save(ioOrderMutiUseEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @GetMapping("/udiwms/inout/order/muti/getMark") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse getMark() { | 
			
		
	
		
			
				
					|  |  |  |  |         String recordId = gennerOrderUtils.createOrderMark(new OrderNoTypeBean("yyMMdd")); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(recordId); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/delectMutiDelect") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse delectMutiDelect(@RequestBody IoOrderMutiUseEntity ioOrderMutiUseEntity) { | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiUseService.removeById(ioOrderMutiUseEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/delectMuti") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse delectMuti(@RequestBody IoOrderMutiEntity ioOrderMutiEntity) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Boolean falg = ioOrderMutiService.removeById(ioOrderMutiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         if (falg) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.success(); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(999, "删除失败"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/udiwms/inout/order/muti/auditMuti") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse auditMuti(@RequestBody IoOrderMutiEntity ioOrderMutiEntity) { | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setUpdateUser(customerService.getUserId()+""); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setAuditTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiEntity.setAuditUser(customerService.getUserId()+""); | 
			
		
	
		
			
				
					|  |  |  |  |         ioOrderMutiService.updateById(ioOrderMutiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } |