Browse Source

[fix]

基础资料 仓库信息
修改添加、编辑仓库信息页面,新增仓库编号自动生成;
修改仓库信息controller、service方法,新增仓库编号自动生成方法;
修改仓库信息mapper,补全信息;
dev
王晓迪 1 month ago
parent
commit
3d39f8bdc7
  1. 22
      ruoyi-admin/src/main/java/com/ruoyi/stock/controller/StockInfoController.java
  2. 21
      ruoyi-admin/src/main/java/com/ruoyi/stock/domain/StockInfo.java
  3. 3
      ruoyi-admin/src/main/java/com/ruoyi/stock/mapper/StockInfoMapper.java
  4. 5
      ruoyi-admin/src/main/java/com/ruoyi/stock/service/IStockInfoService.java
  5. 18
      ruoyi-admin/src/main/java/com/ruoyi/stock/service/impl/StockInfoServiceImpl.java
  6. 20
      ruoyi-admin/src/main/resources/mapper/stock/StockInfoMapper.xml
  7. 22
      ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html
  8. 6
      ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html
  9. 27
      ruoyi-admin/src/main/resources/templates/stock/stockInfo/stockInfo.html

22
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<StockInfo> list = stockInfoService.selectStockInfoList(stockInfo);
if (StringUtils.isEmpty(ids)){
List<StockInfo> stockInfoList = stockInfoService.selectStockInfoList(stockInfo);
ExcelUtil<StockInfo> util = new ExcelUtil<StockInfo>(StockInfo.class);
return util.exportExcel(stockInfoList, "仓库信息数据");
}else {
String[] stockNos = ids.split(",");
List<StockInfo> stockInfoList = stockInfoService.selectStockInfoListByNos(stockNos);
ExcelUtil<StockInfo> util = new ExcelUtil<StockInfo>(StockInfo.class);
return util.exportExcel(list, "仓库信息数据");
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());
}
}

21
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;
}

3
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<StockInfo> selectStockInfoListByNos(String[] stockNos);
}

5
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<StockInfo> selectStockInfoListByNos(String[] stockNos);
String generateStockNo();
}

18
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<StockInfo> selectStockInfoListByNos(String[] stockNos) {
return stockInfoMapper.selectStockInfoListByNos(stockNos);
}
@Override
public String generateStockNo() {
String stockNo = redisCache.generateNo("CK");
return stockNo;
}
}

20
ruoyi-admin/src/main/resources/mapper/stock/StockInfoMapper.xml

@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stockManagerPhone != null">stock_manager_phone,</if>
<if test="stockMemo != null">stockmemo,</if>
<if test="defaltItemclass != null">defalt_itemclass,</if>
first_add_time,
<if test="firstAddTime != null">first_add_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stockNO != null and stockNO != ''">#{stockNO},</if>
@ -68,7 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stockManagerPhone != null">#{stockManagerPhone},</if>
<if test="stockMemo != null">#{stockMemo},</if>
<if test="defaltItemclass != null">#{defaltItemclass},</if>
now(),
<if test="firstAddTime != null">#{firstAddTime},</if>
</trim>
</insert>
@ -76,13 +76,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update stock_info
<trim prefix="SET" suffixOverrides=",">
<if test="stockNO != null and stockNO != ''">StockNO = #{stockNO},</if>
<if test="stockName != null and stockName != ''">Stockname = #{stockname},</if>
<if test="stockName != null and stockName != ''">Stockname = #{stockName},</if>
<if test="stockAddr != null and stockAddr != ''">StockAddr = #{stockAddr},</if>
<if test="stockManager != null">stockmanager = #{stockmanager},</if>
<if test="stockManager != null">stockmanager = #{stockManager},</if>
<if test="stockManagerPhone != null">stock_manager_phone = #{stockManagerPhone},</if>
<if test="stockMemo != null">stockmemo = #{stockmemo},</if>
<if test="stockMemo != null">stockmemo = #{stockMemo},</if>
<if test="defaltItemclass != null">defalt_itemclass = #{defaltItemclass},</if>
update_info_time = CONCAT_WS(',',NOW(),update_info_time),
<if test="updateInfoTime != null">update_info_time = #{updateInfoTime},</if>
</trim>
where stock_id = #{stockId}
</update>
@ -98,4 +98,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="selectStockInfoListByNos" parameterType="String" resultMap="StockInfoResult">
<include refid="selectStockInfoVo"/>
where StockNO in
<foreach item="stockNO" collection="array" open="(" separator="," close=")">
#{stockNO}
</foreach>
</select>
</mapper>

22
ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html

@ -15,7 +15,7 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">仓库名:</label>
<div class="col-sm-8">
<input name="Stockname" class="form-control" type="text" required>
<input name="stockName" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
@ -27,13 +27,13 @@
<div class="form-group">
<label class="col-sm-3 control-label">仓库管理人:</label>
<div class="col-sm-8">
<input name="stockmanager" class="form-control" type="text">
<input name="stockManager" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">仓库备注:</label>
<div class="col-sm-8">
<input name="stockmemo" class="form-control" type="text">
<input name="stockMemo" class="form-control" type="text">
</div>
</div>
</form>
@ -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());

6
ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html

@ -16,7 +16,7 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">仓库名:</label>
<div class="col-sm-8">
<input name="Stockname" th:field="*{Stockname}" class="form-control" type="text" required>
<input name="stockName" th:field="*{stockName}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
@ -28,13 +28,13 @@
<div class="form-group">
<label class="col-sm-3 control-label">仓库管理人:</label>
<div class="col-sm-8">
<input name="stockmanager" th:field="*{stockmanager}" class="form-control" type="text">
<input name="stockManager" th:field="*{stockManager}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">仓库备注:</label>
<div class="col-sm-8">
<input name="stockmemo" th:field="*{stockmemo}" class="form-control" type="text">
<input name="stockMemo" th:field="*{stockMemo}" class="form-control" type="text">
</div>
</div>
</form>

27
ruoyi-admin/src/main/resources/templates/stock/stockInfo/stockInfo.html

@ -45,7 +45,7 @@
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="stock:stockInfo:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="stock:stockInfo:export">
<a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="stock:stockInfo:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
@ -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();
});
});
}
</script>
</body>
</html>
Loading…
Cancel
Save