入库修改
This commit is contained in:
@@ -39,9 +39,9 @@
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
@@ -79,7 +79,7 @@
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void inStock(ConsInOutStockHeadParam param) {
|
||||
public Map<String, Serializable> inStock(ConsInOutStockHeadParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
Long createUserId = StpKit.USER.getLoginIdAsLong();
|
||||
String createUserName = StpKit.USER.getAccount();
|
||||
@@ -87,7 +87,12 @@
|
||||
List<ConsStockFlow> entityList = BeanUtil.copyToList(param.getBodyList(), ConsStockFlow.class);
|
||||
List<ConsStockFlow> insertList = new ArrayList<>();
|
||||
List<ConsInfo> updateStockList = new ArrayList<>();
|
||||
ArrayList<ConsStockFlow> unInConList = new ArrayList<>();
|
||||
for (ConsStockFlow entity : entityList) {
|
||||
if (entity.getId() == null) {
|
||||
unInConList.add(entity);
|
||||
continue;
|
||||
}
|
||||
BeanUtil.copyProperties(head, entity, CopyOptions.create().ignoreNullValue());
|
||||
entity.setShopId(shopId);
|
||||
entity.setInOutType(InOutTypeEnum.IN.value());
|
||||
@@ -97,7 +102,8 @@
|
||||
Long conId = entity.getConId();
|
||||
ConsInfo consInfo = consInfoMapper.selectOneById(conId);
|
||||
if (consInfo == null) {
|
||||
throw new CzgException(StrUtil.format("耗材{}不存在", entity.getConName()));
|
||||
unInConList.add(entity);
|
||||
continue;
|
||||
}
|
||||
entity.setBeforeNumber(consInfo.getStockNumber());
|
||||
entity.setAfterNumber(NumberUtil.add(entity.getBeforeNumber(), entity.getInOutNumber()));
|
||||
@@ -109,6 +115,11 @@
|
||||
for (ConsInfo consInfo : updateStockList) {
|
||||
consInfoMapper.update(consInfo);
|
||||
}
|
||||
|
||||
return Map.of(
|
||||
"reason", "成功入库" + (entityList.size() - unInConList.size()) + "个耗材, " + unInConList.size() + "个耗材未入库",
|
||||
"unInConList", unInConList
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,18 +311,18 @@
|
||||
}
|
||||
ArrayList<SaleOrderDTO.Item> unInCons = new ArrayList<>();
|
||||
for (SaleOrderDTO.Item item : saleOrderDTO.getItems()) {
|
||||
ConsInfo consInfo = consInfoMap.get(item.getConName());
|
||||
if (consInfo == null) {
|
||||
unInCons.add(item);
|
||||
continue;
|
||||
}
|
||||
bodyList.add(new ConsInOutStockBodyParam()
|
||||
.setConId(consInfo.getId().toString())
|
||||
.setConName(consInfo.getConName())
|
||||
ConsInOutStockBodyParam bodyParam = new ConsInOutStockBodyParam()
|
||||
.setConName(item.getConName())
|
||||
.setPurchasePrice(new BigDecimal(item.getPurchasePrice()))
|
||||
.setUnitName(item.getUnitName())
|
||||
.setSubTotal(new BigDecimal(item.getSubTotal()))
|
||||
.setInOutNumber(new BigDecimal(item.getInOutNumber())));
|
||||
.setInOutNumber(new BigDecimal(item.getInOutNumber()));
|
||||
ConsInfo consInfo = consInfoMap.get(item.getConName());
|
||||
if (consInfo != null) {
|
||||
unInCons.add(item);
|
||||
bodyParam.setConId(consInfo.getId().toString());
|
||||
}
|
||||
bodyList.add(bodyParam);
|
||||
}
|
||||
|
||||
ConsInOutStockHeadParam headParam = new ConsInOutStockHeadParam();
|
||||
|
||||
Reference in New Issue
Block a user