提醒修正查询逻辑及入库时检查安全库存
This commit is contained in:
parent
4243d2e464
commit
d92f3feff5
@ -2,12 +2,18 @@ package com.chanko.yunxi.mes.module.heli.controller.admin.storagemat;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.StorageSaveReqVO;
|
import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.StorageSaveReqVO;
|
||||||
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.bdgzsomthing.bdgzsomthingDO;
|
||||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.deliverorder.DeliverOrderDO;
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.deliverorder.DeliverOrderDO;
|
||||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.serialnumber.SerialNumberDO;
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.serialnumber.SerialNumberDO;
|
||||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO;
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO;
|
||||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storagelog.StorageLogDO;
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storagelog.StorageLogDO;
|
||||||
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storagelogNow.StorageLogNowDO;
|
||||||
|
import com.chanko.yunxi.mes.module.heli.dal.mysql.bdgzsomthing.bdgzsomthingMapper;
|
||||||
import com.chanko.yunxi.mes.module.heli.dal.mysql.deliverorder.DeliverOrderMapper;
|
import com.chanko.yunxi.mes.module.heli.dal.mysql.deliverorder.DeliverOrderMapper;
|
||||||
|
import com.chanko.yunxi.mes.module.heli.dal.mysql.storage.StorageMapper;
|
||||||
|
import com.chanko.yunxi.mes.module.heli.dal.mysql.storagelog.StorageLogNowMapper;
|
||||||
import com.chanko.yunxi.mes.module.heli.enums.CodeEnum;
|
import com.chanko.yunxi.mes.module.heli.enums.CodeEnum;
|
||||||
|
import com.chanko.yunxi.mes.module.heli.service.bdgzsomthing.bdgzsomthingService;
|
||||||
import com.chanko.yunxi.mes.module.heli.service.serialnumber.SerialNumberService;
|
import com.chanko.yunxi.mes.module.heli.service.serialnumber.SerialNumberService;
|
||||||
import com.chanko.yunxi.mes.module.heli.service.storage.StorageService;
|
import com.chanko.yunxi.mes.module.heli.service.storage.StorageService;
|
||||||
import com.chanko.yunxi.mes.module.heli.service.storagelog.StorageLogService;
|
import com.chanko.yunxi.mes.module.heli.service.storagelog.StorageLogService;
|
||||||
@ -55,7 +61,12 @@ public class StorageMatController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private StorageMatService storageMatService;
|
private StorageMatService storageMatService;
|
||||||
|
@Resource
|
||||||
|
private StorageMapper storageMapper;
|
||||||
|
@Resource
|
||||||
|
private bdgzsomthingService bdgzsomthingService;
|
||||||
|
@Resource
|
||||||
|
private StorageLogNowMapper storageLogNowMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private SerialNumberService serialNumberService;
|
private SerialNumberService serialNumberService;
|
||||||
|
|
||||||
@ -86,12 +97,50 @@ public class StorageMatController {
|
|||||||
@Operation(summary = "批量创建入/出库物料")
|
@Operation(summary = "批量创建入/出库物料")
|
||||||
@PreAuthorize("@ss.hasPermission('heli:storage-mat:create')")
|
@PreAuthorize("@ss.hasPermission('heli:storage-mat:create')")
|
||||||
public CommonResult<Long> createStorageMat(@Valid @RequestBody List<StorageMatSaveReqVO> createReqVO,@RequestParam("stockid") Long stockid) {
|
public CommonResult<Long> createStorageMat(@Valid @RequestBody List<StorageMatSaveReqVO> createReqVO,@RequestParam("stockid") Long stockid) {
|
||||||
|
|
||||||
storageMatService.deleteStorageMatList(stockid);
|
storageMatService.deleteStorageMatList(stockid);
|
||||||
|
List<String> attr3List = new ArrayList<>();
|
||||||
for (StorageMatSaveReqVO item : createReqVO) {
|
for (StorageMatSaveReqVO item : createReqVO) {
|
||||||
item.setId(null);
|
item.setId(null);
|
||||||
|
if (item.getMatCode()!=null){
|
||||||
|
attr3List.add(item.getMatCode());
|
||||||
|
}
|
||||||
storageMatService.createStorageMat(item);
|
storageMatService.createStorageMat(item);
|
||||||
}
|
}
|
||||||
|
//如果上面插入数据没报错
|
||||||
|
StorageDO storageDO = storageMapper.selectById(stockid);
|
||||||
|
//查询入库单,因为要删待办
|
||||||
|
if (storageDO.getStockType()==1){
|
||||||
|
//如果是要入库,就要删除待办了
|
||||||
|
//查有没有这个物料
|
||||||
|
if (CollUtil.isNotEmpty(attr3List)){
|
||||||
|
//查找待办中有提醒的
|
||||||
|
List<bdgzsomthingDO> bdgzsomthingDOList = bdgzsomthingService.selectSafeStorage(attr3List);
|
||||||
|
if (CollUtil.isNotEmpty(bdgzsomthingDOList)){
|
||||||
|
//如果有这个物料在提醒,就要看这次入库有没有满足需求,如果满足了,就删除提醒
|
||||||
|
List<String> matCodeInDb = bdgzsomthingDOList.stream()
|
||||||
|
.map(bdgzsomthingDO::getAttr3)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
//查出来仍然满足条件的 这部分是不需要更新的
|
||||||
|
List<StorageLogNowDO> storageLogNowDOS = storageLogNowMapper.selectPagesmall2(matCodeInDb);
|
||||||
|
//更新不满足安全库存小于实时库存的,即不在storageLogNowDOS里面的
|
||||||
|
Set<String> matCodesInStorageLog = storageLogNowDOS.stream()
|
||||||
|
.map(StorageLogNowDO::getMatCode)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
// 过滤bdgzsomthingDOList,只保留attr3不在matCodesInStorageLog中的元素
|
||||||
|
List<bdgzsomthingDO> filteredList = bdgzsomthingDOList.stream()
|
||||||
|
.filter(bdgzsomthingDO -> !matCodesInStorageLog.contains(bdgzsomthingDO.getAttr3()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
for (bdgzsomthingDO bdgzsomthingDO : filteredList) {
|
||||||
|
bdgzsomthingDO.setAttr4("1");
|
||||||
|
bdgzsomthingDO.setAttr12("1");
|
||||||
|
bdgzsomthingService.updateById(bdgzsomthingDO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return success(1L);
|
return success(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,8 +192,7 @@ public class StorageMatController {
|
|||||||
@Operation(summary = "导出入/出库物料 Excel")
|
@Operation(summary = "导出入/出库物料 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('heli:storage-mat:export')")
|
@PreAuthorize("@ss.hasPermission('heli:storage-mat:export')")
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void exportStorageMatExcel(@Valid StorageMatPageReqVO pageReqVO,
|
public void exportStorageMatExcel(@Valid StorageMatPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||||
HttpServletResponse response) throws IOException {
|
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<StorageMatDO> list = storageMatService.getStorageMatPage(pageReqVO);
|
List<StorageMatDO> list = storageMatService.getStorageMatPage(pageReqVO);
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
|
@ -22,6 +22,7 @@ public class StorageMatSaveReqVO {
|
|||||||
@NotNull(message = "物料 Id,对应 base_material表中的 Id 列不能为空")
|
@NotNull(message = "物料 Id,对应 base_material表中的 Id 列不能为空")
|
||||||
private Long matId;
|
private Long matId;
|
||||||
|
|
||||||
|
private String matCode;
|
||||||
@Schema(description = "仓库 Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31860")
|
@Schema(description = "仓库 Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31860")
|
||||||
@NotNull(message = "仓库 Id,对应 wms_wh 表中的Id不能为空")
|
@NotNull(message = "仓库 Id,对应 wms_wh 表中的Id不能为空")
|
||||||
private Long whId;
|
private Long whId;
|
||||||
|
@ -114,4 +114,15 @@ public interface bdgzsomthingMapper extends BaseMapperX<bdgzsomthingDO> {
|
|||||||
int deleteByIdNew(@Param("id") Long id);
|
int deleteByIdNew(@Param("id") Long id);
|
||||||
int deleteByIdNew1(@Param("id") Long id);
|
int deleteByIdNew1(@Param("id") Long id);
|
||||||
void deleteOrder(bdgzsomthingDO BdgzsomthingDO);
|
void deleteOrder(bdgzsomthingDO BdgzsomthingDO);
|
||||||
|
|
||||||
|
default List<bdgzsomthingDO> selectSafeStorage(List<String> attr3List){
|
||||||
|
MPJLambdaQueryWrapper<bdgzsomthingDO> query = new MPJLambdaQueryWrapper<>();
|
||||||
|
query.eq(bdgzsomthingDO::getAttr4,0)
|
||||||
|
.eq(bdgzsomthingDO::getThingname,"库存低于安全库存")
|
||||||
|
.in(bdgzsomthingDO::getAttr3,attr3List)
|
||||||
|
.eq(bdgzsomthingDO::getAttr12,"0").or(
|
||||||
|
e->e.isNull(bdgzsomthingDO::getAttr12)
|
||||||
|
);
|
||||||
|
return selectList(query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public interface StorageLogNowMapper extends BaseMapperX<StorageLogNowDO> {
|
|||||||
|
|
||||||
List<StorageLogNowDO> selectPagesmall(Long id);
|
List<StorageLogNowDO> selectPagesmall(Long id);
|
||||||
List<StorageLogNowDO> selectPagesmall1();
|
List<StorageLogNowDO> selectPagesmall1();
|
||||||
|
List<StorageLogNowDO> selectPagesmall2(List<String> matCode);
|
||||||
List<StorageLogNowDO> selectPagesmallbyid(String id);
|
List<StorageLogNowDO> selectPagesmallbyid(String id);
|
||||||
default PageResult<StorageLogNowDO> selectPage(StorageLogPageReqVO reqVO) {
|
default PageResult<StorageLogNowDO> selectPage(StorageLogPageReqVO reqVO) {
|
||||||
MPJLambdaWrapper<StorageLogNowDO> query = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<StorageLogNowDO> query = new MPJLambdaWrapper<>();
|
||||||
|
@ -63,4 +63,6 @@ public interface bdgzsomthingService {
|
|||||||
|
|
||||||
void selectds();
|
void selectds();
|
||||||
public void selectSafeStorageAndDeliverOneYear();
|
public void selectSafeStorageAndDeliverOneYear();
|
||||||
|
public List<bdgzsomthingDO> selectSafeStorage(List<String> attr3List);
|
||||||
|
public int updateById(bdgzsomthingDO entity);
|
||||||
}
|
}
|
||||||
|
@ -814,6 +814,13 @@ public class bdgzsomthingServiceImpl implements bdgzsomthingService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int updateById(bdgzsomthingDO entity){
|
||||||
|
return bdgzsomthingMapper.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<bdgzsomthingDO> selectSafeStorage(List<String> attr3List){
|
||||||
|
return bdgzsomthingMapper.selectSafeStorage(attr3List);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*功能描述 安全库存和发货超一年
|
*功能描述 安全库存和发货超一年
|
||||||
* @param
|
* @param
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
select * from dbzz_table where showname=#{showname} and attr3=#{attr3} and attr4='0' and click=#{click}
|
select * from dbzz_table where showname=#{showname} and attr3=#{attr3} and attr4='0' and click=#{click}
|
||||||
and dborgz=#{dborgz}
|
and dborgz=#{dborgz}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selecteqintq"
|
<select id="selecteqintq"
|
||||||
parameterType="com.chanko.yunxi.mes.module.heli.dal.dataobject.bdgzsomthing.bdgzsomthingDO"
|
parameterType="com.chanko.yunxi.mes.module.heli.dal.dataobject.bdgzsomthing.bdgzsomthingDO"
|
||||||
resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.bdgzsomthing.bdgzsomthingDO">
|
resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.bdgzsomthing.bdgzsomthingDO">
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
ON FIND_IN_SET(p.id, t.sale_order_ids) AND p.tenant_id = 1
|
ON FIND_IN_SET(p.id, t.sale_order_ids) AND p.tenant_id = 1
|
||||||
LEFT JOIN system_users u ON (u.id = t.deliver_person) AND u.tenant_id = 1
|
LEFT JOIN system_users u ON (u.id = t.deliver_person) AND u.tenant_id = 1
|
||||||
LEFT JOIN base_customer e ON (e.id = t.customer_id) AND e.tenant_id = 1
|
LEFT JOIN base_customer e ON (e.id = t.customer_id) AND e.tenant_id = 1
|
||||||
WHERE t.deleted = 0 AND (t.deliver_status = 2) AND t.tenant_id = 1
|
WHERE t.deleted = 0 AND (t.deliver_status = 2)
|
||||||
and DATE_ADD(t.deliver_date, INTERVAL 1 YEAR) < CURDATE()
|
and DATE_ADD(t.deliver_date, INTERVAL 1 YEAR) < CURDATE()
|
||||||
and t.show_zbmoney is null and t.deliver_status in('2')
|
and t.show_zbmoney is null and t.deliver_status in('2')
|
||||||
and t.tenant_id =#{param1}
|
and t.tenant_id =#{param1}
|
||||||
|
@ -132,6 +132,42 @@
|
|||||||
and a.tenant_id =#{param1}
|
and a.tenant_id =#{param1}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectPagesmall2"
|
||||||
|
resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.storagelogNow.StorageLogNowDO">
|
||||||
|
SELECT
|
||||||
|
b.mat_code id,
|
||||||
|
b.create_time,
|
||||||
|
b.mat_name,
|
||||||
|
b.total_storage_ok_qty,
|
||||||
|
b.creator
|
||||||
|
FROM
|
||||||
|
(SELECT
|
||||||
|
mat_code,
|
||||||
|
create_time,
|
||||||
|
mat_name,creator,
|
||||||
|
id,
|
||||||
|
SUM(storage_ok_qty) AS total_storage_ok_qty
|
||||||
|
FROM
|
||||||
|
v_storage_material_now
|
||||||
|
GROUP BY
|
||||||
|
mat_code,
|
||||||
|
create_time,
|
||||||
|
mat_name,
|
||||||
|
id,creator) b
|
||||||
|
JOIN
|
||||||
|
base_material a ON b.mat_code = a.code
|
||||||
|
WHERE
|
||||||
|
b.total_storage_ok_qty < a.inv_safe
|
||||||
|
and a.tenant_id =2
|
||||||
|
and b.mat_code IN
|
||||||
|
<foreach item="matCode" collection="list" open="(" separator="," close=")">
|
||||||
|
#{matCode}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectPagesmall1"
|
<select id="selectPagesmall1"
|
||||||
parameterType="Long"
|
parameterType="Long"
|
||||||
resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.storagelogNow.StorageLogNowDO">
|
resultType="com.chanko.yunxi.mes.module.heli.dal.dataobject.storagelogNow.StorageLogNowDO">
|
||||||
|
Loading…
Reference in New Issue
Block a user