feat(exempt-material): 实现批量判断免检物料功能
- 在IQmsExemptMaterialService接口添加batchCheckExempt方法定义 - QmsExemptMaterialMapper新增batchCheckExempt数据库查询方法及对应XML实现 - 在QmsExemptMaterialServiceImpl中实现batchCheckExempt业务逻辑 - 新增ExemptMaterialCheckQO请求对象用于传递供应商编号和物料编号 - 新增ExemptMaterialCheckVO响应对象用于返回免检判断结果 - 新增MaterialController对外提供批量免检判断接口 - 接口仅返回审核通过、启用且有效期内的免检物料组合
This commit is contained in:
parent
3b5e6b4ef2
commit
66e5407cbf
42
nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/external/MaterialController.java
vendored
Normal file
42
nflg-qms-admin/src/main/java/com/nflg/qms/admin/controller/external/MaterialController.java
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.nflg.qms.admin.controller.external;
|
||||||
|
|
||||||
|
import com.nflg.wms.common.pojo.ApiResult;
|
||||||
|
import com.nflg.wms.common.pojo.qo.ExemptMaterialCheckQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.ExemptMaterialCheckVO;
|
||||||
|
import com.nflg.wms.repository.service.IQmsExemptMaterialService;
|
||||||
|
import com.nflg.wms.starter.BaseController;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对外接口-物料信息
|
||||||
|
* @folder 对外接口/物料信息
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/external/material")
|
||||||
|
public class MaterialController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IQmsExemptMaterialService exemptMaterialService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量判断物料是否免检
|
||||||
|
* - 参数为供应商编号和物料编号的组合列表
|
||||||
|
* - 根据系统中已审核、已启用且在有效期内的免检设置判断
|
||||||
|
* - 返回每个组合的免检标志(exempt=true 表示免检)
|
||||||
|
*/
|
||||||
|
@PostMapping("batchCheckExempt")
|
||||||
|
public ApiResult<List<ExemptMaterialCheckVO>> batchCheckExempt(
|
||||||
|
@Valid @RequestBody @NotEmpty List<ExemptMaterialCheckQO> request) {
|
||||||
|
return ApiResult.success(exemptMaterialService.batchCheckExempt(request));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免检物料判断 单条请求对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExemptMaterialCheckQO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供应商编号
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "供应商编号不能为空")
|
||||||
|
private String supplierCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编号
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "物料编号不能为空")
|
||||||
|
private String materialNo;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.nflg.wms.common.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免检物料判断 结果VO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExemptMaterialCheckVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供应商编号
|
||||||
|
*/
|
||||||
|
private String supplierCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编号
|
||||||
|
*/
|
||||||
|
private String materialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否免检:true=免检,false=非免检
|
||||||
|
*/
|
||||||
|
private Boolean exempt;
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSearchQO;
|
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.ExemptMaterialCheckVO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsExemptMaterialVO;
|
import com.nflg.wms.common.pojo.vo.QmsExemptMaterialVO;
|
||||||
import com.nflg.wms.repository.entity.QmsExemptMaterial;
|
import com.nflg.wms.repository.entity.QmsExemptMaterial;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -29,4 +30,11 @@ public interface QmsExemptMaterialMapper extends BaseMapper<QmsExemptMaterial> {
|
||||||
* 按物料编号查询关联的供应商免检明细
|
* 按物料编号查询关联的供应商免检明细
|
||||||
*/
|
*/
|
||||||
List<QmsExemptMaterialVO> detailByMaterial(@Param("materialNo") String materialNo);
|
List<QmsExemptMaterialVO> detailByMaterial(@Param("materialNo") String materialNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询有效免检物料(供应商编号+物料编号组合)
|
||||||
|
* 仅返回审核通过、启用且在有效期内的记录
|
||||||
|
*/
|
||||||
|
List<ExemptMaterialCheckVO> batchCheckExempt(@Param("supplierCodes") List<String> supplierCodes,
|
||||||
|
@Param("materialNos") List<String> materialNos);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,11 @@ package com.nflg.wms.repository.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nflg.wms.common.pojo.qo.ExemptMaterialCheckQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialAuditQO;
|
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialAuditQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSaveQO;
|
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSaveQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSearchQO;
|
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.ExemptMaterialCheckVO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsExemptMaterialVO;
|
import com.nflg.wms.common.pojo.vo.QmsExemptMaterialVO;
|
||||||
import com.nflg.wms.repository.entity.QmsExemptMaterial;
|
import com.nflg.wms.repository.entity.QmsExemptMaterial;
|
||||||
|
|
||||||
|
|
@ -44,4 +46,10 @@ public interface IQmsExemptMaterialService extends IService<QmsExemptMaterial> {
|
||||||
* 审核免检物料
|
* 审核免检物料
|
||||||
*/
|
*/
|
||||||
void audit(QmsExemptMaterialAuditQO request);
|
void audit(QmsExemptMaterialAuditQO request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量判断物料是否免检
|
||||||
|
* 根据供应商编号和物料编号判断,返回每个组合的免检标志
|
||||||
|
*/
|
||||||
|
List<ExemptMaterialCheckVO> batchCheckExempt(List<ExemptMaterialCheckQO> items);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.nflg.wms.common.constant.STATE;
|
import com.nflg.wms.common.constant.STATE;
|
||||||
import com.nflg.wms.common.exception.NflgException;
|
import com.nflg.wms.common.exception.NflgException;
|
||||||
|
import com.nflg.wms.common.pojo.qo.ExemptMaterialCheckQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialAuditQO;
|
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialAuditQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSaveQO;
|
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSaveQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSearchQO;
|
import com.nflg.wms.common.pojo.qo.QmsExemptMaterialSearchQO;
|
||||||
|
import com.nflg.wms.common.pojo.vo.ExemptMaterialCheckVO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsExemptMaterialVO;
|
import com.nflg.wms.common.pojo.vo.QmsExemptMaterialVO;
|
||||||
import com.nflg.wms.common.util.StringUtil;
|
import com.nflg.wms.common.util.StringUtil;
|
||||||
import com.nflg.wms.common.util.UserUtil;
|
import com.nflg.wms.common.util.UserUtil;
|
||||||
|
|
@ -21,7 +23,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 免检物料 服务实现类
|
* 免检物料 服务实现类
|
||||||
|
|
@ -166,4 +171,36 @@ public class QmsExemptMaterialServiceImpl extends ServiceImpl<QmsExemptMaterialM
|
||||||
}
|
}
|
||||||
return LocalDateTime.parse(dateStr, DATE_FMT);
|
return LocalDateTime.parse(dateStr, DATE_FMT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExemptMaterialCheckVO> batchCheckExempt(List<ExemptMaterialCheckQO> items) {
|
||||||
|
// 提取所有供应商编号和物料编号
|
||||||
|
List<String> supplierCodes = items.stream()
|
||||||
|
.map(ExemptMaterialCheckQO::getSupplierCode)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<String> materialNos = items.stream()
|
||||||
|
.map(ExemptMaterialCheckQO::getMaterialNo)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 一次性查询所有有效免检组合
|
||||||
|
List<ExemptMaterialCheckVO> exemptList = baseMapper.batchCheckExempt(supplierCodes, materialNos);
|
||||||
|
|
||||||
|
// 构建免检组合的快速查询集合,格式:supplierCode:materialNo
|
||||||
|
Set<String> exemptSet = exemptList.stream()
|
||||||
|
.map(v -> v.getSupplierCode() + ":" + v.getMaterialNo())
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
|
// 构建返回结果
|
||||||
|
List<ExemptMaterialCheckVO> result = new ArrayList<>(items.size());
|
||||||
|
for (ExemptMaterialCheckQO item : items) {
|
||||||
|
ExemptMaterialCheckVO vo = new ExemptMaterialCheckVO();
|
||||||
|
vo.setSupplierCode(item.getSupplierCode());
|
||||||
|
vo.setMaterialNo(item.getMaterialNo());
|
||||||
|
vo.setExempt(exemptSet.contains(item.getSupplierCode() + ":" + item.getMaterialNo()));
|
||||||
|
result.add(vo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -134,4 +134,27 @@
|
||||||
ORDER BY em.create_time DESC
|
ORDER BY em.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 批量查询有效免检物料(供应商编号+物料编号组合),仅返回审核通过、启用且在有效期内的记录 -->
|
||||||
|
<select id="batchCheckExempt" resultType="com.nflg.wms.common.pojo.vo.ExemptMaterialCheckVO">
|
||||||
|
SELECT
|
||||||
|
us.supplier_code AS supplierCode,
|
||||||
|
em.material_no AS materialNo
|
||||||
|
FROM qms_exempt_material em
|
||||||
|
INNER JOIN user_supplier us ON us.id = em.supplier_id
|
||||||
|
WHERE em.audit_status = 1
|
||||||
|
AND em.enable = true
|
||||||
|
AND (
|
||||||
|
em.exempt_mode = 0
|
||||||
|
OR (em.exempt_mode = 1 AND em.valid_end_date IS NOT NULL AND em.valid_end_date >= NOW())
|
||||||
|
)
|
||||||
|
AND us.supplier_code IN
|
||||||
|
<foreach collection="supplierCodes" item="code" open="(" separator="," close=")">
|
||||||
|
#{code}
|
||||||
|
</foreach>
|
||||||
|
AND em.material_no IN
|
||||||
|
<foreach collection="materialNos" item="no" open="(" separator="," close=")">
|
||||||
|
#{no}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue