'20240318'

This commit is contained in:
xd 2024-03-18 09:45:03 +08:00
parent 09d6670b8e
commit c227a8c401
8 changed files with 268 additions and 52 deletions

View File

@ -1,6 +1,5 @@
package com.ruoyi.web.controller.storageLocation;
import com.ruoyi.clMaterial.domain.CYlMaterial;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.CacheConstants;
@ -11,13 +10,12 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.storageLocation.domain.StorageLocation;
import com.ruoyi.storageLocation.domain.StorageSelected;
import com.ruoyi.storageLocation.service.StorageLocationService;
import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -106,6 +104,7 @@ public class storageLocationController extends BaseController
return error("已超过有效录入信息时间,当前库位有人正在操作!");
}else{
redisCache.setCacheObject(getLocationZyCacheKey(materialBh),user_name);
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
return toAjax(storageLocationService.addStorageLocation(storageLocation));
}
@ -167,42 +166,26 @@ public class storageLocationController extends BaseController
ajaxResult.put("materialDetailB",listB);
ajaxResult.put("materialDetailC",listC);
//根据库位状态 同步更新库位占用缓存-刷新页面时用
for(StorageLocation sl:listA){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if("1".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
}
}
for(StorageLocation sl:listB){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if("1".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
}
}
for(StorageLocation sl:listC){
String materialBh = sl.getMaterialBh();
String materialState = sl.getMaterialState();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if("1".equals(materialState)){
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
}
// 读取已选列表
List<StorageLocation> selectedListA = storageLocationService.selectStorageSelectedLocationAList(user_name);
List<StorageLocation> selectedListB = storageLocationService.selectStorageSelectedLocationBList(user_name);
List<StorageLocation> selectedListC = storageLocationService.selectStorageSelectedLocationCList(user_name);
ajaxResult.put("selMaterialDetailA",selectedListA);
ajaxResult.put("selMaterialDetailB",selectedListB);
ajaxResult.put("selMaterialDetailC",selectedListC);
// 读取全部已选列表
List<StorageSelected> selectedList = storageLocationService.selectStorageSelectedLocationList();
for(StorageSelected sl:selectedList){
String materialBh = sl.getMaterial_bh();
String userName = sl.getUser_name();
redisCache.setCacheObject(getLocationLyCacheKey(materialBh),userName);//缓存keys丢失重新设置缓存key
}
return ajaxResult;
}
/**
* 校验库位是否被领用
*/
@ -210,16 +193,27 @@ public class storageLocationController extends BaseController
@PostMapping("/checklyStorageLocation")
public AjaxResult checklyStorageLocation(@RequestBody StorageLocation storageLocation)
{
String storageExpire = configService.selectConfigByKey("storage.expire.ly");
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){
return error("当前库位有人正在操作,请勿操作!");
return error("该库位当前有人正在操作,请勿操作!");
}else{
// 判断已选库位表是否存在库位信息
StorageSelected storageSelected = storageLocationService.hasStorageLocation(materialBh);
if(storageSelected!=null){
if(!user_name.equals(storageSelected.getUser_name())){
return error("该库位当前有人正在领用操作,请勿操作!");
}else{
return error("该库位已被选择领用,请勿重复操作!");
}
}else{
// 保存至已选库位表并缓存
redisCache.setCacheObject(getLocationLyCacheKey(materialBh),user_name);
storageLocationService.saveStorageLocation(user_name,materialBh);
}
return success();
}
}
@ -238,6 +232,7 @@ public class storageLocationController extends BaseController
if(StringUtils.isNotNull(kw_user_name)&&user_name.equals(kw_user_name)){
redisCache.deleteObject(getLocationLyCacheKey(materialBh));
}
storageLocationService.deleteStorageLocation(user_name,materialBh);
return success();
}
@ -249,20 +244,15 @@ public class storageLocationController extends BaseController
public AjaxResult confirmStorageLocation(@RequestBody String [] materialBhArr)
{
System.out.println(materialBhArr);
/* String storageExpire = configService.selectConfigByKey("storage.expire.ly");
String user_name = getLoginUser().getUsername();//当前登陆者
String materialBh = storageLocation.getMaterialBh();
String kw_user_name = redisCache.getCacheObject(getLocationLyCacheKey(materialBh));
if(StringUtils.isNotNull(kw_user_name)&&!user_name.equals(kw_user_name)){
return error("当前库位有人正在操作,请勿操作!");
}else{
redisCache.setCacheObject(getLocationLyCacheKey(materialBh),user_name);
return success();
}*/
storageLocationService.confirmStorageLocation(materialBhArr);
List<String> list = new ArrayList<String>();
for(String materialBh:materialBhArr){
list.add(getLocationZyCacheKey(materialBh));
}
Collection<List<String>> collection = new ArrayList<>();
collection.add(list);
redisCache.deleteObject(collection);// 清空占用缓存keys
return success();
}

