仓库管理修改

liweidong
wusiyu 2 weeks ago
parent 5cae3f9ab8
commit 95dd8ae932
  1. 5
      blade-service-api/blade-wms-api/src/main/java/org/springblade/wms/pojo/entity/StGoods.java
  2. 7
      blade-service-api/blade-wms-api/src/main/java/org/springblade/wms/pojo/vo/StStorehouseVO.java
  3. 30
      blade-service/blade-wms/src/main/java/org/springblade/wms/controller/StComboxController.java
  4. 5
      blade-service/blade-wms/src/main/java/org/springblade/wms/controller/StGoodsController.java
  5. 4
      blade-service/blade-wms/src/main/java/org/springblade/wms/controller/StOtherReceiptRecordController.java
  6. 50
      blade-service/blade-wms/src/main/java/org/springblade/wms/controller/StStorehouseController.java
  7. 5
      blade-service/blade-wms/src/main/java/org/springblade/wms/mapper/StOtherOutRecordMapper.xml
  8. 6
      blade-service/blade-wms/src/main/java/org/springblade/wms/mapper/StOtherReceiptRecordMapper.java
  9. 11
      blade-service/blade-wms/src/main/java/org/springblade/wms/mapper/StOtherReceiptRecordMapper.xml
  10. 1
      blade-service/blade-wms/src/main/java/org/springblade/wms/mapper/StStockInoutRecordMapper.xml
  11. 3
      blade-service/blade-wms/src/main/java/org/springblade/wms/service/IStOtherReceiptRecordService.java
  12. 2
      blade-service/blade-wms/src/main/java/org/springblade/wms/service/impl/StAllotRecordServiceImpl.java
  13. 19
      blade-service/blade-wms/src/main/java/org/springblade/wms/service/impl/StGoodsServiceImpl.java
  14. 68
      blade-service/blade-wms/src/main/java/org/springblade/wms/service/impl/StOtherReceiptRecordServiceImpl.java

@ -181,6 +181,11 @@ public class StGoods extends BaseEntity {
@JsonSerialize(nullsUsing = NullSerializer.class)
@Schema(description = "物料类别")
private Long gcId;
/**
* 物料类别名称
*/
@Schema(description = "物料类别名称")
private String gcName;
/**
* 生命周期状态
*/

@ -1,5 +1,6 @@
package org.springblade.wms.pojo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.wms.pojo.entity.StStorehouse;
@ -21,5 +22,11 @@ public class StStorehouseVO extends StStorehouse {
@Serial
private static final long serialVersionUID = 1L;
/**
* 保管员姓名
*/
@Schema(description = "保管员姓名")
private String saveUserName;
}

@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@ -80,10 +79,20 @@ public class StComboxController {
);
List<StRealtimeStockVO> records = new ArrayList<>(pages.getRecords());
Iterator<StRealtimeStockVO> iterator = records.iterator();
while (iterator.hasNext()) {
StRealtimeStockVO vo = iterator.next();
StGoods goods = stGoodsService.getById(vo.getGoodsId());
List<StRealtimeStockVO> newList = new ArrayList<>();
// Iterator<StRealtimeStockVO> iterator = records.iterator();
// while (iterator.hasNext()) {
for (StRealtimeStockVO vo : records) {
// StRealtimeStockVO vo = iterator.next();
Long goodsId = vo.getGoodsId();
// 1. 没有 goodsId → 跳过
if (goodsId == null) {
continue;
}
StGoods goods = stGoodsService.getById(goodsId);
if (goods == null) {
continue;
}
vo.setGoodsCodeAndGoodsName(goods.getGoodsCode()+ "(" + vo.getPiNo() + ")");
Long shId = stRealtimeStock.getShId();
@ -92,12 +101,17 @@ public class StComboxController {
if (surplus < vo.getQuantity()) {
vo.setQuantity(surplus);
}
if (surplus <= 0) {
iterator.remove(); // 安全删除元素
// if (surplus <= 0) {
// iterator.remove(); // 安全删除元素
// }
if (surplus > 0) { // 只有库存>0才保留
newList.add(vo);
}
} else {
newList.add(vo);
}
}
pages.setRecords(records);
pages.setRecords(newList);
return R.data(pages);
}

@ -67,8 +67,9 @@ public class StGoodsController extends BladeController {
@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));
wrapper.eq("is_deleted", 0)
.orderByDesc("create_time");
IPage<StGoods> pages = stGoodsService.page(Condition.getPage(query), wrapper);
return R.data(StGoodsWrapper.build().pageVO(pages));
}

