新增价格相关处理

test
anthonywj 2 years ago
parent a7c709c2e7
commit d9d4ca1771

@ -381,6 +381,13 @@
<artifactId>Java-WebSocket</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.6.0</version>
</dependency>
</dependencies>
<build>

@ -1,11 +1,14 @@
package com.glxp.api;
import org.mybatis.spring.annotation.MapperScan;
import org.redisson.api.RedissonClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@ -0,0 +1,32 @@
package com.glxp.api.annotation;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.lang.annotation.*;
/**
* redisson
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface CusRedissonAnnotation {
@NotBlank(message = "redisson使用的缓存名称不能为空")
String cacheName();
@NotEmpty(message = "redisson使用的key不能为空")
String[] key();
@NotBlank(message = "redisson的超时信息不能为空")
String timeOutMsg();
/**
* 1,00
*
* @return
*/
@Min(value = 0, message = "等待时间最小值为0")
int waitTime() default 1;
}

@ -0,0 +1,95 @@
package com.glxp.api.aspect;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.exception.JsonException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Aspect
@Component
public class RedissonAspect {
private final ExpressionParser expressionParser = new SpelExpressionParser();
private final DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer();
@Resource
private RedissonClient redissonClient;
@Before("@annotation(annotation)")
public void before(JoinPoint joinPoint, CusRedissonAnnotation annotation) throws InterruptedException {
if (StrUtil.isBlank(parseKey(joinPoint, annotation))) {
throw new RuntimeException("redisson使用的key不能为空");
}
if (StrUtil.isBlank(annotation.timeOutMsg())) {
throw new RuntimeException("redisson的超时信息不能为空");
}
RLock lock = redissonClient.getLock(parseKey(joinPoint, annotation));
int waitTime = annotation.waitTime();
boolean tryLock = lock.tryLock(waitTime, TimeUnit.SECONDS);
if (!tryLock) {
throw new JsonException(500, annotation.timeOutMsg());
}
}
@After("@annotation(cusRedissonAnnotation)")
public void after(JoinPoint joinPoint, CusRedissonAnnotation cusRedissonAnnotation) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
CusRedissonAnnotation annotation = signature.getMethod().getAnnotation(CusRedissonAnnotation.class);
RLock lock = redissonClient.getLock(parseKey(joinPoint, annotation));
try {
lock.unlock();
} catch (Exception e) {
e.printStackTrace();
}
}
private String parseKey(JoinPoint joinPoint, CusRedissonAnnotation annotation) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
String[] paramNames = nameDiscoverer.getParameterNames(method);
List<String> keyValue = new ArrayList<>(annotation.key().length);
for (String s : annotation.key()) {
Expression expression = expressionParser.parseExpression(s);
EvaluationContext context = new StandardEvaluationContext();
Object[] args = joinPoint.getArgs();
for (int i = 0; i < args.length; i++) {
context.setVariable(paramNames[i], args[i]);
}
if (s.contains("#")) {
keyValue.add(expression.getValue(context, String.class));
} else {
keyValue.add(s);
}
}
return String.format("%s:%s", annotation.cacheName(), ArrayUtil.join(keyValue.toArray(), "_"));
}
}

@ -3,6 +3,10 @@ package com.glxp.api.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
@ -12,6 +16,8 @@ import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import javax.annotation.Resource;
/**
* redis
* @program: springbootdemo
@ -23,6 +29,19 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@EnableCaching //开启注解
public class RedisConfig extends CachingConfigurerSupport {
@Resource
private RedisProperties redisProperties;
@Bean
public RedissonClient redisson() {
Config config = new Config();
config.useSingleServer()
.setAddress(String.format("redis://%s:%s", redisProperties.getHost(), redisProperties.getPort()))
.setPassword(redisProperties.getPassword())
.setDatabase(redisProperties.getDatabase());
return Redisson.create(config);
}
/**
* retemplate
* @param factory

@ -0,0 +1,41 @@
package com.glxp.api.constant;
//redisson缓存key
public interface RedissonCacheKey {
/**
*
*/
String REGISTER_AUDIT = "register_audit";
/**
* web
*/
String WEB_ADD_ORDER = "web_add_order";
/**
*
*/
String UPGRADE = "upgrade";
/**
*
*/
String SUBMIT_ORDER = "submit_order";
/**
* app
*/
String APP_SUBMIT_ORDER = "app_submit_order";
/**
*
*/
String DELETE_CODE_TEMP = "delete_code_temp";
/**
* web
*/
String WEB_ADD_CODE = "web_add_code";
}

@ -526,14 +526,14 @@ public class InvWarehouseController extends BaseController {
for (WarehouseBussinessTypeEntity warehouseBussinessTypeEntity : removeLists) {
removeList.add(warehouseBussinessTypeEntity.getAction());
}
if (CollUtil.isNotEmpty(removeList)) {
FilterInvBusUserRequest filterInvBusUserRequest = new FilterInvBusUserRequest();
filterInvBusUserRequest.setSubInvCode(relBusRequset.getInvCode());
filterInvBusUserRequest.setSelectedCodes(relBusRequset.getSelectActions());
List<InvBusUserEntity> invBusUserEntities = invBusUserService.filterInvBusUser(filterInvBusUserRequest);
if (CollUtil.isNotEmpty(invBusUserEntities))
return ResultVOUtils.error(999, "请先移除用户关联单据类型!");
}
// if (CollUtil.isNotEmpty(removeList)) {
// FilterInvBusUserRequest filterInvBusUserRequest = new FilterInvBusUserRequest();
// filterInvBusUserRequest.setSubInvCode(relBusRequset.getInvCode());
// filterInvBusUserRequest.setSelectedCodes(relBusRequset.getSelectActions());
// List<InvBusUserEntity> invBusUserEntities = invBusUserService.filterInvBusUser(filterInvBusUserRequest);
// if (CollUtil.isNotEmpty(invBusUserEntities))
// return ResultVOUtils.error(999, "请先移除用户关联单据类型!");
// }
boolean b = warehouseBussinessTypeService.deleteByCode(relBusRequset.getInvCode());

@ -14,13 +14,12 @@ import com.glxp.api.entity.system.SysPdfTemplateRelevanceStatemenEntity;
import com.glxp.api.entity.system.SystemPDFTemplateEntity;
import com.glxp.api.req.basic.FilterOrderPrintRequest;
import com.glxp.api.req.inout.FilterOrderRequest;
import com.glxp.api.res.inout.IoOrderInvoiceResponse;
import com.glxp.api.res.inout.IoOrderResponse;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.basic.UdiProductService;
import com.glxp.api.service.inout.IoCodeService;
import com.glxp.api.service.inout.IoOrderDetailBizService;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.system.SystemPDFModuleService;
import com.glxp.api.service.system.SystemPDFTemplateRelevanceCodeService;
import com.glxp.api.service.system.SystemPDFTemplateRelevanceService;

@ -1,6 +1,7 @@
package com.glxp.api.controller.basic;
import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.service.inout.impl.IoCodeService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
@ -27,7 +28,6 @@ import com.glxp.api.res.basic.BasicProductThirdSysResponse;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.basic.*;
import com.glxp.api.service.inout.IoCodeService;
import com.glxp.api.service.inv.InvPreProductService;
import com.glxp.api.service.inv.InvProductService;
import com.glxp.api.service.system.SystemParamConfigService;
@ -35,7 +35,6 @@ import com.glxp.api.service.thrsys.ThrDataService;
import com.glxp.api.service.thrsys.ThrSystemService;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.udi.FilterUdiUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@ -9,7 +9,7 @@ import com.glxp.api.entity.inout.IoCodeEntity;
import com.glxp.api.req.inout.FilterCodeRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.IoCodeResponse;
import com.glxp.api.service.inout.IoCodeService;
import com.glxp.api.service.inout.impl.IoCodeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@ -1,5 +1,10 @@
package com.glxp.api.controller.inout;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.constant.*;
import com.glxp.api.entity.inv.InvProductDetailEntity;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
@ -11,10 +16,6 @@ import com.glxp.api.annotation.RepeatSubmit;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.constant.ConstantType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.auth.InvWarehouseEntity;
@ -47,10 +48,8 @@ import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.*;
import java.util.stream.Collectors;
@RestController
public class IoCodeTempController extends BaseController {
@ -316,6 +315,7 @@ public class IoCodeTempController extends BaseController {
@RepeatSubmit()
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/addOrderWeb")
@CusRedissonAnnotation(cacheName = RedissonCacheKey.WEB_ADD_CODE, key = {"#addOrderRequest.corpOrderId", "#addOrderRequest.code"}, timeOutMsg = "系统正在处理,请勿重复扫码")
@Log(title = "单据管理", businessType = BusinessType.INSERT)
public BaseResponse addOrderWeb(@RequestBody AddOrderRequest addOrderRequest, BindingResult bindingResult) {
@ -347,7 +347,6 @@ public class IoCodeTempController extends BaseController {
udiEntity.setSerialNo(addOrderRequest.getSerialNo());
}
if (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && udiEntity.getSerialNo().length() > 20) {
return ResultVOUtils.error(500, "无效条码!序列号超出最大范围");
}
@ -437,8 +436,6 @@ public class IoCodeTempController extends BaseController {
}
}
}
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(udiEntity.getUdi());
//近效期提醒
// SystemParamConfigEntity recentParamConfigEntity = systemParamConfigService.selectByParamKey("recent_date_tip");
@ -539,9 +536,11 @@ public class IoCodeTempController extends BaseController {
//先生成扫码单据
IoOrderEntity orderEntity = orderService.findByBillNo(orderId);
String inBatch = "";
if (StringUtils.isBlank(orderId) || orderEntity == null) {
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderId = orderNo;
inBatch = orderNo.substring((Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix())).length());
}
List<IoCodeTempEntity> codeEnttitys = codeTempService.findByOrderId(orderId);
@ -567,7 +566,8 @@ public class IoCodeTempController extends BaseController {
if (!StringUtils.isBlank(exitLocalEntity.getSerialNo())) {
return ResultVOUtils.error(500, "重复扫码!");
}
// IoCodeTempEntity codeTempEntity = isExitToatal(code, codeEnttitys);
//校验库存
BaseResponse invRes = null;
if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存
invRes = checkPreInInv(bussinessTypeEntity, genDetaiEntity, false);
@ -580,7 +580,6 @@ public class IoCodeTempController extends BaseController {
return invRes;
}
if (bussinessTypeEntity.getCheckWebNew() == 1 && bussinessTypeEntity.isCheckEnable()) {
String errMsg = ioCheckInoutService.checkCode(genDetaiEntity);
if (errMsg != null) {
@ -594,13 +593,32 @@ public class IoCodeTempController extends BaseController {
} else
codeTempService.updateById(exitLocalEntity);
} else {
boolean update = true;
String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo");
if (IntUtil.value(priceFifo) > 0) {
if (bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
//1.获取当前批次已出库数量
Integer outCount = invProductDetailService.selectCountByInBatch(bussinessTypeEntity, exitLocalEntity.getInBatchNo(), ConstantType.TYPE_OUT);
//2.获取当前批次入库数量
Integer inCount = invProductDetailService.selectCountByInBatch(bussinessTypeEntity, exitLocalEntity.getInBatchNo(), ConstantType.TYPE_PUT);
if ((IntUtil.value(inCount) - IntUtil.value(outCount) - IntUtil.value(exitLocalEntity.getReCount())) < 0) {
InvProductDetailEntity nextInvProduct = invProductDetailService.selectNextInBatch(bussinessTypeEntity, exitLocalEntity.getRelId() + "", exitLocalEntity.getBatchNo(), exitLocalEntity.getInvCode(), ConstantType.TYPE_PUT, exitLocalEntity.getInBatchNo());
if (nextInvProduct != null) {
genDetaiEntity.setPrice(nextInvProduct.getPrice());
genDetaiEntity.setInBatchNo(nextInvProduct.getInBatchNo());
codeTempService.insert(genDetaiEntity);
update = false;
}
}
}
}
if (update) {
codeTempService.updateById(exitLocalEntity);
}
}
}
}
if (exitLocalEntity == null) {
IoCodeTempEntity codeEnttity = new IoCodeTempEntity();
codeEnttity.setCode(code);
@ -759,31 +777,70 @@ public class IoCodeTempController extends BaseController {
} else
codeTempService.insert(codeEnttity);
} else {
checkPrice(codeEnttity, bussinessTypeEntity, inBatch);
codeTempService.insert(codeEnttity);
}
}
addCodeResult.setOrderId(orderId);
transInoutService.genOrderDetailCode(orderEntity, genDetaiEntity);
return ResultVOUtils.success(addCodeResult);
}
public void checkPrice(IoCodeTempEntity codeTempEntity, BasicBussinessTypeEntity bussinessTypeEntity, String inBatch) {
// 校验价格
String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo");
if (IntUtil.value(priceFifo) > 0) {
//入库时添加入库批号
if (bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
codeTempEntity.setInBatchNo(inBatch);
} else {
//出库时填写价格与入库批次
//1.获取出库最新批次
InvProductDetailEntity invProductDetailEntity = invProductDetailService.selectLastInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), codeTempEntity.getMainAction());
if (invProductDetailEntity == null) {
//首次出库,获取入库最早批次
InvProductDetailEntity inProductDetail = invProductDetailService.selectFirstInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), ConstantType.TYPE_PUT);
if (inProductDetail != null) {
codeTempEntity.setPrice(inProductDetail.getPrice());
codeTempEntity.setInBatchNo(inProductDetail.getInBatchNo());
}
} else {
//非首次出库
//1.获取当前批次已出库数量
Integer outCount = invProductDetailService.selectCountByInBatch(bussinessTypeEntity, invProductDetailEntity.getInBatchNo(), ConstantType.TYPE_OUT);
//2.获取当前批次入库数量
Integer inCount = invProductDetailService.selectCountByInBatch(bussinessTypeEntity, invProductDetailEntity.getInBatchNo(), ConstantType.TYPE_PUT);
//3.若数量还有剩,则此次出库为当前批次
if (inCount > outCount) {
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
} else {
// 4.若数量不足,则出下一批次
InvProductDetailEntity nextInvProduct = invProductDetailService.selectNextInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), codeTempEntity.getMainAction(), invProductDetailEntity.getInBatchNo());
if (nextInvProduct != null) {
codeTempEntity.setPrice(nextInvProduct.getPrice());
codeTempEntity.setInBatchNo(nextInvProduct.getInBatchNo());
}
}
}
}
}
}
public BaseResponse checkInv(BasicBussinessTypeEntity bussinessTypeEntity, IoCodeTempEntity codeTempEntity, boolean isEdit) {
if (bussinessTypeEntity.isVailInv() && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
int count = 0;
if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) {
// if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) {
// count = invProductDetailService.vailStockCountByCode(codeTempEntity.getDeptCode(), codeTempEntity.getInvCode(), null, codeTempEntity.getCode());
// } else
count = invProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), codeTempEntity.getDeptCode(), codeTempEntity.getInvCode(), null);
} else if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_SET) {
// if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) {
// count = invProductDetailService.vailStockCountByCode(codeTempEntity.getDeptCode(), codeTempEntity.getInvCode(), codeTempEntity.getWarehouseCode(), codeTempEntity.getCode());
// } else
count = invProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), codeTempEntity.getDeptCode(), codeTempEntity.getInvCode(), codeTempEntity.getWarehouseCode());
} else if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_CODE) {
//按指定货位出库
if (StrUtil.isEmpty(codeTempEntity.getWarehouseCode())) {
List<InvPlaceDetailResponse> invProductDetailEntities = invProductDetailService.findByGroupCode(codeTempEntity.getInvCode(), codeTempEntity.getCode(), true);
if (CollUtil.isNotEmpty(invProductDetailEntities) && invProductDetailEntities.size() > 1) {
BaseResponse baseResponse = ResultVOUtils.error(511, "存在多个货位,请指定当前货位!");
@ -796,16 +853,15 @@ public class IoCodeTempController extends BaseController {
return ResultVOUtils.error(500, "添加失败,该产品未上架货位!");
}
} else {
// if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) {
// count = invProductDetailService.vailStockCountByCode(codeTempEntity.getDeptCode(), codeTempEntity.getInvCode(), codeTempEntity.getWarehouseCode(), codeTempEntity.getCode());
// } else
count = invProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), codeTempEntity.getDeptCode(), codeTempEntity.getInvCode(), codeTempEntity.getWarehouseCode());
}
}
if (count <= 0) {
if (count == -1) {
return ResultVOUtils.error(500, "该产品未入库");
} else
return ResultVOUtils.error(500, "当前库存不足");
} else {
//查询此单据已扫描的条码数量
if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_CODE) {
int exitCount = IntUtil.value(codeTempService.selectExitCount(codeTempEntity.getOrderId(), codeTempEntity.getCode()));
@ -838,7 +894,9 @@ public class IoCodeTempController extends BaseController {
return null;
}
// 校验寄售库存
/**
*
*/
public BaseResponse checkPreInv(BasicBussinessTypeEntity bussinessTypeEntity, IoCodeTempEntity codeTempEntity, boolean isEdit) {
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_ADVANCE);
@ -867,6 +925,9 @@ public class IoCodeTempController extends BaseController {
}
}
if (count <= 0) {
if (count == -1) {
return ResultVOUtils.error(500, "该产品未入库");
} else
return ResultVOUtils.error(500, "寄售库存数量不足!");
} else {
int exitCount = IntUtil.value(codeTempService.selectExitCount(codeTempEntity.getOrderId(), codeTempEntity.getBatchNo(), codeTempEntity.getRelId(), codeTempEntity.getSupId()));
@ -926,6 +987,9 @@ public class IoCodeTempController extends BaseController {
InvPreInProductDetailEntity invPreinDetailEntity = invPreinProductDetailService.findUseOneByCode(codeTempEntity.getCode());
if (count <= 0) {
if (count == -1) {
return ResultVOUtils.error(500, "该产品未入库");
} else
return ResultVOUtils.error(500, "预验收库存数量不足!");
} else {
if (StrUtil.isNotEmpty(invPreinDetailEntity.getBatchNo()) && StrUtil.isNotEmpty(codeTempEntity.getBatchNo())
@ -938,11 +1002,11 @@ public class IoCodeTempController extends BaseController {
IoCodeTempEntity tempEntity = codeTempService.findByUnique(codeTempEntity.getOrderId(), codeTempEntity.getCode());
if (tempEntity != null) {
if (isEdit) {
if (count < (tempEntity.getMyCount())) {
if (count < (tempEntity.getReCount())) {
return ResultVOUtils.error(500, "超出预验收存数量");
}
} else {
if (count < (tempEntity.getMyCount() + 1)) {
if (count < (tempEntity.getReCount() + codeTempEntity.getReCount())) {
return ResultVOUtils.error(500, "超出预验收存数量");
}
}
@ -1060,34 +1124,72 @@ public class IoCodeTempController extends BaseController {
return null;
}
//判断本单是否存在
/**
*
*
* @param code
* @param codeEnttityList
* @return
*/
public IoCodeTempEntity isExitLocal(String code, List<IoCodeTempEntity> codeEnttityList) {
List<IoCodeTempEntity> codeTempEntities = isExitLocalList(code, codeEnttityList);
if (CollUtil.isNotEmpty(codeTempEntities)) {
return codeTempEntities.get(0);
}
return null;
}
public List<IoCodeTempEntity> isExitLocalList(String code, List<IoCodeTempEntity> codeEnttityList) {
UdiEntity udiEntity = FilterUdiUtils.getUdi(code);
for (int i = 0; i < codeEnttityList.size(); i++) {
IoCodeTempEntity drugCodeSelectEntity = codeEnttityList.get(i);
if (codeEnttityList.get(i).getCode().equals(code)) {
if (StrUtil.emptyIfNull(drugCodeSelectEntity.getSerialNo()).equals(StrUtil.emptyIfNull(udiEntity.getSerialNo()))) {
return drugCodeSelectEntity;
List<IoCodeTempEntity> codeTempEntities = codeEnttityList.stream()
.filter(item -> {
if (item.getCode().equals(code)) {
if (StrUtil.emptyIfNull(item.getSerialNo()).equals(StrUtil.emptyIfNull(udiEntity.getSerialNo()))) {
return true;
}
if (!StrUtil.emptyIfNull(item.getNameCode()).equals(StrUtil.emptyIfNull(udiEntity.getUdi()))) {
return false;
}
if (!StrUtil.emptyIfNull(item.getBatchNo()).toUpperCase(Locale.ROOT).equals(StrUtil.emptyIfNull(udiEntity.getBatchNo()).toUpperCase(Locale.ROOT))) {
return false;
}
// UdiEntity originUdiEntity = FilterUdiUtils.getUdi(drugCodeSelectEntity.getCode());
if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getNameCode()).equals(StrUtil.emptyIfNull(udiEntity.getUdi()))) {
continue;
if (!StrUtil.emptyIfNull(item.getProduceDate()).equals(StrUtil.emptyIfNull(udiEntity.getProduceDate()))) {
return false;
}
if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getBatchNo()).toUpperCase(Locale.ROOT).equals(StrUtil.emptyIfNull(udiEntity.getBatchNo()).toUpperCase(Locale.ROOT))) {
continue;
if (!StrUtil.emptyIfNull(item.getExpireDate()).equals(StrUtil.emptyIfNull(udiEntity.getExpireDate()))) {
return false;
}
if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getProduceDate()).equals(StrUtil.emptyIfNull(udiEntity.getProduceDate()))) {
continue;
if (!StrUtil.emptyIfNull(item.getSerialNo()).equals(StrUtil.emptyIfNull(udiEntity.getSerialNo()))) {
return false;
}
if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getExpireDate()).equals(StrUtil.emptyIfNull(udiEntity.getExpireDate()))) {
continue;
return true;
}
return false;
}).sorted(Comparator.comparing(IoCodeTempEntity::getInBatchNo)).collect(Collectors.toList());
Collections.reverse(codeTempEntities);
return codeTempEntities;
}
/**
* ]=
*
*
* @param code
* @param codeEnttityList
* @return
*/
public IoCodeTempEntity isExitToatal(String code, List<IoCodeTempEntity> codeEnttityList) {
List<IoCodeTempEntity> codeTempEntities = isExitLocalList(code, codeEnttityList);
if (CollUtil.isNotEmpty(codeTempEntities)) {
IoCodeTempEntity codeTempEntity = codeTempEntities.get(0);
if (codeTempEntities.size() > 1) {
for (int i = 1; i < codeTempEntities.size(); i++) {
codeTempEntity.setCount(IntUtil.value(codeTempEntities.get(i).getCount()) + IntUtil.value(codeTempEntity.getCount()));
codeTempEntity.setReCount(IntUtil.value(codeTempEntities.get(i).getReCount()) + IntUtil.value(codeTempEntity.getReCount()));
}
if (!StrUtil.emptyIfNull(drugCodeSelectEntity.getSerialNo()).equals(StrUtil.emptyIfNull(udiEntity.getSerialNo()))) {
continue;
}
return drugCodeSelectEntity;
return codeTempEntity;
}
return null;
}
@ -1180,7 +1282,7 @@ public class IoCodeTempController extends BaseController {
}
//更新扫码详情
IoOrderDetailCodeEntity orderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(orderEntity.getBillNo(), codeTempEntity.getRelId(), codeTempEntity.getBatchNo());
IoOrderDetailCodeEntity orderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(orderEntity.getBillNo(), codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getPrice());
if (orderDetailCodeEntity != null) {
//扫码数量-1
int orderCount = IntUtil.value(orderDetailCodeEntity.getCount());
@ -1271,7 +1373,7 @@ public class IoCodeTempController extends BaseController {
int count = tempEntity.getCount() - codeTempEntity.getCount();
//更新扫码详情
IoOrderDetailCodeEntity orderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(codeTempEntity.getOrderId(), codeTempEntity.getRelId(), codeTempEntity.getBatchNo());
IoOrderDetailCodeEntity orderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(codeTempEntity.getOrderId(), codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getPrice());
if (orderDetailCodeEntity != null) {
//扫码数量-1
int orderCount = orderDetailCodeEntity.getCount();

@ -1,5 +1,10 @@
package com.glxp.api.controller.inout;
import cn.hutool.core.bean.BeanUtil;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.constant.*;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.system.SystemParamConfigService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
@ -12,9 +17,6 @@ import com.glxp.api.annotation.RepeatSubmit;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.auth.InvBusUserEntity;
@ -83,6 +85,8 @@ public class IoOrderController extends BaseController {
IoOrderInvoiceService orderInvoiceService;
@Resource
CustomerService customerService;
@Resource
private SystemParamConfigService systemParamConfigService;
/**
*
@ -163,7 +167,6 @@ public class IoOrderController extends BaseController {
if (ioOrderResponse.getCheckStatus() == null) {
ioOrderResponse.setCheckStatus(0 + "");
}
ioOrderResponse = orderInvoiceService.findRegStausByBillNo(ioOrderResponse);
}
PageInfo<IoOrderResponse> pageInfo = new PageInfo<>(list);
@ -302,7 +305,6 @@ public class IoOrderController extends BaseController {
return ResultVOUtils.error(500, "单据类型不能为空");
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderRequest.getAction());
BasicCorpEntity basicCorpEntity;
//要是特殊往来信息没有就创建
orderEntity.setFromCorp(ioAddInoutService.updateCorp(bussinessTypeEntity, addOrderRequest.getFromCorp()));
orderEntity.setAction(addOrderRequest.getAction());
@ -327,6 +329,7 @@ public class IoOrderController extends BaseController {
@RepeatSubmit()
@AuthRuleAnnotation("")
@PostMapping("warehouse/inout/submitOrderWeb")
@CusRedissonAnnotation(cacheName = RedissonCacheKey.SUBMIT_ORDER, key = {"#addOrderRequest.billNo"}, timeOutMsg = "系统正在处理,请勿重复提交")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse submitOrderWeb(@RequestBody AddOrderRequest addOrderRequest) {
@ -342,11 +345,29 @@ public class IoOrderController extends BaseController {
//校验单据是否已完成
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(addOrderRequest.getBillNo());
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(addOrderRequest.getBillNo());
List<IoCodeTempEntity> codeTempEntities = codeTempService.findByOrderId(orderEntity.getBillNo());
if (CollUtil.isEmpty(orderDetailCodeEntities)) {
return ResultVOUtils.error(500, "提交失败,单据还未扫码或和扫码校验存在异常!");
}
//单据提交后再次校验库存是否足够
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
BaseResponse baseResponse = ioAddInoutService.checkInv(bussinessTypeEntity, orderDetailBizEntities, orderEntity, codeTempEntities);
if (baseResponse != null)
return baseResponse;
String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo");
if (IntUtil.value(priceFifo) > 0 && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
List<IoCodeTempEntity> resultList = ioAddInoutService.checkPrice(bussinessTypeEntity, BeanUtil.copyToList(codeTempEntities, IoCodeTempEntity.class));
for (IoCodeTempEntity codeTempEntity : resultList) {
if (codeTempEntity.getId() == null)
// return ResultVOUtils.error(500, "价格发生变动!");
log.error("价格发生变动");
}
}
if (checkInoutService.checkManual(addOrderRequest.getBillNo())) {
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
@ -719,7 +740,7 @@ public class IoOrderController extends BaseController {
@PostMapping("udiwms/inout/code/finish/delete")
@Log(title = "单据管理", businessType = BusinessType.DELETE)
public BaseResponse deleteCodeById(@RequestBody IoCodeEntity codeEntity) {
orderService.deleteInvCode(codeEntity.getOrderId(), codeEntity.getCode());
orderService.deleteInvCode(codeEntity);
return ResultVOUtils.success("删除成功!");
}

@ -233,6 +233,7 @@ public class IoOrderDetailBizController extends BaseController {
}
//选入第三方单据至业务单据
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/addThrOrder")

@ -2,8 +2,10 @@ package com.glxp.api.controller.inout;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.annotation.Log;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
import com.glxp.api.entity.inout.IoOrderDetailCodeEntity;
import com.glxp.api.req.inout.FilterOrderDetailCodeRequest;
@ -13,6 +15,8 @@ import com.glxp.api.service.inout.IoCheckInoutService;
import com.glxp.api.service.inout.IoOrderDetailBizService;
import com.glxp.api.service.inout.IoOrderDetailCodeService;
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;
@ -61,4 +65,19 @@ public class IoOrderDetailCodeController {
}
/**
* ---
*/
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/updateCodeProduct")
@Log(title = "单据管理-价格修改", businessType = BusinessType.UPDATE)
public BaseResponse updateDetailProduct(@RequestBody IoOrderDetailCodeEntity orderDetailCodeEntity) {
boolean isExit = ioOrderDetailCodeService.isExit(orderDetailCodeEntity.getBindRlFk(), orderDetailCodeEntity.getBatchNo(), orderDetailCodeEntity.getId(), orderDetailCodeEntity.getOrderIdFk());
if (isExit) {
return ResultVOUtils.error(500, "存在相同产品,相同批次号,请检查后保存!");
}
return ioOrderDetailCodeService.update(orderDetailCodeEntity) > 0 ? ResultVOUtils.success("保存成功!") : ResultVOUtils.error(500, "保存失败");
}
}

@ -28,6 +28,7 @@ import com.glxp.api.res.inout.IoOrderDetailResultResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.inout.*;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inout.impl.IoOrderInvoiceService;
import com.glxp.api.service.system.CompanyService;
import com.glxp.api.service.system.SystemPDFModuleService;

@ -1,5 +1,6 @@
package com.glxp.api.controller.inout;
import com.glxp.api.service.inout.impl.IoCodeService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.exceptions.ExceptionUtil;

@ -1,5 +1,6 @@
package com.glxp.api.controller.inv;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
@ -28,9 +29,7 @@ import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.auth.InvWarehouseService;
import com.glxp.api.service.auth.WarehouseUserService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.inv.InvProductDetailService;
import com.glxp.api.service.inv.InvProductService;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.udi.FilterUdiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;

@ -1,23 +1,9 @@
package com.glxp.api.controller.inv;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.annotation.Log;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.inv.InvProductDetailEntity;
import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.entity.inv.InvUserProductEntity;
import com.glxp.api.req.inv.FilterInvProductDetailRequest;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.service.inv.InvProductDetailService;
import com.glxp.api.service.inv.InvUserProductService;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import groovy.util.logging.Slf4j;
import org.springframework.validation.BindingResult;
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;

@ -20,7 +20,7 @@ import com.glxp.api.res.inv.UdiTraceResponse;
import com.glxp.api.service.basic.UdiProductService;
import com.glxp.api.service.basic.UdiRelevanceService;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.inv.InvProductDetailService;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import com.glxp.api.util.MsDateUtil;
import com.glxp.api.util.udi.FilterUdiUtils;
import org.springframework.web.bind.annotation.GetMapping;

@ -2,6 +2,7 @@ package com.glxp.api.dao.inv;
import com.glxp.api.dao.BaseMapperPlus;
import com.glxp.api.entity.inv.InvPreInProductDetailEntity;
import com.glxp.api.entity.inv.InvProductDetailEntity;
import com.glxp.api.req.inv.FilterInvPlaceRequest;
import com.glxp.api.req.inv.FilterInvPreProductDetailRequest;
import com.glxp.api.req.inv.FilterInvPreinProductRequest;
@ -54,4 +55,14 @@ public interface InvPreInProductDetailDao extends BaseMapperPlus<InvPreInProduct
List<InvPreInProductDetailEntity> findBySpaceList(@Param("spaceList") List<String> spaceList);
InvProductDetailEntity selectLastInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("mainAction") String mainAction);
InvProductDetailEntity selectFirstInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("mainAction") String mainAction);
Integer selectCountByInBatch(@Param("inBatchNo") String inBatchNo, @Param("mainAction") String mainAction);
InvProductDetailEntity selectNextInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("mainAction") String mainAction, @Param("inBatchNo") String inBatchNo);
}

@ -2,6 +2,7 @@ package com.glxp.api.dao.inv;
import com.glxp.api.dao.BaseMapperPlus;
import com.glxp.api.entity.inv.InvPreProductDetailEntity;
import com.glxp.api.entity.inv.InvProductDetailEntity;
import com.glxp.api.req.inv.FilterInvPlaceRequest;
import com.glxp.api.req.inv.FilterInvPreProductDetailRequest;
import com.glxp.api.req.inv.FilterInvPreinProductRequest;
@ -50,4 +51,14 @@ public interface InvPreProductDetailDao extends BaseMapperPlus<InvPreProductDeta
List<InvPlaceDetailResponse> filterSpaceList(FilterInvPlaceRequest filterInvPlaceOrderRequest);
List<InvPlaceDetailResponse> findByGroupCode(@Param("invCode") String invCode, @Param("code") String code);
InvProductDetailEntity selectLastInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("mainAction") String mainAction);
InvProductDetailEntity selectFirstInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("mainAction") String mainAction);
Integer selectCountByInBatch(@Param("inBatchNo") String inBatchNo, @Param("mainAction") String mainAction);
InvProductDetailEntity selectNextInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("mainAction") String mainAction, @Param("inBatchNo") String inBatchNo);
}

@ -105,4 +105,12 @@ public interface InvProductDetailDao extends BaseMapperPlus<InvProductDetailDao,
List<InvPlaceDetailResponse> findByGroupCode(@Param("invCode") String invCode, @Param("code") String code, @Param("isCheckSpace") Boolean isCheckSpace);
InvProductDetailEntity selectLastInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("invCode") String invCode, @Param("mainAction") String mainAction);
InvProductDetailEntity selectFirstInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("invCode") String invCode, @Param("mainAction") String mainAction);
Integer selectCountByInBatch(@Param("inBatchNo") String inBatchNo, @Param("mainAction") String mainAction);
InvProductDetailEntity selectNextInBatch(@Param("relId") String relId, @Param("batchNo") String batchNo, @Param("invCode") String invCode, @Param("mainAction") String mainAction, @Param("inBatchNo") String inBatchNo);
}