View File

@ -12,6 +12,7 @@ public class StorageLocation extends BaseEntity
{
private static final long serialVersionUID = 1L;
private String userName;
private String materialBh;
private String materialZlh;
private String materialXingh;
@ -20,6 +21,14 @@ public class StorageLocation extends BaseEntity
private String materialMs;
private String materialState;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getMaterialBh() {
return materialBh;
}

View File

@ -0,0 +1,28 @@
package com.ruoyi.storageLocation.domain;
/**
* 已选库位管理对象 StorageLocation
*
* @author ruoyi
* @date 2024-02-28
*/
public class StorageSelected {
private String user_name;
private String material_bh;
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getMaterial_bh() {
return material_bh;
}
public void setMaterial_bh(String material_bh) {
this.material_bh = material_bh;
}
}

View File

@ -1,6 +1,8 @@
package com.ruoyi.storageLocation.mapper;
import com.ruoyi.storageLocation.domain.StorageLocation;
import com.ruoyi.storageLocation.domain.StorageSelected;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -34,4 +36,39 @@ public interface StorageLocationMapper
* @param materialBhArr
*/
void confirmStorageLocation(String[] materialBhArr);
/**
* 判断已选库位表是否存在库位信息
* @param materialBh
* @return
*/
StorageSelected hasStorageLocation(String materialBh);
/**
* 保存至已选库位表
* @param materialBh
*/
void saveStorageLocation(@Param("userName") String userName, @Param("materialBh") String materialBh);
/**
* 删除已选库位表记录
* @param userName
* @param materialBh
*/
void deleteStorageLocation(@Param("userName") String userName, @Param("materialBh") String materialBh);
/**
* 读取已选列表
* @param userName
* @return
*/
List<StorageLocation> selectStorageSelectedLocationAList(String userName);
List<StorageLocation> selectStorageSelectedLocationBList(String userName);
List<StorageLocation> selectStorageSelectedLocationCList(String userName);
/**
* 读取全部已选列表
* @return
*/
List<StorageSelected> selectStorageSelectedLocationList();
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.storageLocation.service;
import com.ruoyi.clMaterial.domain.CYlMaterial;
import com.ruoyi.storageLocation.domain.StorageLocation;
import com.ruoyi.storageLocation.domain.StorageSelected;
import java.util.List;
@ -35,4 +36,39 @@ public interface StorageLocationService
* @param materialBhArr
*/
void confirmStorageLocation(String[] materialBhArr);
/**
* 判断已选库位表是否存在库位信息
* @param materialBh
* @return
*/
StorageSelected hasStorageLocation(String materialBh);
/**
* 保存至已选库位表
* @param materialBh
*/
void saveStorageLocation(String userName,String materialBh);
/**
* 删除已选库位表记录
* @param userName
* @param materialBh
*/
void deleteStorageLocation(String userName, String materialBh);
/**
* 读取已选列表
* @param userName
* @return
*/
List<StorageLocation> selectStorageSelectedLocationAList(String userName);
List<StorageLocation> selectStorageSelectedLocationBList(String userName);
List<StorageLocation> selectStorageSelectedLocationCList(String userName);
/**
* 读取全部已选列表
* @return
*/
List<StorageSelected> selectStorageSelectedLocationList();
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.storageLocation.service.impl;
import com.ruoyi.storageLocation.domain.StorageLocation;
import com.ruoyi.storageLocation.domain.StorageSelected;
import com.ruoyi.storageLocation.mapper.StorageLocationMapper;
import com.ruoyi.storageLocation.service.StorageLocationService;
import org.springframework.beans.factory.annotation.Autowired;
@ -56,4 +57,60 @@ public class StorageLocationServiceImpl implements StorageLocationService
public void confirmStorageLocation(String[] materialBhArr) {
storageLocationMapper.confirmStorageLocation(materialBhArr);
}
/**
* 判断已选库位表是否存在库位信息
* @param materialBh
* @return
*/
@Override
public StorageSelected hasStorageLocation(String materialBh) {
return storageLocationMapper.hasStorageLocation(materialBh);
}
/**
* 保存至已选库位表
* @param materialBh
*/
@Override
public void saveStorageLocation(String userName,String materialBh) {
storageLocationMapper.saveStorageLocation(userName,materialBh);
}
/**
* 删除已选库位表记录
* @param userName
* @param materialBh
*/
@Override
public void deleteStorageLocation(String userName, String materialBh) {
storageLocationMapper.deleteStorageLocation(userName,materialBh);
}
/**
* 读取已选列表
* @param userName
* @return
*/
@Override
public List<StorageLocation> selectStorageSelectedLocationAList(String userName) {
return storageLocationMapper.selectStorageSelectedLocationAList(userName);
}
@Override
public List<StorageLocation> selectStorageSelectedLocationBList(String userName) {
return storageLocationMapper.selectStorageSelectedLocationBList(userName);
}
@Override
public List<StorageLocation> selectStorageSelectedLocationCList(String userName) {
return storageLocationMapper.selectStorageSelectedLocationCList(userName);
}
/**
* 读取全部已选列表
* @return
*/
@Override
public List<StorageSelected> selectStorageSelectedLocationList() {
return storageLocationMapper.selectStorageSelectedLocationList();
}
}

