盘库前端页面为负数问题

This commit is contained in:
Ledo 2025-07-06 09:43:59 +08:00
parent 05d944ecd4
commit 4ffb6db0a2
12 changed files with 130 additions and 52 deletions

View File

@ -64,7 +64,7 @@ public class StorageCheckController {
@PreAuthorize("@ss.hasPermission('heli:storage-mat:create')") @PreAuthorize("@ss.hasPermission('heli:storage-mat:create')")
public CommonResult<Long> createStorageCheckMat(@Valid @RequestBody List<StorageCheckMatSaveReqVO> createReqVO, @RequestParam("checkId") Long checkId) { public CommonResult<Long> createStorageCheckMat(@Valid @RequestBody List<StorageCheckMatSaveReqVO> createReqVO, @RequestParam("checkId") Long checkId) {
storageCheckMatService.deleteCheckMatList(checkId); storageCheckMatService.deleteCheckMatListNew(checkId);
for (StorageCheckMatSaveReqVO item : createReqVO) { for (StorageCheckMatSaveReqVO item : createReqVO) {
item.setId(null); item.setId(null);

View File

@ -88,5 +88,5 @@ public class StorageInventoryPageReqVO extends PageParam {
@Schema(description = "是否排除库存为0的物料") @Schema(description = "是否排除库存为0的物料")
private Integer noZero; private Integer noZero;
@Schema(description = "是否全部数据") @Schema(description = "是否全部数据")
private boolean isALL; private Integer selectAll;
} }

View File

@ -8,6 +8,7 @@ import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storagecheckmat.StorageCheckMatDO; import com.chanko.yunxi.mes.module.heli.dal.dataobject.storagecheckmat.StorageCheckMatDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.chanko.yunxi.mes.module.heli.controller.admin.storagecheckmat.vo.*; import com.chanko.yunxi.mes.module.heli.controller.admin.storagecheckmat.vo.*;
import org.apache.ibatis.annotations.Param;
/** /**
* 盘点物料 Mapper * 盘点物料 Mapper
@ -35,6 +36,8 @@ public interface StorageCheckMatMapper extends BaseMapperX<StorageCheckMatDO> {
.orderByDesc(StorageCheckMatDO::getId)); .orderByDesc(StorageCheckMatDO::getId));
} }
int deleteCheckMatList(@Param("checkId") Long checkId);
default List<StorageCheckMatDO> selectListByCheckID(Long checkId) { default List<StorageCheckMatDO> selectListByCheckID(Long checkId) {
return selectList(new LambdaQueryWrapperX<StorageCheckMatDO>() return selectList(new LambdaQueryWrapperX<StorageCheckMatDO>()
.eqIfPresent(StorageCheckMatDO::getCheckId, checkId) .eqIfPresent(StorageCheckMatDO::getCheckId, checkId)

View File

@ -116,6 +116,7 @@ public interface StorageInventoryMapper extends BaseMapperX<StorageInventoryDO>
List<StorageInventoryDO> selectNowList(StorageInventoryPageReqVO reqVO); List<StorageInventoryDO> selectNowList(StorageInventoryPageReqVO reqVO);
List<StorageInventoryDO> selectNowListAll(StorageInventoryPageReqVO reqVO);
default PageResult<StorageInventoryDO> getStorageNowPageAll(StorageLogPageReqVO pageReqVO){ default PageResult<StorageInventoryDO> getStorageNowPageAll(StorageLogPageReqVO pageReqVO){
// MPJLambdaWrapper<MaterialDO> query = new MPJLambdaWrapper<>(); // MPJLambdaWrapper<MaterialDO> query = new MPJLambdaWrapper<>();
// //

View File

@ -170,7 +170,7 @@ public class StorageCheckServiceImpl implements StorageCheckService {
//要同步设置 //要同步设置
} else { } else {
storageInventoryDO.setYardAmount(storageInventoryDO.getYardAmount().add(storageMatDO.getStorageOkQty())); storageInventoryDO.setYardAmount(storageMatDO.getStorageOkQty());
} }
if (storageMatDO.getOnemoney() != null && !storageMatDO.getOnemoney().trim().equals("")) { if (storageMatDO.getOnemoney() != null && !storageMatDO.getOnemoney().trim().equals("")) {
@ -188,7 +188,7 @@ public class StorageCheckServiceImpl implements StorageCheckService {
wrapper.eq(StorageInventoryDO::getDeleted, 0); wrapper.eq(StorageInventoryDO::getDeleted, 0);
StorageInventoryDO storageInventoryDO = storageInventoryMapper.selectOne(wrapper); StorageInventoryDO storageInventoryDO = storageInventoryMapper.selectOne(wrapper);
if (ObjectUtil.isNotEmpty(storageInventoryDO)) { if (ObjectUtil.isNotEmpty(storageInventoryDO)) {
storageInventoryDO.setYardAmount(storageInventoryDO.getYardAmount().subtract(storageMatDO.getStorageOkQty())); storageInventoryDO.setYardAmount(storageMatDO.getStorageOkQty());
} }
if (storageMatDO.getOnemoney() != null && !storageMatDO.getOnemoney().trim().equals("")) { if (storageMatDO.getOnemoney() != null && !storageMatDO.getOnemoney().trim().equals("")) {
BigDecimal bigDecimal = new BigDecimal(storageMatDO.getOnemoney()); BigDecimal bigDecimal = new BigDecimal(storageMatDO.getOnemoney());

View File

@ -55,5 +55,5 @@ public interface StorageCheckMatService {
List<StorageCheckMatDO> getStorageMatListByCheckId(Long id); List<StorageCheckMatDO> getStorageMatListByCheckId(Long id);
Integer deleteCheckMatList(Long checkId); Integer deleteCheckMatList(Long checkId);
Integer deleteCheckMatListNew(Long checkId);
} }

View File

@ -146,4 +146,10 @@ public class StorageCheckMatServiceImpl implements StorageCheckMatService {
return storageCheckMatMapper.deleteByMap(columnMap); return storageCheckMatMapper.deleteByMap(columnMap);
} }
@Override
public Integer deleteCheckMatListNew(Long checkId) {
//删除条件
return storageCheckMatMapper.deleteCheckMatList(checkId);
}
} }

View File

@ -86,8 +86,8 @@ public class StorageInventoryServiceImpl implements StorageInventoryService {
return storageInventoryMapper.selectNoZero(queryReqVO); return storageInventoryMapper.selectNoZero(queryReqVO);
}else{ }else{
// 筛选全部的实时库存数据包含未分配仓库的物料信息和已分配仓库的物料信息 // 筛选全部的实时库存数据包含未分配仓库的物料信息和已分配仓库的物料信息
if(queryReqVO.isALL()){ if(queryReqVO.getSelectAll() == 1){
return storageInventoryMapper.selectNowList(queryReqVO); return storageInventoryMapper.selectNowListAll(queryReqVO);
}else{ }else{
return storageInventoryMapper.selectNowList(queryReqVO); return storageInventoryMapper.selectNowList(queryReqVO);
} }

View File

@ -8,5 +8,7 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/ 文档可见https://www.iocoder.cn/MyBatis/x-plugins/
--> -->
<delete id="deleteCheckMatList" parameterType="java.lang.Long" >
delete from wms_storage_check_mat where check_id = #{checkId}
</delete>
</mapper> </mapper>

View File

@ -54,6 +54,65 @@
AND t.tenant_id = 2 AND t.tenant_id = 2
GROUP BY GROUP BY
t.id t.id
) gh
<where>
<if test="matCode != null and matCode != ''">
AND (gh.mat_code LIKE CONCAT('%', #{matCode}, '%') OR gh.mat_name LIKE CONCAT('%', #{matCode}, '%'))
</if>
<if test="matType != null and matType != ''">
AND gh.mat_type = #{matType}
</if>
<if test="matSpec != null and matSpec != ''">
AND gh.mat_spec LIKE CONCAT('%', #{matSpec}, '%')
</if>
</where>
ORDER BY gh.mat_code
</select>
<select id="selectNowListAll"
parameterType="com.chanko.yunxi.mes.module.heli.controller.admin.storageinventory.vo.StorageInventoryPageReqVO"
resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.storageinventory.StorageInventoryDO">
SELECT DISTINCT *
FROM (
-- 第一部分:查询当前库存中的物料
SELECT
t.material_id as id,
t.material_id as material_id,
t.boom_spec as boom_spec,
t.boom_unit as boom_unit,
m.name AS mat_name,
m.code AS mat_code,
d.label AS mat_type,
m.spec AS mat_spec,
m.brand AS mat_band,
d1.label AS mat_unit,
t.wh_id as wh_id,
t.rg_id as rg_id,
t.pn_id as pn_id,
w.wh_name AS wh_name,
r.rg_name AS rg_name,
p.pn_name AS pn_name,
t.lot_no as lot_no,
IFNULL(t.price, 0)as price,
t.short_name as short_name,
IFNULL(SUM(t.yard_amount), 0) AS mat_rest,
0 as exist
FROM
wms_storage_inventory t
LEFT JOIN base_material m ON m.id = t.material_id AND m.tenant_id = 2
LEFT JOIN system_dict_data d ON d.value = m.material_type AND d.dict_type = 'heli_material_type'
LEFT JOIN system_dict_data d1 ON d1.value = m.unit AND d1.dict_type = 'heli_material_unit'
LEFT JOIN wms_wh w ON w.id = t.wh_id AND w.tenant_id = 2
LEFT JOIN wms_rg r ON r.id = t.rg_id AND r.tenant_id = 2
LEFT JOIN wms_pn p ON p.id = t.pn_id AND p.tenant_id = 2
WHERE
t.deleted = 0
AND t.wh_id = #{whId}
AND m.virtual_part = 'N'
AND m.status = 1
AND t.tenant_id = 2
GROUP BY
t.id
UNION ALL UNION ALL
@ -103,6 +162,9 @@
<if test="matSpec != null and matSpec != ''"> <if test="matSpec != null and matSpec != ''">
AND gh.mat_spec LIKE CONCAT('%', #{matSpec}, '%') AND gh.mat_spec LIKE CONCAT('%', #{matSpec}, '%')
</if> </if>
<if test="matSpec != null and matSpec != ''">
AND gh.mat_spec LIKE CONCAT('%', #{matSpec}, '%')
</if>
</where> </where>
ORDER BY gh.mat_code ORDER BY gh.mat_code
</select> </select>

View File

@ -135,7 +135,7 @@
<template #header> <span class="hl-table_header">*</span>盘点数量</template> <template #header> <span class="hl-table_header">*</span>盘点数量</template>
<template #default="scope"> <template #default="scope">
<el-form-item :prop="`${scope.$index}.storageOkQty`" :rules="subFormRules.storageOkQty" class="mb-0px!"> <el-form-item :prop="`${scope.$index}.storageOkQty`" :rules="subFormRules.storageOkQty" class="mb-0px!">
<el-input v-model="scope.row.storageOkQty" @change="(val)=>handleSub(val,scope)" :disabled="ctrView || ctrSave" /> <el-input-number v-model="scope.row.storageOkQty" :min="0" @change="(val)=>handleSub(val,scope)" :disabled="ctrView || ctrSave"/>
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
@ -151,7 +151,7 @@
<el-table-column prop="onemoney" label="单价" min-width="120" align="center"> <el-table-column prop="onemoney" label="单价" min-width="120" align="center">
<template #default="scope"> <template #default="scope">
<el-form-item :prop="`${scope.$index}.onemoney`" class="mb-0px!" > <el-form-item :prop="`${scope.$index}.onemoney`" class="mb-0px!" >
<el-input v-model="scope.row.onemoney" :disabled="ctrView || ctrSave" /> <el-input-number v-model="scope.row.onemoney" :min="0" :disabled="ctrView || ctrSave"/>
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
@ -733,7 +733,10 @@ const handleSub = async (pNum, scope) => {
//------------------- //-------------------
// scope.row.matSub = Number(pNum) - Number(scope.row.matRest) // scope.row.matSub = Number(pNum) - Number(scope.row.matRest)
// console.log(typeof scope.row.matSub) // console.log(typeof scope.row.matSub)
if(scope.row.storageOkQty < 0){
scope.row.storageOkQty = 0;
}
const matSubValue = Number(pNum) - Number(scope.row.matRest) const matSubValue = Number(pNum) - Number(scope.row.matRest)
scope.row.matSub = matSubValue.toFixed(2) // scope.row.matSub = matSubValue.toFixed(2) //
console.log(typeof scope.row.matSub) console.log(typeof scope.row.matSub)

View File

@ -94,7 +94,7 @@ const queryReqVo: any = reactive({
matCode: undefined, matCode: undefined,
matType: undefined, matType: undefined,
matSpec: undefined, matSpec: undefined,
isAll:false, selectAll: 0,
}) })
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = async () => { const handleQuery = async () => {
@ -125,7 +125,7 @@ const getList = async () => {
} }
const overallList = async () => { const overallList = async () => {
// queryReqVo.pageSize = overallnum.value // queryReqVo.pageSize = overallnum.value
queryReqVo.isAll = true queryReqVo.selectAll = 1
const data1 = await SotrageInventoryApi.getStorageNowList(queryReqVo) const data1 = await SotrageInventoryApi.getStorageNowList(queryReqVo)
// queryReqVo.pageSize = 10 // queryReqVo.pageSize = 10
handleSelectionChange(data1) handleSelectionChange(data1)
@ -149,6 +149,7 @@ const open = async (noZero: number, whId?: number, isAll?: number) => {
getList() getList()
chkboxEnable.value = isAll === 2 ? false : true chkboxEnable.value = isAll === 2 ? false : true
if (isAll == 2) { if (isAll == 2) {
queryReqVo.selectAll = 1
getList() getList()
overallList() overallList()
} }