Commit 0e73e9b1 by liuyang

2024-06-11 库存盘点单

parent 7f40fb81
......@@ -112,6 +112,22 @@ public class HGSqlConstant {
}
/**
* HPKC005 SQL 定义
*
* @author:songx
* @date:2024/1/20,16:45
*/
public class HgKc005 {
// 查询
public static final String QUERY_SUM = "HGKC005.querySum";
// 锁
public static final String LOCK = "HGKC005.lock";
// 统计
public static final String STAT_DATE = "HGKC005.statDate";
}
/**
* HGKC010 SQL 定义
*
* @author:songx
......
......@@ -15,6 +15,10 @@ import com.baosight.hggp.hg.zl.domain.HGZL004;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
......@@ -455,6 +459,101 @@ public class HGKCTools {
}
}
/**
* HGKC005公共DAO方法定义
*
* @author:songx
* @date:2024/1/31,16:36
*/
public static class HpKc005 {
/**
* 锁
*
* @param checkNos
* @return
*/
public static void lock(List<String> checkNos) {
if (org.springframework.util.CollectionUtils.isEmpty(checkNos)) {
return;
}
Map queryMap = new HashMap();
queryMap.put("checkNos", checkNos);
DaoBase.getInstance().update(HGSqlConstant.HgKc005.LOCK, queryMap);
}
/**
* 查询盘点单信息
*
* @param checkNos
* @return
*/
public static List<HGKC005> list(List<String> checkNos) {
if (org.springframework.util.CollectionUtils.isEmpty(checkNos)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("checkNos", checkNos);
return DaoBase.getInstance().query(HGKC005.QUERY, queryMap);
}
/**
* 查询盘点单信息
*
* @param checkNos
* @return
*/
public static Map<String, HGKC005> map(List<String> checkNos) {
List<HGKC005> results = list(checkNos);
if (org.springframework.util.CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.toMap(HGKC005::getCheckNo, item -> item));
}
}
/**
* 更新库存
*
* @param whCode
* @param inventRecordId
* @param amount
* @param weight
*/
public static void updateStock(String whCode, Long inventRecordId, BigDecimal amount, BigDecimal weight,String factCode) {
updateStock(whCode, inventRecordId, amount,weight, weight,factCode);
}
/**
* 更新库存
*
* @param whCode
* @param inventRecordId
* @param amount
* @param unitWeight
* @param weight
*/
public static void updateStock(String whCode, Long inventRecordId, BigDecimal amount, BigDecimal unitWeight,
BigDecimal weight,String factoryCode) {
if (amount.compareTo(BigDecimal.ZERO) == 0) {
throw new PlatException("入库数量不能为空");
}
EiInfo inInfo = new EiInfo();
inInfo.set("whCode", whCode);
inInfo.set("inventRecordId", inventRecordId);
inInfo.set("amount", amount);
inInfo.set("unitWeight", unitWeight);
inInfo.set("weight", weight);
inInfo.set("factoryCode", factoryCode);
inInfo.set(EiConstant.serviceName, "HGKC010");
inInfo.set(EiConstant.methodName, "updateStock");
EiInfo outInfo = XLocalManager.call(inInfo);
if (outInfo.getStatus() < 0) {
throw new PlatException("跟新库存失败:" + outInfo.getMsg());
}
}
public static class HgKc006 {
public static HGKC006 getById(Long id) {
AssertUtils.isEmpty(Collections.singleton(id), "ID为空!");
......
package com.baosight.hggp.hg.pz.tools;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.common.InventTypeEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.ValidFlagEnum;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.pz.domain.*;
import com.baosight.hggp.hg.sc.domain.HGSC001A;
import com.baosight.hggp.hg.sc.domain.HGSC005A;
import com.baosight.hggp.hg.sj.domain.HGSJ003;
import com.baosight.hggp.util.*;
import com.baosight.iplat4j.common.ed.domain.TEDCM01;
import com.baosight.hggp.hg.pz.domain.HGPZ002;
import com.baosight.hggp.hg.pz.domain.HGPZ003;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
......@@ -81,89 +76,63 @@ public class HGPZTools {
}
/**
* 仓库管理
* HPPZ007 公共DAO定义
* HPPZ005 公共DAO定义
*
* @author:songx
* @date:2024/2/6,13:37
*/
public static class HgPz007 {
public static class HgPz005 {
/**
* 查询
*
* @param whCode
* @return
*/
public static HGPZ007 get(String whCode) {
AssertUtils.isEmpty(whCode, "仓库编码不能为空");
public static HGPZ005 get(Long id) {
AssertUtils.isNull(id, "规格ID不能为空");
Map queryMap = new HashMap();
queryMap.put("whCode", whCode);
List<HGPZ007> results = DaoBase.getInstance().query(HGPZ007.QUERY, queryMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
queryMap.put("id", id);
List<HGPZ005> results = DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
AssertUtils.isEmpty(results, String.format("规格[%s]不存在", id));
return results.get(0);
}
/**
* HPPZ009 公共DAO定义
*
* @author:songx
* @date:2024/2/6,13:37
*/
public static class HgPz009 {
/**
* 查询企业信息
* 查询
*
* @param accountCode
* @param ids
* @return
*/
public static HGPZ009 getByCode(String accountCode) {
AssertUtils.isEmpty(accountCode, "企业编码不能为空");
public static List<HGPZ005> getIds(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("accountCode", accountCode);
List<HGPZ009> pz009s = DaoBase.getInstance().query(HGPZ009.QUERY, queryMap);
return CollectionUtils.isEmpty(pz009s) ? null : pz009s.get(0);
queryMap.put("ids", ids);
return DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
}
/**
* 企业是否启用
* 查询
*
* @param accountCode
* @param inventCodes
* @return
*/
public static boolean isValid(String accountCode) {
HGPZ009 pz009 = getByCode(accountCode);
if (pz009 == null) {
return false;
}
return !ValidFlagEnum.STOP.getCode().equals(pz009.getValidFlag());
}
public static List<HGPZ005> listByInventCodes(List<String> inventCodes) {
AssertUtils.isEmpty(inventCodes, "存货档案编码不能为空!");
Map queryMap = new HashMap();
queryMap.put("inventCodes", inventCodes);
return DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
}
/**
* 存货管理
* HGPZ005 公共DAO定义
*
* @author:songx
* @date:2024/2/6,13:37
*/
public static class HgPz005 {
/**
* 查询
*
* @param id
* @param ids
* @return
*/
public static HGPZ005 get(Long id) {
AssertUtils.isNull(id, "规格ID不能为空");
Map queryMap = new HashMap();
queryMap.put("id", id);
List<HGPZ005> results = DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
AssertUtils.isEmpty(results, String.format("规格[%s]不存在", id));
return results.get(0);
public static Map<Long, HGPZ005> maps(List<Long> ids) {
List<HGPZ005> results = getIds(ids);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.toMap(HGPZ005::getId, item -> item));
}
/**
......@@ -186,47 +155,85 @@ public class HGPZTools {
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
/**
* 查询
* 查询存货
*
* @param ids
* @param inventCode
* @return
*/
public static List<HGPZ005> list(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return null;
}
public static HGPZ005 getByCode(String inventCode) {
AssertUtils.isEmpty(inventCode, "存货编码不能为空");
Map queryMap = new HashMap();
queryMap.put("ids", ids);
return DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
queryMap.put("inventCode", inventCode);
List<HGPZ005> pz005s = DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
if(pz005s!=null&&pz005s.size()==0){
pz005s = null;
}
AssertUtils.isEmpty(pz005s, String.format("存货编码[%s]不存在", inventCode));
return pz005s.get(0);
}
/**
* 查询
* 查询存货信息
*
* @param inventCodes
* @return
*/
public static List<HGPZ005> listByInventCodes(List<String> inventCodes) {
AssertUtils.isEmpty(inventCodes, "存货档案编码不能为空!");
public static List<HGPZ005> list(List<String> inventCodes) {
if (CollectionUtils.isEmpty(inventCodes)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("inventCodes", inventCodes);
return DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
}
/**
* 查询
* 查询存货信息
*
* @param ids
* @param inventCodes
* @return
*/
public static Map<Long, HGPZ005> map(List<Long> ids) {
List<HGPZ005> results = list(ids);
if (CollectionUtils.isEmpty(results)) {
public static Map<String, HGPZ005> map(List<String> inventCodes) {
List<HGPZ005> pz005s = list(inventCodes);
if (CollectionUtils.isEmpty(pz005s)) {
return null;
}
return results.stream().collect(Collectors.toMap(HGPZ005::getId, item -> item));
return pz005s.stream().collect(Collectors.toMap(HGPZ005::getInventCode, item -> item));
}
/**
* 判断存货名称是否存在,如果存在返回编码,否则新增并返回编码
*
* @param inventType 存货类型
* @param inventName 存货名称
*/
public static String checkAndSave(Integer inventType, String inventName) {
AssertUtils.isNull(inventType, "存货类型不能为空");
AssertUtils.isNull(InventTypeEnum.getEnumByCode(inventType), "存货类型异常");
AssertUtils.isEmpty(inventName, "存货名称不能为空");
Map queryMap = new HashMap();
queryMap.put("inventType", inventType);
queryMap.put("inventName", inventName);
List<HGPZ005> dbPz005s = DaoBase.getInstance().query(HGPZ005.QUERY, queryMap);
if (CollectionUtils.isNotEmpty(dbPz005s)) {
HGPZ005 dbPz005 = dbPz005s.get(0);
if (CommonConstant.YesNo.YES_1.equals(dbPz005.getDeleteFlag())) {
dbPz005.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.update(HGPZ005.DELETE, dbPz005);
}
return dbPz005.getInventCode();
} else {
// 生成编码
HGPZ005 newPz005 = new HGPZ005();
newPz005.setInventCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.INVENT_CODE));
newPz005.setInventType(inventType.toString());
newPz005.setInventName(inventName);
newPz005.setStatus(CommonConstant.YesNo.YES_1);
DaoUtils.insert(HGPZ005.INSERT, newPz005);
return newPz005.getInventCode();
}
}
/**
......@@ -312,20 +319,20 @@ public class HGPZTools {
/**
* 检查不存在就新增
*
* @param newPz006
* @param newPz005
* @return
*/
public static HGPZ005 checkAndSave(HGPZ005 newPz006) {
public static HGPZ005 checkAndSave(HGPZ005 newPz005) {
// 检查存货名称是否存在
jointSpec(newPz006);
HGPZ005 specPz006 = getBySpec(newPz006.getInventCode(), newPz006.getSpec());
jointSpec(newPz005);
HGPZ005 specPz006 = getBySpec(newPz005.getInventCode(), newPz005.getSpec());
if (specPz006 != null) {
return specPz006;
} else {
// 生成编码
newPz006.setStatus(CommonConstant.YesNo.YES_1.intValue());
DaoUtils.insert(HGPZ005.INSERT, newPz006);
return newPz006;
newPz005.setStatus(CommonConstant.YesNo.YES_1.intValue());
DaoUtils.insert(HGPZ005.INSERT, newPz005);
return newPz005;
}
}
......@@ -378,7 +385,7 @@ public class HGPZTools {
public static void setSpecInfo(EiInfo inInfo, String idName) {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Long> ids = ObjectUtils.listKey(resultRows, idName);
Map<Long, HGPZ005> resultMap = map(ids);
Map<Long, HGPZ005> resultMap = maps(ids);
if (MapUtils.isEmpty(resultMap)) {
return;
}
......@@ -480,4 +487,66 @@ public class HGPZTools {
}
}
/**
* 仓库管理
* HPPZ007 公共DAO定义
*
* @author:songx
* @date:2024/2/6,13:37
*/
public static class HgPz007 {
/**
* 查询
*
* @param whCode
* @return
*/
public static HGPZ007 get(String whCode) {
AssertUtils.isEmpty(whCode, "仓库编码不能为空");
Map queryMap = new HashMap();
queryMap.put("whCode", whCode);
List<HGPZ007> results = DaoBase.getInstance().query(HGPZ007.QUERY, queryMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
}
/**
* HPPZ009 公共DAO定义
*
* @author:songx
* @date:2024/2/6,13:37
*/
public static class HgPz009 {
/**
* 查询企业信息
*
* @param accountCode
* @return
*/
public static HGPZ009 getByCode(String accountCode) {
AssertUtils.isEmpty(accountCode, "企业编码不能为空");
Map queryMap = new HashMap();
queryMap.put("accountCode", accountCode);
List<HGPZ009> pz009s = DaoBase.getInstance().query(HGPZ009.QUERY, queryMap);
return CollectionUtils.isEmpty(pz009s) ? null : pz009s.get(0);
}
/**
* 企业是否启用
*
* @param accountCode
* @return
*/
public static boolean isValid(String accountCode) {
HGPZ009 pz009 = getByCode(accountCode);
if (pz009 == null) {
return false;
}
return !ValidFlagEnum.STOP.getCode().equals(pz009.getValidFlag());
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment