Commit 5b393644 by 宋祥

1.优化代码,存货新增时校验逻辑

parent fca2f656
...@@ -131,15 +131,17 @@ public class ServiceHPKC006 extends ServiceBase { ...@@ -131,15 +131,17 @@ public class ServiceHPKC006 extends ServiceBase {
this.setBaseInfo(fKc006); this.setBaseInfo(fKc006);
// 生成入库单号 // 生成入库单号
fKc006.setOtherEnterNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.OTHER_ENTER_NO)); fKc006.setOtherEnterNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.OTHER_ENTER_NO));
HPPZ006 hppz006 = HPPZTools.checkAndSavePZ06(fKc006.getInventType(), fKc006.getInventName(), fKc006.getLength(), // 检查规格,如果不存在就新增
fKc006.getWidth(), fKc006.getThick(), fKc006.getCoefficient(), fKc006.getMaterial(), fKc006.getUnit() HPPZ006 dbPz006 = HPPZTools.HpPz006.checkAndSave(fKc006.getInventType(), fKc006.getInventName(),
fKc006.getLength(), fKc006.getWidth(), fKc006.getThick(), fKc006.getCoefficient(), fKc006.getMaterial(),
fKc006.getUnit()
); );
// 根据规格计算单重 // 根据规格计算单重
fKc006.setUnitWeight(HPPZTools.HpPz006.calcUnitWeight(hppz006.getId())); fKc006.setUnitWeight(HPPZTools.HpPz006.calcUnitWeight(dbPz006));
// 计算总重 // 计算总重
fKc006.setWeight(fKc006.getAmount().multiply(fKc006.getUnitWeight())); fKc006.setWeight(fKc006.getAmount().multiply(fKc006.getUnitWeight()));
fKc006.setInventRecordId(hppz006.getId()); fKc006.setInventRecordId(dbPz006.getId());
fKc006.setInventCode(hppz006.getInventCode()); fKc006.setInventCode(dbPz006.getInventCode());
fKc006.setDeleteFlag(CommonConstant.YesNo.NO_0); fKc006.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPKC006.INSERT, fKc006); DaoUtils.insert(HPKC006.INSERT, fKc006);
// 修改库存 // 修改库存
......
...@@ -118,39 +118,6 @@ public class ServiceHPPZ004 extends ServiceBase { ...@@ -118,39 +118,6 @@ public class ServiceHPPZ004 extends ServiceBase {
} }
/** /**
* 判断存货名称是否存在,如果存在返回编码,否则新增并返回编码
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "存货类型",operType = "查询",operDesc = "判断存货名称是否存在,如果存在返回编码,否则新增并返回编码")
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.isNotEmpty(list)){
hppz004.fromMap(list.get(0));
if(hppz004.getDeleteFlag()== CommonConstant.YesNo.YES_1) {
hppz004.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.update(HPPZ004.DELETE_BACK, hppz004);
}
}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
......
...@@ -5,7 +5,6 @@ import com.baosight.hpjx.common.DdynamicEnum; ...@@ -5,7 +5,6 @@ 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.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.kc.domain.HPKC010; import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.hp.kc.tools.HPKCTools; import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.hp.pz.domain.HPPZ006; import com.baosight.hpjx.hp.pz.domain.HPPZ006;
...@@ -20,11 +19,9 @@ import com.baosight.iplat4j.core.ei.EiConstant; ...@@ -20,11 +19,9 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; 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 org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
...@@ -88,7 +85,7 @@ public class ServiceHPPZ006 extends ServiceBase { ...@@ -88,7 +85,7 @@ public class ServiceHPPZ006 extends ServiceBase {
fPz006.fromMap(resultRows.get(i)); fPz006.fromMap(resultRows.get(i));
// 存货名称 // 存货名称
fPz006.setInventName(HPPZTools.HpPz004.getByCode(fPz006.getInventCode()).getInventName()); fPz006.setInventName(HPPZTools.HpPz004.getByCode(fPz006.getInventCode()).getInventName());
fPz006.setSpec(HPPZTools.jointSpec(fPz006.getLength(),fPz006.getWidth(),fPz006.getThick())); fPz006.setSpec(HPPZTools.HpPz006.jointSpec(fPz006.getLength(),fPz006.getWidth(),fPz006.getThick()));
DaoUtils.insert(HPPZ006.INSERT, fPz006); DaoUtils.insert(HPPZ006.INSERT, fPz006);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
...@@ -141,7 +138,7 @@ public class ServiceHPPZ006 extends ServiceBase { ...@@ -141,7 +138,7 @@ public class ServiceHPPZ006 extends ServiceBase {
fPz006.fromMap(resultRows.get(i)); fPz006.fromMap(resultRows.get(i));
// 存货名称 // 存货名称
fPz006.setInventName(HPPZTools.HpPz004.getByCode(fPz006.getInventCode()).getInventName()); fPz006.setInventName(HPPZTools.HpPz004.getByCode(fPz006.getInventCode()).getInventName());
fPz006.setSpec(HPPZTools.jointSpec(fPz006.getLength(), fPz006.getWidth(), fPz006.getThick())); fPz006.setSpec(HPPZTools.HpPz006.jointSpec(fPz006.getLength(), fPz006.getWidth(), fPz006.getThick()));
DaoUtils.update(HPPZ006.UPDATE, fPz006); DaoUtils.update(HPPZ006.UPDATE, fPz006);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
...@@ -190,48 +187,6 @@ public class ServiceHPPZ006 extends ServiceBase { ...@@ -190,48 +187,6 @@ public class ServiceHPPZ006 extends ServiceBase {
return inInfo; return inInfo;
} }
/**
* 判断存货档案是否存在,如果存在返回ID,否则新增并返回ID
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "存货档案",operType = "查询",operDesc = "判断存货档案是否存在,如果存在返回ID,否则新增并返回ID")
public EiInfo checkAndSave(EiInfo inInfo){
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_INVENT_TYPE,inInfo.getString("inventType"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_INVENT_CODE,inInfo.getString("inventCode"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_INVENT_NAME,inInfo.getString("inventName"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_LENGTH,inInfo.getString("length"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_WIDTH,inInfo.getString("width"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_THICK,inInfo.getString("thick"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_MATERIAL,inInfo.getString("material"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_COEFFICIENT,inInfo.getString("coefficient"));
inInfo.setCell(EiConstant.queryBlock,0,HPPZ006.FIELD_UNIT,inInfo.getString("unit"));
EiInfo eiInfo = super.query(inInfo,"HPPZ006.queryByCondition", new HPPZ006());
HPPZ006 hppz006 = new HPPZ006();
if(CollectionUtils.isNotEmpty(eiInfo.getBlock(EiConstant.resultBlock).getRows())){
Map map = (Map) eiInfo.getBlock(EiConstant.resultBlock).getRows().get(0);
hppz006.fromMap(map);
}else{
// 生成编码
hppz006.setInventType(Integer.parseInt(inInfo.getString("inventType")));
hppz006.setInventCode(inInfo.getString("inventCode"));
hppz006.setInventName(inInfo.getString("inventName"));
hppz006.setLength(new BigDecimal(inInfo.getString("length")));
hppz006.setWidth(new BigDecimal(inInfo.getString("width")));
hppz006.setThick(new BigDecimal(inInfo.getString("thick")));
hppz006.setMaterial(inInfo.getString("material"));
hppz006.setCoefficient(new BigDecimal(inInfo.getString("coefficient")));
hppz006.setUnit(inInfo.getString("unit"));
hppz006.setStatus(CommonConstant.YesNo.YES_1.intValue());
hppz006.setSpec(HPPZTools.jointSpec(hppz006.getLength(),hppz006.getWidth(),hppz006.getThick()));
DaoUtils.insert(HPPZ006.INSERT, hppz006);
}
inInfo.setAttr(new HashMap(){{put("obj",hppz006);}});
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
return inInfo;
}
/** /**
* 规格下拉框 * 规格下拉框
* *
......
...@@ -36,15 +36,21 @@ ...@@ -36,15 +36,21 @@
<isNotEmpty prepend=" AND " property="inventCode"> <isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode# INVENT_CODE = #inventCode#
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME LIKE CONCAT('%', #inventName#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status"> <isNotEmpty prepend=" AND " property="status">
STATUS = #status# STATUS = #status#
</isNotEmpty> </isNotEmpty>
</sql> </sql>
<sql id="getCondition">
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
</isNotEmpty>
</sql>
<sql id="customCondition"> <sql id="customCondition">
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME LIKE CONCAT('%', #inventName#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventTypes"> <isNotEmpty prepend=" AND " property="inventTypes">
INVENT_TYPE IN <iterate close=")" open="(" conjunction="," property="inventTypes">#inventTypes[]#</iterate> INVENT_TYPE IN <iterate close=")" open="(" conjunction="," property="inventTypes">#inventTypes[]#</iterate>
</isNotEmpty> </isNotEmpty>
...@@ -73,6 +79,15 @@ ...@@ -73,6 +79,15 @@
<include refid="order"/> <include refid="order"/>
</select> </select>
<select id="get" resultClass="com.baosight.hpjx.hp.pz.domain.HPPZ004">
SELECT
<include refid="column"/>
FROM hpjx.t_hppz004 WHERE 1=1
<include refid="condition"/>
<include refid="getCondition"/>
<include refid="order"/>
</select>
<select id="queryByCondition" resultClass="java.util.HashMap"> <select id="queryByCondition" resultClass="java.util.HashMap">
SELECT SELECT
<include refid="column"/> <include refid="column"/>
......
...@@ -45,6 +45,24 @@ ...@@ -45,6 +45,24 @@
<isNotEmpty prepend=" AND " property="inventName"> <isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName# INVENT_NAME = #inventName#
</isNotEmpty> </isNotEmpty>
<isNotNull prepend=" AND " property="length">
LENGTH = #length#
</isNotNull>
<isNotNull prepend=" AND " property="width">
WIDTH = #width#
</isNotNull>
<isNotNull prepend=" AND " property="thick">
THICK = #thick#
</isNotNull>
<isNotNull prepend=" AND " property="material">
MATERIAL = #material#
</isNotNull>
<isNotNull prepend=" AND " property="coefficient">
COEFFICIENT = #coefficient#
</isNotNull>
<isNotNull prepend=" AND " property="unit">
UNIT = #unit#
</isNotNull>
<isNotEmpty prepend=" AND " property="status"> <isNotEmpty prepend=" AND " property="status">
STATUS = #status# STATUS = #status#
</isNotEmpty> </isNotEmpty>
...@@ -53,6 +71,10 @@ ...@@ -53,6 +71,10 @@
</isNotNull> </isNotNull>
</sql> </sql>
<sql id="getCondition">
</sql>
<sql id="customCondition"> <sql id="customCondition">
<isNotEmpty prepend=" AND " property="inventTypes"> <isNotEmpty prepend=" AND " property="inventTypes">
INVENT_TYPE IN <iterate close=")" open="(" conjunction="," property="inventTypes">#inventTypes[]#</iterate> INVENT_TYPE IN <iterate close=")" open="(" conjunction="," property="inventTypes">#inventTypes[]#</iterate>
......
...@@ -3,6 +3,8 @@ package com.baosight.hpjx.hp.pz.tools; ...@@ -3,6 +3,8 @@ package com.baosight.hpjx.hp.pz.tools;
import com.baosight.hpjx.common.InventTypeEnum; 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.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant; import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ004; import com.baosight.hpjx.hp.pz.domain.HPPZ004;
import com.baosight.hpjx.hp.pz.domain.HPPZ006; import com.baosight.hpjx.hp.pz.domain.HPPZ006;
...@@ -10,19 +12,14 @@ import com.baosight.hpjx.hp.pz.domain.HPPZ007; ...@@ -10,19 +12,14 @@ 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.HPPZ011; import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.util.AssertUtils; import com.baosight.hpjx.util.AssertUtils;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.ed.util.SequenceGenerator;
import com.baosight.iplat4j.core.ei.EiInfo; import org.apache.commons.collections.CollectionUtils;
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.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
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;
/** /**
...@@ -134,58 +131,38 @@ public class HPPZTools { ...@@ -134,58 +131,38 @@ public class HPPZTools {
} }
return pz004s.stream().collect(Collectors.toMap(HPPZ004::getInventCode, item -> item)); return pz004s.stream().collect(Collectors.toMap(HPPZ004::getInventCode, item -> item));
} }
}
/**
* HPPZ006 公共DAO定义
*
* @author:songx
* @date:2024/2/6,13:37
*/
public static class HpPz006 {
/** /**
* 查询 * 判断存货名称是否存在,如果存在返回编码,否则新增并返回编码
* *
* @param id * @param inventType 存货类型
* @return * @param inventName 存货名称
*/ */
public static HPPZ006 get(Long id) { public static String checkAndSave(Integer inventType, String inventName) {
AssertUtils.isNull(id, "仓库编码不能为空"); AssertUtils.isNull(inventType, "存货类型不能为空");
AssertUtils.isNull(InventTypeEnum.getEnumByCode(inventType), "存货类型异常");
AssertUtils.isEmpty(inventName, "存货名称不能为空");
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("id", id); queryMap.put("inventType", inventType);
List<HPPZ006> results = DaoBase.getInstance().query(HPPZ006.QUERY, queryMap); queryMap.put("inventName", inventName);
AssertUtils.isNull(results, String.format("规格[%s]不存在", id)); List<HPPZ004> dbPz004s = DaoBase.getInstance().query("HPPZ004.get", queryMap);
return results.get(0); if (CollectionUtils.isNotEmpty(dbPz004s)) {
HPPZ004 dbPz004 = dbPz004s.get(0);
if (CommonConstant.YesNo.YES_1.equals(dbPz004.getDeleteFlag())) {
dbPz004.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.update(HPPZ004.DELETE_BACK, dbPz004);
}
return dbPz004.getInventCode();
} else {
// 生成编码
HPPZ004 newPz004 = new HPPZ004();
newPz004.setInventCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.INVENT_CODE));
newPz004.setInventType(inventType);
newPz004.setInventName(inventName);
newPz004.setStatus(CommonConstant.YesNo.YES_1);
DaoUtils.insert(HPPZ004.INSERT, newPz004);
return newPz004.getInventCode();
} }
/**
* 计算单重
*
* @param id
* @return
*/
public static BigDecimal calcUnitWeight(Long id) {
HPPZ006 dbPz006 = get(id);
if ((dbPz006.getLength() == null && dbPz006.getWidth() == null && dbPz006.getThick() == null)
|| dbPz006.getCoefficient() == null) {
return BigDecimal.ZERO;
}
BigDecimal unitWeight = BigDecimal.ONE;
// 长
if (dbPz006.getLength() != null) {
unitWeight = unitWeight.multiply(dbPz006.getLength());
}
// 宽
if (dbPz006.getWidth() != null) {
unitWeight = unitWeight.multiply(dbPz006.getWidth());
}
// 厚
if (dbPz006.getThick() != null) {
unitWeight = unitWeight.multiply(dbPz006.getThick());
}
// 乘以系数
return unitWeight.multiply(dbPz006.getCoefficient()).setScale(3, RoundingMode.HALF_UP);
} }
} }
...@@ -282,6 +259,68 @@ public class HPPZTools { ...@@ -282,6 +259,68 @@ public class HPPZTools {
} }
/** /**
* HPPZ006 公共DAO定义
*
* @author:songx
* @date:2024/2/6,13:37
*/
public static class HpPz006 {
/**
* 查询
*
* @param id
* @return
*/
public static HPPZ006 get(Long id) {
AssertUtils.isNull(id, "仓库编码不能为空");
Map queryMap = new HashMap();
queryMap.put("id", id);
List<HPPZ006> results = DaoBase.getInstance().query(HPPZ006.QUERY, queryMap);
AssertUtils.isNull(results, String.format("规格[%s]不存在", id));
return results.get(0);
}
/**
* 计算单重
*
* @param id
* @return
*/
public static BigDecimal calcUnitWeight(Long id) {
HPPZ006 dbPz006 = get(id);
return calcUnitWeight(dbPz006);
}
/**
* 计算单重
*
* @param dbPz006
* @return
*/
public static BigDecimal calcUnitWeight(HPPZ006 dbPz006) {
if ((dbPz006.getLength() == null && dbPz006.getWidth() == null && dbPz006.getThick() == null)
|| dbPz006.getCoefficient() == null) {
return BigDecimal.ZERO;
}
BigDecimal unitWeight = BigDecimal.ONE;
// 长
if (dbPz006.getLength() != null) {
unitWeight = unitWeight.multiply(dbPz006.getLength());
}
// 宽
if (dbPz006.getWidth() != null) {
unitWeight = unitWeight.multiply(dbPz006.getWidth());
}
// 厚
if (dbPz006.getThick() != null) {
unitWeight = unitWeight.multiply(dbPz006.getThick());
}
// 乘以系数
return unitWeight.multiply(dbPz006.getCoefficient()).setScale(3, RoundingMode.HALF_UP);
}
/**
* 拼接规格 * 拼接规格
* @param length * @param length
* @param width * @param width
...@@ -291,47 +330,22 @@ public class HPPZTools { ...@@ -291,47 +330,22 @@ public class HPPZTools {
public static String jointSpec(BigDecimal length, BigDecimal width, BigDecimal thick) { public static String jointSpec(BigDecimal length, BigDecimal width, BigDecimal thick) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (length != null && length.compareTo(BigDecimal.ZERO) != 0) { if (length != null && length.compareTo(BigDecimal.ZERO) != 0) {
sb.append(length.toString()); sb.append(length);
sb.append("*"); sb.append("*");
} }
if (width != null && width.compareTo(BigDecimal.ZERO) != 0) { if (width != null && width.compareTo(BigDecimal.ZERO) != 0) {
sb.append(width.toString()); sb.append(width);
sb.append("*"); sb.append("*");
} }
if (thick != null && thick.compareTo(BigDecimal.ZERO) != 0) { if (thick != null && thick.compareTo(BigDecimal.ZERO) != 0) {
sb.append(thick.toString()); sb.append(thick);
} }
return sb.toString(); return sb.toString();
} }
/**
* 判断存货名称是否存在,如果存在返回编码,否则新增并返回编码
* @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();
}
/** /**
* 判断存货档案是否存在,如果存在返回存货档案,否则新增并返回存货档案 * 判断存货档案是否存在,如果存在返回存货档案,否则新增并返回存货档案
*
* @param inventType 存货类型 * @param inventType 存货类型
* @param inventName 存货名称 * @param inventName 存货名称
* @param length 长 * @param length 长
...@@ -341,30 +355,34 @@ public class HPPZTools { ...@@ -341,30 +355,34 @@ public class HPPZTools {
* @param material 材质 * @param material 材质
* @param unit 单位 * @param unit 单位
*/ */
public static HPPZ006 checkAndSavePZ06(Integer inventType, String inventName public static HPPZ006 checkAndSave(Integer inventType, String inventName, BigDecimal length,
, BigDecimal length, BigDecimal width, BigDecimal thick, BigDecimal coefficient, String material, String unit) { BigDecimal width,
if(Objects.isNull(inventType)){ BigDecimal thick, BigDecimal coefficient, String material, String unit) {
throw new PlatException("存货类型不能为空!"); // 检查存货名称是否存在
} String inventCode = HPPZTools.HpPz004.checkAndSave(inventType, inventName);
if(Objects.isNull(InventTypeEnum.getEnumByCode(inventType))){ Map queryMap = new HashMap();
throw new PlatException("存货类型异常!"); queryMap.put("inventType", inventType);
} queryMap.put("inventCode", inventCode);
if(StringUtils.isBlank(inventName)){ queryMap.put("inventName", inventName);
throw new PlatException("存货名称不能为空!"); queryMap.put("length", length);
} queryMap.put("width", width);
EiInfo inInfo = new EiInfo(); queryMap.put("thick", thick);
inInfo.set("inventType", inventType); queryMap.put("material", material);
inInfo.set("inventCode", checkAndSavePZ04(inventType, inventName)); queryMap.put("coefficient", coefficient);
inInfo.set("inventName", inventName); queryMap.put("unit", unit);
inInfo.set("length", length); List<HPPZ006> dbPz006s = DaoBase.getInstance().query(HPPZ006.QUERY, queryMap);
inInfo.set("width", width); if (CollectionUtils.isNotEmpty(dbPz006s)) {
inInfo.set("thick", thick); return dbPz006s.get(0);
inInfo.set("material", material); } else {
inInfo.set("coefficient", coefficient); // 生成编码
inInfo.set("unit", unit); HPPZ006 newPz006 = new HPPZ006();
inInfo.set(EiConstant.serviceName, "HPPZ006"); newPz006.fromMap(queryMap);
inInfo.set(EiConstant.methodName, "checkAndSave"); newPz006.setStatus(CommonConstant.YesNo.YES_1.intValue());
EiInfo outInfo = XLocalManager.call(inInfo); newPz006.setSpec(jointSpec(newPz006.getLength(), newPz006.getWidth(), newPz006.getThick()));
return (HPPZ006) outInfo.getAttr().get("obj"); DaoUtils.insert(HPPZ006.INSERT, newPz006);
return newPz006;
} }
}
}
} }
...@@ -99,11 +99,11 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -99,11 +99,11 @@ public class ServiceHPSC002 extends ServiceBase {
// if (StringUtils.isNotEmpty(hppz002.getPrdtCode()) && !hppz002.getParentId().equals("root")) { // if (StringUtils.isNotEmpty(hppz002.getPrdtCode()) && !hppz002.getParentId().equals("root")) {
// hppz002.setPrdtName(HPPZTools.getPz004ByCode(hppz002.getPrdtCode()).getInventName()); // hppz002.setPrdtName(HPPZTools.getPz004ByCode(hppz002.getPrdtCode()).getInventName());
// } // }
hppz002.setSpec(HPPZTools.jointSpec(hppz002.getLength(),hppz002.getWidth(),hppz002.getThick())); hppz002.setSpec(HPPZTools.HpPz006.jointSpec(hppz002.getLength(),hppz002.getWidth(),hppz002.getThick()));
if(hppz002.getParentId().equals("root")){ if(hppz002.getParentId().equals("root")){
hppz002.setLv(new Integer(1)); hppz002.setLv(new Integer(1));
}else{ }else{
hppz002.setPrdtCode(HPPZTools.checkAndSavePZ04(hppz002.getPrdtType(),hppz002.getPrdtName())); hppz002.setPrdtCode(HPPZTools.HpPz004.checkAndSave(hppz002.getPrdtType(),hppz002.getPrdtName()));
Integer lv = (Integer) this.dao.get("HPSC002.queryLv","id",hppz002.getParentId()); Integer lv = (Integer) this.dao.get("HPSC002.queryLv","id",hppz002.getParentId());
hppz002.setLv(lv.intValue()+1); hppz002.setLv(lv.intValue()+1);
} }
...@@ -171,7 +171,7 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -171,7 +171,7 @@ public class ServiceHPSC002 extends ServiceBase {
hpsc005.setPrdtLength(hppz002.getLength()); hpsc005.setPrdtLength(hppz002.getLength());
hpsc005.setPrdtWidth(hppz002.getWidth()); hpsc005.setPrdtWidth(hppz002.getWidth());
hpsc005.setPrdtThick(hppz002.getThick()); hpsc005.setPrdtThick(hppz002.getThick());
hpsc005.setPrdtSpec(HPPZTools.jointSpec(hpsc005.getPrdtLength(),hpsc005.getPrdtWidth(),hpsc005.getPrdtThick())); hpsc005.setPrdtSpec(HPPZTools.HpPz006.jointSpec(hpsc005.getPrdtLength(),hpsc005.getPrdtWidth(),hpsc005.getPrdtThick()));
DaoUtils.update("HPSC005.update", hpsc005.toMap()); DaoUtils.update("HPSC005.update", hpsc005.toMap());
} }
} }
...@@ -210,7 +210,7 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -210,7 +210,7 @@ public class ServiceHPSC002 extends ServiceBase {
HPSC005.setNum(hppz002.getNum()); HPSC005.setNum(hppz002.getNum());
HPSC005.setUnitWt(hppz002.getUnitWt()); HPSC005.setUnitWt(hppz002.getUnitWt());
HPSC005.setTotalWt(hppz002.getTotalWt()); HPSC005.setTotalWt(hppz002.getTotalWt());
HPSC005.setPartSpec(HPPZTools.jointSpec(HPSC005.getPartLength(),HPSC005.getPartWidth(),HPSC005.getPartThick())); HPSC005.setPartSpec(HPPZTools.HpPz006.jointSpec(HPSC005.getPartLength(),HPSC005.getPartWidth(),HPSC005.getPartThick()));
DaoUtils.update("HPSC005.update", HPSC005.toMap()); DaoUtils.update("HPSC005.update", HPSC005.toMap());
} }
} else { } else {
...@@ -243,7 +243,7 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -243,7 +243,7 @@ public class ServiceHPSC002 extends ServiceBase {
BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue()))); BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue())));
hppz002.setDelStatus(CommonConstant.YesNo.NO_0.intValue()); hppz002.setDelStatus(CommonConstant.YesNo.NO_0.intValue());
hppz002.setTotalWt(totalWt); hppz002.setTotalWt(totalWt);
hppz002.setSpec(HPPZTools.jointSpec(hppz002.getLength(),hppz002.getWidth(),hppz002.getThick())); hppz002.setSpec(HPPZTools.HpPz006.jointSpec(hppz002.getLength(),hppz002.getWidth(),hppz002.getThick()));
DaoUtils.update("HPSC002.update", hppz002.toMap()); DaoUtils.update("HPSC002.update", hppz002.toMap());
} }
...@@ -251,7 +251,7 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -251,7 +251,7 @@ public class ServiceHPSC002 extends ServiceBase {
HPSC003.setLength(hppz002.getLength()); HPSC003.setLength(hppz002.getLength());
HPSC003.setWidth(hppz002.getWidth()); HPSC003.setWidth(hppz002.getWidth());
HPSC003.setThick(hppz002.getThick()); HPSC003.setThick(hppz002.getThick());
HPSC003.setSpec(HPPZTools.jointSpec(HPSC003.getLength(),HPSC003.getWidth(),HPSC003.getThick())); HPSC003.setSpec(HPPZTools.HpPz006.jointSpec(HPSC003.getLength(),HPSC003.getWidth(),HPSC003.getThick()));
DaoUtils.update("HPSC003.update", HPSC003.toMap()); DaoUtils.update("HPSC003.update", HPSC003.toMap());
} }
...@@ -262,7 +262,7 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -262,7 +262,7 @@ public class ServiceHPSC002 extends ServiceBase {
HPSC004.setNum(hppz002.getNum()); HPSC004.setNum(hppz002.getNum());
HPSC004.setUnitWt(hppz002.getUnitWt()); HPSC004.setUnitWt(hppz002.getUnitWt());
HPSC004.setTotalWt(hppz002.getTotalWt()); HPSC004.setTotalWt(hppz002.getTotalWt());
HPSC004.setSpec(HPPZTools.jointSpec(HPSC004.getLength(),HPSC004.getWidth(),HPSC004.getThick())); HPSC004.setSpec(HPPZTools.HpPz006.jointSpec(HPSC004.getLength(),HPSC004.getWidth(),HPSC004.getThick()));
DaoUtils.update("HPSC004.update", HPSC004.toMap()); DaoUtils.update("HPSC004.update", HPSC004.toMap());
} }
......
...@@ -106,13 +106,13 @@ public class ServiceHPSC006 extends ServiceBase { ...@@ -106,13 +106,13 @@ public class ServiceHPSC006 extends ServiceBase {
BigDecimal unitWt = HPSC006.getUnitWt(); BigDecimal unitWt = HPSC006.getUnitWt();
DecimalFormat decimalFormat = new DecimalFormat("#.000"); DecimalFormat decimalFormat = new DecimalFormat("#.000");
BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue()))); BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue())));
HPSC006.setInventSpec(HPPZTools.jointSpec(HPSC006.getInventLength(),HPSC006.getInventWidth(),HPSC006.getInventThick())); HPSC006.setInventSpec(HPPZTools.HpPz006.jointSpec(HPSC006.getInventLength(),HPSC006.getInventWidth(),HPSC006.getInventThick()));
HPSC006.setProjCode(projCode); HPSC006.setProjCode(projCode);
HPSC006.setProjName(projName); HPSC006.setProjName(projName);
HPSC006.setProductionOrderNo(productionOrderNo); HPSC006.setProductionOrderNo(productionOrderNo);
HPSC006.setStatus(CommonConstant.YesNo.NO_0.intValue()); HPSC006.setStatus(CommonConstant.YesNo.NO_0.intValue());
HPSC006.setTotalWt(totalWt); HPSC006.setTotalWt(totalWt);
HPSC006.setInventCode(HPPZTools.checkAndSavePZ04(HPSC006.getInventType(),HPSC006.getInventName())); HPSC006.setInventCode(HPPZTools.HpPz004.checkAndSave(HPSC006.getInventType(),HPSC006.getInventName()));
if(HPSC006.getFactoryCode()!=null && !(HPSC006.getFactoryCode().equals(" "))) { if(HPSC006.getFactoryCode()!=null && !(HPSC006.getFactoryCode().equals(" "))) {
AssertUtils.isEmpty(HPSC006.getOrgNo(), "已选择厂区,下料组不能为空"); AssertUtils.isEmpty(HPSC006.getOrgNo(), "已选择厂区,下料组不能为空");
HPSC006.setStatus(1); HPSC006.setStatus(1);
...@@ -152,12 +152,12 @@ public class ServiceHPSC006 extends ServiceBase { ...@@ -152,12 +152,12 @@ public class ServiceHPSC006 extends ServiceBase {
BigDecimal unitWt = HPSC006.getUnitWt(); BigDecimal unitWt = HPSC006.getUnitWt();
DecimalFormat decimalFormat = new DecimalFormat("#.000"); DecimalFormat decimalFormat = new DecimalFormat("#.000");
BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue()))); BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue())));
HPSC006.setInventSpec(HPPZTools.jointSpec(HPSC006.getInventLength(),HPSC006.getInventWidth(),HPSC006.getInventThick())); HPSC006.setInventSpec(HPPZTools.HpPz006.jointSpec(HPSC006.getInventLength(),HPSC006.getInventWidth(),HPSC006.getInventThick()));
HPSC006.setProjCode(projCode); HPSC006.setProjCode(projCode);
HPSC006.setProjName(projName); HPSC006.setProjName(projName);
HPSC006.setProductionOrderNo(productionOrderNo); HPSC006.setProductionOrderNo(productionOrderNo);
HPSC006.setTotalWt(totalWt); HPSC006.setTotalWt(totalWt);
HPSC006.setInventCode(HPPZTools.checkAndSavePZ04(HPSC006.getInventType(),HPSC006.getInventName())); HPSC006.setInventCode(HPPZTools.HpPz004.checkAndSave(HPSC006.getInventType(),HPSC006.getInventName()));
DaoUtils.update("HPSC006.update",HPSC006); DaoUtils.update("HPSC006.update",HPSC006);
} }
inInfo.setStatus(EiConstant.STATUS_SUCCESS); inInfo.setStatus(EiConstant.STATUS_SUCCESS);
......
...@@ -282,8 +282,8 @@ public class ExcelUtils { ...@@ -282,8 +282,8 @@ public class ExcelUtils {
HPSC002.setDelStatus(CommonConstant.YesNo.NO_0.intValue()); HPSC002.setDelStatus(CommonConstant.YesNo.NO_0.intValue());
HPSC002.setStatus(CommonConstant.YesNo.NO_0.intValue()); HPSC002.setStatus(CommonConstant.YesNo.NO_0.intValue());
HPSC002.setTotalWt(totalWt); HPSC002.setTotalWt(totalWt);
HPSC002.setSpec(HPPZTools.jointSpec(HPSC002.getLength(),HPSC002.getWidth(),HPSC002.getThick())); HPSC002.setSpec(HPPZTools.HpPz006.jointSpec(HPSC002.getLength(),HPSC002.getWidth(),HPSC002.getThick()));
HPSC002.setPrdtCode(HPPZTools.checkAndSavePZ04(HPSC002.getPrdtType(),HPSC002.getPrdtName())); HPSC002.setPrdtCode(HPPZTools.HpPz004.checkAndSave(HPSC002.getPrdtType(),HPSC002.getPrdtName()));
if (!checkStatus) { if (!checkStatus) {
checkOkBlock.addRow(HPSC002.toMap()); checkOkBlock.addRow(HPSC002.toMap());
} }
...@@ -317,10 +317,10 @@ public class ExcelUtils { ...@@ -317,10 +317,10 @@ public class ExcelUtils {
BigDecimal unitWt = HPSC006.getUnitWt(); BigDecimal unitWt = HPSC006.getUnitWt();
DecimalFormat decimalFormat = new DecimalFormat("#.000"); DecimalFormat decimalFormat = new DecimalFormat("#.000");
BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue()))); BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue())));
HPSC006.setInventSpec(HPPZTools.jointSpec(HPSC006.getInventLength(),HPSC006.getInventWidth(),HPSC006.getInventThick())); HPSC006.setInventSpec(HPPZTools.HpPz006.jointSpec(HPSC006.getInventLength(),HPSC006.getInventWidth(),HPSC006.getInventThick()));
HPSC006.setStatus(CommonConstant.YesNo.NO_0.intValue()); HPSC006.setStatus(CommonConstant.YesNo.NO_0.intValue());
HPSC006.setTotalWt(totalWt); HPSC006.setTotalWt(totalWt);
HPSC006.setInventCode(HPPZTools.checkAndSavePZ04(HPSC006.getInventType(),HPSC006.getInventName())); HPSC006.setInventCode(HPPZTools.HpPz004.checkAndSave(HPSC006.getInventType(),HPSC006.getInventName()));
if (!checkStatus) { if (!checkStatus) {
checkOkBlock.addRow(HPSC006.toMap()); checkOkBlock.addRow(HPSC006.toMap());
} }
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<EF:EFColumn ename="inventCode" cname="存货名称" width="120" align="center" required="true" readonly="true" <EF:EFColumn ename="inventCode" cname="存货名称" width="120" align="center" required="true" readonly="true"
hidden="true"/> hidden="true"/>
<EF:EFColumn ename="inventName" cname="存货名称" width="120" align="center" required="true" readonly="true"/> <EF:EFColumn ename="inventName" cname="存货名称" width="120" align="center" required="true" readonly="true"/>
<EF:EFColumn ename="inventRecordId" cname="规格" width="120" align="center" required="false" readonly="true"/> <EF:EFColumn ename="inventRecordId" cname="规格" width="120" align="center" required="true" readonly="true"/>
<EF:EFColumn ename="amount" cname="数量" format="{0:N3}" maxLength="20" width="100" align="right" <EF:EFColumn ename="amount" cname="数量" format="{0:N3}" maxLength="20" width="100" align="right"
sumType="all" required="true" readonly="true"/> sumType="all" required="true" readonly="true"/>
<EF:EFColumn ename="unitWeight" cname="单重" enable="false" width="100" align="right" format="{0:N3}"/> <EF:EFColumn ename="unitWeight" cname="单重" enable="false" width="100" align="right" format="{0:N3}"/>
......
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