diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java index 39f3d402..68f0d3bf 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java @@ -18,6 +18,9 @@ import java.util.List; * @Date: 2019/1/24 16:59 */ public interface DepotItemMapperEx { + + int batchInsert(List depotItemList); + List selectByConditionDepotItem( @Param("name") String name, @Param("type") Integer type, diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/DepotItemService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/DepotItemService.java index d39611bf..ac221cc1 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/DepotItemService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/DepotItemService.java @@ -394,6 +394,7 @@ public class DepotItemService { checkAssembleWithMaterialType(rowArr, depotHead.getSubType()); //校验多行明细当中是否存在重复的序列号 checkSerialNumberRepeat(rowArr); + List 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)) { diff --git a/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml index c2add95c..623c8260 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml @@ -110,6 +110,23 @@ + + insert into jsh_depot_item (header_id, material_id, material_extend_id, material_unit, sku, oper_number, + basic_number, unit_price, purchase_unit_price, tax_unit_price, all_price, remark, depot_id, another_depot_id, + tax_rate, tax_money, tax_last_money, material_type, sn_list, batch_number, expiration_date, link_id) + values + + (#{item.headerId,jdbcType=BIGINT}, #{item.materialId,jdbcType=BIGINT}, + #{item.materialExtendId,jdbcType=BIGINT}, #{item.materialUnit,jdbcType=VARCHAR}, #{item.sku,jdbcType=VARCHAR}, + #{item.operNumber,jdbcType=DECIMAL}, #{item.basicNumber,jdbcType=DECIMAL}, #{item.unitPrice,jdbcType=DECIMAL}, + #{item.purchaseUnitPrice,jdbcType=DECIMAL}, #{item.taxUnitPrice,jdbcType=DECIMAL}, #{item.allPrice,jdbcType=DECIMAL}, + #{item.remark,jdbcType=VARCHAR}, #{item.depotId,jdbcType=BIGINT}, #{item.anotherDepotId,jdbcType=BIGINT}, + #{item.taxRate,jdbcType=DECIMAL}, #{item.taxMoney,jdbcType=DECIMAL}, #{item.taxLastMoney,jdbcType=DECIMAL}, + #{item.materialType,jdbcType=VARCHAR}, #{item.snList,jdbcType=VARCHAR}, #{item.batchNumber,jdbcType=VARCHAR}, + #{item.expirationDate,jdbcType=TIMESTAMP}, #{item.linkId,jdbcType=BIGINT}) + + +