优化商品库存报表
This commit is contained in:
@@ -367,7 +367,7 @@ public class MaterialController {
|
||||
src = workbook.getSheet(0);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
res = materialService.importExcel(src);
|
||||
res = materialService.importExcel(src, request);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.jsh.erp.service.depot.DepotService;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
|
||||
import com.jsh.erp.service.redis.RedisService;
|
||||
import com.jsh.erp.service.unit.UnitService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
@@ -67,6 +68,8 @@ public class MaterialService {
|
||||
private DepotService depotService;
|
||||
@Resource
|
||||
private MaterialExtendService materialExtendService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
public Material getMaterial(long id)throws Exception {
|
||||
Material result=null;
|
||||
@@ -182,7 +185,8 @@ public class MaterialService {
|
||||
String number = jsonObj.getString("initStock");
|
||||
Long depotId = jsonObj.getLong("id");
|
||||
if(StringUtil.isNotEmpty(number) && Double.valueOf(number)>0) {
|
||||
insertStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
||||
insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
||||
insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,13 +220,16 @@ public class MaterialService {
|
||||
if (jsonObj.get("id") != null && jsonObj.get("initStock") != null) {
|
||||
String number = jsonObj.getString("initStock");
|
||||
Long depotId = jsonObj.getLong("id");
|
||||
//先清除再插入
|
||||
//初始库存-先清除再插入
|
||||
MaterialInitialStockExample example = new MaterialInitialStockExample();
|
||||
example.createCriteria().andMaterialIdEqualTo(material.getId()).andDepotIdEqualTo(depotId);
|
||||
materialInitialStockMapper.deleteByExample(example);
|
||||
if (StringUtil.isNotEmpty(number) && Double.valueOf(number) > 0) {
|
||||
insertStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx(number));
|
||||
insertInitialStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx(number));
|
||||
}
|
||||
//更新当前库存
|
||||
Long tenantId = redisService.getTenantId(request);
|
||||
depotItemService.updateCurrentStockFun(material.getId(), depotId, tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,7 +442,7 @@ public class MaterialService {
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public BaseResponseInfo importExcel(Sheet src) throws Exception {
|
||||
public BaseResponseInfo importExcel(Sheet src, HttpServletRequest request) throws Exception {
|
||||
List<Depot> depotList= depotService.getDepot();
|
||||
int depotCount = depotList.size();
|
||||
List<MaterialWithInitStock> mList = new ArrayList<>();
|
||||
@@ -577,13 +584,16 @@ public class MaterialService {
|
||||
Long depotId = null;
|
||||
for(Depot depot: depotList){
|
||||
BigDecimal stock = stockMap.get(depot.getId());
|
||||
//先清除再插入
|
||||
//初始库存-先清除再插入
|
||||
MaterialInitialStockExample example = new MaterialInitialStockExample();
|
||||
example.createCriteria().andMaterialIdEqualTo(mId).andDepotIdEqualTo(depot.getId());
|
||||
materialInitialStockMapper.deleteByExample(example);
|
||||
if(stock!=null && stock.compareTo(BigDecimal.ZERO)!=0) {
|
||||
depotId = depot.getId();
|
||||
insertStockByMaterialAndDepot(depotId, mId, stock);
|
||||
insertInitialStockByMaterialAndDepot(depotId, mId, stock);
|
||||
//更新当前库存
|
||||
Long tenantId = redisService.getTenantId(request);
|
||||
depotItemService.updateCurrentStockFun(mId, depotId, tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -643,7 +653,7 @@ public class MaterialService {
|
||||
* @param stock
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void insertStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock){
|
||||
public void insertInitialStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock){
|
||||
MaterialInitialStock materialInitialStock = new MaterialInitialStock();
|
||||
materialInitialStock.setDepotId(depotId);
|
||||
materialInitialStock.setMaterialId(mId);
|
||||
@@ -651,6 +661,21 @@ public class MaterialService {
|
||||
materialInitialStockMapper.insertSelective(materialInitialStock); //存入初始库存
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入当前库存
|
||||
* @param depotId
|
||||
* @param mId
|
||||
* @param stock
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void insertCurrentStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock){
|
||||
MaterialCurrentStock materialCurrentStock = new MaterialCurrentStock();
|
||||
materialCurrentStock.setDepotId(depotId);
|
||||
materialCurrentStock.setMaterialId(mId);
|
||||
materialCurrentStock.setCurrentNumber(stock);
|
||||
materialCurrentStockMapper.insertSelective(materialCurrentStock); //存入初始库存
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> getMaterialEnableSerialNumberList(String q, Integer offset, Integer rows)throws Exception {
|
||||
List<MaterialVo4Unit> list =null;
|
||||
try{
|
||||
|
||||
Reference in New Issue
Block a user