Commit f1faf702 by wuwenlong

判断存货档案是否存在,如果存在返回存货档案,否则新增并返回存货档案

parent 39e7a7cd
......@@ -2,7 +2,10 @@ 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.HPPZ004;
import com.baosight.hpjx.hp.pz.domain.HPPZ006;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.util.AssertUtils;
......@@ -14,13 +17,12 @@ 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.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
/**
* @author:songx
......@@ -156,6 +158,62 @@ public class ServiceHPPZ006 extends ServiceBase {
return inInfo;
}
/**
* 判断存货档案是否存在,如果存在返回ID,否则新增并返回ID
* @param inInfo
* @return
*/
public EiInfo checkAndSave(EiInfo inInfo){
String inventType = inInfo.getString("inventType");
String inventCode = inInfo.getString("inventCode");
String inventName = inInfo.getString("inventName");
String length = inInfo.getString("length");
String width = inInfo.getString("width");
String thick = inInfo.getString("thick");
String material = inInfo.getString("material");
String coefficient = inInfo.getString("coefficient");
String unit = inInfo.getString("unit");
List<Map> list = dao.query("HPPZ006.queryByCondition",new HashMap<String,Object>(){{
put("inventType",inventType);
put("inventCode",inventCode);
put("inventName",inventName);
put("length", Objects.nonNull(length)?length:"");
put("width",Objects.nonNull(width)?width:"");
put("thick",Objects.nonNull(thick)?thick:"");
put("material",Objects.nonNull(material)?material:"");
put("coefficient",Objects.nonNull(coefficient)?coefficient:"");
put("unit",Objects.nonNull(unit)?unit:"");
}});
HPPZ006 hppz006 = new HPPZ006();
if(CollectionUtils.isEmpty(list)){
hppz006.fromMap(list.get(0));
}else{
// 生成编码
hppz006.setInventType(Integer.parseInt(inventType));
hppz006.setInventCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.INVENT_CODE));
hppz006.setInventName(inventName);
hppz006.setLength(new BigDecimal(length));
hppz006.setWidth(new BigDecimal(width));
hppz006.setThick(new BigDecimal(thick));
hppz006.setMaterial(material);
hppz006.setCoefficient(new BigDecimal(coefficient));
hppz006.setUnit(unit);
hppz006.setStatus(CommonConstant.YesNo.YES_1.intValue());
StringBuffer sepbuf = new StringBuffer();
if(Objects.nonNull(length)){sepbuf.append(length).append("*");}
if(Objects.nonNull(width)){sepbuf.append(width).append("*");}
if(Objects.nonNull(thick)){sepbuf.append(thick);}
if(StringUtils.isNotEmpty(sepbuf.toString())){
hppz006.setSpec(sepbuf.toString());
}
DaoUtils.insert(HPPZ006.INSERT, hppz006);
}
inInfo.setAttr(new HashMap(){{put("obj",hppz006);}});
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
return inInfo;
}
/**
* 规格下拉框
*
......
......@@ -76,6 +76,9 @@
SELECT
<include refid="column"/>
FROM hpjx.t_hppz004 WHERE 1=1
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
......
......@@ -79,6 +79,45 @@
<include refid="order"/>
</select>
<select id="queryByCondition" resultClass="java.util.HashMap">
SELECT
<include refid="column"/>
FROM hpjx.t_hppz006 WHERE 1=1
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<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>
<isNotNull prepend=" AND " property="length">
IFNULL(LENGTH,'') = #length#
</isNotNull>
<isNotNull prepend=" AND " property="width">
IFNULL(WIDTH,'') = #width#
</isNotNull>
<isNotNull prepend=" AND " property="thick">
IFNULL(THICK,'') = #thick#
</isNotNull>
<isNotNull prepend=" AND " property="material">
IFNULL(MATERIAL,'') = #material#
</isNotNull>
<isNotNull prepend=" AND " property="coefficient">
IFNULL(COEFFICIENT,'') = #coefficient#
</isNotNull>
<isNotNull prepend=" AND " property="unit">
IFNULL(UNIT,'') = #unit#
</isNotNull>
<isNotEmpty prepend=" AND " property="status">
STATUS = #status#
</isNotEmpty>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM hpjx.t_hppz006 WHERE 1=1
<include refid="condition"/>
......
......@@ -3,6 +3,7 @@ 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.HPPZ006;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.domain.HPPZ004;
......@@ -167,5 +168,35 @@ public class HPPZTools {
EiInfo outInfo = XLocalManager.call(inInfo);
return outInfo.getAttr().get("inventCode").toString();
}
/**
* 判断存货档案是否存在,如果存在返回存货档案,否则新增并返回存货档案
* @param inventType
* @param inventName
*/
public static HPPZ006 checkAndSavePZ06(Integer inventType, String inventCode, String inventName
, BigDecimal length, BigDecimal width, BigDecimal thick, BigDecimal coefficient, String unit) {
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("inventCode", checkAndSavePZ04(inventType,inventName));
inInfo.set("inventName", inventName);
inInfo.set("length", length);
inInfo.set("width", width);
inInfo.set("thick", thick);
inInfo.set("coefficient", coefficient);
inInfo.set("unit", unit);
inInfo.set(EiConstant.serviceName, "HPPZ006");
inInfo.set(EiConstant.methodName, "checkAndSave");
EiInfo outInfo = XLocalManager.call(inInfo);
return (HPPZ006) outInfo.getAttr().get("obj");
}
}
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