Commit 27ba095ca3045c9c5fb60935718547007001a617

Authored by 周峰
1 parent 16c8f286

增加库存水位查询页面,预警消息增加连接跳转

ant-design-vue-jeecg/src/views/system/inventory/InventoryLevelAlarmList.vue 0 → 100644
  1 +<template>
  2 + <a-card :bordered="false">
  3 + <!-- 查询区域 -->
  4 + <div class="table-page-search-wrapper">
  5 + <a-form layout="inline" @keyup.enter.native="searchQuery">
  6 + <a-row :gutter="24">
  7 + <a-col :xl="6" :lg="7" :md="8" :sm="24">
  8 + <a-form-item label="物料编码">
  9 + <a-input placeholder="请输入物料编码" v-model="queryParam.materialCode"></a-input>
  10 + </a-form-item>
  11 + </a-col>
  12 + <a-col :xl="6" :lg="7" :md="8" :sm="24">
  13 + <a-form-item label="物料名称">
  14 + <a-input placeholder="请输入物料名称" v-model="queryParam.materialName"></a-input>
  15 + </a-form-item>
  16 + </a-col>
  17 + <a-col :xl='6' :lg='7' :md='8' :sm='24'>
  18 + <a-form-item label='预警状态'>
  19 + <a-select show-search placeholder='请选择预警状态' option-filter-prop='children' v-model='queryParam.alarmStatus'>
  20 + <a-select-option v-for='item in alarmStatusList' :key='item.name' :value='item.code'>
  21 + {{ item.name }}
  22 + </a-select-option>
  23 + </a-select>
  24 + </a-form-item>
  25 + </a-col>
  26 + <a-col :xl="6" :lg="7" :md="8" :sm="24">
  27 + <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  28 + <a-button id="search" type="primary" @click="searchQuery" icon="search">查询</a-button>
  29 + <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  30 + </span>
  31 + </a-col>
  32 + </a-row>
  33 + </a-form>
  34 + </div>
  35 + <!-- 查询区域-END -->
  36 +
  37 + <!-- 操作按钮区域 -->
  38 + <div class="table-operator" style="display: none">
  39 + <a-button type="primary" icon="download" @click="handleExportXls('inventory_level_alarm')">导出</a-button>
  40 + </div>
  41 +
  42 + <!-- table区域-begin -->
  43 + <div>
  44 + <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  45 + <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
  46 + style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  47 + <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  48 + </div>
  49 +
  50 + <a-table
  51 + ref="table"
  52 + size="middle"
  53 + :scroll="{x:true}"
  54 + bordered
  55 + rowKey="id"
  56 + :columns="columns"
  57 + :dataSource="dataSource"
  58 + :pagination="ipagination"
  59 + :loading="loading"
  60 + :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  61 + class="j-table-force-nowrap"
  62 + @change="handleTableChange">
  63 +
  64 + <span slot="min" slot-scope="text, record">
  65 + <a-tag :key="record" :color="minColor(record)">
  66 + {{ minStatus(record) }}
  67 + </a-tag>
  68 + </span>
  69 +
  70 + <span slot="max" slot-scope="text, record">
  71 + <a-tag :key="record" :color="maxColor(record)">
  72 + {{ maxStatus(record) }}
  73 + </a-tag>
  74 + </span>
  75 +
  76 + <span slot="qtySum" slot-scope="text, record">
  77 + <a-tag :key="record" :color="qtySumColor(record)">
  78 + {{ qtySumStatus(record) }}
  79 + </a-tag>
  80 + </span>
  81 +
  82 + <span slot="upper" slot-scope="text, record">
  83 + <a-tag :key="record" :color="upperColor(record)">
  84 + {{ record.upper }}
  85 + </a-tag>
  86 + </span>
  87 +
  88 + <span slot="lower" slot-scope="text, record">
  89 + <a-tag :key="record" :color="lowerColor(record)">
  90 + {{ record.lower }}
  91 + </a-tag>
  92 + </span>
  93 +
  94 + <template slot="htmlSlot" slot-scope="text">
  95 + <div v-html="text"></div>
  96 + </template>
  97 + <template slot="imgSlot" slot-scope="text">
  98 + <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
  99 + <img v-else :src="getImgView(text)" height="25px" alt=""
  100 + style="max-width:80px;font-size: 12px;font-style: italic;"/>
  101 + </template>
  102 + <template slot="fileSlot" slot-scope="text">
  103 + <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
  104 + <a-button
  105 + v-else
  106 + :ghost="true"
  107 + type="primary"
  108 + icon="download"
  109 + size="small"
  110 + @click="downloadFile(text)">
  111 + 下载
  112 + </a-button>
  113 + </template>
  114 +
  115 + </a-table>
  116 + </div>
  117 + </a-card>
  118 +</template>
  119 +
  120 +<script>
  121 +
  122 +import '@/assets/less/TableExpand.less'
  123 +import {mixinDevice} from '@/utils/mixin'
  124 +import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  125 +
  126 +export default {
  127 + name: 'InventoryLevelAlarmList',
  128 + mixins: [JeecgListMixin, mixinDevice],
  129 + components: {},
  130 + queryParam: {
  131 + materialName2:""
  132 + },
  133 + data() {
  134 + return {
  135 + description: '库存水位预警',
  136 + // alarmStatusList:['所有', '无预警', '有预警', '上限预警', '下限预警'],
  137 + alarmStatusList:[
  138 + {'name':'所有', 'code':'all'},
  139 + {'name':'无预警', 'code':'noAlarm'},
  140 + {'name':'有预警', 'code':'isAlarm'},
  141 + {'name':'上限预警', 'code':'upperAlarm'},
  142 + {'name':'下限预警', 'code':'lowerAlarm'}],
  143 + // 表头
  144 + columns: [
  145 + {
  146 + title: '#',
  147 + dataIndex: '',
  148 + key: 'rowIndex',
  149 + width: 60,
  150 + align: "center",
  151 + customRender: function (t, r, index) {
  152 + return parseInt(index) + 1;
  153 + }
  154 + },
  155 + {
  156 + title: '物料编码',
  157 + align: "center",
  158 + dataIndex: 'materialCode'
  159 + },
  160 + {
  161 + title: '物料名称',
  162 + align: "center",
  163 + dataIndex: 'materialName'
  164 + },
  165 + {
  166 + title: '最小值',
  167 + align: "center",
  168 + dataIndex: 'min',
  169 + scopedSlots: {customRender: 'min'}
  170 + },
  171 + {
  172 + title: '下限预警值',
  173 + align: "center",
  174 + dataIndex: 'lower',
  175 + scopedSlots: {customRender: 'lower'}
  176 + },
  177 + {
  178 + title: '库存数量',
  179 + align: "center",
  180 + dataIndex: 'qtySum',
  181 + scopedSlots: {customRender: 'qtySum'}
  182 + },
  183 + {
  184 + title: '上限预警值',
  185 + align: "center",
  186 + dataIndex: 'upper',
  187 + scopedSlots: {customRender: 'upper'}
  188 + },
  189 + {
  190 + title: '最大值',
  191 + align: "center",
  192 + dataIndex: 'max',
  193 + scopedSlots: {customRender: 'max'}
  194 + },
  195 + {
  196 + title: '物料规格',
  197 + align: "center",
  198 + dataIndex: 'materialSpec'
  199 + },
  200 + {
  201 + title: '物料单位',
  202 + align: "center",
  203 + dataIndex: 'materialUnit'
  204 + },
  205 + {
  206 + title: '仓库编码',
  207 + align: "center",
  208 + dataIndex: 'warehouseCode'
  209 + },
  210 + {
  211 + title: '货主编码',
  212 + align: "center",
  213 + dataIndex: 'companyCode'
  214 + },
  215 + {
  216 + title: '备注',
  217 + align: "center",
  218 + dataIndex: 'remark'
  219 + },
  220 + ],
  221 + url: {
  222 + list: "/inventory/inventoryLevel/list",
  223 + exportXlsUrl: "/inventory/inventoryLevel/exportXls",
  224 + },
  225 + dictOptions: {},
  226 + superFieldList: [],
  227 + }
  228 + },
  229 + created() {
  230 + this.getSuperFieldList();
  231 + },
  232 + computed: {
  233 + importExcelUrl: function () {
  234 + return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  235 + },
  236 + },
  237 + methods: {
  238 + initDictConfig() {
  239 + },
  240 + qtySumStatus(record) {
  241 + if(record.qtySum <= record.lower){
  242 + return record.qtySum + " 🠋"
  243 + }
  244 + if(record.qtySum >= record.upper){
  245 + return record.qtySum + " 🠉"
  246 + }
  247 + return record.qtySum;
  248 + },
  249 + qtySumColor(record) {
  250 + if(record.qtySum > record.upper || record.qtySum < record.lower){
  251 + return 'red';
  252 + }
  253 + return '';
  254 + },
  255 +
  256 + lowerColor(record) {
  257 + if(record.qtySum <= record.lower){
  258 + return 'blue';
  259 + }
  260 + return '';
  261 + },
  262 +
  263 + upperColor(record) {
  264 + if(record.qtySum >= record.upper){
  265 + return 'blue';
  266 + }
  267 + return '';
  268 + },
  269 +
  270 + maxColor(record) {
  271 + if(record.qtySum >= record.max){
  272 + return 'blue';
  273 + }
  274 + return '';
  275 + },
  276 +
  277 + minColor(record) {
  278 + if(record.qtySum <= record.min){
  279 + return 'blue';
  280 + }
  281 + return '';
  282 + },
  283 +
  284 + minStatus(record) {
  285 + if(record.min <= 0){
  286 + return ''
  287 + }
  288 + return record.min;
  289 + },
  290 +
  291 + maxStatus(record) {
  292 + if(record.max <= 0){
  293 + return '';
  294 + }
  295 + return record.max;
  296 + },
  297 + getSuperFieldList() {
  298 + let fieldList = [];
  299 + fieldList.push({type: 'string', value: 'alarmType', text: '预警类别代码'})
  300 + fieldList.push({type: 'string', value: 'warehouseCode', text: '仓库编码'})
  301 + fieldList.push({type: 'string', value: 'companyCode', text: '货主编码'})
  302 + fieldList.push({type: 'string', value: 'materialCode', text: '物料编码'})
  303 + fieldList.push({type: 'string', value: 'materialName', text: '物料名称'})
  304 + fieldList.push({type: 'string', value: 'materialSpec', text: '物料规格'})
  305 + fieldList.push({type: 'string', value: 'materialUnit', text: '物料单位'})
  306 + fieldList.push({type: 'int', value: 'qtysum', text: 'qtysum'})
  307 + fieldList.push({type: 'int', value: 'inlower', text: 'inlower'})
  308 + fieldList.push({type: 'int', value: 'inupper', text: 'inupper'})
  309 + fieldList.push({type: 'int', value: 'inmin', text: 'inmin'})
  310 + fieldList.push({type: 'int', value: 'inmax', text: 'inmax'})
  311 + fieldList.push({type: 'int', value: 'needalarm', text: 'needalarm'})
  312 + fieldList.push({type: 'int', value: 'max', text: '最大'})
  313 + fieldList.push({type: 'int', value: 'min', text: '最小'})
  314 + fieldList.push({type: 'int', value: 'upper', text: '上限预警值'})
  315 + fieldList.push({type: 'int', value: 'lower', text: '下限预警值'})
  316 + fieldList.push({type: 'string', value: 'remark', text: '备注'})
  317 + fieldList.push({type: 'string', value: 'userdef1', text: '备用字段1'})
  318 + fieldList.push({type: 'string', value: 'userdef2', text: '备用字段2'})
  319 + fieldList.push({type: 'string', value: 'userdef3', text: '备用字段3'})
  320 + this.superFieldList = fieldList
  321 + }
  322 + }
  323 +}
  324 +</script>
  325 +<style scoped>
  326 +@import '~@assets/less/common.less';
  327 +</style>
