Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.zt.plat.module.qms.resource.material.controller.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import com.zt.plat.module.qms.core.aspect.annotation.Dict;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@@ -91,6 +93,9 @@ public class MaterialProductPageReqVO extends PageParam {
|
||||
@Schema(description = "是否进行库存预警,1-是,0-否")
|
||||
private Integer InventoryAlarmFlag;
|
||||
|
||||
@Schema(description = "库存预警级别,safe-安全,warn-警告,danger")
|
||||
private String InventoryAlarmLevel;
|
||||
|
||||
@Schema(description = "库存预警区间,json格式配置")
|
||||
private String InventoryAlarmRange;
|
||||
|
||||
|
||||
@@ -138,6 +138,12 @@ public class MaterialProductRespVO {
|
||||
@Dict(dicCode = "yes_or_no")
|
||||
private Integer InventoryAlarmFlag;
|
||||
|
||||
|
||||
@Schema(description = "库存预警级别,safe-安全,warn-警告,danger")
|
||||
@ExcelProperty("库存预警级别,safe-安全,warn-警告,danger")
|
||||
@Dict(dicCode = "alarm_level")
|
||||
private String InventoryAlarmLevel;
|
||||
|
||||
@Schema(description = "库存预警区间,json格式配置")
|
||||
@ExcelProperty("库存预警区间,json格式配置")
|
||||
private String InventoryAlarmRange;
|
||||
|
||||
@@ -172,6 +172,11 @@ public class MaterialProductDO extends BusinessBaseDO {
|
||||
*/
|
||||
@TableField("INVT_ALM_FLG")
|
||||
private Integer InventoryAlarmFlag;
|
||||
/**
|
||||
* 库存预警级别,safe-安全,warn-警告,danger
|
||||
*/
|
||||
@TableField("INVT_ALM_LVL")
|
||||
private String InventoryAlarmLevel;
|
||||
/**
|
||||
* 库存预警区间,json格式配置
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,7 @@ public interface MaterialProductMapper extends BaseMapperX<MaterialProductDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialProductDO>()
|
||||
.eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_DATA)
|
||||
.eqIfPresent(MaterialProductDO::getParentId, reqVO.getParentId())
|
||||
.eqIfPresent(MaterialProductDO::getInventoryAlarmLevel, reqVO.getInventoryAlarmLevel())
|
||||
.likeIfPresent(MaterialProductDO::getIdPath, reqVO.getIdPath())
|
||||
.likeIfPresent(MaterialProductDO::getName, reqVO.getName())
|
||||
.likeIfPresent(MaterialProductDO::getCode, reqVO.getCode())
|
||||
|
||||
@@ -2,9 +2,19 @@ package com.zt.plat.module.qms.resource.material.enums;
|
||||
|
||||
/**
|
||||
* 物料验收状态
|
||||
*
|
||||
*/
|
||||
public enum MaterialAcceptStatus {
|
||||
/**
|
||||
* 已验收
|
||||
*/
|
||||
accepted,
|
||||
/**
|
||||
* 部分验收
|
||||
*/
|
||||
partAccepted,
|
||||
/**
|
||||
* 未验收
|
||||
*/
|
||||
notAccepted
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zt.plat.module.qms.resource.material.enums;
|
||||
|
||||
/**
|
||||
* 物料库存预警等级
|
||||
*
|
||||
*/
|
||||
public enum MaterialInventoryAlarmLevel {
|
||||
/**
|
||||
* 安全
|
||||
*/
|
||||
safe,
|
||||
/**
|
||||
* 警告
|
||||
*/
|
||||
warn,
|
||||
/**
|
||||
* 危险
|
||||
*/
|
||||
danger
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.zt.plat.module.qms.resource.material.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zt.plat.framework.common.exception.ServiceException;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
@@ -13,6 +16,7 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductSav
|
||||
import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialProductQueryVO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
|
||||
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialProductMapper;
|
||||
import com.zt.plat.module.qms.resource.material.enums.MaterialInventoryAlarmLevel;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@@ -41,9 +45,6 @@ public class MaterialProductServiceImpl implements MaterialProductService {
|
||||
@Resource
|
||||
private MaterialProductMapper materialProductMapper;
|
||||
|
||||
// @Autowired
|
||||
// private MaterialBatchService materialBatchService;
|
||||
|
||||
@Autowired
|
||||
private MaterialInfomationService materialInfomationService;
|
||||
|
||||
@@ -332,12 +333,35 @@ public class MaterialProductServiceImpl implements MaterialProductService {
|
||||
for (MaterialProductRespVO vo : voList) {
|
||||
Long val = stockQuantityMap.get(vo.getId());
|
||||
vo.setInventoryQuantity(BigDecimal.valueOf(val == null ? 0L : val));
|
||||
vo.setInventoryAlarmLevel(getAlarmLevel(vo));
|
||||
}
|
||||
}
|
||||
|
||||
return new PageResult<>(voList, pageResult.getTotal());
|
||||
}
|
||||
|
||||
private String getAlarmLevel(MaterialProductRespVO vo) {
|
||||
String customConfig = vo.getCustomConfig();
|
||||
String alarmLevel = null;
|
||||
if (StrUtil.isNotEmpty(customConfig) && vo.getInventoryAlarmFlag() == 1) {
|
||||
JSONObject alarmRange = JSONUtil.parseObj(customConfig).getJSONObject("alarmRange");
|
||||
if (alarmRange != null) {
|
||||
// BigDecimal[] safeRange = (BigDecimal[]) alarmRange.get(MaterialInventoryAlarmLevel.safe.name());
|
||||
List<BigDecimal> dangerRange = alarmRange.getJSONArray(MaterialInventoryAlarmLevel.danger.name()).toList(BigDecimal.class);
|
||||
List<BigDecimal> warnRange = alarmRange.getJSONArray(MaterialInventoryAlarmLevel.warn.name()).toList(BigDecimal.class);
|
||||
BigDecimal inventoryQuantity = vo.getInventoryQuantity();
|
||||
if (inventoryQuantity.compareTo(dangerRange.get(1)) <= 0) {
|
||||
alarmLevel = MaterialInventoryAlarmLevel.danger.name();
|
||||
} else if (inventoryQuantity.compareTo(warnRange.get(1)) <= 0) {
|
||||
alarmLevel = MaterialInventoryAlarmLevel.warn.name();
|
||||
} else {
|
||||
alarmLevel = MaterialInventoryAlarmLevel.safe.name();
|
||||
}
|
||||
}
|
||||
}
|
||||
return alarmLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterialProductDO> getMaterialProductsByLikeIdPath(Long pdtId) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user