@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@ -146,6 +147,15 @@ public class IoCodeEntity implements Serializable {
@TableField(value = "createTime")
private Date createTime;
@TableField(value = "price")
private BigDecimal price;
/**
*
*/
@TableField(value = "inBatchNo")
private String inBatchNo;
@TableField(exist = false)
private int status; //条码校验状态
@TableField(exist = false)

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@ -144,6 +145,11 @@ public class IoCodeTempEntity {
*/
@TableField(value = "createTime")
private Date createTime;
/**
*
*/
@TableField(value = "inBatchNo")
private String inBatchNo;
@TableField(exist = false)
@ -153,7 +159,8 @@ public class IoCodeTempEntity {
@TableField(exist = false)
private String mySupId; //更新供应商
@TableField(value = "price")
private BigDecimal price;
@TableField(exist = false)
private boolean checkSuccess; //临时字段校验是否成功

@ -176,6 +176,12 @@ public class IoOrderDetailCodeEntity {
*/
@TableField(value = "remark4")
private String remark4;
/**
*
*/
@TableField(exist = false)
private String inBatchNo;
/**
* 5

@ -3,6 +3,7 @@ package com.glxp.api.entity.inv;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -134,7 +135,13 @@ public class InvPreInProductDetailEntity {
*
*/
@TableField(value = "price")
private String price;
private BigDecimal price;
/**
*
*/
@TableField(value = "inBatchNo")
private String inBatchNo;
public static final String COL_ID = "id";

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -138,7 +139,12 @@ public class InvPreProductDetailEntity {
*
*/
@TableField(value = "price")
private String price;
private BigDecimal price;
/**
*
*/
@TableField(value = "inBatchNo")
private String inBatchNo;
public static final String COL_ID = "id";

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -101,6 +102,12 @@ public class InvPreProductEntity {
@TableField(value = "updateTime")
private Date updateTime;
/**
*
*/
@TableField(value = "price")
private BigDecimal price;
public static final String COL_ID = "id";
public static final String COL_RELIDFK = "relIdFk";

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -100,6 +101,11 @@ public class InvPreinProductEntity {
*/
@TableField(value = "updateTime")
private Date updateTime;
/**
*
*/
@TableField(value = "price")
private BigDecimal price;
public static final String COL_ID = "id";

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@ -128,6 +129,10 @@ public class InvProductDetailEntity {
*
*/
@TableField(value = "price")
private String price;
private BigDecimal price;
/**
*
*/
@TableField(value = "inBatchNo")
private String inBatchNo;
}

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@ -137,4 +138,11 @@ public class InvProductEntity {
private Integer availableStock;
/**
*
*/
@TableField(value = "price")
private BigDecimal price;
}

@ -3,6 +3,7 @@ package com.glxp.api.req.inv;
import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
@ -87,4 +88,6 @@ public class FilterInvProductDetailRequest extends ListPageRequest {
*
*/
private String expireDate;
private BigDecimal price;
}

@ -2,6 +2,7 @@ package com.glxp.api.res.inv;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -129,4 +130,6 @@ public class InvProductDetailResponse {
private String invSpaceName;
private BigDecimal price;
}

@ -2,6 +2,8 @@ package com.glxp.api.res.inv;
import lombok.Data;
import java.math.BigDecimal;
/**
* VO
*/
@ -118,11 +120,11 @@ public class InvProductResponse {
private String manufactoryl;
/**
*
* */
*/
private String measname;
private BigDecimal price;
}

@ -1,5 +1,9 @@
package com.glxp.api.service.inout;
import cn.hutool.core.bean.BeanUtil;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
@ -18,15 +22,11 @@ import com.glxp.api.entity.basic.BasicCorpEntity;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.entity.basic.UdiRlSupEntity;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.inv.InvPreInProductDetailEntity;
import com.glxp.api.entity.inv.InvProductDetailEntity;
import com.glxp.api.entity.system.SystemParamConfigEntity;
import com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest;
import com.glxp.api.entity.inout.PdaCodeEntity;
import com.glxp.api.req.inout.PdaPostOrderRequest;
import com.glxp.api.req.inout.PostOrderRequest;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.res.inv.InvPlaceDetailResponse;
import com.glxp.api.service.auth.InvWarehouseService;
import com.glxp.api.service.basic.BasicCorpService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
@ -34,22 +34,19 @@ import com.glxp.api.service.basic.UdiRelevanceService;
import com.glxp.api.service.basic.UdiRlSupService;
import com.glxp.api.service.inv.InvPreProductDetailService;
import com.glxp.api.service.inv.InvPreinProductDetailService;
import com.glxp.api.service.inv.InvProductDetailService;
import com.glxp.api.service.system.SystemParamConfigService;
import com.glxp.api.util.*;
import com.glxp.api.util.udi.FilterUdiUtils;
import com.glxp.api.util.udi.UdiCalCountUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static com.glxp.api.constant.ConstantStatus.ORDER_STATUS_CHECK_PROCESS;
@Slf4j
@Service
public class IoAddInoutService {
@ -317,19 +314,20 @@ public class IoAddInoutService {
//生成扫码单据详情
public List<IoOrderDetailCodeEntity> genOrderDetailCode(IoOrderEntity orderEntity, IoCodeTempEntity codeTempEntity) {
List<IoOrderDetailCodeEntity> ioOrderDetailCodeEntities = orderDetailCodeDao.selectList(new QueryWrapper<IoOrderDetailCodeEntity>().select("id", "count", "reCount", "bindRlFk", "batchNo").eq("orderIdFk", orderEntity.getBillNo()));
List<IoOrderDetailCodeEntity> ioOrderDetailCodeEntities = orderDetailCodeDao.selectList(new QueryWrapper<IoOrderDetailCodeEntity>().select("id", "count", "reCount", "bindRlFk", "batchNo", "price").eq("orderIdFk", orderEntity.getBillNo()));
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectSupGroupById(codeTempEntity.getRelId(), codeTempEntity.getSupId());
if (CollUtil.isEmpty(ioOrderDetailCodeEntities)) {
orderDetailCodeService.insert(buildEntity(orderEntity, codeTempEntity, udiRelevanceResponse));
ioOrderDetailCodeEntities = orderDetailCodeDao.selectList(new QueryWrapper<IoOrderDetailCodeEntity>().select("id", "count", "reCount", "bindRlFk", "batchNo", "price").eq("orderIdFk", orderEntity.getBillNo()));
} else {
boolean isUpdate = false;
for (IoOrderDetailCodeEntity orderDetailCodeEntity : ioOrderDetailCodeEntities) {
if (orderDetailCodeEntity.getBindRlFk().longValue() == udiRelevanceResponse.getId().longValue()
&&
StrUtil.trimToEmpty(orderDetailCodeEntity.getBatchNo()).equals(StrUtil.trimToEmpty(codeTempEntity.getBatchNo()))) {
&& StrUtil.trimToEmpty(orderDetailCodeEntity.getBatchNo()).equals(StrUtil.trimToEmpty(codeTempEntity.getBatchNo()))
&& BigDecimalUtil.equalTo(orderDetailCodeEntity.getPrice(), codeTempEntity.getPrice())
) {
orderDetailCodeEntity.setCount(orderDetailCodeEntity.getCount() + codeTempEntity.getMyCount());
orderDetailCodeEntity.setReCount(orderDetailCodeEntity.getReCount() + codeTempEntity.getMyReCount());
UpdateWrapper<IoOrderDetailCodeEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("count", orderDetailCodeEntity.getCount()).set("reCount", orderDetailCodeEntity.getReCount());
orderDetailCodeEntity.setUpdateTime(new Date());
@ -440,6 +438,17 @@ public class IoAddInoutService {
if (baseResponse != null)
return baseResponse;
String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo");
if (IntUtil.value(priceFifo) > 0 && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
List<IoCodeTempEntity> resultList = checkPrice(bussinessTypeEntity, BeanUtil.copyToList(pdaPostOrderRequest.getCodeTempEntities(), IoCodeTempEntity.class));
for (IoCodeTempEntity codeTempEntity : resultList) {
if (codeTempEntity.getId() == null)
// return ResultVOUtils.error(500, "价格发生变动!");
log.error("价格发生变动");
}
}
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderEntity.setBillNo(orderNo);
orderService.insertOrder(orderEntity);
@ -701,7 +710,11 @@ public class IoAddInoutService {
int count = 0;
if (filterList != null) {
for (IoCodeTempEntity temp : filterList) {
if (temp.getCode().equals(codeEntity.getCode()) && StrUtil.trimToEmpty(temp.getSerialNo()).equals(StrUtil.trimToEmpty(codeEntity.getSerialNo()))) {
if (temp.getCode().equals(codeEntity.getCode())
&& StrUtil.trimToEmpty(temp.getSerialNo()).equals(StrUtil.trimToEmpty(codeEntity.getSerialNo()))
&& StrUtil.trimToEmpty(temp.getInBatchNo()).equals(StrUtil.trimToEmpty(codeEntity.getInBatchNo()))
&& BigDecimalUtil.equalTo(temp.getPrice(), codeEntity.getPrice())
) {
count = count + 1;
}
}
@ -768,7 +781,13 @@ public class IoAddInoutService {
ioOrderDetailCodeEntity.setMeasname(udiRelevanceResponse.getMeasname());
ioOrderDetailCodeEntity.setSpec(udiRelevanceResponse.getGgxh());
ioOrderDetailCodeEntity.setSupId(codeTempEntity.getSupId());
if (codeTempEntity.getPrice() == null) {
ioOrderDetailCodeEntity.setPrice(udiRelevanceResponse.getPrice());
codeTempEntity.setPrice(udiRelevanceResponse.getPrice());
codeTempService.updateById(codeTempEntity);
} else {
ioOrderDetailCodeEntity.setPrice(codeTempEntity.getPrice());
}
ioOrderDetailCodeEntity.setCount(codeTempEntity.getCount());
ioOrderDetailCodeEntity.setReCount(codeTempEntity.getMyReCount());
ioOrderDetailCodeEntity.setUpdateTime(new Date());
@ -877,4 +896,150 @@ public class IoAddInoutService {
return null;
}
/**
*
*/
public List<IoCodeTempEntity> checkPrice(BasicBussinessTypeEntity bussinessTypeEntity, List<IoCodeTempEntity> codeTempEntities) {
// Map<Long, IoCodeTempEntity> personMap = codeTempEntities.stream()
// .collect(Collectors.toMap(IoCodeTempEntity::getId, person -> person, (person1, person2) -> {
// if (person1.getBindRlFk().equals(person2.getBindRlFk())
// && StrUtil.emptyIfNull(person1.getBatchNo()).equals(StrUtil.emptyIfNull(person2.getBatchNo()))
// ) {
// person1.setCount(IntUtil.value(person1.getCount()) + IntUtil.value(person2.getCount()));
// person1.setCount(IntUtil.value(person1.getReCount()) + IntUtil.value(person2.getReCount()));
// return person1;
// } else {
// return person2;
// }
// }));
Map<String, List<IoCodeTempEntity>> stringListMap = codeTempEntities.stream()
.collect(Collectors.groupingBy(person -> person.getRelId() + ":" + person.getBatchNo()));
List<IoCodeTempEntity> resultList = new ArrayList<>();
for (String key : stringListMap.keySet()) {
List<IoCodeTempEntity> temps = stringListMap.get(key);
IoCodeTempEntity codeEntity = temps.get(0);
InvProductDetailEntity invProductDetailEntity = invProductDetailService.selectLastInBatch(bussinessTypeEntity, codeEntity.getRelId() + "", codeEntity.getBatchNo(), codeEntity.getInvCode(), codeEntity.getMainAction());
Map<String, Integer> lastCountMap = new HashMap<>();
for (IoCodeTempEntity codeTempEntity : temps) {
if (invProductDetailEntity == null) {
//首次出库,获取入库最早批次
invProductDetailEntity = invProductDetailService.selectFirstInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), ConstantType.TYPE_PUT);
if (invProductDetailEntity != null) {
int count = IntUtil.value(invProductDetailEntity.getCount());
int reCount = IntUtil.value(invProductDetailEntity.getReCount());
//当数量>0时
if (reCount >= codeTempEntity.getReCount()) {
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
Integer tt = lastCountMap.get(invProductDetailEntity.getInBatchNo());
lastCountMap.put(invProductDetailEntity.getInBatchNo(), IntUtil.value(tt) + codeTempEntity.getReCount());
} else {
while (codeTempEntity.getReCount() - reCount > 0) {
IoCodeTempEntity newCodeEntity = new IoCodeTempEntity();
BeanUtils.copyProperties(codeTempEntity, newCodeEntity);
newCodeEntity.setId(null);
newCodeEntity.setCount(count);
newCodeEntity.setReCount(reCount);
newCodeEntity.setPrice(invProductDetailEntity.getPrice());
newCodeEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
lastCountMap.put(invProductDetailEntity.getInBatchNo(), IntUtil.value(lastCountMap.get(invProductDetailEntity.getInBatchNo())) + reCount);
codeTempService.insert(newCodeEntity);
resultList.add(newCodeEntity);
codeTempEntity.setCount(codeTempEntity.getCount() - count);
codeTempEntity.setReCount(codeTempEntity.getReCount() - reCount);
codeTempService.updateById(codeTempEntity);
invProductDetailEntity = invProductDetailService.selectNextInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), ConstantType.TYPE_PUT, invProductDetailEntity.getInBatchNo());
if (invProductDetailEntity != null) {
count = IntUtil.value(invProductDetailEntity.getCount());
reCount = IntUtil.value(invProductDetailEntity.getReCount());
} else {
break;
}
}
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
lastCountMap.put(invProductDetailEntity.getInBatchNo(), IntUtil.value(lastCountMap.get(invProductDetailEntity.getInBatchNo())) + reCount);
}
}
} else {
//非首次出库
int lastCount = IntUtil.value(lastCountMap.get(invProductDetailEntity.getInBatchNo()));
//1.获取当前批次已出库数量
Integer outCount = IntUtil.value(invProductDetailService.selectCountByInBatch(bussinessTypeEntity, invProductDetailEntity.getInBatchNo(), ConstantType.TYPE_OUT));
//2.获取当前批次入库数量
Integer inCount = IntUtil.value(invProductDetailService.selectCountByInBatch(bussinessTypeEntity, invProductDetailEntity.getInBatchNo(), ConstantType.TYPE_PUT));
//3.若数量还有剩,则此次出库为当前批次
if (IntUtil.value(inCount) >= (IntUtil.value(outCount) + IntUtil.value(lastCount) + codeTempEntity.getReCount())) {
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
lastCountMap.put(invProductDetailEntity.getInBatchNo(), IntUtil.value(lastCountMap.get(invProductDetailEntity.getInBatchNo())) + codeTempEntity.getReCount());
} else {
// 4.若数量不足,则出下一批次
// InvProductDetailEntity nextInvProduct = invProductDetailService.selectNextInBatch(codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), codeTempEntity.getMainAction(), invProductDetailEntity.getInBatchNo());
// inCount = nextInvProduct.getReCount();
int curCount = outCount + lastCount;
while (curCount >= inCount) {
invProductDetailEntity = invProductDetailService.selectNextInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), codeTempEntity.getMainAction(), invProductDetailEntity.getInBatchNo());
if (invProductDetailEntity != null) {
if (invProductDetailEntity.getReCount() > codeTempEntity.getReCount()) {
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
lastCountMap.put(invProductDetailEntity.getInBatchNo(), inCount);
} else {
IoCodeTempEntity newCodeEntity = new IoCodeTempEntity();
BeanUtils.copyProperties(codeTempEntity, newCodeEntity);
newCodeEntity.setId(null);
newCodeEntity.setReCount(inCount);
newCodeEntity.setPrice(invProductDetailEntity.getPrice());
newCodeEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
lastCountMap.put(invProductDetailEntity.getInBatchNo(), inCount);
codeTempService.insert(newCodeEntity);
resultList.add(newCodeEntity);
codeTempEntity.setReCount(curCount - inCount);
codeTempService.updateById(codeTempEntity);
}
inCount = IntUtil.value(invProductDetailEntity.getReCount());
lastCount = IntUtil.value(lastCountMap.get(invProductDetailEntity.getInBatchNo()));
//1.获取当前批次已出库数量
outCount = IntUtil.value(invProductDetailService.selectCountByInBatch(bussinessTypeEntity, invProductDetailEntity.getInBatchNo(), ConstantType.TYPE_OUT));
curCount = outCount + lastCount;
} else {
break;
}
}
if (invProductDetailEntity != null) {
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
lastCountMap.put(invProductDetailEntity.getInBatchNo(), inCount);
}
}
if (invProductDetailEntity != null) {
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
}
}
resultList.add(codeTempEntity);
}
}
return resultList;
}
}

@ -1,5 +1,7 @@
package com.glxp.api.service.inout;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.UUID;
@ -17,13 +19,11 @@ import com.glxp.api.service.auth.InvWarehouseService;
import com.glxp.api.service.basic.IBasicBusTypePreService;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.inout.impl.IoOrderInvoiceService;
import com.glxp.api.service.inv.InvProductDetailService;
import com.glxp.api.service.system.SystemParamConfigService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.MsDateUtil;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

@ -1,5 +1,7 @@
package com.glxp.api.service.inout;
import com.glxp.api.dao.inout.IoOrderDetailCodeDao;
import com.glxp.api.service.inout.impl.IoCodeService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
@ -122,7 +124,9 @@ public class IoCheckInoutService {
}
}
//校验流程 //一次校验
/**
* //一次校验
*/
public void check(String orderId) {
IoOrderEntity orderEntity = orderService.findByBillNo(orderId);
//过滤非未校验或校验异常
@ -356,7 +360,7 @@ public class IoCheckInoutService {
if (bizEntity == null) {
return "非此单产品!";
}
IoOrderDetailCodeEntity orderDetailCodeEntity = orderDetailCodeService.findByUnique(codeEntity.getOrderId(), codeEntity.getRelId(), codeEntity.getBatchNo());
IoOrderDetailCodeEntity orderDetailCodeEntity = orderDetailCodeService.findByUnique(codeEntity.getOrderId(), codeEntity.getRelId(), codeEntity.getBatchNo(), codeEntity.getPrice());
int curCount = 0;
if (orderDetailCodeEntity != null) {
curCount = orderDetailCodeEntity.getReCount() + codeEntity.getMyReCount();
@ -440,6 +444,13 @@ public class IoCheckInoutService {
for (IoCodeTempEntity codeTempEntity : codeTempEntities) {
IoCodeEntity codeEnttity = new IoCodeEntity();
BeanUtils.copyProperties(codeTempEntity, codeEnttity);
for (IoOrderDetailCodeEntity orderDetailCodeEntity : orderDetailCodeEntities) {
if (orderDetailCodeEntity.getBindRlFk().longValue() == codeEnttity.getRelId().longValue()
&& StrUtil.nullToEmpty(orderDetailCodeEntity.getBatchNo()).equals(StrUtil.nullToEmpty(codeEnttity.getBatchNo()))) {
codeEnttity.setPrice(orderDetailCodeEntity.getPrice());
break;
}
}
codeEnttity.setId(null);
codeService.insert(codeEnttity);
}
@ -454,6 +465,8 @@ public class IoCheckInoutService {
checkThird(orderEntity);
}
@Resource
IoOrderDetailCodeDao orderDetailCodeDao;
//一次校验完成
public void checkFirstFinish(IoOrderEntity orderEntity) {
@ -491,6 +504,7 @@ public class IoCheckInoutService {
bizEntity.setCheckSuccess(true);
bizEntity.setScanCount(codeEntity.getReCount());
codeEntity.setCheckSuccess(true);
codeEntity.setPrice(bizEntity.getPrice());
} else {
bizEntity.setScanCount(codeEntity.getReCount());
bizEntity.setCheckSuccess(false);
@ -558,6 +572,9 @@ public class IoCheckInoutService {
BeanUtils.copyProperties(codeTempEntity, codeEnttity);
codeService.insert(codeEnttity);
}
//更新扫码详情表
orderDetailCodeDao.updateBatchById(orderDetailCodeEntities);
// orderDetailCodeService.update()
codeTempService.deleteByBillNo(orderEntity.getBillNo());
orderEntity.setErrMsg("校验成功!");
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK_SUCCESS);

@ -1,61 +0,0 @@
package com.glxp.api.service.inout;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.entity.inout.IoCodeEntity;
import com.glxp.api.req.inout.FilterCodeRequest;
import com.glxp.api.res.inout.IoCodeResponse;
import java.util.List;
public interface IoCodeService {
int insert(IoCodeEntity codeEnttity);
boolean insertBatch(List<IoCodeEntity> codeEnttities);
List<IoCodeEntity> findByOrderId(String billNo);
List<IoCodeResponse> findJoinByOrderId(String billNo);
int updateById(IoCodeEntity codeEnttity);
int deleteById(Integer id);
public IoCodeEntity findByUnique(String orderId, String code);
List<IoCodeEntity> findByOrderIds(List<String> orderIds, String code);
int findByOrderIdsCount(List<String> orderIds, String code);
boolean isExitByRelId(String relId);
/**
*
*
* @param filterCodeRequest
* @return
*/
List<IoCodeEntity> filterCodeList(FilterCodeRequest filterCodeRequest);
/**
* VO
*/
List<IoCodeResponse> filterList(FilterCodeRequest filterCodeRequest);
/**
*
*
* @param orderId
* @return
*/
BaseResponse deleteCodeByOrderId(String orderId);
/**
*
*
* @param filterCodeRequest
* @return
*/
List<IoCodeResponse> getCodeListForEdit(FilterCodeRequest filterCodeRequest);
}

@ -1,5 +1,7 @@
package com.glxp.api.service.inout;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.constant.BusinessType;
@ -68,7 +70,7 @@ public class IoGenInvService {
//生成库存产品表
for (IoOrderDetailResultEntity orderDetailResultEntity : orderDetailResultEntities) {
InvProductEntity invProductEntity = invProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode());
InvProductEntity invProductEntity = invProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getPrice());
if (invProductEntity == null) {
invProductEntity = new InvProductEntity();
invProductEntity.setRelIdFk(orderDetailResultEntity.getBindRlFk());
@ -83,6 +85,7 @@ public class IoGenInvService {
invProductEntity.setInvCode(orderEntity.getInvCode());
invProductEntity.setCreateTime(new Date());
invProductEntity.setUpdateTime(new Date());
invProductEntity.setPrice(orderDetailResultEntity.getPrice());
invProductService.insert(invProductEntity);
}
@ -198,7 +201,7 @@ public class IoGenInvService {
//生成库存产品表
for (IoOrderDetailResultEntity orderDetailResultEntity : orderDetailResultEntities) {
InvPreProductEntity invPreProductEntity = invPreProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode());
InvPreProductEntity invPreProductEntity = invPreProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getPrice());
if (invPreProductEntity == null) {
invPreProductEntity = new InvPreProductEntity();
invPreProductEntity.setRelIdFk(orderDetailResultEntity.getBindRlFk());
@ -208,6 +211,7 @@ public class IoGenInvService {
invPreProductEntity.setExpireDate(orderDetailResultEntity.getExpireDate());
invPreProductEntity.setInCount(0);
invPreProductEntity.setOutCount(0);
invPreProductEntity.setPrice(orderDetailResultEntity.getPrice());
invPreProductEntity.setSupId(orderDetailResultEntity.getSupId());
invPreProductEntity.setDeptCode(orderEntity.getDeptCode());
invPreProductEntity.setInvCode(orderEntity.getInvCode());
@ -268,6 +272,7 @@ public class IoGenInvService {
invUserProductEntity.setInCount(0);
invUserProductEntity.setType(ConstantStatus.ACTION_TYPE_PREIN);
invUserProductEntity.setOutCount(0);
invUserProductEntity.setSupId(orderDetailResultEntity.getSupId());
invUserProductEntity.setDeptCode(orderEntity.getDeptCode());
invUserProductEntity.setInvCode(orderEntity.getInvCode());
@ -341,7 +346,7 @@ public class IoGenInvService {
List<IoOrderDetailResultEntity> orderDetailResultEntities = orderDetailResultService.findByOrderId(orderId);
//生成库存产品表
for (IoOrderDetailResultEntity orderDetailResultEntity : orderDetailResultEntities) {
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode());
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getPrice());
if (invProductEntity == null) {
invProductEntity = new InvPreinProductEntity();
invProductEntity.setRelIdFk(orderDetailResultEntity.getBindRlFk());
@ -353,6 +358,7 @@ public class IoGenInvService {
invProductEntity.setOutCount(0);
invProductEntity.setSupId(orderDetailResultEntity.getSupId());
invProductEntity.setDeptCode(orderEntity.getDeptCode());
invProductEntity.setPrice(orderDetailResultEntity.getPrice());
invProductEntity.setInvCode(orderEntity.getInvCode());
invProductEntity.setCreateTime(new Date());
invProductEntity.setUpdateTime(new Date());

@ -4,13 +4,14 @@ import com.glxp.api.entity.inout.IoOrderDetailCodeEntity;
import com.glxp.api.req.inout.FilterOrderDetailCodeRequest;
import com.glxp.api.res.inout.IoOrderDetailCodeResponse;
import java.math.BigDecimal;
import java.util.List;
public interface IoOrderDetailCodeService {
List<IoOrderDetailCodeEntity> findByOrderId(String orderId);
IoOrderDetailCodeEntity findByUnique(String orderId, Long relId, String bacthNo);
IoOrderDetailCodeEntity findByUnique(String orderId, Long relId, String bacthNo, BigDecimal price);
int findByRelIdCount(String orderId, Long relId, String batchNo);
@ -41,6 +42,9 @@ public interface IoOrderDetailCodeService {
boolean isExit(String orderId);
boolean isExit(Long relId, String bacthNo, Long ignoreId, String orderId);
/**
* VO
*

@ -1,6 +1,7 @@
package com.glxp.api.service.inout;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.entity.inout.IoCodeEntity;
import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.req.inout.FilterOrderRequest;
@ -47,7 +48,7 @@ public interface IoOrderService {
int deleteInvByBillNo(List<String> billNo);
int deleteInvCode(String billNo, String code);
int deleteInvCode(IoCodeEntity codeEntity);
boolean rollUnCheckOrder(String billNo);

@ -1,5 +1,8 @@
package com.glxp.api.service.inout.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.dao.inv.InvProductDetailDao;
import com.glxp.api.entity.inv.InvProductDetailEntity;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
@ -16,7 +19,6 @@ import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.req.inout.FilterCodeRequest;
import com.glxp.api.res.inout.IoCodeResponse;
import com.glxp.api.res.inout.IoCodeTempResponse;
import com.glxp.api.service.inout.IoCodeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -27,7 +29,7 @@ import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class IoCodeServiceImpl implements IoCodeService {
public class IoCodeService extends ServiceImpl<IoCodeDao, IoCodeEntity> {
@Resource
private IoCodeDao ioCodeDao;
@ -36,23 +38,23 @@ public class IoCodeServiceImpl implements IoCodeService {
@Resource
private IoCodeTempDao ioCodeTempDao;
@Override
public int insert(IoCodeEntity codeEnttity) {
codeEnttity.setId(null);
return ioCodeDao.insert(codeEnttity);
}
@Override
public boolean insertBatch(List<IoCodeEntity> codeEnttities) {
return ioCodeDao.insertBatch(codeEnttities);
}
@Override
public List<IoCodeEntity> findByOrderId(String billNo) {
return ioCodeDao.selectList(new QueryWrapper<IoCodeEntity>().eq("orderId", billNo));
}
@Override
public List<IoCodeResponse> findJoinByOrderId(String billNo) {
if (StrUtil.isEmpty(billNo))
return null;
@ -61,22 +63,22 @@ public class IoCodeServiceImpl implements IoCodeService {
return ioCodeDao.filterJoinProduct(filterCodeRequest);
}
@Override
public int updateById(IoCodeEntity codeEnttity) {
return ioCodeDao.updateById(codeEnttity);
public boolean updateById(IoCodeEntity codeEnttity) {
return ioCodeDao.updateById(codeEnttity) > 0;
}
@Override
public int deleteById(Integer id) {
return ioCodeDao.deleteById(id);
}
@Override
public IoCodeEntity findByUnique(String orderId, String code) {
return ioCodeDao.selectOne(new QueryWrapper<IoCodeEntity>().eq("orderId", orderId).eq("code", code));
}
@Override
public List<IoCodeEntity> findByOrderIds(List<String> orderIds, String code) {
if (StrUtil.isNotEmpty(code))
@ -86,7 +88,7 @@ public class IoCodeServiceImpl implements IoCodeService {
}
}
@Override
public int findByOrderIdsCount(List<String> orderIds, String code) {
List<IoCodeEntity> codeEntities = findByOrderIds(orderIds, code);
if (CollUtil.isNotEmpty(codeEntities)) {
@ -100,13 +102,13 @@ public class IoCodeServiceImpl implements IoCodeService {
return 0;
}
@Override
public boolean isExitByRelId(String relId) {
// return ioCodeDao.selectList(new QueryWrapper<IoCodeEntity>().eq("relId", relId).last("limit 1"));
return ioCodeDao.exists(new QueryWrapper<IoCodeEntity>().eq("relId", relId));
}
@Override
public List<IoCodeEntity> filterCodeList(FilterCodeRequest filterCodeRequest) {
if (null == filterCodeRequest) {
return Collections.emptyList();
@ -117,7 +119,7 @@ public class IoCodeServiceImpl implements IoCodeService {
return ioCodeDao.filterCodeList(filterCodeRequest);
}
@Override
public List<IoCodeResponse> filterList(FilterCodeRequest filterCodeRequest) {
if (null == filterCodeRequest) {
return Collections.emptyList();
@ -128,7 +130,7 @@ public class IoCodeServiceImpl implements IoCodeService {
return ioCodeDao.filterList(filterCodeRequest);
}
@Override
public BaseResponse deleteCodeByOrderId(String orderId) {
if (StrUtil.isBlank(orderId)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "单据号不能为空");
@ -137,7 +139,7 @@ public class IoCodeServiceImpl implements IoCodeService {
return ResultVOUtils.success("删除成功");
}
@Override
public List<IoCodeResponse> getCodeListForEdit(FilterCodeRequest filterCodeRequest) {
List<IoCodeResponse> ioCodeResponses = new ArrayList<>();
//查询此单的数据

@ -1,5 +1,6 @@
package com.glxp.api.service.inout.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -74,7 +75,21 @@ public class IoCodeTempServiceImpl implements IoCodeTempService {
@Override
public IoCodeTempEntity findByUnique(String orderId, String code) {
return ioCodeTempDao.selectOne(new QueryWrapper<IoCodeTempEntity>().eq("orderId", orderId).eq("code", code));
List<IoCodeTempEntity> codeTempEntities = ioCodeTempDao.selectList(new QueryWrapper<IoCodeTempEntity>().eq("orderId", orderId).eq("code", code));
if (CollUtil.isNotEmpty(codeTempEntities)) {
IoCodeTempEntity codeTempEntity = codeTempEntities.get(0);
if (codeTempEntities.size() > 1) {
for (int i = 1; i < codeTempEntities.size(); i++) {
codeTempEntity.setCount(codeTempEntity.getCount() + codeTempEntities.get(i).getCount());
codeTempEntity.setReCount(codeTempEntity.getReCount() + codeTempEntities.get(i).getReCount());
}
}
return codeTempEntity;
}
return null;
}
@Override

@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -44,9 +45,13 @@ public class IoOrderDetailCodeServiceImpl implements IoOrderDetailCodeService {
}
@Override
public IoOrderDetailCodeEntity findByUnique(String orderId, Long relId, String bacthNo) {
return ioOrderDetailCodeDao.selectOne(new QueryWrapper<IoOrderDetailCodeEntity>().eq("orderIdFk", orderId).eq("bindRlFk", relId).eq(StrUtil.isNotEmpty(bacthNo), "batchNo", bacthNo)
.isNull(StrUtil.isEmpty(bacthNo), "batchNo"));
public IoOrderDetailCodeEntity findByUnique(String orderId, Long relId, String bacthNo, BigDecimal price) {
return ioOrderDetailCodeDao.selectOne(new QueryWrapper<IoOrderDetailCodeEntity>()
.eq("orderIdFk", orderId).eq("bindRlFk", relId)
.eq(StrUtil.isNotEmpty(bacthNo), "batchNo", bacthNo)
.isNull(StrUtil.isEmpty(bacthNo), "batchNo")
.eq(price != null, "price", price)
);
}
@Override
@ -106,6 +111,13 @@ public class IoOrderDetailCodeServiceImpl implements IoOrderDetailCodeService {
return ioOrderDetailCodeDao.exists(new QueryWrapper<IoOrderDetailCodeEntity>().eq("orderIdFk", orderId));
}
@Override
public boolean isExit(Long relId, String bacthNo, Long ignoreId, String orderId) {
return ioOrderDetailCodeDao.exists(new QueryWrapper<IoOrderDetailCodeEntity>().eq("bindRlFk", relId).eq(StrUtil.isNotEmpty(bacthNo), "batchNo", bacthNo)
.isNull(StrUtil.isEmpty(bacthNo), "batchNo").eq("orderIdFk", orderId).ne("id", ignoreId));
}
@Override
public List<IoOrderDetailCodeResponse> getDetailCodeResponse(List<IoOrderDetailCodeEntity> orderEntityList) {
if (CollUtil.isEmpty(orderEntityList)) {

@ -1,5 +1,6 @@
package com.glxp.api.service.inout.impl;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.UUID;
@ -237,7 +238,8 @@ public class IoOrderServiceImpl implements IoOrderService {
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
for (InvPreInProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
//更新库存
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
@ -261,7 +263,8 @@ public class IoOrderServiceImpl implements IoOrderService {
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
for (InvPreProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
//更新库存
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(),
invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
@ -286,7 +289,7 @@ public class IoOrderServiceImpl implements IoOrderService {
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
//更新库存
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
@ -313,14 +316,14 @@ public class IoOrderServiceImpl implements IoOrderService {
//单据编辑条码减一
@Override
public int deleteInvCode(String billNo, String code) {
public int deleteInvCode(IoCodeEntity codeEntity) {
//查询条码
IoOrderEntity orderEntity = findByBillNo(billNo);
IoOrderEntity orderEntity = findByBillNo(codeEntity.getOrderId());
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED
|| orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS || orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_REW) {
//更新正式表
IoCodeEntity ioCodeEntity = codeService.findByUnique(billNo, code);
IoCodeEntity ioCodeEntity = codeService.getById(codeEntity.getId());
if (ioCodeEntity.getMyCount() > 1) {
//更新码表
ioCodeEntity.setCount(ioCodeEntity.getMyCount() - 1);
@ -335,7 +338,7 @@ public class IoOrderServiceImpl implements IoOrderService {
orderDetailBizService.update(orderDetailBizEntity);
}
//更新扫码单据详情
IoOrderDetailCodeEntity ioOrderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(ioCodeEntity.getOrderId(), ioCodeEntity.getRelId(), ioCodeEntity.getBatchNo());
IoOrderDetailCodeEntity ioOrderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(ioCodeEntity.getOrderId(), ioCodeEntity.getRelId(), ioCodeEntity.getBatchNo(), ioCodeEntity.getPrice());
if (ioOrderDetailCodeEntity != null) {
ioOrderDetailCodeEntity.setReCount(IntUtil.value(ioOrderDetailCodeEntity.getReCount()) - reCount);
ioOrderDetailCodeEntity.setCount(IntUtil.value(ioOrderDetailCodeEntity.getCount()) - reCount);
@ -354,7 +357,7 @@ public class IoOrderServiceImpl implements IoOrderService {
//如果数量扣减之后为0直接删除此条码
codeService.deleteById(ioCodeEntity.getId());
//更新扫码单据详情
IoOrderDetailCodeEntity ioOrderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(ioCodeEntity.getOrderId(), ioCodeEntity.getRelId(), ioCodeEntity.getBatchNo());
IoOrderDetailCodeEntity ioOrderDetailCodeEntity = ioOrderDetailCodeService.findByUnique(ioCodeEntity.getOrderId(), ioCodeEntity.getRelId(), ioCodeEntity.getBatchNo(), ioCodeEntity.getPrice());
if (ioOrderDetailCodeEntity != null) {
ioOrderDetailCodeEntity.setReCount(ioOrderDetailCodeEntity.getReCount() - reCount);
ioOrderDetailCodeService.update(ioOrderDetailCodeEntity);
@ -373,7 +376,7 @@ public class IoOrderServiceImpl implements IoOrderService {
//预验收库存
if (basicBussinessTypeEntity.getActionType() == ConstantStatus.ACTION_TYPE_PREIN) {
InvPreInProductDetailEntity invProductDetailEntity = invPreinProductDetailService.selectByCode(billNo, code);
InvPreInProductDetailEntity invProductDetailEntity = invPreinProductDetailService.selectByCode(codeEntity.getOrderId(), codeEntity.getCode(), codeEntity.getPrice());
if (invProductDetailEntity != null) {
int count = invProductDetailEntity.getCount() - 1;
int reCount = udiCalCountUtil.getActCount(invProductDetailEntity.getNameCode());
@ -386,7 +389,8 @@ public class IoOrderServiceImpl implements IoOrderService {
invPreinProductDetailService.update(invProductDetailEntity);
}
//更新产品表
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(),
invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int inCount = invProductEntity.getInCount() - reCount;
@ -402,7 +406,7 @@ public class IoOrderServiceImpl implements IoOrderService {
} else if (basicBussinessTypeEntity.getActionType() == ConstantStatus.ACTION_TYPE_ADVANCE) { //寄售库存
InvPreProductDetailEntity invProductDetailEntity = invPreProductDetailService.selectByCode(billNo, code);
InvPreProductDetailEntity invProductDetailEntity = invPreProductDetailService.selectByCode(codeEntity.getOrderId(), codeEntity.getCode(), codeEntity.getPrice());
if (invProductDetailEntity != null) {
int count = invProductDetailEntity.getCount() - 1;
int reCount = udiCalCountUtil.getActCount(invProductDetailEntity.getNameCode());
@ -415,7 +419,8 @@ public class IoOrderServiceImpl implements IoOrderService {
invPreProductDetailService.update(invProductDetailEntity);
}
//更新产品表
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(),
invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int inCount = invProductEntity.getInCount() - reCount;
@ -430,7 +435,7 @@ public class IoOrderServiceImpl implements IoOrderService {
}
} else { //普通库存
InvProductDetailEntity invProductDetailEntity = invProductDetailService.selectByCode(billNo, code);
InvProductDetailEntity invProductDetailEntity = invProductDetailService.selectByCode(codeEntity.getOrderId(), codeEntity.getCode(), codeEntity.getPrice());
if (invProductDetailEntity != null) {
int count = invProductDetailEntity.getCount() - 1;
@ -445,7 +450,8 @@ public class IoOrderServiceImpl implements IoOrderService {
invProductDetailService.update(invProductDetailEntity);
}
//更新产品表
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int inCount = invProductEntity.getInCount() - reCount;
@ -465,7 +471,7 @@ public class IoOrderServiceImpl implements IoOrderService {
} else {
//更新临时表
IoCodeTempEntity ioCodeEntity = codeTempService.findByUnique(billNo, code);
IoCodeTempEntity ioCodeEntity = codeTempService.selectById(codeEntity.getId());
if (ioCodeEntity.getCount() > 1) {
//删除一个条码
ioCodeEntity.setCount(ioCodeEntity.getCount() - 1);
@ -514,7 +520,7 @@ public class IoOrderServiceImpl implements IoOrderService {
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
for (InvPreInProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
@ -533,7 +539,7 @@ public class IoOrderServiceImpl implements IoOrderService {
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
for (InvPreProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
@ -552,7 +558,7 @@ public class IoOrderServiceImpl implements IoOrderService {
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelId(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode());
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
@ -763,14 +769,15 @@ public class IoOrderServiceImpl implements IoOrderService {
* 使
*
*
*
* <p>
* or
*
* <p>
*
*
*
*
*
*
* @param filterOrderRequest
*/
@ -1131,7 +1138,7 @@ public class IoOrderServiceImpl implements IoOrderService {
for (IoOrderDetailResultEntity ioOrderDetailResultEntity : ioOrderDetailResultEntityList) {
//查询该产品是不是存在
InvProductEntity invProductEntity = invProductService.selectByUnique(ioOrderDetailResultEntity.getBindRlFk(), ioOrderDetailResultEntity.getBatchNo(),
ioOrderDetailResultEntity.getSupId(), ioOrderEntity.getDeptCode(), ioOrderEntity.getInvCode());
ioOrderDetailResultEntity.getSupId(), ioOrderEntity.getDeptCode(), ioOrderEntity.getInvCode(), ioOrderDetailResultEntity.getPrice());
if (invProductEntity == null) {
//没有该产品就填充数据
invProductEntity = new InvProductEntity();
@ -1145,6 +1152,7 @@ public class IoOrderServiceImpl implements IoOrderService {
invProductEntity.setSupId(ioOrderDetailResultEntity.getSupId());
invProductEntity.setDeptCode(ioOrderEntity.getDeptCode());
invProductEntity.setInvCode(ioOrderEntity.getInvCode());
invProductEntity.setPrice(ioOrderDetailResultEntity.getPrice());
invProductEntity.setCreateTime(new Date());
invProductEntity.setUpdateTime(new Date());
invProductEntity.setNowStock(0); //现存量

@ -8,6 +8,7 @@ import com.glxp.api.req.inv.FilterInvProductDetailRequest;
import com.glxp.api.res.inv.InvPlaceDetailResponse;
import com.glxp.api.res.inv.InvPreProductDetailResponse;
import java.math.BigDecimal;
import java.util.List;
/**
@ -21,7 +22,7 @@ public interface InvPreProductDetailService {
List<InvPreProductDetailEntity> selectByOrderIdFk(String billNo);
InvPreProductDetailEntity selectByCode(String billNo, String code);
InvPreProductDetailEntity selectByCode(String billNo, String code, BigDecimal price);
boolean update(InvPreProductDetailEntity invPreProductDetailEntity);

@ -4,6 +4,7 @@ import com.glxp.api.entity.inv.InvPreProductEntity;
import com.glxp.api.req.inv.FilterInvPreProductRequest;
import com.glxp.api.res.inv.InvPreProductResponse;
import java.math.BigDecimal;
import java.util.List;
/**
@ -16,7 +17,7 @@ public interface InvPreProductService {
boolean update(InvPreProductEntity invPreProductEntity);
InvPreProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode);
InvPreProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode, BigDecimal price);
boolean deleteById(Integer id);

@ -9,6 +9,7 @@ import com.glxp.api.res.inv.InvPlaceDetailResponse;
import com.glxp.api.res.inv.InvPreProductDetailResponse;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
/**
@ -24,7 +25,7 @@ public interface InvPreinProductDetailService {
List<InvPreInProductDetailEntity> findByCode(String code);
InvPreInProductDetailEntity selectByCode(String billNo, String code);
InvPreInProductDetailEntity selectByCode(String billNo, String code, BigDecimal price);
boolean update(InvPreInProductDetailEntity invPreInProductDetailEntity);

@ -4,6 +4,7 @@ import com.glxp.api.entity.inv.InvPreinProductEntity;
import com.glxp.api.req.inv.FilterInvPreinProductRequest;
import com.glxp.api.res.inv.InvPreinProductResponse;
import java.math.BigDecimal;
import java.util.List;
/**
@ -16,7 +17,7 @@ public interface InvPreinProductService {
boolean update(InvPreinProductEntity invPreinProductEntity);
InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode);
InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode, BigDecimal price);
InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId);

@ -1,60 +0,0 @@
package com.glxp.api.service.inv;
import com.glxp.api.entity.inv.InvPreinDetailEntity;
import com.glxp.api.entity.inv.InvProductDetailEntity;
import com.glxp.api.req.inv.FilterInvProductDetailRequest;
import com.glxp.api.res.inv.InvPlaceDetailResponse;
import com.glxp.api.res.inv.InvProductDetailResponse;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface InvProductDetailService {
int insert(InvProductDetailEntity invProductDetailEntity);
List<InvProductDetailEntity> selectByOrderIdFk(String billNo);
InvProductDetailEntity selectByCode(String billNo, String code);
int deleteByOrderId(String billNo);
int deleteById(Integer id);
int update(InvProductDetailEntity invProductDetailEntity);
List<InvProductDetailEntity> selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode);
InvProductDetailEntity sortFindByCode(String code);
boolean insertList(List<InvProductDetailEntity> invProductDetailEntities);
/**
*
*
* @param filterInvProductDetailRequest
* @return
*/
List<InvProductDetailEntity> filterInvProductDetailList(FilterInvProductDetailRequest filterInvProductDetailRequest);
boolean deleteInvProductDetail(FilterInvProductDetailRequest detailRequest);
/**
*
*
* @param response
*/
void setOrderInfo(InvProductDetailResponse response);
int vailStockCount(Long relId, String batchNo, String supId, String deptCode, String invCode, String invSpaceCode);
int vailStockCountByCode(String deptCode, String invCode, String invSpaceCode, String code);
List<InvPlaceDetailResponse> findByGroupCode(String invCode, String code , Boolean isCheckSpace);
}

@ -4,6 +4,7 @@ import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.req.inv.FilterInvProductRequest;
import com.glxp.api.res.inv.InvProductResponse;
import java.math.BigDecimal;
import java.util.List;
public interface InvProductService {
@ -15,7 +16,7 @@ public interface InvProductService {
boolean updateBatch(List<InvProductEntity> invProductEntities);
InvProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode);
InvProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode, BigDecimal price);
InvProductEntity selectByUnique(Long relId, String batchNo, String supId);

@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@ -73,9 +74,9 @@ public class InvPreInProductDetailServiceImpl implements InvPreinProductDetailSe
}
@Override
public InvPreInProductDetailEntity selectByCode(String billNo, String code) {
public InvPreInProductDetailEntity selectByCode(String billNo, String code, BigDecimal price) {
List<InvPreInProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.selectList
(new QueryWrapper<InvPreInProductDetailEntity>().eq("code", code).eq("orderId", billNo));
(new QueryWrapper<InvPreInProductDetailEntity>().eq("code", code).eq("orderId", billNo).eq(price != null, "price", price));
if (CollUtil.isNotEmpty(invProductDetailEntities))
return invProductDetailEntities.get(0);
else

@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@ -67,9 +68,9 @@ public class InvPreProductDetailServiceImpl implements InvPreProductDetailServic
}
@Override
public InvPreProductDetailEntity selectByCode(String billNo, String code) {
public InvPreProductDetailEntity selectByCode(String billNo, String code, BigDecimal price) {
List<InvPreProductDetailEntity> invProductDetailEntities = invPreProductDetailDao.selectList
(new QueryWrapper<InvPreProductDetailEntity>().eq("code", code).eq("orderId", billNo));
(new QueryWrapper<InvPreProductDetailEntity>().eq("code", code).eq("orderId", billNo).eq(price != null, "price", price));
if (CollUtil.isNotEmpty(invProductDetailEntities))
return invProductDetailEntities.get(0);
else

@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@ -35,9 +36,10 @@ public class InvPreProductServiceImpl implements InvPreProductService {
}
@Override
public InvPreProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode) {
public InvPreProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode, BigDecimal price) {
return invPreProductDao.selectOne(new QueryWrapper<InvPreProductEntity>().eq("relIdFk", relId).eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo)
.isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId).eq("deptCode", deptCode).eq("invCode", invCode));
.isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId).eq("deptCode", deptCode).eq("invCode", invCode)
.eq(price != null, "price", price).isNull(price == null, "price"));
}

@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@ -35,9 +36,10 @@ public class InvPreinProductServiceImpl implements InvPreinProductService {
}
@Override
public InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode) {
public InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode, BigDecimal price) {
return invPreinProductDao.selectOne(new QueryWrapper<InvPreinProductEntity>().eq("relIdFk", relId).eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo)
.isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId).eq("deptCode", deptCode).eq("invCode", invCode));
.isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId).eq("deptCode", deptCode).eq("invCode", invCode)
.eq(price != null, "price", price).isNull(price == null, "price"));
}

@ -3,11 +3,15 @@ package com.glxp.api.service.inv.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.constant.ConstantType;
import com.glxp.api.dao.basic.BasicBussinessTypeDao;
import com.glxp.api.dao.basic.UdiProductDao;
import com.glxp.api.dao.inout.IoOrderDao;
import com.glxp.api.dao.inv.InvPreInProductDetailDao;
import com.glxp.api.dao.inv.InvPreProductDetailDao;
import com.glxp.api.dao.inv.InvProductDetailDao;
import com.glxp.api.entity.auth.InvSpace;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
@ -17,21 +21,22 @@ import com.glxp.api.req.inv.FilterInvProductDetailRequest;
import com.glxp.api.res.inv.InvPlaceDetailResponse;
import com.glxp.api.res.inv.InvProductDetailResponse;
import com.glxp.api.service.auth.InvSpaceService;
import com.glxp.api.service.inv.InvProductDetailService;
import com.glxp.api.util.MsDateUtil;
import com.glxp.api.util.IntUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class InvProductDetailServiceImpl implements InvProductDetailService {
public class InvProductDetailService extends ServiceImpl<InvProductDetailDao, InvProductDetailEntity> {
@Resource
private InvProductDetailDao invProductDetailDao;
@ -43,7 +48,6 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
private UdiProductDao udiProductDao;
@Override
public int insert(InvProductDetailEntity invProductDetailEntity) {
invProductDetailEntity.setId(null);
if (invProductDetailEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
@ -54,7 +58,6 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return invProductDetailDao.insert(invProductDetailEntity);
}
@Override
public List<InvProductDetailEntity> selectByOrderIdFk(String billNo) {
if (StrUtil.isEmpty(billNo))
return null;
@ -62,10 +65,10 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return invProductDetailEntities;
}
@Override
public InvProductDetailEntity selectByCode(String billNo, String code) {
public InvProductDetailEntity selectByCode(String billNo, String code, BigDecimal price) {
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.selectList
(new QueryWrapper<InvProductDetailEntity>().eq("code", code).eq("orderId", billNo));
(new QueryWrapper<InvProductDetailEntity>().eq("code", code).eq("orderId", billNo).eq(price != null, "price", price));
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
if (IntUtil.value(invProductDetailEntity.getReCount()) > 0) {
@ -77,17 +80,17 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return null;
}
@Override
public int deleteByOrderId(String billNo) {
return invProductDetailDao.delete(new QueryWrapper<InvProductDetailEntity>().eq("orderId", billNo));
}
@Override
public int deleteById(Integer id) {
return invProductDetailDao.deleteById(id);
}
@Override
public int update(InvProductDetailEntity invProductDetailEntity) {
if (invProductDetailEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
@ -99,13 +102,13 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return invProductDetailDao.updateById(invProductDetailEntity);
}
@Override
public List<InvProductDetailEntity> selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode) {
return invProductDetailDao.selectList(new QueryWrapper<InvProductDetailEntity>().eq("relId", relId).eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo)
.isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId).eq("deptCode", deptCode).eq("invCode", invCode));
}
@Override
public InvProductDetailEntity sortFindByCode(String code) {
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.selectList(new QueryWrapper<InvProductDetailEntity>().eq("code", code).orderByDesc("id"));
if (CollUtil.isNotEmpty(invProductDetailEntities))
@ -114,12 +117,12 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return null;
}
@Override
public boolean insertList(List<InvProductDetailEntity> invProductDetailEntities) {
return invProductDetailDao.insertBatch(invProductDetailEntities);
}
@Override
public List<InvProductDetailEntity> filterInvProductDetailList(FilterInvProductDetailRequest filterInvProductDetailRequest) {
if (null == filterInvProductDetailRequest) {
return Collections.emptyList();
@ -130,7 +133,7 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return invProductDetailDao.filterInvProductDetailList(filterInvProductDetailRequest);
}
@Override
public boolean deleteInvProductDetail(FilterInvProductDetailRequest detailRequest) {
return invProductDetailDao.deleteInvProductDetail(detailRequest);
}
@ -138,7 +141,7 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
@Resource
InvSpaceService invSpaceService;
@Override
public void setOrderInfo(InvProductDetailResponse response) {
//查询DI层级根据DI层级设置数量取值
Integer packLevel = udiProductDao.selectPackLevel(response.getNameCode());
@ -177,7 +180,6 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
}
@Override
public int vailStockCount(Long relId, String batchNo, String supId, String deptCode, String invCode, String invSpaceCode) {
if (relId == null) {
return 0;
@ -202,7 +204,7 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return count;
}
@Override
public int vailStockCountByCode(String deptCode, String invCode, String invSpaceCode, String code) {
List<InvProductDetailEntity> datas =
invProductDetailDao.selectList(new QueryWrapper<InvProductDetailEntity>().eq("deptCode", deptCode).eq("invCode", invCode)
@ -223,7 +225,7 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return count;
}
@Override
public List<InvPlaceDetailResponse> findByGroupCode(String invCode, String code, Boolean isCheckSpace) {
if (StrUtil.isNotEmpty(invCode) && StrUtil.isNotEmpty(code)) {
List<InvPlaceDetailResponse> datas =
@ -233,4 +235,59 @@ public class InvProductDetailServiceImpl implements InvProductDetailService {
return null;
}
@Resource
InvPreInProductDetailDao invPreInProductDetailDao;
@Resource
InvPreProductDetailDao invPreProductDetailDao;
public InvProductDetailEntity selectLastInBatch(BasicBussinessTypeEntity bussinessTypeEntity, String relId, String batchNo, String invCode, String mainAction) {
if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存
return invPreInProductDetailDao.selectLastInBatch(relId, batchNo, mainAction);
} else if (bussinessTypeEntity.isAdvancePreIn()) { //校验寄售库存
return invPreProductDetailDao.selectLastInBatch(relId, batchNo, mainAction);
} else {
return invProductDetailDao.selectLastInBatch(relId, batchNo, invCode, mainAction);
}
}
public InvProductDetailEntity selectFirstInBatch(BasicBussinessTypeEntity bussinessTypeEntity, String relId, String batchNo, String invCode, String mainAction) {
if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存
return invPreInProductDetailDao.selectFirstInBatch(relId, batchNo, mainAction);
} else if (bussinessTypeEntity.isAdvancePreIn()) { //校验寄售库存
return invPreProductDetailDao.selectFirstInBatch(relId, batchNo, mainAction);
} else {
return invProductDetailDao.selectFirstInBatch(relId, batchNo, invCode, mainAction);
}
}
public Integer selectCountByInBatch(BasicBussinessTypeEntity bussinessTypeEntity, String inBatchNo, String mainAction) {
if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存
return invPreInProductDetailDao.selectCountByInBatch(inBatchNo, mainAction);
} else if (bussinessTypeEntity.isAdvancePreIn()) { //校验寄售库存
return invPreProductDetailDao.selectCountByInBatch(inBatchNo, mainAction);
} else {
return invProductDetailDao.selectCountByInBatch(inBatchNo, mainAction);
}
}
public InvProductDetailEntity selectNextInBatch(BasicBussinessTypeEntity bussinessTypeEntity, String relId, String batchNo, String invCode, String mainAction, String inBatchNo) {
if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存
return invPreInProductDetailDao.selectNextInBatch(relId, batchNo, mainAction, inBatchNo);
} else if (bussinessTypeEntity.isAdvancePreIn()) { //校验寄售库存
return invPreProductDetailDao.selectNextInBatch(relId, batchNo, mainAction, inBatchNo);
} else {
return invProductDetailDao.selectNextInBatch(relId, batchNo, invCode, mainAction, inBatchNo);
}
}
}

@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@ -42,9 +43,14 @@ public class InvProductServiceImpl implements InvProductService {
}
@Override
public InvProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode) {
return invProductDao.selectOne(new QueryWrapper<InvProductEntity>().eq("relIdFk", relId).eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo)
.isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId).eq("deptCode", deptCode).eq("invCode", invCode));
public InvProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode, BigDecimal price) {
return invProductDao.selectOne(new QueryWrapper<InvProductEntity>().eq("relIdFk", relId)
.eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo).isNull(StrUtil.isEmpty(batchNo), "batchNo")
.eq("supId", supId)
.eq("deptCode", deptCode)
.eq("invCode", invCode)
.eq(price != null, "price", price).isNull(price == null, "price")
);
}
@Override

@ -18,8 +18,8 @@ import com.glxp.api.req.basic.DeleteBasicDataRequest;
import com.glxp.api.req.system.DeleteCompanyFileRequest;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.service.basic.*;
import com.glxp.api.service.inout.IoCodeService;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.inout.impl.IoCodeService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@ -1,5 +1,6 @@
package com.glxp.api.service.sync;
import com.glxp.api.service.inout.impl.IoCodeService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
import com.glxp.api.constant.ConstantStatus;

@ -67,7 +67,6 @@ public class VailInvTask implements SchedulingConfigurer {
stringBuffer.append(invPreInStr);
}
@Resource
@ -86,7 +85,8 @@ public class VailInvTask implements SchedulingConfigurer {
if (baseResponse.getCode() == 20000) {
List<InvProductResponse> list = baseResponse.getData().getList();
list.forEach(invProductResponse -> {
InvProductEntity invProductEntity = invProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode());
InvProductEntity invProductEntity = invProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(),
invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode(), invProductResponse.getPrice());
if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) {
buffer.append(invProductResponse.getCpmctymc() + ","
+ invProductResponse.getNameCode() + ","
@ -117,7 +117,8 @@ public class VailInvTask implements SchedulingConfigurer {
if (baseResponse.getCode() == 20000) {
List<InvProductResponse> list = baseResponse.getData().getList();
list.forEach(invProductResponse -> {
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode());
InvPreProductEntity invProductEntity = invPreProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(),
invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode(), invProductResponse.getPrice());
if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) {
buffer.append(invProductResponse.getCpmctymc() + ","
+ invProductResponse.getNameCode() + ","
@ -148,7 +149,8 @@ public class VailInvTask implements SchedulingConfigurer {
if (baseResponse.getCode() == 20000) {
List<InvProductResponse> list = baseResponse.getData().getList();
list.forEach(invProductResponse -> {
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode());
InvPreinProductEntity invProductEntity = invPreinProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(),
invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode(), invProductResponse.getPrice());
if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) {
buffer.append(invProductResponse.getCpmctymc() + ","
+ invProductResponse.getNameCode() + ","

@ -0,0 +1,155 @@
package com.glxp.api.util;
import java.math.BigDecimal;
public class BigDecimalUtil {
/**
* @author MCJ
* @date 2018730
* @description 1( )
*/
// 除法运算默认精度
private static final int DEF_DIV_SCALE = 10;
private BigDecimalUtil() {
}
/**
*
*/
public static double add(double value1, double value2) {
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.add(b2).doubleValue();
}
/**
*
*/
public static double add(String value1, String value2) {
BigDecimal b1 = new BigDecimal(value1);
BigDecimal b2 = new BigDecimal(value2);
return b1.add(b2).doubleValue();
}
/**
*
*/
public static double sub(double value1, double value2) {
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.subtract(b2).doubleValue();
}
/**
*
*/
public static double sub(String value1, String value2) {
BigDecimal b1 = new BigDecimal(value1);
BigDecimal b2 = new BigDecimal(value2);
return b1.subtract(b2).doubleValue();
}
/**
*
*/
public static double mul(double value1, double value2) {
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.multiply(b2).doubleValue();
}
/**
*
*/
public static double mul(String value1, String value2) {
BigDecimal b1 = new BigDecimal(value1);
BigDecimal b2 = new BigDecimal(value2);
return b1.multiply(b2).doubleValue();
}
/**
* 使
*/
public static double div(double value1, double value2) throws IllegalAccessException {
return div(value1, value2, DEF_DIV_SCALE);
}
/**
* 使
*/
public static double div(String value1, String value2) throws IllegalAccessException {
return div(value1, value2, DEF_DIV_SCALE);
}
/**
*
*
* @param scale
*/
public static double div(double value1, double value2, int scale) throws IllegalAccessException {
if (scale < 0) {
throw new IllegalAccessException("精确度不能小于0");
}
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
// return b1.divide(b2, scale).doubleValue();
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
*
*
* @param scale
*/
public static double div(String value1, String value2, int scale) throws IllegalAccessException {
if (scale < 0) {
throw new IllegalAccessException("精确度不能小于0");
}
BigDecimal b1 = new BigDecimal(value1);
BigDecimal b2 = new BigDecimal(value2);
// return b1.divide(b2, scale).doubleValue();
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
*
*
* @param scale
*/
public static double round(double v, int scale) throws IllegalAccessException {
return div(v, 1, scale);
}
/**
*
*
* @param scale
*/
public static double round(String v, int scale) throws IllegalAccessException {
return div(v, "1", scale);
}
/**
*
*/
public static boolean equalTo(BigDecimal b1, BigDecimal b2) {
if (b1 == null && b2 == null) {
return true;
}
if (b1 == null && b2 != null) {
return false;
}
if (b1 != null && b2 == null) {
return true;
}
return 0 == b1.compareTo(b2);
}
}

@ -343,4 +343,83 @@
</where>
group by code
</select>
<select id="selectLastInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_prein_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo desc
limit 1;
</select>
<select id="selectFirstInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_prein_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo
limit 1;
</select>
<select id="selectCountByInBatch" resultType="java.lang.Integer">
select sum(reCount)
from inv_prein_product_detail
<where>
<if test="inBatchNo != null and inBatchNo != ''">
AND inBatchNo = #{inBatchNo}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
</where>
</select>
<select id="selectNextInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_prein_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
and inBatchNo > #{inBatchNo}
LIMIT 1
</where>
</select>
</mapper>

@ -311,4 +311,82 @@
</where>
group by pd.invSpaceCode
</select>
<select id="selectLastInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_pre_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo desc
limit 1;
</select>
<select id="selectFirstInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_pre_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo
limit 1;
</select>
<select id="selectCountByInBatch" resultType="java.lang.Integer">
select sum(reCount)
from inv_pre_product_detail
<where>
<if test="inBatchNo != null and inBatchNo != ''">
AND inBatchNo = #{inBatchNo}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
</where>
</select>
<select id="selectNextInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_pre_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
and inBatchNo > #{inBatchNo}
LIMIT 1
</where>
</select>
</mapper>

@ -26,7 +26,8 @@
auth_warehouse.name invName,
ip.deptCode,
ip.invCode,
as.name spaceName
as.name spaceName,
ip.price
from inv_product ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
@ -85,7 +86,7 @@
</foreach>
</if>
</where>
GROUP BY ip.relIdFk, ip.batchNo, ip.supId
GROUP BY ip.relIdFk, ip.batchNo, ip.supId, ip.price
order by ip.updateTime desc
</select>
@ -148,8 +149,7 @@
</select>
<select id="getMAInvProducts" resultType="com.glxp.api.res.inv.InvProductResponse">
SELECT
ip.id,
SELECT ip.id,
bp.nameCode,
bp.cpmctymc,
bp.ggxh,
@ -161,8 +161,7 @@
basic_corp.NAME supName,
bp.manufactory,
bp.zczbhhzbapzbh
FROM
inv_product_detail ip
FROM inv_product_detail ip
LEFT JOIN basic_udirel bu ON bu.id = ip.relId
LEFT JOIN basic_products bp ON bu.uuid = bp.uuid
LEFT JOIN basic_corp ON ip.supId = basic_corp.erpId
@ -493,6 +492,5 @@
group by ip.relIdFk
having reCount > 0
order by ip.updateTime desc
</select>
</mapper>

@ -124,9 +124,17 @@
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null and batchNo == ''">
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
<if test="price != null">
AND price = #{price}
</if>
<if test="price == null">
AND price is null
</if>
<if test="productionDate != null and productionDate != ''">
AND produceDate = #{productionDate}
</if>
@ -366,7 +374,6 @@
WHERE CODE = #{code}
and invCode = #{invCode}
and (invSpaceCode is null or invSpaceCode = '')
</select>
<select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
@ -400,4 +407,91 @@
GROUP BY CODE,
invSpaceCode
</select>
<select id="selectLastInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo desc
limit 1;
</select>
<select id="selectFirstInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo
limit 1;
</select>
<select id="selectCountByInBatch" resultType="java.lang.Integer">
select sum(reCount)
from inv_product_detail
<where>
<if test="inBatchNo != null and inBatchNo != ''">
AND inBatchNo = #{inBatchNo}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
</where>
</select>
<select id="selectNextInBatch" resultType="com.glxp.api.entity.inv.InvProductDetailEntity">
select *
from inv_product_detail
<where>
<if test="relId != null and relId != ''">
AND relId = #{relId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
and inBatchNo > #{inBatchNo}
LIMIT 1
</where>
</select>
</mapper>

@ -900,3 +900,21 @@ CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'editType', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('auth_user', 'lastUpdatePwdTime', 'datetime', 1);
CALL Pro_Temp_ColumnWork('io_code', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('io_code_temp', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('inv_prein_product', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('inv_product', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('inv_pre_product', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('inv_product_detail', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('inv_prein_product_detail', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('inv_pre_product_detail', 'price', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('io_code', 'inBatchNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_code_temp', 'inBatchNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('inv_product_detail', 'inBatchNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('inv_prein_product_detail', 'inBatchNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('inv_pre_product_detail', 'inBatchNo', 'varchar(255)', 1);
INSERT ignore INTO `sys_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`,
`paramType`, `paramExplain`, `updateTime`)
VALUES (20078, 0, '是否启用价格先进先出策略', 'price_fifo', '1', 1, 0, '01', '2023-10-10 10:10:08');

Loading…
Cancel
Save