@ -226,8 +226,8 @@ public class StOtherReceiptRecordController extends BladeController {
@ApiOperationSupport(order = 11)
@ApiLog("物料id和车间订单号获取玻璃饼信息")
@Operation(summary = "根据物料id和车间订单号获取玻璃饼信息", description = "传入goodsId、woCode")
public R<List<StOtherReceiptRecordVO>> getGlassCakeByWoCode(@RequestParam String woCode) {
return R.data(stOtherReceiptRecordService.getGlassCakeByWoCode(woCode));
public R<StStockInoutRecord> getGlassCakeByWoCode(@RequestParam String woCode, @RequestParam String goodsCode) {
return R.data(stOtherReceiptRecordService.getGlassCakeByWoCode(woCode, goodsCode));
}
/**

@ -22,6 +22,9 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.system.feign.IUserClient;
import org.springblade.system.pojo.entity.User;
import org.springblade.wms.excel.StStorehouseExcel;
import org.springblade.wms.pojo.entity.StStorageLocation;
import org.springblade.wms.pojo.entity.StStorehouse;
@ -36,6 +39,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @version 1.0
@ -59,6 +64,14 @@ public class StStorehouseController extends BladeController {
private final IStStorageLocationService stStorageLocationService;
private final IStUserRightService stUserRightService;
private static IUserClient userClient;
private static IUserClient getUserClient() {
if (userClient == null) {
userClient = SpringUtil.getBean(IUserClient.class);
}
return userClient;
}
/**
* 库房维护表 详情
@ -93,7 +106,42 @@ public class StStorehouseController extends BladeController {
wrapper.orderByAsc("sh_code");
}
IPage<StStorehouse> pages = stStorehouseService.page(Condition.getPage(query), wrapper);
return R.data(StStorehouseWrapper.build().pageVO(pages));
// 转换为 VO
IPage<StStorehouseVO> voPage = StStorehouseWrapper.build().pageVO(pages);
// ========== 新增:批量查询保管员姓名 ==========
if (voPage.getRecords() != null && !voPage.getRecords().isEmpty()) {
// 1. 提取所有保管员ID
List<Long> keeperIdList = voPage.getRecords().stream()
.map(StStorehouseVO::getSaveUser)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!keeperIdList.isEmpty()) {
// 2. 把 List<Long> 转成 逗号分隔的字符串 "1,2,3"
String ids = keeperIdList.stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
List<User> userList = getUserClient().userListByIds(ids);
Map<Long, String> userMap = userList.stream()
.collect(Collectors.toMap(
User::getId,
User::getRealName
));
// 循环赋值保管员姓名
for (StStorehouseVO vo : voPage.getRecords()) {
Long saveUserId = vo.getSaveUser();
if (saveUserId != null) {
// 从map里取出姓名,set到VO
vo.setSaveUserName(userMap.get(saveUserId));
}
}
}
}
return R.data(voPage);
}
/**

@ -67,6 +67,11 @@
<if test="stOtherOutRecord.sirCode != null and stOtherOutRecord.sirCode != ''">
AND sir.sir_code LIKE '%' || #{stOtherOutRecord.sirCode} || '%'
</if>
<if test="stOtherOutRecord.crCode != null and stOtherOutRecord.crCode != ''">
AND sir.cr_code LIKE '%' || #{stOtherOutRecord.crCode} || '%'
</if>
<if test="stOtherOutRecord.userRoleName != null and stOtherOutRecord.userRoleName.contains('process_engineer')">
AND soor.approval_status = 0
</if>

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.desk.order.pojo.entity.YieldOrder;
import org.springblade.desk.produce.pojo.entity.WorkOrder;
import org.springblade.wms.excel.StOtherReceiptRecordExcel;
import org.springblade.wms.pojo.entity.StOtherReceiptRecord;
import org.springblade.wms.pojo.vo.StOtherReceiptRecordVO;
@ -40,5 +42,9 @@ public interface StOtherReceiptRecordMapper extends BaseMapper<StOtherReceiptRec
List<StOtherReceiptRecordExcel> exportStOtherReceiptRecord(@Param("ew") Wrapper<StOtherReceiptRecord> queryWrapper);
List<StOtherReceiptRecord> selectByWoCode(String woCode);
WorkOrder getByWoCode(String woCode);
YieldOrder getByYoId(Long yoId);
}

@ -111,4 +111,15 @@
SELECT * FROM ST_OTHER_RECEIPT_RECORD ${ew.customSqlSegment}
</select>
<select id="getByWoCode" resultType="org.springblade.desk.produce.pojo.entity.WorkOrder">
SELECT *
FROM MES_WORK_ORDER
WHERE WO_CODE = #{woCode}
</select>
<select id="getByYoId" resultType="org.springblade.desk.order.pojo.entity.YieldOrder">
SELECT *
FROM MES_YIELD_ORDER
WHERE ID = #{yoId}
</select>
</mapper>

@ -56,6 +56,7 @@
sir.in_out_source,
sir.check_no ,
sir.buy_code ,
sir.unit_price ,
-- 关联物料表(ST_GOODS):补充物料相关字段
g.goods_code ,
g.goods_name ,

@ -7,6 +7,7 @@ import org.springblade.core.secure.BladeUser;
import org.springblade.wms.excel.StOtherReceiptRecordExcel;
import org.springblade.wms.pojo.dto.InitStockDTO;
import org.springblade.wms.pojo.entity.StOtherReceiptRecord;
import org.springblade.wms.pojo.entity.StStockInoutRecord;
import org.springblade.wms.pojo.vo.StOtherReceiptRecordVO;
import java.util.List;
@ -43,6 +44,6 @@ public interface IStOtherReceiptRecordService extends BaseService<StOtherReceipt
void otherWarehousing(StOtherReceiptRecord stOtherReceiptRecord, BladeUser user);
List<StOtherReceiptRecordVO> getGlassCakeByWoCode(String woCode);
StStockInoutRecord getGlassCakeByWoCode(String woCode, String goodsCode);
}

@ -82,7 +82,7 @@ public class StAllotRecordServiceImpl extends BaseServiceImpl<StAllotRecordMappe
}
// 2. 批量保存主表(MyBatis-Plus 批量保存)
boolean batchSaveSuccess = super.saveBatch(stAllotRecordList);
boolean batchSaveSuccess = super.saveOrUpdateBatch(stAllotRecordList);
if (!batchSaveSuccess) {
throw new RuntimeException("批量保存调拨主表失败"); // 抛出异常触发事务回滚
}

@ -2,6 +2,7 @@ package org.springblade.wms.service.impl;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@ -11,12 +12,15 @@ import org.springblade.wms.excel.StGoodsExcel;
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.StGoodsClass;
import org.springblade.wms.pojo.entity.StGoodsExt;
import org.springblade.wms.pojo.vo.StGoodsVO;
import org.springblade.wms.service.IStGoodsClassService;
import org.springblade.wms.service.IStGoodsExtService;
import org.springblade.wms.service.IStGoodsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
@ -39,6 +43,8 @@ public class StGoodsServiceImpl extends BaseServiceImpl<StGoodsMapper, StGoods>
private StHttpRequestService stHttpRequestService;
@Resource
private IStGoodsExtService stGoodsExtService;
@Resource
private IStGoodsClassService stGoodsClassService;
@Override
public IPage<StGoodsVO> selectStGoodsPage(IPage<StGoodsVO> page, StGoodsVO stGoods) {
@ -69,6 +75,10 @@ public class StGoodsServiceImpl extends BaseServiceImpl<StGoodsMapper, StGoods>
List<StPdmPartDTO> pdmPartInfo = stHttpRequestService.getPdmPartInfo(prtnoList);
log.debug("pdmPartInfo:{}", pdmPartInfo);
if (CollectionUtils.isEmpty(pdmPartInfo)) {
throw new Exception("PDM未查询到物料信息!");
}
if (pdmPartInfo != null) {
for (StPdmPartDTO dto : pdmPartInfo) {
//保存物料信息
@ -101,6 +111,15 @@ public class StGoodsServiceImpl extends BaseServiceImpl<StGoodsMapper, StGoods>
goods.setIsDeleted(0);
goods.setCreateTime(new Date());
goods.setReleaseNoTime(dto.getRcdchgdatd());
String goodsName = dto.getPrtdesc();
if (goodsName != null && (goodsName.contains("环规") || goodsName.contains("塞规"))) {
QueryWrapper<StGoodsClass> qw = new QueryWrapper<>();
qw.eq("gc_name", "量具")
.eq("is_deleted", 0);
StGoodsClass goodsClass = stGoodsClassService.getOne(qw);
goods.setGcId(goodsClass.getId());
goods.setGcName("量具");
}
this.save(goods);
}
}

@ -1,17 +1,22 @@
package org.springblade.wms.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.annotation.Resource;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.BladeUser;
import org.springblade.desk.dashboard.feign.IPartClient;
import org.springblade.desk.dashboard.pojo.entity.DsPartEntity;
import org.springblade.desk.dashboard.pojo.entity.DsPartRelationEntity;
import org.springblade.desk.order.pojo.entity.YieldOrder;
import org.springblade.desk.produce.pojo.entity.WorkOrder;
import org.springblade.wms.excel.StOtherReceiptRecordExcel;
import org.springblade.wms.mapper.StOtherReceiptRecordMapper;
import org.springblade.wms.mapper.StStockInoutRecordMapper;
import org.springblade.wms.pojo.dto.InitStockDTO;
import org.springblade.wms.pojo.entity.*;
import org.springblade.wms.pojo.vo.StOtherReceiptRecordVO;
@ -22,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -49,6 +53,15 @@ public class StOtherReceiptRecordServiceImpl extends BaseServiceImpl<StOtherRece
IStRealtimeStockService stRealtimeStockService;
@Resource
IStStockInoutRecordService stStockInoutRecordService;
@Resource
IPartClient partClient;
// private static IPartClient getPartClient() {
// if (partClient == null) {
// partClient = SpringUtil.getBean(IPartClient.class);
// }
// return partClient;
// }
@Override
public IPage<StOtherReceiptRecordVO> selectStOtherReceiptRecordPage(IPage<StOtherReceiptRecordVO> page, StOtherReceiptRecordVO stOtherReceiptRecord) {
return page.setRecords(baseMapper.selectStOtherReceiptRecordPage(page, stOtherReceiptRecord));
@ -275,12 +288,55 @@ public class StOtherReceiptRecordServiceImpl extends BaseServiceImpl<StOtherRece
}
@Override
public List<StOtherReceiptRecordVO> getGlassCakeByWoCode(String woCode) {
public StStockInoutRecord getGlassCakeByWoCode(String woCode, String goodsCode) {
List<StOtherReceiptRecord> list = baseMapper.selectByWoCode(woCode);
if (CollUtil.isEmpty(list)) {
WorkOrder workOrder = baseMapper.getByWoCode(woCode);
YieldOrder yieldOrder = baseMapper.getByYoId(workOrder.getYoId());
DsPartEntity partOne = partClient.getPart(workOrder.getPartCode(),yieldOrder.getPartVersion());
List<DsPartRelationEntity> partRelationEntityList = partClient.getSubPart(partOne.getId());
List<DsPartEntity> glassCakePartList = new ArrayList<>();
if (!CollectionUtils.isEmpty(partRelationEntityList)) {
// 步骤1:提取所有非空的childPartId并去重(避免null和重复ID,减少查询压力)
List<Long> childPartIdList = partRelationEntityList.stream()
.map(DsPartRelationEntity::getChildPartId) // 提取子件ID
.filter(Objects::nonNull) // 过滤null的ID
.distinct() // 去重,避免重复查询
.collect(Collectors.toList());
// 步骤2:批量查询DS_PART表(一次SQL,性能最优)
if (!CollectionUtils.isEmpty(childPartIdList)) {
// 调用dsPartService的批量查询方法(根据ID列表查DS_PART)
List<DsPartEntity> allChildPartList = partClient.batchParts(childPartIdList);
// 步骤3:筛选出IS_CLASS_CAKE为"玻璃饼"的记录(核心过滤)
if (!CollectionUtils.isEmpty(allChildPartList)) {
glassCakePartList = allChildPartList.stream()
.filter(part -> Boolean.TRUE.equals(part.getIsGlassCake()))
.collect(Collectors.toList());
}
}
}
StStockInoutRecord inoutRecord = new StStockInoutRecord();
if (!CollectionUtils.isEmpty(glassCakePartList)) {
DsPartEntity targetPart = glassCakePartList.stream()
.filter(part -> goodsCode.equals(part.getPartCode()))
.findFirst()
.orElse(null);
inoutRecord.setPrintMark(Boolean.valueOf(targetPart.getIsPrint()));
inoutRecord.setPowderWeight(String.valueOf(targetPart.getPowderWeight()));
inoutRecord.setMaterialNo(targetPart.getMaterial());
inoutRecord.setThickness(String.valueOf(targetPart.getFormingThickness()));
}
if (ObjectUtil.isEmpty(inoutRecord)) {
throw new ServiceException("未找到对应的玻璃饼信息");
}
return StOtherReceiptRecordWrapper.build().listVO(list);
return inoutRecord;
}
@Override

Loading…
Cancel
Save