0 \ No newline at end of file 328 \ No newline at end of file
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/materialWarning/service/IMaterialWarningService.java
1 package org.jeecg.modules.wms.config.materialWarning.service; 1 package org.jeecg.modules.wms.config.materialWarning.service;
2 2
3 import com.baomidou.mybatisplus.extension.service.IService; 3 import com.baomidou.mybatisplus.extension.service.IService;
4 -import org.jeecg.modules.wms.config.materialWarning.entity.MaterialLevelAlarm;  
5 import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning; 4 import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning;
6 5
7 -import java.util.List;  
8 -  
9 /** 6 /**
10 * @Description: 物料预警 7 * @Description: 物料预警
11 * @Author: jeecg-boot 8 * @Author: jeecg-boot
@@ -14,5 +11,4 @@ import java.util.List; @@ -14,5 +11,4 @@ import java.util.List;
14 */ 11 */
15 public interface IMaterialWarningService extends IService<MaterialWarning> { 12 public interface IMaterialWarningService extends IService<MaterialWarning> {
16 13
17 - List<MaterialLevelAlarm> getLevelAlarm(String materialCode);  
18 } 14 }
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/materialWarning/service/impl/MaterialWarningServiceImpl.java
1 package org.jeecg.modules.wms.config.materialWarning.service.impl; 1 package org.jeecg.modules.wms.config.materialWarning.service.impl;
2 2
3 -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;  
4 -import org.jeecg.modules.wms.config.materialWarning.entity.MaterialLevelAlarm; 3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning; 4 import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning;
6 import org.jeecg.modules.wms.config.materialWarning.mapper.MaterialWarningMapper; 5 import org.jeecg.modules.wms.config.materialWarning.mapper.MaterialWarningMapper;
7 import org.jeecg.modules.wms.config.materialWarning.service.IMaterialWarningService; 6 import org.jeecg.modules.wms.config.materialWarning.service.IMaterialWarningService;
8 -import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail;  
9 -import org.jeecg.modules.wms.inventory.inventoryHeader.service.impl.InventoryDetailServiceImpl;  
10 -import org.jeecg.utils.StringUtils;  
11 -import org.jeecg.utils.constant.QuantityConstant;  
12 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
13 8
14 -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;  
15 -  
16 -import javax.annotation.Resource;  
17 -import java.math.BigDecimal;  
18 -import java.util.ArrayList;  
19 -import java.util.List;  
20 -import java.util.stream.Collectors;  
21 -  
22 /** 9 /**
23 * @Description: 物料预警 10 * @Description: 物料预警
24 * @Author: jeecg-boot 11 * @Author: jeecg-boot
@@ -28,26 +15,4 @@ import java.util.stream.Collectors; @@ -28,26 +15,4 @@ import java.util.stream.Collectors;
28 @Service 15 @Service
29 public class MaterialWarningServiceImpl extends ServiceImpl<MaterialWarningMapper, MaterialWarning> implements IMaterialWarningService { 16 public class MaterialWarningServiceImpl extends ServiceImpl<MaterialWarningMapper, MaterialWarning> implements IMaterialWarningService {
30 17
31 - @Resource  
32 - InventoryDetailServiceImpl inventoryDetailService;  
33 -  
34 - @Override  
35 - public List<MaterialLevelAlarm> getLevelAlarm(String materialCode) {  
36 - LambdaQueryWrapper<MaterialWarning> query = new LambdaQueryWrapper<>();  
37 - query.eq(StringUtils.isNotEmpty(materialCode), MaterialWarning::getMaterialCode, materialCode);  
38 - List<MaterialWarning> warningList = list(query);  
39 -  
40 - List<MaterialLevelAlarm> alarmList = new ArrayList<>();  
41 - warningList.forEach(w -> {  
42 - InventoryDetail d = new InventoryDetail();  
43 - d.setMaterialCode(w.getMaterialCode());  
44 - d.setCompanyCode(w.getCompanyCode());  
45 - d.setWarehouseCode(w.getWarehouseCode());  
46 - d.setInventoryStatus(QuantityConstant.QUALITY_GOOD);  
47 - BigDecimal sum = inventoryDetailService.getInventorySumQty(d);  
48 - alarmList.add(new MaterialLevelAlarm(w, sum));  
49 - });  
50 -  
51 - return alarmList.stream().filter(MaterialLevelAlarm::needAlarm).collect(Collectors.toList());  
52 - }  
53 } 18 }
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/controller/InventoryLevelAlarmController.java 0 → 100644
  1 +package org.jeecg.modules.wms.inventory.inventoryLevel.controller;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5 +import com.baomidou.mybatisplus.core.metadata.IPage;
  6 +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7 +import io.swagger.annotations.Api;
  8 +import io.swagger.annotations.ApiOperation;
  9 +import lombok.extern.slf4j.Slf4j;
  10 +import org.jeecg.common.api.vo.Result;
  11 +import org.jeecg.common.system.base.controller.JeecgController;
  12 +import org.jeecg.common.system.query.QueryGenerator;
  13 +import org.jeecg.modules.oss.entity.OSSFile;
  14 +import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning;
  15 +import org.jeecg.modules.wms.config.materialWarning.service.IMaterialWarningService;
  16 +import org.jeecg.modules.wms.inventory.inventoryLevel.entity.InventoryLevelAlarm;
  17 +import org.jeecg.modules.wms.inventory.inventoryLevel.service.IInventoryLevelAlarmService;
  18 +import org.jeecg.utils.StringUtils;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.web.bind.annotation.*;
  21 +import org.springframework.web.servlet.ModelAndView;
  22 +
  23 +import javax.servlet.http.HttpServletRequest;
  24 +import java.util.List;
  25 +import java.util.stream.Collectors;
  26 +
  27 +/**
  28 + * @Description: inventory_level_alarm
  29 + * @Author: jeecg-boot
  30 + * @Date: 2023-10-30
  31 + * @Version: V1.0
  32 + */
  33 +@Api(tags="inventory_level_alarm")
  34 +@RestController
  35 +@RequestMapping("/inventory/inventoryLevel")
  36 +@Slf4j
  37 +public class InventoryLevelAlarmController extends JeecgController<InventoryLevelAlarm, IInventoryLevelAlarmService> {
  38 + @Autowired
  39 + private IInventoryLevelAlarmService iInventoryLevelAlarmService;
  40 +
  41 + @Autowired
  42 + private IMaterialWarningService iMaterialWarningService;
  43 +
  44 + /**
  45 + * 分页列表查询
  46 + *
  47 + * @param inventoryLevelAlarm
  48 + * @param pageNo
  49 + * @param pageSize
  50 + * @param req
  51 + * @return
  52 + */
  53 + //@AutoLog(value = "inventory_level_alarm-分页列表查询")
  54 + @ApiOperation(value="inventory_level_alarm-分页列表查询", notes="inventory_level_alarm-分页列表查询")
  55 + @GetMapping(value = "/list")
  56 + public Result<IPage<InventoryLevelAlarm>> queryPageList(String materialCode, String materialName, String alarmStatus,
  57 + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
  58 + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
  59 + HttpServletRequest req) {
  60 +
  61 + Page<InventoryLevelAlarm> page = new Page<>(pageNo, pageSize);
  62 + IPage<InventoryLevelAlarm> pageList = iInventoryLevelAlarmService.queryLevelAlarm(page, materialCode, materialName, alarmStatus);
  63 + //对list分页处理
  64 + return Result.OK(pageList);
  65 + }
  66 +
  67 +
  68 + /**
  69 + * 通过id查询
  70 + *
  71 + * @param id
  72 + * @return
  73 + */
  74 + //@AutoLog(value = "inventory_level_alarm-通过id查询")
  75 + @ApiOperation(value="inventory_level_alarm-通过id查询", notes="inventory_level_alarm-通过id查询")
  76 + @GetMapping(value = "/queryById")
  77 + public Result<InventoryLevelAlarm> queryById(@RequestParam(name="id",required=true) String id) {
  78 + InventoryLevelAlarm inventoryLevelAlarm = iInventoryLevelAlarmService.getById(id);
  79 + if(inventoryLevelAlarm ==null) {
  80 + return Result.error("未找到对应数据");
  81 + }
  82 + return Result.OK(inventoryLevelAlarm);
  83 + }
  84 +
  85 + /**
  86 + * 导出excel
  87 + *
  88 + * @param request
  89 + * @param inventoryLevelAlarm
  90 + */
  91 + @RequestMapping(value = "/exportXls")
  92 + public ModelAndView exportXls(HttpServletRequest request, InventoryLevelAlarm inventoryLevelAlarm) {
  93 + return super.exportXls(request, inventoryLevelAlarm, InventoryLevelAlarm.class, "inventory_level_alarm");
  94 + }
  95 +
  96 +
  97 +}
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/materialWarning/entity/MaterialLevelAlarm.java renamed to huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/entity/InventoryLevelAlarm.java
1 -package org.jeecg.modules.wms.config.materialWarning.entity; 1 +package org.jeecg.modules.wms.inventory.inventoryLevel.entity;
2 2
3 import lombok.Data; 3 import lombok.Data;
  4 +import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning;
