1.完善建垛功能

master
x_z 3 years ago
parent 8eecda5a2d
commit f56c14c4b6

@ -7,10 +7,12 @@ import com.glxp.udi.admin.common.res.BaseResponse;
import com.glxp.udi.admin.common.util.ResultVOUtils;
import com.glxp.udi.admin.entity.product.StackCode;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.product.AddStackCodeRequest;
import com.glxp.udi.admin.req.product.FilterStackCodeRequest;
import com.glxp.udi.admin.res.PageSimpleResponse;
import com.glxp.udi.admin.service.product.StackCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -61,4 +63,20 @@ public class StackCodeController {
return ResultVOUtils.success("删除成功");
}
/**
*
*
* @param addStackCodeRequest
* @param bindingResult
* @return
*/
@PostMapping("/udims/stack/code/addCode")
public BaseResponse addStackCode(@RequestBody AddStackCodeRequest addStackCodeRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
StackCode stackCode = stackCodeService.addCode(addStackCodeRequest);
return ResultVOUtils.success(stackCode);
}
}

@ -51,11 +51,11 @@ public class StackOrderController {
@AuthRuleAnnotation("")
@PostMapping("/udims/stack/order/update")
public BaseResponse updateStack(@RequestBody StackOrder stackOrderEntity, BindingResult bindingResult) {
public BaseResponse updateStack(@RequestBody StackUploadRequest stackUploadRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
stackOrderService.updateOrder(stackOrderEntity);
stackOrderService.updateOrder(stackUploadRequest);
return ResultVOUtils.success("更新成功");
}

@ -0,0 +1,27 @@
package com.glxp.udi.admin.req.product;
import lombok.Data;
/**
*
*/
@Data
public class AddStackCodeRequest {
/**
*
*/
private String orderId;
/**
*
*/
private String code;
/**
* ID
*/
private String customerId;
}

@ -6,8 +6,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.dao.product.StackCodeDao;
import com.glxp.udi.admin.dao.product.StackOrderDao;
import com.glxp.udi.admin.entity.product.StackCode;
import com.glxp.udi.admin.entity.product.StackOrder;
import com.glxp.udi.admin.req.product.AddStackCodeRequest;
import com.glxp.udi.admin.req.product.FilterStackCodeRequest;
import com.glxp.udi.admin.util.IdUtil;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
@ -16,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
@ -27,6 +32,10 @@ public class StackCodeService {
private SqlSessionFactory sqlSessionFactory;
@Resource
private StackCodeDao stackCodeDao;
@Resource
private StackOrderDao stackOrderDao;
@Resource
private IdUtil idUtil;
public void batchInsert(List<StackCode> stackCodeEntityList) {
@ -38,8 +47,6 @@ public class StackCodeService {
});
batchSession.commit();
}
}
/**
@ -64,4 +71,33 @@ public class StackCodeService {
public void deleteById(String id) {
stackCodeDao.deleteById(id);
}
/**
*
*
* @param addStackCodeRequest
* @return
*/
public StackCode addCode(AddStackCodeRequest addStackCodeRequest) {
StackCode stackCode = new StackCode();
stackCode.setCode(addStackCodeRequest.getCode());
if (StrUtil.isBlank(addStackCodeRequest.getOrderId())) {
//垛号为空,此条码为这个垛的第一个条码数据,先生垛号和垛数据,再添加条码
String stackId = idUtil.getStackId(addStackCodeRequest.getCustomerId());
stackCode.setOrderIdFk(stackId);
//创建垛数据
StackOrder stackOrder = new StackOrder();
//垛码
stackOrder.setOrderId(stackId);
stackOrder.setCreateTime(new Date());
stackOrder.setExportStatus(0);
stackOrder.setCustomerId(addStackCodeRequest.getCustomerId());
stackOrderDao.insert(stackOrder);
} else {
stackCode.setOrderIdFk(addStackCodeRequest.getOrderId());
}
int id = stackCodeDao.insert(stackCode);
stackCode.setId(id);
return stackCode;
}
}

@ -1,18 +1,27 @@
package com.glxp.udi.admin.service.product;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glxp.udi.admin.dao.product.StackCodeDao;
import com.glxp.udi.admin.dao.product.StackOrderDao;
import com.glxp.udi.admin.entity.product.StackCode;
import com.glxp.udi.admin.entity.product.StackOrder;
import com.glxp.udi.admin.req.product.StackOrderFilterRequest;
import com.glxp.udi.admin.req.product.StackUploadRequest;
import com.glxp.udi.admin.util.IdUtil;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.TransactionIsolationLevel;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
@ -24,6 +33,8 @@ public class StackOrderService {
private IdUtil idUtil;
@Resource
private StackCodeDao stackCodeDao;
@Resource
private SqlSessionFactory sqlSessionFactory;
public IPage<StackOrder> filterList(StackOrderFilterRequest stackOrderFilterRequest) {
@ -40,8 +51,25 @@ public class StackOrderService {
}
public void updateOrder(StackOrder stackOrderEntity) {
stackOrderDao.updateById(stackOrderEntity);
public void updateOrder(StackUploadRequest stackUploadRequest) {
//更新垛数据
stackOrderDao.updateById(stackUploadRequest.getStackOrderEntity());
//更新码详情
if (CollUtil.isNotEmpty(stackUploadRequest.getStackCodeEntityList())) {
stackUploadRequest.getStackCodeEntityList().forEach(stackCode -> {stackCode.setOrderIdFk(stackUploadRequest.getStackOrderEntity().getOrderId());});
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
StackCodeDao mapper = batchSession.getMapper(StackCodeDao.class);
List<StackCode> stackCodeEntityList = stackUploadRequest.getStackCodeEntityList();
for (StackCode stackCode : stackCodeEntityList) {
if (null != stackCode.getId()) {
mapper.updateById(stackCode);
} else {
mapper.insert(stackCode);
}
}
batchSession.commit();
batchSession.close();
}
}
public boolean isExit(String orderId) {
@ -51,6 +79,9 @@ public class StackOrderService {
public String insertOrder(StackOrder stackOrderEntity) {
String stackId = idUtil.getStackId(stackOrderEntity.getCustomerId());
stackOrderEntity.setOrderId(stackId);
if (null == stackOrderEntity.getCreateTime()) {
stackOrderEntity.setCreateTime(new Date());
}
stackOrderDao.insert(stackOrderEntity);
return stackId;
}

Loading…
Cancel
Save