| | |
| | | package org.jeecg.modules.tms.controller; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.tms.entity.BaseTools; |
| | | import org.jeecg.modules.tms.entity.ToolLedger; |
| | | import org.jeecg.modules.tms.entity.ToolsConfigProperty; |
| | | import org.jeecg.modules.tms.service.IBaseToolsService; |
| | | import org.jeecg.modules.tms.service.IToolLedgerService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecg.modules.tms.service.IToolsConfigPropertyService; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | |
| | | public class ToolLedgerController extends JeecgController<ToolLedger, IToolLedgerService> { |
| | | @Autowired |
| | | private IToolLedgerService toolLedgerService; |
| | | @Autowired |
| | | private IToolsConfigPropertyService toolsConfigPropertyService; |
| | | @Autowired |
| | | private IBaseToolsService baseToolsService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | @ApiOperation(value="tms_tool_ledger-库存预警", notes = "tms_tool_ledger-库存预警") |
| | | @GetMapping(value = "/toolsStockWarning") |
| | | public Result<?> toolsStockWarning() { |
| | | List<ToolLedger> toolLedgerList = toolLedgerService.list(); |
| | | Map<String, ToolLedger> toolLedgerMap = toolLedgerList.stream() |
| | | .collect(Collectors.toMap(ToolLedger::getToolId, item -> item, (k1, k2) -> k1)); |
| | | Map<String, ToolsConfigProperty> toolsConfigPropertyMap = toolsConfigPropertyService.list(new LambdaQueryWrapper<ToolsConfigProperty>() |
| | | .in(ToolsConfigProperty::getToolCode, toolLedgerMap.keySet()).eq(ToolsConfigProperty::getStatus, CommonConstant.STATUS_1)) |
| | | .stream().collect(Collectors.toMap(ToolsConfigProperty::getToolCode, item -> item, (k1, k2) -> k1)); |
| | | List<String> warningMsg = CollectionUtil.newArrayList(); |
| | | for (String toolCode : toolsConfigPropertyMap.keySet()) { |
| | | ToolsConfigProperty configProperty = toolsConfigPropertyMap.get(toolCode); |
| | | if (Objects.nonNull(configProperty.getLowerInventory()) && Objects.nonNull(configProperty.getHighestInventory())) { |
| | | ToolLedger toolLedger = toolLedgerMap.get(toolCode); |
| | | if (Objects.nonNull(toolLedger)) { |
| | | BigDecimal totalCount = toolLedger.getTotalCount(); |
| | | BaseTools tools = baseToolsService.getById(toolCode); |
| | | if (totalCount.compareTo(configProperty.getLowerInventory()) < 0) { |
| | | warningMsg.add("编码为【" + tools.getToolCode() + "】的工具,库存低于库存下限!"); |
| | | } |
| | | if (totalCount.compareTo(configProperty.getHighestInventory()) > 0) { |
| | | warningMsg.add("编码为【" + tools.getToolCode() + "】的工具,库存高于库存上限!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return Result.OK(warningMsg); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |