commit
807c0817c5
10 changed files with 531 additions and 0 deletions
@ -0,0 +1,177 @@ |
|||||||
|
package org.springblade.wms.controller; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||||
|
import jakarta.validation.Valid; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import org.springblade.core.boot.ctrl.BladeController; |
||||||
|
import org.springblade.core.excel.util.ExcelUtil; |
||||||
|
import org.springblade.core.mp.support.Condition; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
import org.springblade.core.secure.BladeUser; |
||||||
|
import org.springblade.core.secure.annotation.IsAdmin; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.DateUtil; |
||||||
|
import org.springblade.core.tool.utils.Func; |
||||||
|
import org.springblade.desk.quality.pojo.entity.LiquidTank; |
||||||
|
import org.springblade.wms.excel.StGoodsExcel; |
||||||
|
import org.springblade.wms.pojo.entity.StGoods; |
||||||
|
import org.springblade.wms.pojo.vo.StGoodsVO; |
||||||
|
import org.springblade.wms.service.IStGoodsNewService; |
||||||
|
import org.springblade.wms.wrapper.StGoodsWrapper; |
||||||
|
import org.springframework.validation.annotation.Validated; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @version 1.0 |
||||||
|
* @program: jonhon-mes-svr |
||||||
|
* @ClassName StGoodsController |
||||||
|
* @description: |
||||||
|
* @autor: WuSiYu |
||||||
|
* @create 2025-12-10 11:39 |
||||||
|
**/ |
||||||
|
|
||||||
|
@RestController |
||||||
|
@AllArgsConstructor |
||||||
|
@RequestMapping("/stGoodsNew") |
||||||
|
@Tag(name = "物料信息表", description = "物料信息表接口") |
||||||
|
public class StGoodsNewController extends BladeController { |
||||||
|
|
||||||
|
private final IStGoodsNewService stGoodsService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 物料信息表 详情 |
||||||
|
*/ |
||||||
|
@GetMapping("/detail") |
||||||
|
@ApiOperationSupport(order = 1) |
||||||
|
@Operation(summary = "详情", description = "传入stGoods") |
||||||
|
public R<StGoodsVO> detail(StGoods stGoods) { |
||||||
|
StGoods detail = stGoodsService.getOne(Condition.getQueryWrapper(stGoods)); |
||||||
|
return R.data(StGoodsWrapper.build().entityVO(detail)); |
||||||
|
} |
||||||
|
/** |
||||||
|
* 物料信息表 分页 |
||||||
|
*/ |
||||||
|
@GetMapping("/list") |
||||||
|
@ApiOperationSupport(order = 2) |
||||||
|
@Operation(summary = "分页", description = "传入stGoods") |
||||||
|
public R<IPage<StGoodsVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> stGoods, Query query) { |
||||||
|
QueryWrapper<StGoods> wrapper = Condition.getQueryWrapper(stGoods, StGoods.class); |
||||||
|
wrapper.eq("is_deleted", 0); |
||||||
|
IPage<StGoods> pages = stGoodsService.page(Condition.getPage(query), Condition.getQueryWrapper(stGoods, StGoods.class)); |
||||||
|
return R.data(StGoodsWrapper.build().pageVO(pages)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 物料信息表 自定义分页 |
||||||
|
*/ |
||||||
|
@GetMapping("/page") |
||||||
|
@ApiOperationSupport(order = 3) |
||||||
|
@Operation(summary = "分页", description = "传入stGoods") |
||||||
|
public R<IPage<StGoodsVO>> page(StGoodsVO stGoods, Query query) { |
||||||
|
stGoods.setIsDeleted(0); |
||||||
|
IPage<StGoodsVO> pages = stGoodsService.selectStGoodsPage(Condition.getPage(query), stGoods); |
||||||
|
return R.data(pages); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 物料信息表 新增 |
||||||
|
*/ |
||||||
|
@PostMapping("/save") |
||||||
|
@ApiOperationSupport(order = 4) |
||||||
|
@Operation(summary = "新增", description = "传入stGoods") |
||||||
|
public R save(@Valid @RequestBody String goodsCode) throws Exception{ |
||||||
|
stGoodsService.saveGoods(goodsCode); |
||||||
|
return R.success(); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/listForStGoods") |
||||||
|
@ApiOperationSupport(order = 22) |
||||||
|
@Operation(summary = "list下拉选择", description = "") |
||||||
|
public R<List<StGoods>> listForStGoods() { |
||||||
|
List<StGoods> list = stGoodsService.list(); |
||||||
|
return R.data(list); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 物料信息表 修改 |
||||||
|
*/ |
||||||
|
@PostMapping("/update") |
||||||
|
@ApiOperationSupport(order = 5) |
||||||
|
@Operation(summary = "修改", description = "传入stGoods") |
||||||
|
public R update(@Valid @RequestBody StGoods stGoods) { |
||||||
|
return R.status(stGoodsService.updateById(stGoods)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 物料信息表 新增或修改 |
||||||
|
*/ |
||||||
|
@PostMapping("/submit") |
||||||
|
@ApiOperationSupport(order = 6) |
||||||
|
@Operation(summary = "新增或修改", description = "传入stGoods") |
||||||
|
public R submit(@Valid @RequestBody StGoods stGoods) { |
||||||
|
return R.status(stGoodsService.saveOrUpdate(stGoods)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 物料信息表 删除 |
||||||
|
*/ |
||||||
|
@PostMapping("/remove") |
||||||
|
@ApiOperationSupport(order = 7) |
||||||
|
@Operation(summary = "逻辑删除", description = "传入ids") |
||||||
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
||||||
|
return R.status(stGoodsService.deleteLogic(Func.toLongList(ids))); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置物料状态 |
||||||
|
*/ |
||||||
|
@PostMapping("/setUsed") |
||||||
|
@ApiOperationSupport(order = 8) |
||||||
|
@Operation(summary = "设置物料状态", description = "传入goodsId(物料ID)和used(状态:true=启用,false=禁用)") |
||||||
|
public R setUsed(@Validated @RequestBody StGoods stGoods) throws Exception { |
||||||
|
stGoodsService.changeUsed(stGoods.getId(), stGoods.getUsed()); |
||||||
|
return R.success(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据物料编码查询物料 |
||||||
|
*/ |
||||||
|
@GetMapping("/getGoodsByGoodsCode") |
||||||
|
@ApiOperationSupport(order = 9) |
||||||
|
@Operation(summary = "根据物料编码查询物料", description = "传入物料编码goodsCode(路径参数)") |
||||||
|
public R getGoodsByGoodsCode( |
||||||
|
@Validated |
||||||
|
@PathVariable(value = "goodsCode") String goodsCode |
||||||
|
) throws Exception { |
||||||
|
Object goods = stGoodsService.queryByCode(goodsCode); |
||||||
|
return R.data(goods); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 导出数据 |
||||||
|
*/ |
||||||
|
@IsAdmin |
||||||
|
@GetMapping("/export-stGoods") |
||||||
|
@ApiOperationSupport(order = 10) |
||||||
|
@Operation(summary = "导出数据", description = "传入stGoods") |
||||||
|
public void exportStGoods(@Parameter(hidden = true) @RequestParam Map<String, Object> stGoods, BladeUser bladeUser, HttpServletResponse response) { |
||||||
|
QueryWrapper<StGoods> queryWrapper = Condition.getQueryWrapper(stGoods, StGoods.class); |
||||||
|
//if (!AuthUtil.isAdministrator()) {
|
||||||
|
// queryWrapper.lambda().eq(StGoods::getTenantId, bladeUser.getTenantId());
|
||||||
|
//}
|
||||||
|
//queryWrapper.lambda().eq(StGoodsEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
|
||||||
|
List<StGoodsExcel> list = stGoodsService.exportStGoods(queryWrapper); |
||||||
|
ExcelUtil.export(response, "物料信息表数据" + DateUtil.time(), "物料信息表数据表", list, StGoodsExcel.class); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,55 @@ |
|||||||
|
package org.springblade.wms.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
import org.springblade.wms.excel.StGoodsExcel; |
||||||
|
import org.springblade.wms.pojo.entity.StGoods; |
||||||
|
import org.springblade.wms.pojo.vo.StGoodsVO; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @version 1.0 |
||||||
|
* @program: jonhon-mes-svr |
||||||
|
* @ClassName IStGoodsService |
||||||
|
* @description: |
||||||
|
* @autor: WuSiYu |
||||||
|
* @create 2025-12-12 14:18 |
||||||
|
**/ |
||||||
|
|
||||||
|
public interface IStGoodsNewService extends BaseService<StGoods> { |
||||||
|
/** |
||||||
|
* 自定义分页 |
||||||
|
* |
||||||
|
* @param page 分页参数 |
||||||
|
* @param stGoods 查询参数 |
||||||
|
* @return IPage<StGoodsVO> |
||||||
|
*/ |
||||||
|
IPage<StGoodsVO> selectStGoodsPage(IPage<StGoodsVO> page, StGoodsVO stGoods); |
||||||
|
|
||||||
|
void changeUsed(Long id, Boolean used) throws Exception; |
||||||
|
|
||||||
|
StGoods queryByCode(String goodsCode); |
||||||
|
|
||||||
|
/** |
||||||
|
* 导出数据 |
||||||
|
* |
||||||
|
* @param queryWrapper 查询条件 |
||||||
|
* @return List<StGoodsExcel> |
||||||
|
*/ |
||||||
|
List<StGoodsExcel> exportStGoods(Wrapper<StGoods> queryWrapper); |
||||||
|
|
||||||
|
void saveGoods(String goodsCode) throws Exception; |
||||||
|
|
||||||
|
StGoods queryByCodeAndVersion(String prtno, String releaseNo); |
||||||
|
|
||||||
|
void addOnthewayQuantity(Long goodsId, Double num); |
||||||
|
|
||||||
|
void addCurQuantity(Long goodsId, Double quantity); |
||||||
|
|
||||||
|
IPage<StGoodsVO> selectFindAllGoodsPage(IPage<StGoodsVO> page, StGoodsVO stGoods); |
||||||
|
|
||||||
|
void addLockQuantity(Long goodsId, double v); |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,201 @@ |
|||||||
|
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.IStGoodsNewService; |
||||||
|
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 StGoodsNewServiceImpl extends BaseServiceImpl<StGoodsMapper, StGoods> implements IStGoodsNewService { |
||||||
|
// @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; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
Loading…
Reference in new issue