|
@@ -1,11 +1,14 @@
|
|
|
package org.jeecg.modules.storeCode.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
+import org.jeecg.modules.saleCode.entity.SaleDelivery;
|
|
|
import org.jeecg.modules.saleCode.entity.SaleDeliveryDetails;
|
|
|
import org.jeecg.modules.saleCode.mapper.SaleDeliveryDetailsMapper;
|
|
|
+import org.jeecg.modules.saleCode.mapper.SaleDeliveryMapper;
|
|
|
import org.jeecg.modules.storeCode.entity.StoreOnhand;
|
|
|
import org.jeecg.modules.storeCode.entity.StoreSaleOut;
|
|
|
import org.jeecg.modules.storeCode.entity.StoreSaleOutShip;
|
|
@@ -47,6 +50,9 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
@Autowired
|
|
|
private SaleDeliveryDetailsMapper saleDeliveryDetailsMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SaleDeliveryMapper saleDeliveryMapper;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void saveMain(StoreSaleOut storeSaleOut, List<StoreSaleOutShip> storeSaleOutShipList, List<StoreSaleOutDetails> storeSaleOutDetailsList) {
|
|
@@ -67,14 +73,14 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
if (storeSaleOutDetailsList != null && storeSaleOutDetailsList.size() > 0) {
|
|
|
for (StoreSaleOutDetails entity : storeSaleOutDetailsList) {
|
|
|
|
|
|
- BigDecimal stockOutQuantity = entity.getStockOutQuantity()==null?BigDecimal.ZERO:entity.getStockOutQuantity();
|
|
|
+ BigDecimal stockOutQuantity = entity.getStockOutQuantity() == null ? BigDecimal.ZERO : entity.getStockOutQuantity();
|
|
|
|
|
|
String productId = entity.getProductId();
|
|
|
String setBatchId = entity.getBatchId();
|
|
|
// 项目、仓库、货位、产品编码
|
|
|
- if(StringUtils.isNotBlank(warehouse) && StringUtils.isNotBlank(goodsAllocation)
|
|
|
+ if (StringUtils.isNotBlank(warehouse) && StringUtils.isNotBlank(goodsAllocation)
|
|
|
&& StringUtils.isNotBlank(project) && StringUtils.isNotBlank(productId)
|
|
|
- && StringUtils.isBlank(setBatchId)){
|
|
|
+ && StringUtils.isBlank(setBatchId)) {
|
|
|
|
|
|
QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("project", project);
|
|
@@ -108,8 +114,8 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
arrivalQuantity = arrivalQuantity.add(stockOutQuantity);
|
|
|
saleDeliveryDetails.setDeliveryQuantity(arrivalQuantity);
|
|
|
|
|
|
- if(arrivalQuantity.compareTo(saleDeliveryDetails.getQuantity()) > 0){
|
|
|
- throw new JeecgBootException(entity.getProductCode()+entity.getEnglishName()+"发货单数量不足,请修改出库数量(已出库数量:"+saleDeliveryDetails.getDeliveryQuantity()+")");
|
|
|
+ if (arrivalQuantity.compareTo(saleDeliveryDetails.getQuantity()) > 0) {
|
|
|
+ throw new JeecgBootException(entity.getProductCode() + entity.getEnglishName() + "发货单数量不足,请修改出库数量(已出库数量:" + saleDeliveryDetails.getDeliveryQuantity() + ")");
|
|
|
}
|
|
|
|
|
|
saleDeliveryDetailsMapper.updateById(saleDeliveryDetails);
|
|
@@ -137,7 +143,7 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
String sourceId = entity.getSourceId();
|
|
|
if (StringUtils.isNotBlank(sourceId)) {
|
|
|
|
|
|
- BigDecimal stockOutQuantity = entity.getStockOutQuantity()==null?BigDecimal.ZERO:entity.getStockOutQuantity();
|
|
|
+ BigDecimal stockOutQuantity = entity.getStockOutQuantity() == null ? BigDecimal.ZERO : entity.getStockOutQuantity();
|
|
|
|
|
|
SaleDeliveryDetails saleDeliveryDetails = saleDeliveryDetailsMapper.selectById(sourceId);
|
|
|
|
|
@@ -183,15 +189,15 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
if (storeSaleOutDetailsList != null && storeSaleOutDetailsList.size() > 0) {
|
|
|
for (StoreSaleOutDetails entity : storeSaleOutDetailsList) {
|
|
|
|
|
|
- BigDecimal stockOutQuantity = entity.getStockOutQuantity()==null?BigDecimal.ZERO:entity.getStockOutQuantity();
|
|
|
+ BigDecimal stockOutQuantity = entity.getStockOutQuantity() == null ? BigDecimal.ZERO : entity.getStockOutQuantity();
|
|
|
|
|
|
String productId = entity.getProductId();
|
|
|
String setBatchId = entity.getBatchId();
|
|
|
// 项目、仓库、货位、产品编码
|
|
|
|
|
|
- if(StringUtils.isNotBlank(warehouse) && StringUtils.isNotBlank(goodsAllocation)
|
|
|
+ if (StringUtils.isNotBlank(warehouse) && StringUtils.isNotBlank(goodsAllocation)
|
|
|
&& StringUtils.isNotBlank(project) && StringUtils.isNotBlank(productId)
|
|
|
- && StringUtils.isBlank(setBatchId)){
|
|
|
+ && StringUtils.isBlank(setBatchId)) {
|
|
|
|
|
|
QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("project", project);
|
|
@@ -226,8 +232,8 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
arrivalQuantity = arrivalQuantity.add(stockOutQuantity);
|
|
|
saleDeliveryDetails.setDeliveryQuantity(arrivalQuantity);
|
|
|
|
|
|
- if(arrivalQuantity.compareTo(saleDeliveryDetails.getQuantity()) > 0){
|
|
|
- throw new JeecgBootException(entity.getProductCode()+entity.getEnglishName()+"发货单数量不足,请修改出库数量(已出库数量:"+saleDeliveryDetails.getDeliveryQuantity()+")");
|
|
|
+ if (arrivalQuantity.compareTo(saleDeliveryDetails.getQuantity()) > 0) {
|
|
|
+ throw new JeecgBootException(entity.getProductCode() + entity.getEnglishName() + "发货单数量不足,请修改出库数量(已出库数量:" + saleDeliveryDetails.getDeliveryQuantity() + ")");
|
|
|
}
|
|
|
saleDeliveryDetailsMapper.updateById(saleDeliveryDetails);
|
|
|
}
|
|
@@ -254,7 +260,7 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
String sourceId = entity.getSourceId();
|
|
|
if (StringUtils.isNotBlank(sourceId)) {
|
|
|
|
|
|
- BigDecimal stockOutQuantity = entity.getStockOutQuantity()==null?BigDecimal.ZERO:entity.getStockOutQuantity();
|
|
|
+ BigDecimal stockOutQuantity = entity.getStockOutQuantity() == null ? BigDecimal.ZERO : entity.getStockOutQuantity();
|
|
|
|
|
|
SaleDeliveryDetails saleDeliveryDetails = saleDeliveryDetailsMapper.selectById(sourceId);
|
|
|
|
|
@@ -296,7 +302,7 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
String sourceId = entity.getSourceId();
|
|
|
if (StringUtils.isNotBlank(sourceId)) {
|
|
|
|
|
|
- BigDecimal stockOutQuantity = entity.getStockOutQuantity()==null?BigDecimal.ZERO:entity.getStockOutQuantity();
|
|
|
+ BigDecimal stockOutQuantity = entity.getStockOutQuantity() == null ? BigDecimal.ZERO : entity.getStockOutQuantity();
|
|
|
|
|
|
SaleDeliveryDetails saleDeliveryDetails = saleDeliveryDetailsMapper.selectById(sourceId);
|
|
|
|
|
@@ -347,6 +353,42 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
QueryWrapper<StoreSaleOut> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.in("id", Arrays.asList(ids.split(",")));
|
|
|
|
|
|
+ List<StoreSaleOut> list = this.list(queryWrapper);
|
|
|
+ if (list.size() == 0) {
|
|
|
+ return Result.error("数据为空!");
|
|
|
+ }
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (StoreSaleOut o : list) {
|
|
|
+ // 1-已提交,0-未提交
|
|
|
+ String submit = o.getSubmit();
|
|
|
+ String code = o.getBillCode();
|
|
|
+ String applyInvoice = o.getApplyInvoice();//是否开票申请(1是 0否)
|
|
|
+ String sourceCode = o.getSourceCode();
|
|
|
+
|
|
|
+ if (submit == null || submit == "" || submit.equals("0")) {
|
|
|
+ sb.append("单据编码" + code).append("还未提交,请勿此操作;");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(applyInvoice) && applyInvoice.equals("1")) {
|
|
|
+ sb.append("单据编码" + code).append("已申请开票,请勿重复申请;");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ codeList.add(sourceCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(sb.toString())) {
|
|
|
+
|
|
|
+ return Result.error(sb.toString());
|
|
|
+ }
|
|
|
+ if(codeList.size() > 0){
|
|
|
+
|
|
|
+ UpdateWrapper<SaleDelivery> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("bill_code", codeList); // 设置主键
|
|
|
+ updateWrapper.set("apply_Invoice", "1"); // 设置 invoice_code 为 1
|
|
|
+ saleDeliveryMapper.update(new SaleDelivery(), updateWrapper); // 调用更新
|
|
|
+ }
|
|
|
+
|
|
|
StoreSaleOut ent = new StoreSaleOut();
|
|
|
ent.setApplyInvoice("1");
|
|
|
this.update(ent, queryWrapper);
|
|
@@ -422,16 +464,30 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
|
for (StoreSaleOut o : list) {
|
|
|
|
|
|
//提交(1-是 ,0-否)
|
|
|
String submit = o.getSubmit();
|
|
|
String code = o.getBillCode();
|
|
|
+ String sourceCode = o.getSourceCode();
|
|
|
|
|
|
if (submit == null || submit == "" || submit.equals("0")) {
|
|
|
sb.append("单号" + code).append("已取消提交,请勿再次取消提交;");
|
|
|
continue;
|
|
|
}
|
|
|
+ codeList.add(sourceCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(codeList.size() > 0){
|
|
|
+
|
|
|
+ QueryWrapper<SaleDelivery> queryWrapperSaleDelivery = new QueryWrapper<>();
|
|
|
+ queryWrapperSaleDelivery.in("bill_code", codeList);
|
|
|
+ queryWrapperSaleDelivery.isNotNull("invoice_code");
|
|
|
+ List<SaleDelivery> listSaleDelivery = saleDeliveryMapper.selectList(queryWrapperSaleDelivery);
|
|
|
+ if (listSaleDelivery.size() > 0) {
|
|
|
+ sb.append("含有已开发票数据,无法取消提交");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(sb.toString())) {
|