将单据中明细的写入数据库,优化成批量写入
This commit is contained in:
@@ -18,6 +18,9 @@ import java.util.List;
|
||||
* @Date: 2019/1/24 16:59
|
||||
*/
|
||||
public interface DepotItemMapperEx {
|
||||
|
||||
int batchInsert(List<DepotItem> depotItemList);
|
||||
|
||||
List<DepotItem> selectByConditionDepotItem(
|
||||
@Param("name") String name,
|
||||
@Param("type") Integer type,
|
||||
|
||||
@@ -394,6 +394,7 @@ public class DepotItemService {
|
||||
checkAssembleWithMaterialType(rowArr, depotHead.getSubType());
|
||||
//校验多行明细当中是否存在重复的序列号
|
||||
checkSerialNumberRepeat(rowArr);
|
||||
List<DepotItem> depotItemList = new ArrayList<>();
|
||||
for (int i = 0; i < rowArr.size(); i++) {
|
||||
DepotItem depotItem = new DepotItem();
|
||||
JSONObject rowObj = JSONObject.parseObject(rowArr.getString(i));
|
||||
@@ -677,13 +678,17 @@ public class DepotItemService {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.insertDepotItemWithObj(depotItem);
|
||||
depotItemList.add(depotItem);
|
||||
}
|
||||
//批量写入单据明细数据
|
||||
depotItemMapperEx.batchInsert(depotItemList);
|
||||
for (DepotItem depotItem : depotItemList) {
|
||||
//更新当前库存
|
||||
updateCurrentStock(depotItem);
|
||||
//更新当前成本价
|
||||
updateCurrentUnitPrice(depotItem);
|
||||
//更新商品的价格
|
||||
updateMaterialExtendPrice(materialExtend.getId(), depotHead.getSubType(), depotHead.getBillType(), rowObj);
|
||||
updateMaterialExtendPrice(depotItem.getMaterialExtendId(), depotHead.getSubType(), depotHead.getBillType(), depotItem.getUnitPrice());
|
||||
}
|
||||
//如果关联单据号非空则更新订单的状态,单据类型:采购入库单、销售出库单、盘点复盘单、其它入库单、其它出库单
|
||||
if(BusinessConstants.SUB_TYPE_PURCHASE.equals(depotHead.getSubType())
|
||||
@@ -915,13 +920,12 @@ public class DepotItemService {
|
||||
* 更新商品的价格
|
||||
* @param meId
|
||||
* @param subType
|
||||
* @param rowObj
|
||||
* @param unitPrice
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void updateMaterialExtendPrice(Long meId, String subType, String billType, JSONObject rowObj) throws Exception {
|
||||
public void updateMaterialExtendPrice(Long meId, String subType, String billType, BigDecimal unitPrice) throws Exception {
|
||||
if(systemConfigService.getUpdateUnitPriceFlag()) {
|
||||
if (StringUtil.isExist(rowObj.get("unitPrice"))) {
|
||||
BigDecimal unitPrice = rowObj.getBigDecimal("unitPrice");
|
||||
if (unitPrice!=null) {
|
||||
MaterialExtend materialExtend = new MaterialExtend();
|
||||
materialExtend.setId(meId);
|
||||
if(BusinessConstants.SUB_TYPE_PURCHASE.equals(subType)) {
|
||||
|
||||
Reference in New Issue
Block a user