Commit 39e7a7cd by wuwenlong

* 判断存货名称是否存在,如果存在返回编码,否则新增并返回编码

parent 99b518b9
......@@ -2,20 +2,17 @@ package com.baosight.hpjx.common;
import com.baosight.iplat4j.core.ei.EiBlock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Author wwl
* @Date 2024/1/10 14:29
*/
public enum InventTypeEnun {
public enum InventTypeEnum {
MATERIAL(1,"原材料"),
CONSUMABLE(2,"耗材"),
SEMI_FINISHED_PRODUCT(3,"零部件"),
FINISHED_PRODUCT(4,"产成品"),
FINISHED_PRODUCT(4,"部件"),
WASTE(5,"废料"),
OTHER(6,"其他");
......@@ -23,31 +20,27 @@ public enum InventTypeEnun {
private String value;
InventTypeEnun(Integer code, String value) {
InventTypeEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
public static String getNameByCode(String code){
String returnName = "";
switch (code){
case "1":
returnName = MATERIAL.value;
break;
case "2":
returnName = CONSUMABLE.value;
break;
case "3":
returnName = SEMI_FINISHED_PRODUCT.value;
break;
case "4":
returnName = FINISHED_PRODUCT.value;
break;
default:
break;
public static InventTypeEnum getEnumByCode(Integer code){
for (InventTypeEnum en : InventTypeEnum.values()){
if(code.compareTo(en.code)==0){
return en;
}
}
return returnName;
};
return null;
}
public static String getNameByCode(Integer code){
InventTypeEnum en = getEnumByCode(code);
if(Objects.nonNull(en)){
return en.getValue();
}
return null;
}
public Integer getCode() {
return code;
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -36,8 +36,8 @@ public class ServiceHPKC001 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 画面初始化
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -32,8 +32,8 @@ import java.util.Map;
public class ServiceHPKC002 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 画面初始化.
......@@ -48,7 +48,7 @@ public class ServiceHPKC002 extends ServiceBase {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_SPEC_BLOCK_ID), queryMap, false);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.SPEC_NAME_BLOCK_ID), queryMap, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC002().eiMetadata);
inInfo.setBlock(InventTypeEnun.generatorEiBlock());
inInfo.setBlock(InventTypeEnum.generatorEiBlock());
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -36,8 +36,8 @@ import java.util.Map;
public class ServiceHPKC002A extends ServiceEPBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 初始化
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -31,9 +31,9 @@ import java.util.Map;
public class ServiceHPKC004 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode(), InventTypeEnun.SEMI_FINISHED_PRODUCT.getCode(),
InventTypeEnun.FINISHED_PRODUCT.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode(), InventTypeEnum.SEMI_FINISHED_PRODUCT.getCode(),
InventTypeEnum.FINISHED_PRODUCT.getCode()};
/**
* 画面初始化
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -36,9 +36,9 @@ import java.util.Map;
public class ServiceHPKC004A extends ServiceEPBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode(), InventTypeEnun.SEMI_FINISHED_PRODUCT.getCode(),
InventTypeEnun.FINISHED_PRODUCT.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode(), InventTypeEnum.SEMI_FINISHED_PRODUCT.getCode(),
InventTypeEnum.FINISHED_PRODUCT.getCode()};
/**
* 初始化
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -38,8 +38,8 @@ import java.util.Map;
public class ServiceHPKC006 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode(), InventTypeEnun.WASTE.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode(), InventTypeEnum.WASTE.getCode()};
/**
* 画面初始化
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -38,8 +38,8 @@ import java.util.Map;
public class ServiceHPKC007 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode(), InventTypeEnun.WASTE.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode(), InventTypeEnum.WASTE.getCode()};
/**
* 画面初始化
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC007;
......@@ -35,8 +35,8 @@ import java.util.Map;
public class ServiceHPKC007A extends ServiceEPBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode(), InventTypeEnun.WASTE.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.MATERIAL.getCode(),
InventTypeEnum.CONSUMABLE.getCode(), InventTypeEnum.WASTE.getCode()};
/**
* 初始化
......
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
......@@ -29,7 +29,7 @@ import java.util.Map;
public class ServiceHPKC008 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.OTHER.getCode()};
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.OTHER.getCode()};
/**
......
......@@ -2,6 +2,7 @@ package com.baosight.hpjx.hp.pz.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InitiateModeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ003;
......@@ -15,7 +16,9 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -73,7 +76,7 @@ public class ServiceHPPZ004 extends ServiceBase {
for (int i = 0; i < resultRows.size(); i++) {
HPPZ004 fPz004 = new HPPZ004();
fPz004.fromMap(resultRows.get(i));
// 生成客户编码
// 生成编码
fPz004.setInventCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.INVENT_CODE));
DaoUtils.insert(HPPZ004.INSERT, fPz004);
}
......@@ -108,6 +111,34 @@ public class ServiceHPPZ004 extends ServiceBase {
}
return inInfo;
}
/**
* 判断存货名称是否存在,如果存在返回编码,否则新增并返回编码
* @param inInfo
* @return
*/
public EiInfo checkAndSave(EiInfo inInfo){
String inventType = inInfo.getString("inventType");
String inventName = inInfo.getString("inventName");
List<Map> list = dao.query("HPPZ004.queryByCondition",new HashMap<String,Object>(){{
put("inventType",inventType);
put("inventName",inventName);
}});
HPPZ004 hppz004 = new HPPZ004();
if(CollectionUtils.isEmpty(list)){
hppz004.fromMap(list.get(0));
}else{
// 生成编码
hppz004.setInventCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.INVENT_CODE));
hppz004.setInventType(Integer.parseInt(inventType));
hppz004.setInventName(inventName);
hppz004.setStatus(CommonConstant.YesNo.YES_1.intValue());
DaoUtils.insert(HPPZ004.INSERT, hppz004);
}
inInfo.setAttr(new HashMap(){{put("inventCode",hppz004.getInventCode());}});
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
return inInfo;
}
/**
* 删除操作
......
......@@ -72,6 +72,21 @@
<include refid="order"/>
</select>
<select id="queryByCondition" resultClass="java.util.HashMap">
SELECT
<include refid="column"/>
FROM hpjx.t_hppz004 WHERE 1=1
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
</isNotEmpty>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM hpjx.t_hppz004 WHERE 1=1
<include refid="condition"/>
......
package com.baosight.hpjx.hp.pz.tools;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.domain.HPPZ004;
import com.baosight.hpjx.util.AssertUtils;
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 org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -134,5 +142,30 @@ public class HPPZTools {
}
return CommonConstant.YesNo.YES_1.equals(pz009.getValidFlag());
}
/**
* 判断存货名称是否存在,如果存在返回编码,否则新增并返回编码
* @param inventType
* @param inventName
*/
public static String checkAndSavePZ04(Integer inventType, String inventName) {
if(Objects.isNull(inventType)){
throw new PlatException("存货类型不能为空!");
}
if(Objects.isNull(InventTypeEnum.getEnumByCode(inventType))){
throw new PlatException("存货类型异常!");
}
if(StringUtils.isBlank(inventName)){
throw new PlatException("存货名称不能为空!");
}
EiInfo inInfo = new EiInfo();
inInfo.set("inventType", inventType);
inInfo.set("inventName", inventName);
inInfo.set(EiConstant.serviceName, "HPPZ004");
inInfo.set(EiConstant.methodName, "checkAndSave");
EiInfo outInfo = XLocalManager.call(inInfo);
return outInfo.getAttr().get("inventCode").toString();
}
}
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