将单据中明细的写入数据库,优化成批量写入
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)) {
|
||||
|
||||
@@ -110,6 +110,23 @@
|
||||
<result column="oper_number" jdbcType="VARCHAR" property="operNumber" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
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
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{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})
|
||||
</foreach >
|
||||
</insert>
|
||||
|
||||
<select id="selectByConditionDepotItem" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap">
|
||||
select *
|
||||
FROM jsh_depot_item
|
||||
|
||||
Reference in New Issue
Block a user