4 5
5 import java.math.BigDecimal; 6 import java.math.BigDecimal;
6 7
7 @Data 8 @Data
8 -public class MaterialLevelAlarm extends MaterialWarning { 9 +public class InventoryLevelAlarm extends MaterialWarning {
9 private int qtySum; 10 private int qtySum;
10 - //小于等于下线预警  
11 - private boolean inLower;  
12 - //小于等于上线预警  
13 - private boolean inUpper;  
14 11
15 - //小于等于最小值  
16 - private boolean inMin;  
17 - //大于等于最大值  
18 - private boolean inMax; 12 + public InventoryLevelAlarm(){
  13 +
  14 + }
19 15
20 /** 16 /**
21 - * 构造预警数据 17 + * 判断是否低于下限
22 **/ 18 **/
23 - public MaterialLevelAlarm(MaterialWarning warning, BigDecimal qtySum) {  
24 - org.springframework.beans.BeanUtils.copyProperties(warning, this);  
25 - this.qtySum = qtySum.intValue();  
26 - if (getLower() > 0) {  
27 - inLower = this.qtySum <= getLower();  
28 - }  
29 - if (getUpper() > 0) {  
30 - inUpper = this.qtySum >= getUpper();  
31 - } 19 + public boolean inLower() {
  20 + return this.qtySum <= getLower();
  21 + }
32 22
33 - if (getMin() > 0) {  
34 - inMin = this.qtySum <= getMin();  
35 - } 23 + /**
  24 + * 判断是否高于上限
  25 + **/
  26 + public boolean inUpper(){
  27 + return this.qtySum >= getUpper();
  28 + }
36 29
37 - if (getMax() > 0) {  
38 - inMax = this.qtySum >= getMax();  
39 - } 30 + /** 判断是否低于最小值 **/
  31 + public boolean inMin(){
  32 + return this.qtySum <= getMin();
  33 + }
  34 +
  35 + /** 判断是否高于最大值 **/
  36 + public boolean inMax(){
  37 + return this.qtySum >= getMax();
40 } 38 }
41 39
42 /** 40 /**
43 * 判断是否有预警 41 * 判断是否有预警
44 **/ 42 **/
45 public Boolean needAlarm() { 43 public Boolean needAlarm() {
46 - return inLower || inUpper || inMin || inMax; 44 + return inLower() || inUpper() || inMin() || inMax();
47 } 45 }
48 46
49 @Override 47 @Override
50 public String toString() { 48 public String toString() {
51 String str = "<ul>"; 49 String str = "<ul>";
52 - if (inLower) { 50 + if (inLower()) {
53 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;低于下限预警值<b> " + getLower() + "</b></li>"; 51 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;低于下限预警值<b> " + getLower() + "</b></li>";
54 - } else if (inUpper) { 52 + } else if (inUpper()) {
55 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;高于上限预警值<b> " + getUpper() + "</b></li>"; 53 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;高于上限预警值<b> " + getUpper() + "</b></li>";
56 - } else if (inMin) { 54 + } else if (inMin()) {
57 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;低于最低值<b> " + getMin() + "</b></li>"; 55 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;低于最低值<b> " + getMin() + "</b></li>";
58 - } else if (inMax) { 56 + } else if (inMax()) {
59 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;超过最高值<b> " + getMax() + "</b></li>"; 57 str = str + "<li><b>" + getMaterialName() + "</b> &nbsp;&nbsp;" + getMaterialCode() + " 库存数 <b>" + getQtySum() + "</b>&nbsp;&nbsp;超过最高值<b> " + getMax() + "</b></li>";
60 } 58 }
61 return str + "</ul>"; 59 return str + "</ul>";
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/mapper/InventoryLevelAlarmMapper.java 0 → 100644
  1 +package org.jeecg.modules.wms.inventory.inventoryLevel.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.baomidou.mybatisplus.core.metadata.IPage;
  5 +import org.apache.ibatis.annotations.Param;
  6 +import org.jeecg.modules.wms.inventory.inventoryLevel.entity.InventoryLevelAlarm;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * @Description: material_level_alarm
  12 + * @Author: jeecg-boot
  13 + * @Date: 2023-10-30
  14 + * @Version: V1.0
  15 + */
  16 +public interface InventoryLevelAlarmMapper extends BaseMapper<InventoryLevelAlarm> {
  17 + IPage<InventoryLevelAlarm> queryLevelAlarm(IPage<InventoryLevelAlarm> page,
  18 + @Param("materialCode") String materialCode,
  19 + @Param("materialName") String materialName,
  20 + @Param("alarmStatus") String alarmStatus);
  21 +
  22 + List<InventoryLevelAlarm> queryLevelAlarm(@Param("materialCode") String materialCode,
  23 + @Param("materialName") String materialName,
  24 + @Param("alarmStatus") String alarmStatus);
  25 +}
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/mapper/xml/InventoryLevelAlarmMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="org.jeecg.modules.wms.inventory.inventoryLevel.mapper.InventoryLevelAlarmMapper">
  4 +
  5 + <select id="queryLevelAlarm"
  6 + resultType="org.jeecg.modules.wms.inventory.inventoryLevel.entity.InventoryLevelAlarm">
  7 + select t.* from (
  8 + SELECT w.*, sum(qty) as qtySum FROM inventory_detail i inner join material_warning w
  9 + on i.material_code = w.material_code
  10 + WHERE i.inventory_status='good' and i.material_code IN ( SELECT material_code FROM material_warning
  11 + <where>
  12 + <if test="materialCode != null and materialCode != ''">
  13 + and material_code = #{materialCode}
  14 + </if>
  15 + <if test="materialName != null and materialName != ''">
  16 + <bind name="materialNameLike" value="'%'+materialName+'%'"/>
  17 + and material_name like #{materialNameLike}
  18 + </if>
  19 + </where>
  20 + )
  21 + group by material_code
  22 + ) t
  23 + <where>
  24 + <if test="alarmStatus != null and alarmStatus == 'noAlarm'">
  25 + and qtySum between lower and upper
  26 + </if>
  27 + <if test="alarmStatus != null and alarmStatus == 'isAlarm'">
  28 + and qtySum &lt;= lower or qtySum &gt;= upper
  29 + </if>
  30 + <if test="alarmStatus != null and alarmStatus == 'lowerAlarm'">
  31 + and qtySum &lt;= lower
  32 + </if>
  33 + <if test="alarmStatus != null and alarmStatus == 'upperAlarm'">
  34 + and qtySum &gt;= upper
  35 + </if>
  36 + </where>
  37 + </select>
  38 +</mapper>
0 \ No newline at end of file 39 \ No newline at end of file
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/service/IInventoryLevelAlarmService.java 0 → 100644
  1 +package org.jeecg.modules.wms.inventory.inventoryLevel.service;
  2 +
  3 +import com.baomidou.mybatisplus.core.metadata.IPage;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning;
  6 +import org.jeecg.modules.wms.inventory.inventoryLevel.entity.InventoryLevelAlarm;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * @Description: inventory_level_alarm
  12 + * @Author: jeecg-boot
  13 + * @Date: 2023-10-30
  14 + * @Version: V1.0
  15 + */
  16 +public interface IInventoryLevelAlarmService extends IService<InventoryLevelAlarm> {
  17 + List<InventoryLevelAlarm> getLevelAlarm(String materialCode);
  18 +
  19 + IPage<InventoryLevelAlarm> queryLevelAlarm(IPage<InventoryLevelAlarm> page, String materialCode, String materialName, String alarmStatus);
  20 +
  21 +}
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryLevel/service/impl/InventoryLevelAlarmServiceImpl.java 0 → 100644
  1 +package org.jeecg.modules.wms.inventory.inventoryLevel.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.metadata.IPage;
  5 +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  7 +import org.jeecg.modules.wms.config.materialWarning.entity.MaterialWarning;
  8 +import org.jeecg.modules.wms.config.materialWarning.service.impl.MaterialWarningServiceImpl;
  9 +import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail;
  10 +import org.jeecg.modules.wms.inventory.inventoryHeader.service.impl.InventoryDetailServiceImpl;
  11 +import org.jeecg.modules.wms.inventory.inventoryLevel.entity.InventoryLevelAlarm;
  12 +import org.jeecg.modules.wms.inventory.inventoryLevel.mapper.InventoryLevelAlarmMapper;
  13 +import org.jeecg.modules.wms.inventory.inventoryLevel.service.IInventoryLevelAlarmService;
  14 +import org.jeecg.utils.StringUtils;
  15 +import org.jeecg.utils.constant.QuantityConstant;
  16 +import org.springframework.stereotype.Service;
  17 +
  18 +import javax.annotation.Resource;
  19 +import java.math.BigDecimal;
  20 +import java.util.ArrayList;
  21 +import java.util.List;
  22 +import java.util.stream.Collectors;
  23 +
  24 +/**
  25 + * @Description: inventory_level_alarm
  26 + * @Author: jeecg-boot
  27 + * @Date: 2023-10-30
  28 + * @Version: V1.0
  29 + */
  30 +@Service
  31 +public class InventoryLevelAlarmServiceImpl extends ServiceImpl<InventoryLevelAlarmMapper, InventoryLevelAlarm> implements IInventoryLevelAlarmService {
  32 +
  33 + @Resource
  34 + InventoryDetailServiceImpl inventoryDetailService;
  35 +
  36 + @Resource
  37 + MaterialWarningServiceImpl materialWarningService;
  38 +
  39 + @Resource
  40 + InventoryLevelAlarmMapper inventoryLevelAlarmMapper;
  41 +
  42 + @Override
  43 + public List<InventoryLevelAlarm> getLevelAlarm(String materialCode) {
  44 + List<InventoryLevelAlarm> alarmList = inventoryLevelAlarmMapper.queryLevelAlarm(materialCode,null,"isAlarm");
  45 +
  46 + return alarmList;
  47 + }
  48 +
  49 +
  50 + @Override
  51 + public IPage<InventoryLevelAlarm> queryLevelAlarm(IPage<InventoryLevelAlarm> page, String materialCode, String materialName, String alarmStatus) {
  52 + return inventoryLevelAlarmMapper.queryLevelAlarm(page, materialCode, materialName, alarmStatus);
  53 + }
  54 +}
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/MaterialLevelAlarmTask.java renamed to huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/InventoryLevelAlarmTask.java
@@ -11,14 +11,12 @@ import org.jeecg.modules.system.entity.SysUser; @@ -11,14 +11,12 @@ import org.jeecg.modules.system.entity.SysUser;
11 import org.jeecg.modules.system.service.impl.SysAnnouncementServiceImpl; 11 import org.jeecg.modules.system.service.impl.SysAnnouncementServiceImpl;
12 import org.jeecg.modules.system.service.impl.SysRoleServiceImpl; 12 import org.jeecg.modules.system.service.impl.SysRoleServiceImpl;
13 import org.jeecg.modules.system.service.impl.SysUserServiceImpl; 13 import org.jeecg.modules.system.service.impl.SysUserServiceImpl;
14 -import org.jeecg.modules.wms.config.materialWarning.entity.MaterialLevelAlarm;  
15 -import org.jeecg.modules.wms.config.materialWarning.service.impl.MaterialWarningServiceImpl; 14 +import org.jeecg.modules.wms.inventory.inventoryLevel.entity.InventoryLevelAlarm;
  15 +import org.jeecg.modules.wms.inventory.inventoryLevel.service.impl.InventoryLevelAlarmServiceImpl;
16 import org.quartz.*; 16 import org.quartz.*;
17 -import org.springframework.beans.factory.annotation.Autowired;  
18 import org.springframework.util.CollectionUtils; 17 import org.springframework.util.CollectionUtils;
19 18
20 import javax.annotation.Resource; 19 import javax.annotation.Resource;
21 -import java.util.ArrayList;  
22 import java.util.Date; 20 import java.util.Date;
23 import java.util.List; 21 import java.util.List;
24 import java.util.stream.Collectors; 22 import java.util.stream.Collectors;
@@ -31,7 +29,7 @@ import java.util.stream.Collectors; @@ -31,7 +29,7 @@ import java.util.stream.Collectors;
31 @Slf4j 29 @Slf4j
32 @PersistJobDataAfterExecution 30 @PersistJobDataAfterExecution
33 @DisallowConcurrentExecution 31 @DisallowConcurrentExecution
34 -public class MaterialLevelAlarmTask implements Job { 32 +public class InventoryLevelAlarmTask implements Job {
35 private String parameter; 33 private String parameter;
36 34
37 @Resource 35 @Resource
@@ -43,14 +41,14 @@ public class MaterialLevelAlarmTask implements Job { @@ -43,14 +41,14 @@ public class MaterialLevelAlarmTask implements Job {
43 @Resource 41 @Resource
44 private SysRoleServiceImpl sysRoleService; 42 private SysRoleServiceImpl sysRoleService;
45 43
46 - @Autowired 44 + @Resource
47 private SqlSession sqlSession; 45 private SqlSession sqlSession;
48 46
49 - @Autowired 47 + @Resource
50 private SysAnnouncementServiceImpl sysAnnouncementService; 48 private SysAnnouncementServiceImpl sysAnnouncementService;
51 49
52 - @Autowired  
53 - private MaterialWarningServiceImpl materialWarningService; 50 + @Resource
  51 + private InventoryLevelAlarmServiceImpl inventoryLevelAlarmService;
54 52
55 public void setParameter(String parameter) { 53 public void setParameter(String parameter) {
56 this.parameter = parameter; 54 this.parameter = parameter;
@@ -60,13 +58,15 @@ public class MaterialLevelAlarmTask implements Job { @@ -60,13 +58,15 @@ public class MaterialLevelAlarmTask implements Job {
60 public void execute(JobExecutionContext context) throws JobExecutionException { 58 public void execute(JobExecutionContext context) throws JobExecutionException {
61 log.info(StrUtil.format("定时任务 MaterialLevelAlarmTask 参数:{},执行时间:{}", this.parameter, DateUtils.getTimestamp())); 59 log.info(StrUtil.format("定时任务 MaterialLevelAlarmTask 参数:{},执行时间:{}", this.parameter, DateUtils.getTimestamp()));
62 60
63 - List<MaterialLevelAlarm> alarmList = materialWarningService.getLevelAlarm(null); 61 + List<InventoryLevelAlarm> alarmList = inventoryLevelAlarmService.getLevelAlarm(null);
64 if (CollectionUtils.isEmpty(alarmList)) { 62 if (CollectionUtils.isEmpty(alarmList)) {
65 return; 63 return;
66 } 64 }
67 65
68 - List<String> list = alarmList.stream().map(MaterialLevelAlarm::toString).collect(Collectors.toList()); 66 + List<String> list = alarmList.stream().map(InventoryLevelAlarm::toString).collect(Collectors.toList());
69 String msg = String.join("\n", list); 67 String msg = String.join("\n", list);
  68 + msg = msg + "<a href='/wms/#/system/inventory/inventoryLevel'>库存水位详情</a>&nbsp;&nbsp;&nbsp;&nbsp;" +
  69 + "<a href='/wms/#/system/config/MaterialWarningList'>预警配置</a>";
70 70
71 List<SysUser> userList; 71 List<SysUser> userList;
72 try { 72 try {
@@ -75,7 +75,7 @@ public class MaterialLevelAlarmTask implements Job { @@ -75,7 +75,7 @@ public class MaterialLevelAlarmTask implements Job {
75 if (userList.size() == 0) { 75 if (userList.size() == 0) {
76 userList = null; 76 userList = null;
77 } 77 }
78 - sysAnnouncementService.quickAnnouncementToUser(userList, "物料水位预警", msg, DateUtil.offsetDay(new Date(), 1), "H"); 78 + sysAnnouncementService.quickAnnouncementToUser(userList, "库存水位预警", msg, DateUtil.offsetDay(new Date(), 1), "H");
79 } catch (Exception e) { 79 } catch (Exception e) {
80 log.error("获取预警通知用户出错", e); 80 log.error("获取预警通知用户出错", e);
81 } 81 }