|
|
@ -1,11 +1,10 @@ |
|
|
|
package com.win.module.wms.service.balance; |
|
|
|
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.mybatis.core.util.MyBatisUtils; |
|
|
|
import com.win.framework.mybatis.core.util.QueryWrapperUtils; |
|
|
|
import com.win.module.system.api.dict.DictDataApi; |
|
|
|
import com.win.module.system.api.dict.dto.DictDataRespDTO; |
|
|
|
import com.win.module.system.api.user.AdminUserApi; |
|
|
@ -14,6 +13,7 @@ import com.win.module.wms.controller.balance.vo.BalancePageReqVO; |
|
|
|
import com.win.module.wms.controller.balance.vo.BalanceRespVO; |
|
|
|
import com.win.module.wms.controller.balance.vo.BalanceUpdateReqVO; |
|
|
|
import com.win.module.wms.controller.packageMassage.vo.PackageUpdateReqVO; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleRespVO; |
|
|
|
import com.win.module.wms.controller.transaction.vo.TransactionCreateReqVO; |
|
|
|
import com.win.module.wms.convert.balance.BalanceConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.balance.BalanceDO; |
|
|
@ -22,6 +22,7 @@ import com.win.module.wms.dal.dataobject.transactiontype.TransactiontypeDO; |
|
|
|
import com.win.module.wms.dal.mysql.balance.BalanceMapper; |
|
|
|
import com.win.module.wms.dal.mysql.packageMassage.PackageMapper; |
|
|
|
import com.win.module.wms.service.packageMassage.PackageService; |
|
|
|
import com.win.module.wms.service.rule.RuleService; |
|
|
|
import com.win.module.wms.service.transaction.TransactionService; |
|
|
|
import com.win.module.wms.util.JobUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
@ -30,8 +31,11 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
|
|
@ -59,6 +63,8 @@ public class BalanceServiceImpl implements BalanceService { |
|
|
|
@Resource |
|
|
|
private BalanceMapper balanceMapper; |
|
|
|
@Resource |
|
|
|
private RuleService ruleService; |
|
|
|
@Resource |
|
|
|
private DictDataApi dictDataApi; |
|
|
|
|
|
|
|
@Override |
|
|
@ -143,7 +149,6 @@ public class BalanceServiceImpl implements BalanceService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<BalanceDO> selectPackaging(String itemCode, String packingNumber, String batch, List<String> inventoryStatus, String locationCode) { |
|
|
|
|
|
|
|
QueryWrapper<BalanceDO> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("item_code", itemCode); |
|
|
|
queryWrapper.eq("packing_number", packingNumber); |
|
|
@ -272,7 +277,6 @@ public class BalanceServiceImpl implements BalanceService { |
|
|
|
DictDataRespDTO dictDataRespDTO = dictDataApi.selectDictTypeAndLabel("stagnant_time", "默认时间(天)"); |
|
|
|
QueryWrapper<BalanceDO> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.apply(" DATEDIFF(NOW(), arrive_date) > {0}", dictDataRespDTO.getValue()); |
|
|
|
queryWrapper.last("LIMIT 10"); |
|
|
|
List<BalanceDO> balanceDOList = balanceMapper.selectList(queryWrapper); |
|
|
|
return BalanceConvert.INSTANCE.convertList(balanceDOList); |
|
|
|
} |
|
|
@ -281,8 +285,36 @@ public class BalanceServiceImpl implements BalanceService { |
|
|
|
public List<BalanceRespVO> getOverdueBalanceList() { |
|
|
|
QueryWrapper<BalanceDO> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.apply("expire_date>NOW()"); |
|
|
|
queryWrapper.last("LIMIT 10"); |
|
|
|
List<BalanceDO> balanceDOList = balanceMapper.selectList(queryWrapper); |
|
|
|
return BalanceConvert.INSTANCE.convertList(balanceDOList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<BalanceRespVO> getWarningBalanceList() { |
|
|
|
List<BalanceDO> balanceDOList = balanceMapper.selectList(new QueryWrapper<>()); |
|
|
|
List<BalanceRespVO> balanceRespVOList = new ArrayList<>(); |
|
|
|
//存储规则,防止同一个规则取多次
|
|
|
|
Map<String, RuleRespVO> ruleRespVOHashMap = new HashMap<>(); |
|
|
|
for(BalanceDO balanceDO : balanceDOList) { |
|
|
|
RuleRespVO ruleRespVO = ruleRespVOHashMap.get(balanceDO.getItemCode() + "_" + balanceDO.getLocationCode()); |
|
|
|
if(ruleRespVO == null) { |
|
|
|
ruleRespVO = ruleService.replenishment(balanceDO.getItemCode(), balanceDO.getLocationCode()); |
|
|
|
if (ruleRespVO == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
ruleRespVOHashMap.put(balanceDO.getItemCode() + "_" + balanceDO.getLocationCode(), ruleRespVO); |
|
|
|
} |
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(ruleRespVO.getConfiguration()); |
|
|
|
//最大库存和最小库存,超过预警
|
|
|
|
int maxQty = Integer.parseInt(jsonObject.getStr("MaxQty")); |
|
|
|
int minQty = Integer.parseInt(jsonObject.getStr("MinQty")); |
|
|
|
if(maxQty > 0 && balanceDO.getQty().compareTo(new BigDecimal(maxQty)) > 0) { |
|
|
|
balanceRespVOList.add(BalanceConvert.INSTANCE.convert(balanceDO)); |
|
|
|
} |
|
|
|
if(minQty > 0 && balanceDO.getQty().compareTo(new BigDecimal(minQty)) < 0) { |
|
|
|
balanceRespVOList.add(BalanceConvert.INSTANCE.convert(balanceDO)); |
|
|
|
} |
|
|
|
} |
|
|
|
return balanceRespVOList; |
|
|
|
} |
|
|
|
} |
|
|
|