package com.fzzy.sys.manager.inout;
|
|
import com.fzzy.igds.constant.Constant;
|
import com.fzzy.igds.domain.InoutConf;
|
import com.fzzy.igds.domain.InoutSysConf;
|
import com.fzzy.igds.service.InoutConfService;
|
import com.fzzy.igds.utils.SystemUtil;
|
import com.ruoyi.common.core.redis.RedisCache;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @Description 出入库业务处理
|
* @Author CZT
|
* @Date 2025/11/29 11:02
|
*/
|
@Slf4j
|
@Component
|
public class InoutManager {
|
|
@Resource
|
private RedisCache redisCache;
|
@Resource
|
private InoutConfService inoutConfService;
|
|
/**
|
* 根据用户请求信息,根据当前客户电脑IP,获取出入库称重上次选择的地磅
|
*
|
* @param httpRequest
|
* @return
|
*/
|
public String getInoutWeightByClient(HttpServletRequest httpRequest) {
|
String userIp = SystemUtil.getIP(httpRequest);
|
log.debug("----------------根据用户IP获取选择-地磅----{}", userIp);
|
|
String key = "INOUT:WEIGHT:" + userIp;
|
String sort = (String) redisCache.getCacheObject(key);
|
if (com.ruoyi.common.utils.StringUtils.isEmpty(sort)) sort = "1";
|
return sort;
|
}
|
|
/**
|
* 获取出入库的整个流程信息
|
*
|
* @param companyId
|
* @param deptId
|
* @param inoutType
|
* @return
|
*/
|
public String getInoutProgressConf(String companyId, String deptId, String inoutType) {
|
// 从缓存中获取出入库系统配置信息
|
InoutSysConf inoutSysConf = inoutConfService.getCacheInoutSysConf(companyId, deptId);
|
String progressConf = null;
|
if (inoutSysConf != null) {
|
if (Constant.TYPE_IN.equals(inoutType)) {
|
progressConf = inoutSysConf.getProgressIn();
|
}
|
if (Constant.TYPE_OUT.equals(inoutType)) {
|
progressConf = inoutSysConf.getProgressOut();
|
}
|
}
|
return progressConf;
|
}
|
|
/**
|
* 获取出入库设备配置信息
|
*
|
* @param companyId
|
* @param deptId
|
* @return
|
*/
|
public List<InoutConf> getListInoutConf(String companyId, String deptId) {
|
return inoutConfService.getCacheInoutConf(companyId, deptId);
|
}
|
|
/**
|
* 根据配置获取出入库的配置参数
|
*
|
* @param listInoutConf 配置列表
|
* @param sort 方案序号
|
* @param type 设备类型
|
* @param inoutProgress 出入库流程
|
* @return 车牌设备配置,没有则返回NULL
|
*/
|
public InoutConf getInoutConf(List<InoutConf> listInoutConf, String sort, String type, String inoutProgress, int inOrder) {
|
if (null == listInoutConf) {
|
return new InoutConf(sort);
|
}
|
if (StringUtils.isEmpty(sort)) sort = "1";
|
|
InoutConf result = null;
|
for (InoutConf conf : listInoutConf) {
|
if (sort.equals(conf.getSort()) && type.equals(conf.getType()) && inoutProgress.equals(conf.getInoutProgress())) {
|
if (conf.getInOrder() == inOrder) {
|
result = conf;
|
break;
|
}
|
}
|
}
|
|
if (null == result) return new InoutConf(sort);
|
|
return result;
|
}
|
|
public List<InoutConf> getInoutConf(List<InoutConf> listInoutConf, String type) {
|
List<InoutConf> result = new ArrayList<>();
|
if (null == listInoutConf) return result;
|
for (InoutConf conf : listInoutConf) {
|
if (type.equals(conf.getType())) {
|
result.add(conf);
|
}
|
}
|
return result;
|
}
|
|
public InoutConf getInoutConf(List<InoutConf> listInoutConf, String sort, String type) {
|
if (null == listInoutConf) return new InoutConf(sort);
|
if (StringUtils.isEmpty(sort)) sort = "1";
|
|
for (InoutConf conf : listInoutConf) {
|
if (sort.equals(conf.getSort()) && type.equals(conf.getType())) {
|
return conf;
|
}
|
}
|
return new InoutConf(sort);
|
}
|
|
/**
|
* 获取地磅重量编辑标签
|
*
|
* @param companyId
|
* @param deptId
|
* @return
|
*/
|
public String getWeightEditTag(String companyId, String deptId) {
|
// 从缓存中获取出入库系统配置信息
|
InoutSysConf inoutSysConf = inoutConfService.getCacheInoutSysConf(companyId, deptId);
|
String weightEditTag = Constant.YN_N;
|
if (inoutSysConf != null) {
|
weightEditTag = inoutSysConf.getWeightEditTag();
|
}
|
if (null == weightEditTag) weightEditTag = Constant.YN_N;
|
|
return weightEditTag;
|
}
|
}
|