parent
4dc36652d2
commit
a9ac95d20a
3 changed files with 737 additions and 737 deletions
@ -1,200 +1,200 @@ |
||||
package org.springblade.wms.service.impl; |
||||
|
||||
import cn.hutool.core.util.NumberUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import jakarta.annotation.Resource; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.wms.excel.StGoodsExcel; |
||||
import org.springblade.wms.mapper.StGoodsClassMapper; |
||||
import org.springblade.wms.mapper.StGoodsMapper; |
||||
import org.springblade.wms.pojo.dto.StPdmPartDTO; |
||||
import org.springblade.wms.pojo.entity.StGoods; |
||||
import org.springblade.wms.pojo.entity.StGoodsExt; |
||||
import org.springblade.wms.pojo.vo.StGoodsVO; |
||||
import org.springblade.wms.service.IStGoodsExtService; |
||||
import org.springblade.wms.service.IStGoodsService; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @version 1.0 |
||||
* @program: jonhon-mes-svr |
||||
* @ClassName StGoodsServiceImpl |
||||
* @description: |
||||
* @autor: WuSiYu |
||||
* @create 2025-12-12 14:21 |
||||
**/ |
||||
|
||||
@Service |
||||
@Slf4j |
||||
public class StGoodsServiceImpl extends BaseServiceImpl<StGoodsMapper, StGoods> implements IStGoodsService { |
||||
@Resource |
||||
private StHttpRequestService stHttpRequestService; |
||||
@Resource |
||||
private IStGoodsExtService stGoodsExtService; |
||||
|
||||
@Override |
||||
public IPage<StGoodsVO> selectStGoodsPage(IPage<StGoodsVO> page, StGoodsVO stGoods) { |
||||
return page.setRecords(baseMapper.selectStGoodsPage(page, stGoods)); |
||||
} |
||||
|
||||
@Override |
||||
public IPage<StGoodsVO> selectFindAllGoodsPage(IPage<StGoodsVO> page, StGoodsVO stGoods) { |
||||
return page.setRecords(baseMapper.selectFindAllGoodsPage(page, stGoods)); |
||||
} |
||||
|
||||
@Override |
||||
public void saveGoods(String goodsCode) throws Exception { |
||||
StGoods stGoods = baseMapper.queryByCode(goodsCode); |
||||
if (stGoods != null) { |
||||
throw new Exception("该物料已存在!"); |
||||
} else { |
||||
List<String> prtnoList = new ArrayList<>(); |
||||
prtnoList.add(goodsCode); |
||||
// saveGoodsInfo(prtnoList);
|
||||
|
||||
} |
||||
} |
||||
|
||||
/*public void saveGoodsInfo(List<String> prtnoList) throws Exception { |
||||
StGoods goods = null; |
||||
//查询物料信息
|
||||
List<StPdmPartDTO> pdmPartInfo = stHttpRequestService.getPdmPartInfo(prtnoList); |
||||
log.debug("pdmPartInfo:{}", pdmPartInfo); |
||||
|
||||
if (pdmPartInfo != null) { |
||||
for (StPdmPartDTO dto : pdmPartInfo) { |
||||
//保存物料信息
|
||||
goods = this.queryByCodeAndVersion(dto.getPrtno(), dto.getReleaseNo()); |
||||
if (goods == null) { |
||||
goods = new StGoods(); |
||||
// goods.setDept();
|
||||
goods.setDrawingNo(dto.getDrwpartno()); |
||||
goods.setGoodsCode(dto.getPrtno()); |
||||
goods.setGoodsName(dto.getPrtdesc()); |
||||
goods.setDensity(dto.getDensity()); |
||||
goods.setPrtType(dto.getPrtType()); |
||||
goods.setSourceByStr(dto.getSource()); |
||||
goods.setSpecifications(dto.getMtlspcf()); |
||||
goods.setUnitName(dto.getPrtum()); |
||||
goods.setCavityNo(dto.getCavityNo()); |
||||
goods.setProductCategory(dto.getProductCategory()); |
||||
goods.setEcnNo(dto.getEcnNo()); |
||||
goods.setEndItem(dto.getEndItem()); |
||||
goods.setMaterialModel(dto.getMaterialModel()); |
||||
goods.setPartLink(dto.getPartLink()); |
||||
goods.setPriority(dto.getPriority()); |
||||
goods.setPartRevisionStatus(dto.getPartRevisionStatus()); |
||||
goods.setProductTechSpec(dto.getProductTechSpec()); |
||||
goods.setWeight(dto.getWeight()); |
||||
goods.setReleaseNo(dto.getReleaseNo()); |
||||
goods.setRemark(dto.getRemark()); |
||||
goods.setTradeMark(dto.getTradeMark()); |
||||
goods.setUsed(Boolean.TRUE); |
||||
goods.setIsDeleted(0); |
||||
goods.setCreateTime(new Date()); |
||||
goods.setReleaseNoTime(dto.getRcdchgdatd()); |
||||
this.save(goods); |
||||
} |
||||
} |
||||
} |
||||
}*/ |
||||
|
||||
@Override |
||||
public StGoods queryByCodeAndVersion(String prtno, String releaseNo) { |
||||
return baseMapper.queryByCodeAndVersion(prtno, releaseNo); |
||||
} |
||||
|
||||
@Override |
||||
public void changeUsed(Long id, Boolean used) throws Exception { |
||||
StGoods stGoods = this.getById(id); |
||||
if (stGoods == null) { |
||||
return; |
||||
} |
||||
stGoods.setUsed(used); |
||||
this.updateById(stGoods); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public StGoods queryByCode(String goodsCode) { |
||||
return baseMapper.queryByCode(goodsCode); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void addOnthewayQuantity(Long goodsId, Double num) { |
||||
StGoods coGoods = baseMapper.selectById(goodsId); |
||||
if (coGoods == null) { |
||||
throw new ServiceException("物料不存在或已停用:ID=" + goodsId); |
||||
} |
||||
|
||||
// 累加在途数量(负值自动归零)
|
||||
double ontheway = NumberUtil.add( |
||||
BigDecimal.valueOf(coGoods.getOnthewayQuantity()), |
||||
BigDecimal.valueOf(num) |
||||
).doubleValue(); |
||||
if (ontheway < 0) { |
||||
ontheway = 0D; |
||||
} |
||||
coGoods.setOnthewayQuantity(ontheway); |
||||
baseMapper.updateById(coGoods); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void addCurQuantity(Long goodsId, Double num) { |
||||
StGoods stGoods = baseMapper.selectById(goodsId); |
||||
if (stGoods == null) { |
||||
throw new ServiceException("物料不存在:ID=" + goodsId); |
||||
} |
||||
|
||||
// 累加当前库存(负值自动归零)
|
||||
double curQuantity = NumberUtil.add( |
||||
BigDecimal.valueOf(stGoods.getCurrentQuantity()), |
||||
BigDecimal.valueOf(num) |
||||
).doubleValue(); |
||||
if (curQuantity < 0) { |
||||
curQuantity = 0D; |
||||
} |
||||
stGoods.setCurrentQuantity(curQuantity); |
||||
baseMapper.updateById(stGoods); |
||||
|
||||
// 同步更新物料扩展表二级库存
|
||||
StGoodsExt stGoodsExt = stGoodsExtService.getById(stGoods.getId()); |
||||
if (stGoodsExt != null) { |
||||
stGoodsExt.setLastStore(curQuantity); |
||||
stGoodsExtService.updateById(stGoodsExt); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void addLockQuantity(Long goodsId, double num) { |
||||
StGoods stGoods = this.getById(goodsId); |
||||
Double lockQuantity = |
||||
BigDecimal.valueOf(stGoods.getLockQuantity()).add(BigDecimal.valueOf(num)).doubleValue(); |
||||
if (lockQuantity < 0) { |
||||
lockQuantity = 0d; |
||||
} |
||||
stGoods.setLockQuantity(lockQuantity); |
||||
} |
||||
|
||||
@Override |
||||
public List<StGoodsExcel> exportStGoods(Wrapper<StGoods> queryWrapper) { |
||||
List<StGoodsExcel> stGoodsList = baseMapper.exportStGoods(queryWrapper); |
||||
//stGoodsList.forEach(stGoods -> {
|
||||
// stGoods.setTypeName(DictCache.getValue(DictEnum.YES_NO, StGoods.getType()));
|
||||
//});
|
||||
return stGoodsList; |
||||
} |
||||
|
||||
} |
||||
|
||||
//package org.springblade.wms.service.impl;
|
||||
//
|
||||
//import cn.hutool.core.util.NumberUtil;
|
||||
//import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import jakarta.annotation.Resource;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springblade.core.log.exception.ServiceException;
|
||||
//import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
//import org.springblade.wms.excel.StGoodsExcel;
|
||||
//import org.springblade.wms.mapper.StGoodsClassMapper;
|
||||
//import org.springblade.wms.mapper.StGoodsMapper;
|
||||
//import org.springblade.wms.pojo.dto.StPdmPartDTO;
|
||||
//import org.springblade.wms.pojo.entity.StGoods;
|
||||
//import org.springblade.wms.pojo.entity.StGoodsExt;
|
||||
//import org.springblade.wms.pojo.vo.StGoodsVO;
|
||||
//import org.springblade.wms.service.IStGoodsExtService;
|
||||
//import org.springblade.wms.service.IStGoodsService;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import org.springframework.transaction.annotation.Transactional;
|
||||
//
|
||||
//import java.math.BigDecimal;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @version 1.0
|
||||
// * @program: jonhon-mes-svr
|
||||
// * @ClassName StGoodsServiceImpl
|
||||
// * @description:
|
||||
// * @autor: WuSiYu
|
||||
// * @create 2025-12-12 14:21
|
||||
// **/
|
||||
//
|
||||
//@Service
|
||||
//@Slf4j
|
||||
//public class StGoodsServiceImpl extends BaseServiceImpl<StGoodsMapper, StGoods> implements IStGoodsService {
|
||||
// @Resource
|
||||
// private StHttpRequestService stHttpRequestService;
|
||||
// @Resource
|
||||
// private IStGoodsExtService stGoodsExtService;
|
||||
//
|
||||
// @Override
|
||||
// public IPage<StGoodsVO> selectStGoodsPage(IPage<StGoodsVO> page, StGoodsVO stGoods) {
|
||||
// return page.setRecords(baseMapper.selectStGoodsPage(page, stGoods));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IPage<StGoodsVO> selectFindAllGoodsPage(IPage<StGoodsVO> page, StGoodsVO stGoods) {
|
||||
// return page.setRecords(baseMapper.selectFindAllGoodsPage(page, stGoods));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void saveGoods(String goodsCode) throws Exception {
|
||||
// StGoods stGoods = baseMapper.queryByCode(goodsCode);
|
||||
// if (stGoods != null) {
|
||||
// throw new Exception("该物料已存在!");
|
||||
// } else {
|
||||
// List<String> prtnoList = new ArrayList<>();
|
||||
// prtnoList.add(goodsCode);
|
||||
//// saveGoodsInfo(prtnoList);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /*public void saveGoodsInfo(List<String> prtnoList) throws Exception {
|
||||
// StGoods goods = null;
|
||||
// //查询物料信息
|
||||
// List<StPdmPartDTO> pdmPartInfo = stHttpRequestService.getPdmPartInfo(prtnoList);
|
||||
// log.debug("pdmPartInfo:{}", pdmPartInfo);
|
||||
//
|
||||
// if (pdmPartInfo != null) {
|
||||
// for (StPdmPartDTO dto : pdmPartInfo) {
|
||||
// //保存物料信息
|
||||
// goods = this.queryByCodeAndVersion(dto.getPrtno(), dto.getReleaseNo());
|
||||
// if (goods == null) {
|
||||
// goods = new StGoods();
|
||||
// // goods.setDept();
|
||||
// goods.setDrawingNo(dto.getDrwpartno());
|
||||
// goods.setGoodsCode(dto.getPrtno());
|
||||
// goods.setGoodsName(dto.getPrtdesc());
|
||||
// goods.setDensity(dto.getDensity());
|
||||
// goods.setPrtType(dto.getPrtType());
|
||||
// goods.setSourceByStr(dto.getSource());
|
||||
// goods.setSpecifications(dto.getMtlspcf());
|
||||
// goods.setUnitName(dto.getPrtum());
|
||||
// goods.setCavityNo(dto.getCavityNo());
|
||||
// goods.setProductCategory(dto.getProductCategory());
|
||||
// goods.setEcnNo(dto.getEcnNo());
|
||||
// goods.setEndItem(dto.getEndItem());
|
||||
// goods.setMaterialModel(dto.getMaterialModel());
|
||||
// goods.setPartLink(dto.getPartLink());
|
||||
// goods.setPriority(dto.getPriority());
|
||||
// goods.setPartRevisionStatus(dto.getPartRevisionStatus());
|
||||
// goods.setProductTechSpec(dto.getProductTechSpec());
|
||||
// goods.setWeight(dto.getWeight());
|
||||
// goods.setReleaseNo(dto.getReleaseNo());
|
||||
// goods.setRemark(dto.getRemark());
|
||||
// goods.setTradeMark(dto.getTradeMark());
|
||||
// goods.setUsed(Boolean.TRUE);
|
||||
// goods.setIsDeleted(0);
|
||||
// goods.setCreateTime(new Date());
|
||||
// goods.setReleaseNoTime(dto.getRcdchgdatd());
|
||||
// this.save(goods);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }*/
|
||||
//
|
||||
// @Override
|
||||
// public StGoods queryByCodeAndVersion(String prtno, String releaseNo) {
|
||||
// return baseMapper.queryByCodeAndVersion(prtno, releaseNo);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void changeUsed(Long id, Boolean used) throws Exception {
|
||||
// StGoods stGoods = this.getById(id);
|
||||
// if (stGoods == null) {
|
||||
// return;
|
||||
// }
|
||||
// stGoods.setUsed(used);
|
||||
// this.updateById(stGoods);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public StGoods queryByCode(String goodsCode) {
|
||||
// return baseMapper.queryByCode(goodsCode);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void addOnthewayQuantity(Long goodsId, Double num) {
|
||||
// StGoods coGoods = baseMapper.selectById(goodsId);
|
||||
// if (coGoods == null) {
|
||||
// throw new ServiceException("物料不存在或已停用:ID=" + goodsId);
|
||||
// }
|
||||
//
|
||||
// // 累加在途数量(负值自动归零)
|
||||
// double ontheway = NumberUtil.add(
|
||||
// BigDecimal.valueOf(coGoods.getOnthewayQuantity()),
|
||||
// BigDecimal.valueOf(num)
|
||||
// ).doubleValue();
|
||||
// if (ontheway < 0) {
|
||||
// ontheway = 0D;
|
||||
// }
|
||||
// coGoods.setOnthewayQuantity(ontheway);
|
||||
// baseMapper.updateById(coGoods);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void addCurQuantity(Long goodsId, Double num) {
|
||||
// StGoods stGoods = baseMapper.selectById(goodsId);
|
||||
// if (stGoods == null) {
|
||||
// throw new ServiceException("物料不存在:ID=" + goodsId);
|
||||
// }
|
||||
//
|
||||
// // 累加当前库存(负值自动归零)
|
||||
// double curQuantity = NumberUtil.add(
|
||||
// BigDecimal.valueOf(stGoods.getCurrentQuantity()),
|
||||
// BigDecimal.valueOf(num)
|
||||
// ).doubleValue();
|
||||
// if (curQuantity < 0) {
|
||||
// curQuantity = 0D;
|
||||
// }
|
||||
// stGoods.setCurrentQuantity(curQuantity);
|
||||
// baseMapper.updateById(stGoods);
|
||||
//
|
||||
// // 同步更新物料扩展表二级库存
|
||||
// StGoodsExt stGoodsExt = stGoodsExtService.getById(stGoods.getId());
|
||||
// if (stGoodsExt != null) {
|
||||
// stGoodsExt.setLastStore(curQuantity);
|
||||
// stGoodsExtService.updateById(stGoodsExt);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addLockQuantity(Long goodsId, double num) {
|
||||
// StGoods stGoods = this.getById(goodsId);
|
||||
// Double lockQuantity =
|
||||
// BigDecimal.valueOf(stGoods.getLockQuantity()).add(BigDecimal.valueOf(num)).doubleValue();
|
||||
// if (lockQuantity < 0) {
|
||||
// lockQuantity = 0d;
|
||||
// }
|
||||
// stGoods.setLockQuantity(lockQuantity);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<StGoodsExcel> exportStGoods(Wrapper<StGoods> queryWrapper) {
|
||||
// List<StGoodsExcel> stGoodsList = baseMapper.exportStGoods(queryWrapper);
|
||||
// //stGoodsList.forEach(stGoods -> {
|
||||
// // stGoods.setTypeName(DictCache.getValue(DictEnum.YES_NO, StGoods.getType()));
|
||||
// //});
|
||||
// return stGoodsList;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue