解决给商品批量修正库存的bug
This commit is contained in:
@@ -1049,9 +1049,10 @@ public class DepotItemService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public void updateCurrentStock(DepotItem depotItem) throws Exception {
|
public void updateCurrentStock(DepotItem depotItem) throws Exception {
|
||||||
updateCurrentStockFun(depotItem.getMaterialId(), depotItem.getDepotId());
|
BigDecimal currentUnitPrice = materialCurrentStockMapperEx.getCurrentUnitPriceByMId(depotItem.getMaterialId());
|
||||||
|
updateCurrentStockFun(depotItem.getMaterialId(), depotItem.getDepotId(), currentUnitPrice);
|
||||||
if(depotItem.getAnotherDepotId()!=null){
|
if(depotItem.getAnotherDepotId()!=null){
|
||||||
updateCurrentStockFun(depotItem.getMaterialId(), depotItem.getAnotherDepotId());
|
updateCurrentStockFun(depotItem.getMaterialId(), depotItem.getAnotherDepotId(), currentUnitPrice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,7 +1137,7 @@ public class DepotItemService {
|
|||||||
* @param mId
|
* @param mId
|
||||||
* @param dId
|
* @param dId
|
||||||
*/
|
*/
|
||||||
public void updateCurrentStockFun(Long mId, Long dId) throws Exception {
|
public void updateCurrentStockFun(Long mId, Long dId, BigDecimal currentUnitPrice) throws Exception {
|
||||||
if(mId!=null && dId!=null) {
|
if(mId!=null && dId!=null) {
|
||||||
MaterialCurrentStockExample example = new MaterialCurrentStockExample();
|
MaterialCurrentStockExample example = new MaterialCurrentStockExample();
|
||||||
example.createCriteria().andMaterialIdEqualTo(mId).andDepotIdEqualTo(dId)
|
example.createCriteria().andMaterialIdEqualTo(mId).andDepotIdEqualTo(dId)
|
||||||
@@ -1146,6 +1147,7 @@ public class DepotItemService {
|
|||||||
materialCurrentStock.setMaterialId(mId);
|
materialCurrentStock.setMaterialId(mId);
|
||||||
materialCurrentStock.setDepotId(dId);
|
materialCurrentStock.setDepotId(dId);
|
||||||
materialCurrentStock.setCurrentNumber(getStockByParam(dId,mId,null,null));
|
materialCurrentStock.setCurrentNumber(getStockByParam(dId,mId,null,null));
|
||||||
|
materialCurrentStock.setCurrentUnitPrice(currentUnitPrice);
|
||||||
if(list!=null && list.size()>0) {
|
if(list!=null && list.size()>0) {
|
||||||
Long mcsId = list.get(0).getId();
|
Long mcsId = list.get(0).getId();
|
||||||
materialCurrentStock.setId(mcsId);
|
materialCurrentStock.setId(mcsId);
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ public class MaterialService {
|
|||||||
materialMapperEx.setExpiryNumToNull(material.getId());
|
materialMapperEx.setExpiryNumToNull(material.getId());
|
||||||
}
|
}
|
||||||
materialExtendService.saveDetials(obj, obj.getString("sortList"),material.getId(), "update");
|
materialExtendService.saveDetials(obj, obj.getString("sortList"),material.getId(), "update");
|
||||||
|
BigDecimal currentUnitPrice = materialCurrentStockMapperEx.getCurrentUnitPriceByMId(material.getId());
|
||||||
if(obj.get("stock")!=null) {
|
if(obj.get("stock")!=null) {
|
||||||
JSONArray stockArr = obj.getJSONArray("stock");
|
JSONArray stockArr = obj.getJSONArray("stock");
|
||||||
for (int i = 0; i < stockArr.size(); i++) {
|
for (int i = 0; i < stockArr.size(); i++) {
|
||||||
@@ -232,7 +233,7 @@ public class MaterialService {
|
|||||||
insertInitialStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx(number), lowSafeStock, highSafeStock);
|
insertInitialStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx(number), lowSafeStock, highSafeStock);
|
||||||
}
|
}
|
||||||
//更新当前库存
|
//更新当前库存
|
||||||
depotItemService.updateCurrentStockFun(material.getId(), depotId);
|
depotItemService.updateCurrentStockFun(material.getId(), depotId, currentUnitPrice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1432,8 +1433,9 @@ public class MaterialService {
|
|||||||
List<Long> idList = StringUtil.strToLongList(ids);
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
List<Depot> depotList = depotService.getAllList();
|
List<Depot> depotList = depotService.getAllList();
|
||||||
for(Long mId: idList) {
|
for(Long mId: idList) {
|
||||||
|
BigDecimal currentUnitPrice = materialCurrentStockMapperEx.getCurrentUnitPriceByMId(mId);
|
||||||
for(Depot depot: depotList) {
|
for(Depot depot: depotList) {
|
||||||
depotItemService.updateCurrentStockFun(mId, depot.getId());
|
depotItemService.updateCurrentStockFun(mId, depot.getId(), currentUnitPrice);
|
||||||
res = 1;
|
res = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,10 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="getCurrentUnitPriceByMId" resultType="java.math.BigDecimal">
|
<select id="getCurrentUnitPriceByMId" resultType="java.math.BigDecimal">
|
||||||
select ifnull(mcs.current_unit_price,0) as current_unit_price from jsh_material_current_stock mcs where mcs.material_id=#{materialId} limit 1
|
select mcs.current_unit_price as current_unit_price from jsh_material_current_stock mcs
|
||||||
|
where mcs.material_id=#{materialId}
|
||||||
|
and mcs.current_unit_price is not null
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="batchDeleteByDepots">
|
<update id="batchDeleteByDepots">
|
||||||
|
|||||||
Reference in New Issue
Block a user