View File

@ -5,6 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.storageLocation.mapper.StorageLocationMapper">
<resultMap type="StorageLocation" id="StorageLocationResult">
<result property="userName" column="userName" />
<result property="materialBh" column="materialBh" />
<result property="materialZlh" column="materialZlh" />
<result property="materialXingh" column="materialXingh" />
@ -50,5 +51,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</update>
<select id="hasStorageLocation" parameterType="java.lang.String" resultType="StorageSelected">
select user_name, material_bh
from storageSelected where material_bh = #{materialBh}
</select>
<insert id="saveStorageLocation" parameterType="java.lang.String">
insert into storageSelected (user_name,material_bh) values (#{userName},#{materialBh})
</insert>
<delete id="deleteStorageLocation">
delete from storageSelected where user_name = #{userName} and material_bh = #{materialBh}
</delete>
<select id="selectStorageSelectedLocationAList" parameterType="java.lang.String" resultMap="StorageLocationResult">
select a.user_name userName,b.materialBh,b.materialXingh,
b.materialGuig,b.materialDiany,
b.materialMs,b.materialZlh
from storageSelected a
left join storageLocation b
on a.material_Bh = b.materialBh
where a.user_name = #{userName} and a.material_bh like 'A%'
</select>
<select id="selectStorageSelectedLocationBList" parameterType="java.lang.String" resultMap="StorageLocationResult">
select a.user_name userName,b.materialBh,b.materialXingh,
b.materialGuig,b.materialDiany,
b.materialMs,b.materialZlh
from storageSelected a
left join storageLocation b
on a.material_Bh = b.materialBh
where a.user_name = #{userName} and a.material_bh like 'B%'
</select>
<select id="selectStorageSelectedLocationCList" parameterType="java.lang.String" resultMap="StorageLocationResult">
select a.user_name userName,b.materialBh,b.materialXingh,
b.materialGuig,b.materialDiany,
b.materialMs,b.materialZlh
from storageSelected a
left join storageLocation b
on a.material_Bh = b.materialBh
where a.user_name = #{userName} and a.material_bh like 'C%'
</select>
<select id="selectStorageSelectedLocationList" resultType="StorageSelected">
select user_name,material_bh
from storageSelected
</select>
</mapper>

View File

@ -519,6 +519,11 @@
this.materialDetailA = response.materialDetailA;
this.materialDetailB = response.materialDetailB;
this.materialDetailC = response.materialDetailC;
//
this.selMaterialDetailA = response.selMaterialDetailA;
this.selMaterialDetailB = response.selMaterialDetailB;
this.selMaterialDetailC = response.selMaterialDetailC;
});
},
@ -675,6 +680,15 @@
this.selMaterialDetailC.forEach(function(item,index,array) {
materialBhArr.push(item.materialBh)
})
if(materialBhArr.length==0){
this.$message({
message: '没有选择库位领用,无法继续操作!',
type: 'error'
});
return;
}
confirmStorageLocation(materialBhArr).then(response => {
this.$modal.msgSuccess("领用成功");
this.activeName = 'locationShow';