From 3d39f8bdc7425853d212b7ea9f832ff8a4bb5bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=99=93=E8=BF=AA?= <2596750866@qq.com> Date: Sat, 12 Oct 2024 09:20:20 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E5=9F=BA=E7=A1=80=E8=B5=84=E6=96=99=20?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E4=BF=A1=E6=81=AF=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E3=80=81=E7=BC=96=E8=BE=91=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E9=A1=B5=E9=9D=A2=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E7=BC=96=E5=8F=B7=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=BF=A1=E6=81=AFcontroller=E3=80=81service=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BB=93=E5=BA=93=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E6=96=B9=E6=B3=95=EF=BC=9B?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E4=BB=93=E5=BA=93=E4=BF=A1=E6=81=AFmapper?= =?UTF-8?q?=EF=BC=8C=E8=A1=A5=E5=85=A8=E4=BF=A1=E6=81=AF=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stock/controller/StockInfoController.java | 24 ++++++++++++++--- .../com/ruoyi/stock/domain/StockInfo.java | 21 +++++++++------ .../ruoyi/stock/mapper/StockInfoMapper.java | 3 +++ .../stock/service/IStockInfoService.java | 5 ++++ .../service/impl/StockInfoServiceImpl.java | 18 +++++++++++++ .../mapper/stock/StockInfoMapper.xml | 20 +++++++++----- .../templates/stock/stockInfo/add.html | 22 ++++++++++++--- .../templates/stock/stockInfo/edit.html | 6 ++--- .../templates/stock/stockInfo/stockInfo.html | 27 +++++++++++++++++-- 9 files changed, 119 insertions(+), 27 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/controller/StockInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/controller/StockInfoController.java index 97589b72..944ce95d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/controller/StockInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/controller/StockInfoController.java @@ -9,10 +9,12 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.stock.domain.StockInfo; import com.ruoyi.stock.service.IStockInfoService; +import com.ruoyi.system.domain.OutsourceQuoteChild; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -59,11 +61,18 @@ public class StockInfoController extends BaseController @Log(title = "仓库信息", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody - public AjaxResult export(StockInfo stockInfo) + public AjaxResult export(StockInfo stockInfo,String ids) { - List list = stockInfoService.selectStockInfoList(stockInfo); - ExcelUtil util = new ExcelUtil(StockInfo.class); - return util.exportExcel(list, "仓库信息数据"); + if (StringUtils.isEmpty(ids)){ + List stockInfoList = stockInfoService.selectStockInfoList(stockInfo); + ExcelUtil util = new ExcelUtil(StockInfo.class); + return util.exportExcel(stockInfoList, "仓库信息数据"); + }else { + String[] stockNos = ids.split(","); + List stockInfoList = stockInfoService.selectStockInfoListByNos(stockNos); + ExcelUtil util = new ExcelUtil(StockInfo.class); + return util.exportExcel(stockInfoList, ids); + } } /** @@ -155,4 +164,11 @@ public class StockInfoController extends BaseController } + @RequestMapping("/getId") + @ResponseBody + public AjaxResult getId(){ + + return AjaxResult.success(stockInfoService.generateStockNo()); + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/domain/StockInfo.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/domain/StockInfo.java index dfd8ed64..95dbce5b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/domain/StockInfo.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/domain/StockInfo.java @@ -1,10 +1,13 @@ package com.ruoyi.stock.domain; +import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import java.util.Date; + /** * 仓库信息对象 stock_info * @@ -45,12 +48,14 @@ public class StockInfo extends BaseEntity private String defaltItemclass; /** 录入时间 */ - @Excel(name = "录入时间") - private String firstAddTime; + @Excel(name = "录入时间",dateFormat = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date firstAddTime; /** 修改时间 */ - @Excel(name = "修改时间") - private String updateInfoTime; + @Excel(name = "修改时间",dateFormat = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateInfoTime; public Long getStockId() { return stockId; @@ -110,19 +115,19 @@ public class StockInfo extends BaseEntity return defaltItemclass; } - public String getFirstAddTime() { + public Date getFirstAddTime() { return firstAddTime; } - public void setFirstAddTime(String firstAddTime) { + public void setFirstAddTime(Date firstAddTime) { this.firstAddTime = firstAddTime; } - public String getUpdateInfoTime() { + public Date getUpdateInfoTime() { return updateInfoTime; } - public void setUpdateInfoTime(String updateInfoTime) { + public void setUpdateInfoTime(Date updateInfoTime) { this.updateInfoTime = updateInfoTime; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/mapper/StockInfoMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/mapper/StockInfoMapper.java index 6afb0f25..bbbff564 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/mapper/StockInfoMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/mapper/StockInfoMapper.java @@ -70,4 +70,7 @@ public interface StockInfoMapper * 根据仓库ID查询仓库名称 * */ public StockInfo selectStockInfoByCode(String warehouseCode); + + //根据仓库号列表查询仓库信息 + public List selectStockInfoListByNos(String[] stockNos); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/service/IStockInfoService.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/service/IStockInfoService.java index a8680006..6cdff343 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/service/IStockInfoService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/service/IStockInfoService.java @@ -69,4 +69,9 @@ public interface IStockInfoService * 根据仓库ID查询仓库名称 * */ public StockInfo selectStockInfoByCode(String warehouseCode); + + //根据仓库号列表查询仓库信息 + public List selectStockInfoListByNos(String[] stockNos); + + String generateStockNo(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/stock/service/impl/StockInfoServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/stock/service/impl/StockInfoServiceImpl.java index 2ee9528c..3b5c2019 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/stock/service/impl/StockInfoServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/stock/service/impl/StockInfoServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.stock.service.impl; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; import com.ruoyi.stock.domain.StockInfo; import com.ruoyi.stock.mapper.StockInfoMapper; import com.ruoyi.stock.service.IStockInfoService; @@ -21,6 +23,9 @@ public class StockInfoServiceImpl implements IStockInfoService @Autowired private StockInfoMapper stockInfoMapper; + @Autowired + private RedisCache redisCache; + /** * 查询仓库信息 * @@ -54,6 +59,7 @@ public class StockInfoServiceImpl implements IStockInfoService @Override public int insertStockInfo(StockInfo stockInfo) { + stockInfo.setFirstAddTime(DateUtils.getNowDate()); return stockInfoMapper.insertStockInfo(stockInfo); } @@ -66,6 +72,7 @@ public class StockInfoServiceImpl implements IStockInfoService @Override public int updateStockInfo(StockInfo stockInfo) { + stockInfo.setUpdateInfoTime(DateUtils.getNowDate()); return stockInfoMapper.updateStockInfo(stockInfo); } @@ -109,4 +116,15 @@ public class StockInfoServiceImpl implements IStockInfoService public StockInfo selectStockInfoByCode(String warehouseCode) { return stockInfoMapper.selectStockInfoByCode(warehouseCode); } + + @Override + public List selectStockInfoListByNos(String[] stockNos) { + return stockInfoMapper.selectStockInfoListByNos(stockNos); + } + + @Override + public String generateStockNo() { + String stockNo = redisCache.generateNo("CK"); + return stockNo; + } } diff --git a/ruoyi-admin/src/main/resources/mapper/stock/StockInfoMapper.xml b/ruoyi-admin/src/main/resources/mapper/stock/StockInfoMapper.xml index 5cc69914..bae74704 100644 --- a/ruoyi-admin/src/main/resources/mapper/stock/StockInfoMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/stock/StockInfoMapper.xml @@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" stock_manager_phone, stockmemo, defalt_itemclass, - first_add_time, + first_add_time, #{stockNO}, @@ -68,7 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{stockManagerPhone}, #{stockMemo}, #{defaltItemclass}, - now(), + #{firstAddTime}, @@ -76,13 +76,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update stock_info StockNO = #{stockNO}, - Stockname = #{stockname}, + Stockname = #{stockName}, StockAddr = #{stockAddr}, - stockmanager = #{stockmanager}, + stockmanager = #{stockManager}, stock_manager_phone = #{stockManagerPhone}, - stockmemo = #{stockmemo}, + stockmemo = #{stockMemo}, defalt_itemclass = #{defaltItemclass}, - update_info_time = CONCAT_WS(',',NOW(),update_info_time), + update_info_time = #{updateInfoTime}, where stock_id = #{stockId} @@ -98,4 +98,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html b/ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html index 183514cc..6c72fc87 100644 --- a/ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html +++ b/ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html @@ -15,7 +15,7 @@
- +
@@ -27,13 +27,13 @@
- +
- +
@@ -44,7 +44,21 @@ $("#form-stockInfo-add").validate({ focusCleanup: true }); - + $(function (){ + $.ajax({ + url: prefix + "/getId", + type: "post", + dataType: "json", + success: function (result) { + console.log(result); + if (result.code == 0) { + $("input[name='StockNO']").val(result.msg); + } else { + $.modal.msgError(result.msg); + } + } + }); + }) function submitHandler() { if ($.validate.form()) { $.operate.save(prefix + "/add", $('#form-stockInfo-add').serialize()); diff --git a/ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html b/ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html index c3f529d4..0f65db2b 100644 --- a/ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html +++ b/ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html @@ -16,7 +16,7 @@
- +
@@ -28,13 +28,13 @@
- +
- +
diff --git a/ruoyi-admin/src/main/resources/templates/stock/stockInfo/stockInfo.html b/ruoyi-admin/src/main/resources/templates/stock/stockInfo/stockInfo.html index dbefeffb..f6246ea8 100644 --- a/ruoyi-admin/src/main/resources/templates/stock/stockInfo/stockInfo.html +++ b/ruoyi-admin/src/main/resources/templates/stock/stockInfo/stockInfo.html @@ -45,7 +45,7 @@ 删除 - + 导出
@@ -80,7 +80,7 @@ {title: '仓库备注',field: 'stockMemo',}, {title: '录入时间',field: 'firstAddTime', formatter: function (value, row, index) { - console.log(row) + // console.log(row) if (value == null) {return " ";} else {return value;} } @@ -108,6 +108,29 @@ }; $.table.init(options); }); + + // 导出 + function exportExcel() { + var ids = $.table.selectColumns("stockNO"); + var dataParam = $("#formId").serializeArray(); + + let tipMsg = "确定导出当前所有数据吗?"; + if ($.common.isNotEmpty(ids)) { + tipMsg = `确定导出 ${ids} 数据吗?`; + dataParam.push({ "name": "ids", "value": ids }); + } + $.modal.confirm(tipMsg, function () { + $.modal.loading("正在导出数据,请稍后..."); + $.post( prefix + "/export", dataParam, function (result) { + if (result.code === web_status.SUCCESS) { + window.location.href = ctx + "common/download?fileName="+ encodeURI(result.msg) + "&delete=" + true; + } else { + $.modal.alertError(result.msg); + } + $.modal.closeLoading(); + }); + }); + } \ No newline at end of file