Commit 39e7a7cd by wuwenlong

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

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