Commit 8d10b3c4 by chuishuo

新增字段 ---完成

关联改为用id(物料、库位、仓库)——测试数据有问题,需要造数据后再测试
首页统计接口--完成
parent c38b7b1a
......@@ -62,3 +62,11 @@ export function delStocktakes(id) {
method: 'delete'
})
}
// 首页-本月盘点次数
export function countStocktakes() {
return request({
url: '/inventory/stocktakes/countStocktakes',
method: 'get'
})
}
......@@ -42,3 +42,19 @@ export function delItems(id) {
method: 'delete'
})
}
// 盘盈金额 盘亏金额
export function stocktakeVarianceAmount() {
return request({
url: '/inventory/items/stocktakeVarianceAmount',
method: 'get'
})
}
// 3. 本月差异分析
export function varianceAnalysis() {
return request({
url: '/inventory/items/varianceAnalysis',
method: 'get'
})
}
......@@ -10,13 +10,16 @@
@reset="resetQuery"
>
<el-form-item label="计划日期">
<el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
<el-date-picker v-model="dateRange" style="width: 240px"
value-format="yyyy-MM-dd" type="daterange"
range-separator="-" start-placeholder="开始日期"
end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item label="物料" prop="materialId">
<common-dict-select
v-model="queryParams.materialId"
dict-url="/inventory/materials/getMapList"
value-key="sap_no"
value-key="id"
label-key="material_name"
placeholder="请选择物料"
@change="handleQuery"
......@@ -67,40 +70,23 @@
<el-table-column label="物料" align="center" prop="materialId" fixed>
<template slot-scope="scope">
{{ getDictLabel(materialDict, scope.row.materialId, 'sap_no', 'material_name') }}
{{ getDictLabel(materialDict, scope.row.materialId, 'id', 'material_name') }}
</template>
</el-table-column>
<el-table-column label="SAP物料号" align="center" prop="sapNo" />
<el-table-column label="TS Code" align="center" prop="tsCode" />
<el-table-column label="危险类别" align="center" prop="hazardName" />
<!-- <el-table-column label="批次编号" prop="batchCode">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input v-model="scope.row.batchCode" placeholder="请输入批次编号" disabled />-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="仓库Id" align="center" prop="warehousesId" v-if="false" />
<el-table-column label="库位Id" align="center" prop="locationId" v-if="false" />
<el-table-column label="仓库" align="center" prop="warehousesName" />
<el-table-column label="库位" align="center" prop="locationName" />
<el-table-column label="差异总数" align="center" prop="countQuantity" />
<!-- <template slot-scope="scope">-->
<!-- <el-input type="number" v-model="scope.row.varianceQuantity" placeholder="请输入差异数量" disabled />-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="单价" prop="unitPrice">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input v-model="scope.row.unitPrice" placeholder="请输入单价" disabled />-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="差异总金额" prop="unitPrice">
<template slot-scope="scope">
{{ formatAmount(scope.row.countAmount) }}
</template>
<!-- <template slot-scope="scope">-->
<!-- <el-input v-model="scope.row.varianceAmount" placeholder="请输入差异金额" disabled />-->
<!-- </template>-->
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
......@@ -129,7 +115,7 @@
<!-- 库位选择组件 -->
<LocationSelector
v-model="locationSelectorVisible"
:warehousesId="currentWarehouseId"
:warehousesId="queryParams.warehouseId"
@selected="handleLocationSelected"
/>
</div>
......@@ -139,7 +125,7 @@
<el-table-column label="计划日期" prop="plannedDates" />
<el-table-column label="物料" prop="materialId" fixed>
<template slot-scope="scope">
{{ getDictLabel(materialDict, scope.row.materialId, 'sap_no', 'material_name') || '无' }}
{{ getDictLabel(materialDict, scope.row.materialId, 'id', 'material_name') || '无' }}
</template>
</el-table-column>
<el-table-column label="SAP物料号" align="center" prop="sapNo" />
......@@ -152,6 +138,12 @@
{{ formatAmount(scope.row.varianceAmount) }}
</template>
</el-table-column>
<el-table-column prop="adjustedType" label="调整原因类型" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.adjusted_type" :value="scope.row.adjustedType"/>
</template>
</el-table-column>
<el-table-column label="调整原因" align="center" prop="adjustmentReason" width="150px" />
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">关 闭</el-button>
......@@ -169,6 +161,7 @@ import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import LocationSelector from "@/views/compononents/LocationSelector.vue"
export default {
name: "stocktakeCountTable",
dicts: ['adjusted_type'],
components: { CommonDictSelect,WarehouseSelector,LocationSelector }, // 注册通用字典组件
props: {
// 接收父组件传递的子表原始数据(双向绑定)
......@@ -207,15 +200,10 @@ export default {
// 库位选择相关
locationSelectorVisible: false,
queryLocationName: null,
currentWarehouseId: "", // 存仓库原始ID(0eb22b11...),供库位联动
checkedRows: [], // 子表选中的行
materialDict: [], // 物料字典数组(存储sap_no和name)
warehouseDict: [], // 仓库数组
locationDict: [], // 库位数组
// 分页总数
total: 0,
// 表格加载状态
tableLoading: false
total: 0
}
},
created() {
......@@ -224,10 +212,7 @@ export default {
methods: {
// 挂载全局字典工具方法(模板中可直接调用)
getDictLabel,
/** 打开仓库选择器 */
openWarehouseSelector() {
this.warehouseSelectorVisible = true
},
// 取消按钮
cancel() {
this.viewOpen = false
......@@ -240,7 +225,6 @@ export default {
getCountInfo(row).then(response => {
if (response && response.rows) {
this.detailList = response.rows; // 直接赋值数组给detailList
console.log('赋值后的detailList:', this.detailList); // 打印3
} else {
}
this.viewOpen = true;
......@@ -250,36 +234,27 @@ export default {
this.viewOpen = false;
})
},
// 仓库清空时触发
handleWarehouseClear() {
this.queryParams.locationId = ''
this.queryParams.warehouseId = ''
this.currentWarehouseId = ''
this.handleQuery()
},
/** 库位选择回调 */
handleLocationSelected(location) {
if (!location) return
this.queryParams.locationId = location.locationCode
this.queryLocationName = location.locationName || location.locationCode
// console.log('selected LocationName', location);
this.handleQuery()
},
/** 仓库选择回调 */
handleWarehouseSelected(warehouse) {
if (!warehouse) return
// 供库位联动:存仓库原始ID(0eb22b11...)
this.currentWarehouseId = warehouse.warehouseId
// 供列表筛选:存仓库编码333(匹配列表里的warehouseId:333
this.queryParams.warehouseId = warehouse.warehousesCode
this.queryParams.warehousesCode = warehouse.warehousesCode
this.queryWarehouseName = warehouse.warehousesName || warehouse.warehousesCode
this.queryParams.warehouseId = warehouse.warehouseId
this.queryWarehouseName = warehouse.warehousesName || warehouse.warehouseId
// 仓库选择后,清空库位信息
this.queryLocationName = null
this.queryParams.locationId = null
this.handleQuery()
// console.log('selected warehouse', warehouse);
},
/** 库位选择回调 */
handleLocationSelected(location) {
if (!location) return
this.queryParams.locationId = location.locationId
this.queryLocationName = location.locationName || location.locationId
this.handleQuery()
},
/** 格式化金额,保留2位小数 */
formatAmount(amount) {
if (amount === null || amount === undefined || isNaN(amount)) {
......@@ -294,12 +269,11 @@ export default {
this.getList();
});
},
/** 清空仓库选择 */
clearQueryWarehouse() {
this.queryWarehouseName = null
this.queryParams.warehouseId = null
this.queryParams.warehousesCode = null
this.currentWarehouseId = ""
// 清空仓库时,同时清空库位
this.queryLocationName = null
this.queryParams.locationId = null
......@@ -307,8 +281,7 @@ export default {
},
/** 打开库位选择器 */
openLocationSelector() {
// console.log('this.currentWarehouseId========',this.currentWarehouseId)
if (!this.currentWarehouseId) {
if (!this.queryParams.warehouseId) {
this.$message.warning("请先选择仓库")
return
}
......@@ -320,6 +293,17 @@ export default {
this.queryParams.locationId = null
this.handleQuery()
},
/** 打开仓库选择器 */
openWarehouseSelector() {
this.warehouseSelectorVisible = true
},
// 仓库清空时触发
handleWarehouseClear() {
this.queryParams.locationId = ''
this.queryParams.warehouseId = ''
this.currentWarehouseId = ''
this.handleQuery()
},
// 重置
resetQuery() {
this.queryWarehouseName = null
......@@ -349,16 +333,8 @@ export default {
},
// 字典加载完成回调(缓存字典数据,供表格展示使用)
handleDictLoaded(type, data) {
switch (type) {
case 'material':
this.materialDict = data
break
case 'warehouse':
this.warehouseDict = data
break
case 'location':
this.locationDict = data
break
if (type === 'material') {
this.materialDict = data
}
},
// 给子表设置序号
......
......@@ -13,7 +13,7 @@
<common-dict-select
v-model="searchParams.materialId"
dict-url="/inventory/materials/getMapList"
value-key="sap_no"
value-key="id"
label-key="material_name"
placeholder="请选择物料"
@change="handleQuery"
......@@ -44,7 +44,7 @@
readonly
@focus="openLocationSelector"
:suffix-icon="''"
:disabled="!searchParams.warehousesCode"
:disabled="!searchParams.warehouseId"
>
<template v-if="queryLocationName" #suffix>
<i
......@@ -65,7 +65,7 @@
<!-- 库位选择组件 -->
<LocationSelector
v-model="locationSelectorVisible"
:warehousesId="currentWarehouseId"
:warehousesId="searchParams.warehouseId"
@selected="handleLocationSelected"
/>
......@@ -80,7 +80,7 @@
<el-table-column label="物料" align="center" prop="materialId" width="150px" fixed>
<template slot-scope="scope">
<div class="el-input__inner disabled-input" style="padding: 0 15px; height: 32px; line-height: 32px;">
{{ getDictLabel(materialDict, scope.row.materialId, 'sap_no', 'material_name') }}
{{ getDictLabel(materialDict, scope.row.materialId, 'id', 'material_name') }}
</div>
</template>
</el-table-column>
......@@ -92,16 +92,10 @@
<el-table-column label="仓库" align="center" prop="warehouseName" width="150px" >
<template slot-scope="scope">
<el-input v-model="scope.row.warehouseName" placeholder="请输入仓库" disabled />
<!-- <div class="el-input__inner disabled-input" style="padding: 0 15px; height: 32px; line-height: 32px;">-->
<!-- {{ scope.row.warehouse_name || scope.row.warehouseId || '未知仓库' }}-->
<!-- </div>-->
</template>
</el-table-column>
<el-table-column label="库位" align="center" prop="locationName" width="150px" >
<template slot-scope="scope">
<!-- <div class="el-input__inner disabled-input" style="padding: 0 15px; height: 32px; line-height: 32px;">-->
<!-- {{ scope.row.location_name || scope.row.locationId || '未知库位' }}-->
<!-- </div>-->
<el-input v-model="scope.row.locationName" placeholder="请输入库位" disabled />
</template>
</el-table-column>
......@@ -144,6 +138,11 @@
<el-input v-model="scope.row.adjusted" placeholder="请输入是否已调整0否1是" disabled />
</template>
</el-table-column>
<el-table-column prop="adjustedType" label="调整原因类型" width="80">
<template slot-scope="scope">
<dict-tag :options="dict.type.adjusted_type" :value="scope.row.adjustedType"/>
</template>
</el-table-column>
<el-table-column label="调整原因" align="center" prop="adjustmentReason" width="150px" >
<template slot-scope="scope">
<el-input
......@@ -187,6 +186,7 @@ import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import LocationSelector from "@/views/compononents/LocationSelector.vue"
export default {
name: "stocktakeItemsTable",
dicts: ['adjusted_type'],
components: { CommonDictSelect,WarehouseSelector,LocationSelector }, // 注册通用字典组件
props: {
// 接收父组件传递的子表原始数据(双向绑定)
......@@ -207,7 +207,6 @@ export default {
materialId: "",
batchCode: "",
warehouseId: "",
warehousesCode: null,
locationId: ""
},
// 仓库选择相关
......@@ -216,7 +215,6 @@ export default {
// 库位选择相关
locationSelectorVisible: false,
queryLocationName: null,
currentWarehouseId: "", // 存仓库原始ID(0eb22b11...),供库位联动
checkedRows: [], // 子表选中的行
materialDict: [], // 物料字典数组(存储sap_no和name)
warehouseDict: [], // 仓库数组
......@@ -239,8 +237,8 @@ export default {
const normalizedItems = this.itemsList.map(item => ({
...item,
materialId: String(item.materialId || '').trim(),
warehouseId: String(item.warehouseId || item.warehouses_code || '').trim(),
locationId: String(item.locationId || item.location_code || '').trim()
warehouseId: String(item.warehouseId || '').trim(),
locationId: String(item.locationId || '').trim()
}))
// 精准筛选
......@@ -267,86 +265,43 @@ export default {
methods: {
// 挂载全局字典工具方法(模板中可直接调用)
getDictLabel,
// 手动加载字典(按你的字典接口规则来)
loadDict(type) {
// 字典接口地址(和你注释里的common-dict-select一致)
const dictConfig = {
// material: { url: '/inventory/materials/getMapList' },
warehouse: { url: '/inventory/warehouses/getMapList' },
// 库位字典需要传仓库编码(warehousesCode),
location: { url: '/inventory/locations/getMapList', params: { warehousesCode: this.searchParams.warehousesCode } }
/** 格式化金额,保留2位小数 */
formatAmount(amount) {
if (amount === null || amount === undefined || isNaN(amount)) {
return '0.00'
}
const config = dictConfig[type]
if (!config) return
this.$http.get(config.url, { params: config.params }).then(res => {
this.handleDictLoaded(type, res.data || [])
})
return parseFloat(amount).toFixed(2)
},
// 仓库选择变化时触发
handleWarehouseChange(warehouseId) {
// 1. 清空库位选择
this.searchParams.locationId = ''
// 2. 执行搜索
this.searchParams.warehouseId = warehouseId
this.handleQuery()
// 搜索,补全逻辑(无后端请求,仅重置页码)
handleQuery() {
this.searchParams.pageNum = 1; // 搜索后重置页码
},
/** 打开仓库选择器 */
openWarehouseSelector() {
this.warehouseSelectorVisible = true
},
// 仓库清空时触发
handleWarehouseClear() {
this.searchParams.locationId = ''
this.searchParams.warehouseId = ''
this.currentWarehouseId = ''
this.handleQuery()
},
/** 库位选择回调 */
handleLocationSelected(location) {
if (!location) return
this.searchParams.locationId = location.locationCode
this.queryLocationName = location.locationName || location.locationCode
// console.log('selected LocationName', location);
this.handleQuery()
},
/** 仓库选择回调 */
handleWarehouseSelected(warehouse) {
if (!warehouse) return
// 供库位联动:存仓库原始ID(0eb22b11...)
this.currentWarehouseId = warehouse.warehouseId
// 供列表筛选:存仓库编码333(匹配列表里的warehouseId:333
this.searchParams.warehouseId = warehouse.warehousesCode
this.searchParams.warehousesCode = warehouse.warehousesCode
this.queryWarehouseName = warehouse.warehousesName || warehouse.warehousesCode
this.searchParams.warehouseId = warehouse.warehouseId
this.queryWarehouseName = warehouse.warehousesName || warehouse.warehouseId
// 仓库选择后,清空库位信息
this.queryLocationName = null
this.searchParams.locationId = null
this.handleQuery()
// console.log('selected warehouse', warehouse);
},
/** 格式化金额,保留2位小数 */
formatAmount(amount) {
if (amount === null || amount === undefined || isNaN(amount)) {
return '0.00'
}
return parseFloat(amount).toFixed(2)
},
// 搜索,补全逻辑(无后端请求,仅重置页码)
handleQuery() {
this.searchParams.pageNum = 1; // 搜索后重置页码
},
/** 清空仓库选择 */
clearQueryWarehouse() {
this.queryWarehouseName = null
this.searchParams.warehouseId = null
this.searchParams.warehousesCode = null
this.currentWarehouseId = ""
// 清空仓库时,同时清空库位
this.queryLocationName = null
this.searchParams.locationId = null
this.handleQuery()
},
/** 打开库位选择器 */
openLocationSelector() {
if (!this.currentWarehouseId) {
......@@ -355,17 +310,26 @@ export default {
}
this.locationSelectorVisible = true
},
/** 库位选择回调 */
handleLocationSelected(location) {
if (!location) return
this.searchParams.locationId = location.locationId
this.queryLocationName = location.locationName || location.locationId
this.handleQuery()
},
/** 清空库位选择 */
clearQueryLocation() {
this.queryLocationName = null
this.searchParams.locationId = null
this.handleQuery()
},
// 重置
resetQuery() {
this.queryWarehouseName = null
this.queryLocationName = null
this.currentWarehouseId = ''
this.searchParams = {
pageNum: 1,
pageSize: 10,
......@@ -378,30 +342,33 @@ export default {
this.handleWarehouseClear()
},
// (解决报错)
getList() {},
// 字典加载完成回调(缓存字典数据,供表格展示使用)
handleDictLoaded(type, data) {
switch (type) {
case 'material':
this.materialDict = data
break
case 'warehouse':
this.warehouseDict = data
break
case 'location':
this.locationDict = data
break
}
// 仓库清空时触发
handleWarehouseClear() {
this.searchParams.locationId = ''
this.searchParams.warehouseId = ''
this.handleQuery()
},
// 给子表设置序号
setRowIndex({row, rowIndex}) {
row.index = rowIndex + 1;
},
// 选中行变化
handleSelectionChange(selection) {
this.checkedRows = selection;
},
// (解决报错)
getList() {},
// 字典加载完成回调(缓存字典数据,供表格展示使用)
handleDictLoaded(type, data) {
if (type === 'material') {
this.materialDict = data
}
},
// 校验调整原因必填项
validateAdjustReason() {
const invalidRows = this.filteredItemsList.filter(row => {
......
......@@ -101,4 +101,27 @@ public class StocktakeItemsController extends BaseController
{
return toAjax(stocktakeItemsService.deleteStocktakeItemsByIds(ids));
}
/**
* @description: 本月 盘盈金额 和 盘亏金额
* @author cs
* @date 2025/12/10
* @version 1.0
*/
@GetMapping(value = "/stocktakeVarianceAmount")
public AjaxResult stocktakeVarianceAmount()
{
return success(stocktakeItemsService.stocktakeVarianceAmount());
}
/**
* @description: 本月 本月差异分析
* @author cs
* @date 2025/12/10
* @version 1.0
*/
@GetMapping(value = "/varianceAnalysis")
public AjaxResult varianceAnalysis()
{
return success(stocktakeItemsService.selectItemsVarianceAnalysis());
}
}
......@@ -125,4 +125,16 @@ public class StocktakesController extends BaseController
List<StocktakesVo> list = stocktakesService.selectStocktakesCountInfo(stocktakes);
return getDataTable(list);
}
/**
* @description: 首页-本月盘点次数
* @author cs
* @date 2025/12/10
* @version 1.0
*/
@GetMapping(value = "/countStocktakes")
public AjaxResult countStocktakes()
{
return success(stocktakesService.selectStocktakesCountByMonth());
}
}
......@@ -127,6 +127,16 @@ public class StocktakeItems extends BaseEntity
/** 单价 */
@Excel(name = "单价")
private double unitPrice;
@Excel(name = "调整原因类型0-未调整、1-数量差异、2-记录错误、3-损坏丢失、4-其他,默认为0")
private String adjustedType;
public String getAdjustedType() {
return adjustedType;
}
public void setAdjustedType(String adjustedType) {
this.adjustedType = adjustedType;
}
public double getUnitPrice() {
return unitPrice;
......
......@@ -68,4 +68,10 @@ public interface StocktakeItemsMapper
// 查询处理统计-详情
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes);
// 本月 盘盈金额 和 盘亏金额
@SuppressWarnings("MybatisX")
public Map<String, Object> selectstocktakeVarianceAmount(StocktakeItems stocktakeItems);
// 本月 本月差异分析
public Map<String, Object> selectItemsVarianceAnalysis(StocktakeItems stocktakeItems);
}
......@@ -94,4 +94,11 @@ public interface StocktakesMapper
* @version 1.0
*/
public List<StocktakesVo> selectStocktakesListCount(StocktakesVo stocktakes);
/**
* @description: 首页-本月盘点次数
* @author cs
* @date 2025/12/10
* @version 1.0
*/
public int selectStocktakesCountByMonth(Stocktakes stocktakes);
}
......@@ -3,9 +3,11 @@ package com.ruoyi.inventory.service;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.domain.TO.StocktakeItemsTo;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
import org.springframework.web.bind.annotation.GetMapping;
/**
* 盘点单明细Service接口
......@@ -68,4 +70,22 @@ public interface IStocktakeItemsService
// 查询处理统计-详情
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes);
/**
* @description: 本月 盘盈金额 和 盘亏金额
* @author cs
* @date 2025/12/10
* @version 1.0
*/
public Map<String, Object> stocktakeVarianceAmount();
/**
* @description: 本月 本月差异分析
* @author cs
* @date 2025/12/10
* @version 1.0
*/
public Map<String, Object> selectItemsVarianceAnalysis();
public Map<String,Object> getMonthDay();
}
......@@ -80,4 +80,12 @@ public interface IStocktakesService
* @version 1.0
*/
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes);
/**
* @description: 首页-本月盘点次数
* @author cs
* @date 2025/12/10
* @version 1.0
*/
public int selectStocktakesCountByMonth();
}
package com.ruoyi.inventory.service.impl;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -126,4 +129,46 @@ public class StocktakeItemsServiceImpl implements IStocktakeItemsService
}
return stocktakeItemsMapper.selectStocktakesCountInfo(stocktakes);
}
/**
* @description: 本月 盘盈金额 和 盘亏金额
* @author cs
* @date 2025/12/10
* @version 1.0
*/
public Map<String, Object> stocktakeVarianceAmount(){
StocktakeItems stocktakeItems = new StocktakeItems();
Map<String, Object> params = getMonthDay();
stocktakeItems.setParams(params);
return stocktakeItemsMapper.selectstocktakeVarianceAmount(stocktakeItems);
}
/**
* @description: 本月 本月差异分析
* 统计 adjusted_type 字段为 1-数量差异、2-记录错误、3-损坏丢失、4-其他 的
* 1-数量差异 占比
* 2-记录错误 占比
* 3-损坏丢失 占比
* @author cs
* @date 2025/12/10
* @version 1.0
*/
public Map<String, Object> selectItemsVarianceAnalysis(){
StocktakeItems stocktakeItems = new StocktakeItems();
Map<String, Object> params = getMonthDay();
stocktakeItems.setParams(params);
return stocktakeItemsMapper.selectItemsVarianceAnalysis(stocktakeItems);
}
public Map<String,Object> getMonthDay(){
Map<String, Object> params = new HashMap<>();
// 获取当前日期
LocalDate today = LocalDate.now();
// 本月第一天
LocalDate firstDay = today.with(TemporalAdjusters.firstDayOfMonth());
// 本月最后一天
LocalDate lastDay = today.with(TemporalAdjusters.lastDayOfMonth());
params.put("beginTime",firstDay);
params.put("endTime",lastDay);
return params;
}
}
package com.ruoyi.inventory.service.impl;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import com.ruoyi.common.core.domain.model.LoginUser;
......@@ -302,4 +304,17 @@ public class StocktakesServiceImpl implements IStocktakesService
List<StocktakesVo> list = stocktakeItemsService.selectStocktakesCountInfo(stocktakes);
return list;
}
/**
* @description: 首页-本月盘点次数
* @author cs
* @date 2025/12/10
* @version 1.0
*/
public int selectStocktakesCountByMonth(){
Stocktakes stocktakes = new Stocktakes();
Map<String, Object> params = stocktakeItemsService.getMonthDay();
stocktakes.setParams(params);
return stocktakesMapper.selectStocktakesCountByMonth(stocktakes);
}
}
......@@ -88,7 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<!-- 获取物料 的 sap_no Name 做成字典-->
<select id="getMapList" resultType="java.util.Map">
select sap_no, IFNULL(material_name, '') as material_name from materials where is_used = 1;
select id, IFNULL(material_name, '') as material_name from materials where is_used = 1;
</select>
<insert id="insertMaterials" parameterType="Materials">
......
......@@ -37,15 +37,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateUserCode" column="update_user_code" />
<result property="inventoryId" column="inventory_id" />
<result property="unitPrice" column="unit_price" />
<result property="adjustedType" column="adjusted_type" />
</resultMap>
<sql id="selectStocktakeItemsVo">
select id, inventory_id,unit_price, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktake_items
select id, inventory_id,adjusted_type,unit_price, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktake_items
</sql>
<select id="selectStocktakeItemsList" parameterType="StocktakeItems" resultMap="StocktakeItemsResult">
<include refid="selectStocktakeItemsVo"/>
<where>
<if test="adjustedType != null and adjustedType != ''"> and adjusted_type = #{adjustedType}</if>
<if test="stocktakeId != null and stocktakeId != ''"> and stocktake_id = #{stocktakeId}</if>
<if test="materialId != null and materialId != ''"> and material_id = #{materialId}</if>
<if test="batchCode != null and batchCode != ''"> and batch_code = #{batchCode}</if>
......@@ -103,8 +105,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
, st_it.end_time
, st_it.material_range
, st_it.location_range
,(select w.warehouses_name from warehouses w where st_it.warehouse_id = w.warehouses_code and w.is_used = 1) as warehouse_name
,(select sl.location_name from storage_locations sl where st_it.location_id = sl.location_code and sl.is_used = 1) as location_name
,(select w.warehouses_name from warehouses w where st_it.warehouse_id = w.id and w.is_used = 1) as warehouse_name
,(select sl.location_name from storage_locations sl where st_it.location_id = sl.id and sl.is_used = 1) as location_name
,(select dict.dict_label from sys_dict_data dict where st_it.adjusted_type = dict.dict_sort and dict.status =0 and dict.dict_type ='adjusted_type') as adjusted_type
from stocktake_items st_it
where stocktake_id = #{stocktake_id} and is_used = 1
<if test="adjusted != null and adjusted != ''"> and adjusted = #{adjusted}</if>
......@@ -123,11 +126,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
,dict.dict_label as hazardName
,IFNULL(st_it.variance_quantity, '0') as varianceQuantity
,IFNULL(st_it.variance_amount, '0') as varianceAmount
,(select dict.dict_label from sys_dict_data dict where st_it.adjusted_type = dict.dict_sort and dict.status =0 and dict.dict_type ='adjusted_type') as adjustedType
from stocktakes st
left join stocktake_items st_it on st.id = st_it.stocktake_id and st_it.is_used = 1
left join materials ma on st_it.material_id = ma.sap_no and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.warehouses_code and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.location_code and sl.is_used = 1
left join materials ma on st_it.material_id = ma.id and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.id and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.id and sl.is_used = 1
left join sys_dict_data dict on ma.hazard_id = dict.dict_sort and dict.status =0 and dict.dict_type ='danger_type'
where
st.is_used = 1 and IFNULL(st_it.variance_quantity, 0) != 0
......@@ -152,11 +156,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
order by st.planned_date
</select>
<!-- 本月 盘盈金额 和 盘亏金额-->
<select id="selectstocktakeVarianceAmount" parameterType="StocktakeItems" resultType="java.util.Map">
select
SUM(CASE WHEN variance_amount &gt;= 0 THEN variance_amount ELSE 0 END) AS positiveTotal,
SUM(CASE WHEN variance_amount &lt; 0 THEN ABS(variance_amount) ELSE 0 END) AS negativeAbsTotal
from stocktake_items
where
is_used = 1 and IFNULL(variance_quantity, 0) != 0
AND date_format(create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
AND date_format(create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</select>
<!-- 本月 本月差异分析-->
<select id="selectItemsVarianceAnalysis" parameterType="StocktakeItems" resultType="java.util.Map">
select
COUNT(*) AS totalCount, -- 修改总记录数
ROUND(IFNULL(COUNT(CASE WHEN adjusted_type = 1 THEN 1 END) / NULLIF(COUNT(*), 0) * 100, 0), 2) AS type1Ratio,
ROUND(IFNULL(COUNT(CASE WHEN adjusted_type = 2 THEN 1 END) / NULLIF(COUNT(*), 0) * 100, 0), 2) AS type2Ratio,
ROUND(IFNULL(COUNT(CASE WHEN adjusted_type = 3 THEN 1 END) / NULLIF(COUNT(*), 0) * 100, 0), 2) AS type3Ratio
FROM stocktake_items
where
is_used = 1 and adjusted_type != '0'
AND date_format(create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
AND date_format(create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</select>
<insert id="insertStocktakeItems" parameterType="StocktakeItems">
insert into stocktake_items
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="adjustedType != null">adjusted_type,</if>
<if test="stocktakeId != null">stocktake_id,</if>
<if test="inventoryId != null">inventory_id,</if>
<if test="materialId != null">material_id,</if>
......@@ -189,6 +219,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="adjustedType != null">#{adjustedType},</if>
<if test="stocktakeId != null">#{stocktakeId},</if>
<if test="inventoryId != null">#{inventoryId},</if>
<if test="materialId != null">#{materialId},</if>
......@@ -224,6 +255,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateStocktakeItems" parameterType="StocktakeItems">
update stocktake_items
<trim prefix="SET" suffixOverrides=",">
<if test="adjustedType != null">adjusted_type = #{adjustedType},</if>
<if test="stocktakeId != null">stocktake_id = #{stocktakeId},</if>
<if test="inventoryId != null">inventory_id = #{inventoryId},</if>
<if test="materialId != null">material_id = #{materialId},</if>
......
......@@ -75,12 +75,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
,GROUP_CONCAT(DISTINCT dict.dict_label SEPARATOR ',') as hazardName
,IFNULL(sum(st_it.variance_quantity), '0') as countQuantity
,IFNULL(sum(st_it.variance_amount), '0') as countAmount
,GROUP_CONCAT(DISTINCT dict1.dict_label SEPARATOR ',') as adjustedType
from stocktakes st
left join stocktake_items st_it on st.id = st_it.stocktake_id and st_it.is_used = 1
left join materials ma on st_it.material_id = ma.sap_no and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.warehouses_code and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.location_code and sl.is_used = 1
left join materials ma on st_it.material_id = ma.id and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.id and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.id and sl.is_used = 1
left join sys_dict_data dict on ma.hazard_id = dict.dict_sort and dict.status =0 and dict.dict_type ='danger_type'
left join sys_dict_data dict1 on st_it.adjusted_type = dict1.dict_sort and dict1.status =0 and dict1.dict_type ='adjusted_type'
where
st.is_used = 1 and IFNULL(st_it.variance_quantity, 0) != 0
<if test="materialId != null "> and st_it.material_id = #{materialId}</if>
......@@ -94,6 +96,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="locationId != null "> and st_it.location_id = #{locationId}</if>
group by st_it.material_id
</select>
<!-- 首页-本月盘点次数-->
<select id="selectStocktakesCountByMonth" parameterType="Stocktakes" resultType="java.lang.Integer">
select count(*) from stocktakes
where is_used = 1
AND date_format(planned_date,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
AND date_format(planned_date,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</select>
<insert id="insertStocktakes" parameterType="Stocktakes">
......
......@@ -73,8 +73,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<!-- 获取库位表 的 location_code 编码 location_name 做成字典-->
<select id="getMapList" parameterType="StorageLocations" resultType="java.util.Map">
select location_code, IFNULL(location_name, '') as location_name from storage_locations where is_used = 1
<if test="warehousesCode != null and warehousesCode != ''"> and warehouses_code = #{warehousesCode}</if>
select id, IFNULL(location_name, '') as location_name from storage_locations where is_used = 1
<if test="warehousesCode != null and warehousesCode != ''"> and warehouses_id = #{warehousesCode}</if>
</select>
<insert id="insertStorageLocations" parameterType="StorageLocations">
......
......@@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<!-- 获取仓库 的 warehouses_code 仓库编码 warehouses_name 做成字典-->
<select id="getMapList" resultType="java.util.Map">
select warehouses_code, IFNULL(warehouses_name, '') as warehouses_name from warehouses where is_used = 1;
select id, IFNULL(warehouses_name, '') as warehouses_name from warehouses where is_used = 1;
</select>
<insert id="insertWarehouses" parameterType="Warehouses">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论