1.修改库存预警设置相关代码,增加批量添加设置和库存ID新增预警设置接口

master
x_z 2 years ago
parent 6789710d90
commit cbe589c377

@ -12,10 +12,7 @@ import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.res.inv.InvRemindSetResponse;
import com.glxp.api.service.inv.InvRemindSetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@ -54,6 +51,17 @@ public class InvRemindSetController {
return invRemindSetService.addInvRemindSet(addInvRemindSetRequest);
}
/**
*
*
* @param addInvRemindSetRequest
* @return
*/
@PostMapping("/udiwms/inv/remind/set/batchAddInvRemindSet")
public BaseResponse batchAddInvRemindSet(@RequestBody AddInvRemindSetRequest addInvRemindSetRequest) {
return invRemindSetService.batchAddInvRemindSet(addInvRemindSetRequest);
}
/**
*
*
@ -86,11 +94,11 @@ public class InvRemindSetController {
* @return
*/
@GetMapping("/udiwms/inv/remind/set/getInfoByInvId")
public BaseResponse getInfoByInvId(Integer invId) {
if (null == invId) {
public BaseResponse getInfoByInvId(FilterInvRemindSetRequest filterInvRemindSetRequest) {
if (null == filterInvRemindSetRequest || null == filterInvRemindSetRequest.getInvId()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return invRemindSetService.getInfoByInvId(invId);
return invRemindSetService.getInfoByInvId(filterInvRemindSetRequest.getInvId());
}
}

@ -90,6 +90,12 @@ public class InvRemindSetEntity {
@TableField(value = "updateTime")
private Date updateTime;
/**
* 0 1
*/
@TableField(value = "`status`")
private Integer status;
@Override
public String toString() {
return "InvRemindSetEntity{" +

@ -2,6 +2,8 @@ package com.glxp.api.req.inv;
import lombok.Data;
import java.util.List;
/**
*
*/
@ -64,5 +66,10 @@ public class AddInvRemindSetRequest {
*
*/
private String remark;
/**
* ID
*/
private List<String> relIdList;
}

@ -24,4 +24,14 @@ public class FilterInvRemindSetRequest extends ListPageRequest {
*/
private String invSpaceCode;
/**
* ID
*/
private Integer invId;
/**
* 0 1
*/
private Integer status;
}

@ -99,4 +99,10 @@ public class InvRemindSetResponse {
* 12
*/
private Integer isDateBy;
/**
* 0 1
*/
private Integer status;
}

@ -52,4 +52,12 @@ public interface InvRemindSetService {
* @return
*/
BaseResponse getInfoByInvId(Integer invId);
/**
*
*
* @param addInvRemindSetRequest
* @return
*/
BaseResponse batchAddInvRemindSet(AddInvRemindSetRequest addInvRemindSetRequest);
}

@ -1,12 +1,16 @@
package com.glxp.api.service.inv.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.dao.inv.InvRemindSetDao;
import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.inv.InvRemindSetEntity;
import com.glxp.api.req.inv.AddInvRemindSetRequest;
import com.glxp.api.req.inv.FilterInvRemindSetRequest;
@ -14,6 +18,10 @@ import com.glxp.api.res.inv.InvRemindSetResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.inv.InvRemindSetService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.TransactionIsolationLevel;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -31,6 +39,10 @@ public class InvRemindSetServiceImpl implements InvRemindSetService {
private InvRemindSetDao invRemindSetDao;
@Resource
private CustomerService customerService;
@Resource
private UdiRelevanceDao udiRelevanceDao;
@Resource
private SqlSessionFactory sqlSessionFactory;
@Override
public List<InvRemindSetResponse> filterList(FilterInvRemindSetRequest filterInvRemindSetRequest) {
@ -51,18 +63,66 @@ public class InvRemindSetServiceImpl implements InvRemindSetService {
if (false == addInvRemindSetRequest.getLowStock() && false == addInvRemindSetRequest.getLackStock() && false == addInvRemindSetRequest.getOverStock() && false == addInvRemindSetRequest.getExpireDate() && false == addInvRemindSetRequest.getRecentDate()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "预警设置至少开启一项预警!");
}
InvRemindSetEntity invRemindSetEntity = new InvRemindSetEntity();
BeanUtil.copyProperties(addInvRemindSetRequest, invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.insert(invRemindSetEntity);
//查询此设置项是否已经存在,若已经存在,则直接覆盖,没有则新增
InvRemindSetEntity invRemindSetEntity = invRemindSetDao.selectOne(new QueryWrapper<InvRemindSetEntity>()
.eq("invCode", addInvRemindSetRequest.getInvCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getInvSpaceCode()), "invSpaceCode", addInvRemindSetRequest.getInvSpaceCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getRelId()), "relId", addInvRemindSetRequest.getRelId())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getGgxh()), "ggxh", addInvRemindSetRequest.getGgxh())
);
if (null == invRemindSetEntity) {
invRemindSetEntity = new InvRemindSetEntity();
BeanUtil.copyProperties(addInvRemindSetRequest, invRemindSetEntity);
verifySetParams(invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.insert(invRemindSetEntity);
} else {
//设置预警参数设置
invRemindSetEntity.setLackStock(addInvRemindSetRequest.getLackStock());
invRemindSetEntity.setLowStock(addInvRemindSetRequest.getLowStock());
invRemindSetEntity.setOverStock(addInvRemindSetRequest.getOverStock());
invRemindSetEntity.setExpireDate(addInvRemindSetRequest.getExpireDate());
invRemindSetEntity.setRecentDate(addInvRemindSetRequest.getRecentDate());
//校验预警参数是否符合开启条件
verifySetParams(invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.updateById(invRemindSetEntity);
}
return ResultVOUtils.success("添加成功");
}
/**
*
*
* @param invRemindSetEntity
*/
private void verifySetParams(InvRemindSetEntity invRemindSetEntity) {
//判断开启的预警设置,是否有设置对应的参数,若未设置,则修改状态为不启用
if (null != invRemindSetEntity.getRelId()) {
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceDao.selectRemindParams(Long.valueOf(invRemindSetEntity.getRelId()));
if (null == udiRelevanceEntity) {
invRemindSetEntity.setStatus(0);
} else {
if (invRemindSetEntity.getLowStock() && null == udiRelevanceEntity.getLowStockNum()) {
invRemindSetEntity.setStatus(0);
} else if (invRemindSetEntity.getOverStock() && null == udiRelevanceEntity.getOverStockNum()) {
invRemindSetEntity.setStatus(0);
} else if (invRemindSetEntity.getRecentDate() && null == udiRelevanceEntity.getRecentDateTime()) {
invRemindSetEntity.setStatus(0);
} else {
invRemindSetEntity.setStatus(1);
}
}
}
}
@Override
public BaseResponse updateInvRemindSet(InvRemindSetEntity invRemindSetEntity) {
if (false == invRemindSetEntity.getLowStock() && false == invRemindSetEntity.getLackStock() && false == invRemindSetEntity.getOverStock() && false == invRemindSetEntity.getExpireDate() && false == invRemindSetEntity.getRecentDate()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "预警设置至少开启一项预警!");
}
verifySetParams(invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.updateById(invRemindSetEntity);
return ResultVOUtils.success("更新成功");
@ -81,7 +141,7 @@ public class InvRemindSetServiceImpl implements InvRemindSetService {
public BaseResponse getInfoByInvId(Integer invId) {
InvRemindSetResponse response = invRemindSetDao.selectInfoByInvId(invId);
if (null != response) {
if (response.getIsDateBy() == 1) {
if (response.getIsDateBy() == 1 && null != response.getRecentDateTime()) {
//将近效期预警值由小时换算成天
response.setRecentDateTime(response.getRecentDateTime() / 24);
}
@ -90,6 +150,55 @@ public class InvRemindSetServiceImpl implements InvRemindSetService {
return ResultVOUtils.error(500, "未查询到指定的库存产品信息");
}
@Override
public BaseResponse batchAddInvRemindSet(AddInvRemindSetRequest addInvRemindSetRequest) {
if (CollUtil.isNotEmpty(addInvRemindSetRequest.getRelIdList())) {
//生成多条库存预警设置
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
addInvRemindSetRequest.getRelIdList().forEach(relId -> {
//查询此产品是否存在预警设置
//查询此设置项是否已经存在,若已经存在,则直接覆盖,没有则新增
InvRemindSetEntity invRemindSetEntity = invRemindSetDao.selectOne(new QueryWrapper<InvRemindSetEntity>()
.eq("invCode", addInvRemindSetRequest.getInvCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getInvSpaceCode()), "invSpaceCode", addInvRemindSetRequest.getInvSpaceCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getRelId()), "relId", addInvRemindSetRequest.getRelId())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getGgxh()), "ggxh", addInvRemindSetRequest.getGgxh())
);
if (null == invRemindSetEntity) {
invRemindSetEntity = new InvRemindSetEntity();
BeanUtil.copyProperties(addInvRemindSetRequest, invRemindSetEntity);
verifySetParams(invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.insert(invRemindSetEntity);
} else {
//校验预警参数是否符合开启条件
verifySetParams(invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.updateById(invRemindSetEntity);
}
});
sqlSession.commit();
sqlSession.close();
} else {
//只选择了仓库货位信息,未选择产品列表,直接添加单条预警设置
//查询有无相同设置,有则更新时间
InvRemindSetEntity invRemindSetEntity = invRemindSetDao.selectOne(new QueryWrapper<InvRemindSetEntity>()
.eq("invCode", addInvRemindSetRequest.getInvCode())
.eq(StrUtil.isNotBlank(addInvRemindSetRequest.getInvSpaceCode()), "invSpaceCode", addInvRemindSetRequest.getInvSpaceCode()));
if (null == invRemindSetEntity) {
invRemindSetEntity = new InvRemindSetEntity();
BeanUtil.copyProperties(addInvRemindSetRequest, invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.insert(invRemindSetEntity);
} else {
verifySetParams(invRemindSetEntity);
setUpdateInfo(invRemindSetEntity);
invRemindSetDao.updateById(invRemindSetEntity);
}
}
return ResultVOUtils.success("添加成功");
}
/**
*
*

@ -3,6 +3,7 @@ package com.glxp.api.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.thread.ExecutorBuilder;
import cn.hutool.core.thread.ThreadUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.glxp.api.dao.inv.InvRemindSetDao;
import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.entity.inv.InvRemindSetEntity;
@ -59,7 +60,7 @@ public class InvRemindMsgTask implements SchedulingConfigurer {
private void process() {
log.info("开始扫描库存信息,生成库存预警消息");
List<InvRemindSetEntity> invRemindSetEntities = invRemindSetDao.selectList(null);
List<InvRemindSetEntity> invRemindSetEntities = invRemindSetDao.selectList(new QueryWrapper<InvRemindSetEntity>().eq("status", 1));
if (CollUtil.isNotEmpty(invRemindSetEntities)) {
log.info("库存预警设置条数:{}", invRemindSetEntities.size());
//开始生成库存信息

@ -30,19 +30,24 @@
<if test="invSpaceCode != null and invSpaceCode != ''">
AND irs.invSpaceCode = #{invSpaceCode}
</if>
<if test="status != null">
AND irs.status = #{status}
</if>
</where>
order by irs.updateTime desc
</select>
<select id="selectInfoByInvId" resultType="com.glxp.api.res.inv.InvRemindSetResponse">
select ip.relIdFk relId,
select ip.relIdFk relId,
ip.deptCode,
ip.invCode,
ipd.invSpaceCode,
(select `name` from auth_warehouse where code = ip.invCode) invName,
(select `name` from auth_space where code = ipd.invSpaceCode and invWarehouseCode = ip.invCode) invSpaceName,
(select `name` from auth_warehouse where code = ip.invCode) invName,
(select `name`
from auth_space
where code = ipd.invSpaceCode and invWarehouseCode = ip.invCode) invSpaceName,
bp.ggxh,
bp.cpmctymc productName,
bp.cpmctymc productName,
bu.lowStockNum,
bu.overStockNum,
bu.recentDateTime,
@ -54,5 +59,6 @@
on ip.relIdFk = ipd.relId and IFNULL(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
and ip.invCode = ipd.invCode
where ip.id = #{invId}
group by ip.id
</select>
</mapper>

@ -367,6 +367,9 @@
#{item}
</foreach>
</if>
<if test="supName != null and supName != ''">
AND basic_corp.name like concat('%', #{supName}, '%')
</if>
</where>
group by ip.relIdFk
order by ip.updateTime desc

Loading…
Cancel
Save