Commit 50e71e74 by liuyang

2024-07-31 材料计划添加导入功能

parent a5c1f750
package com.baosight.hggp.hg.sc.domain;
import com.baosight.hggp.util.DateUtils;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.data.DaoEPBase;
......@@ -30,6 +31,7 @@ public class HGSC009 extends DaoEPBase {
public static final String FIELD_PROJ_NAME = "projName"; /* 项目名称*/
public static final String FIELD_PLAN_MATERIAL_CODE = "planMaterialCode"; /* 材料计划编码*/
public static final String FIELD_PLAN_MATERIAL_NAME = "planMaterialName"; /* 材料计划名称*/
public static final String FIELD_PLAN_MATERIAL_DATE = "planMaterialDate"; /* 材料计划日期*/
public static final String FIELD_STATUS = "status"; /* 提交状态 0-未提交 1-已提交*/
public static final String FIELD_CREATED_BY = "createdBy"; /* 创建人*/
public static final String FIELD_CREATED_NAME = "createdName"; /* 创建人名称*/
......@@ -74,6 +76,7 @@ public class HGSC009 extends DaoEPBase {
private String projName = " "; /* 项目名称*/
private String planMaterialCode = " "; /* 材料计划编码*/
private String planMaterialName = " "; /* 材料计划名称*/
private String planMaterialDate = " "; /* 材料计划日期*/
private Integer status; /* 提交状态 0-未提交 1-已提交*/
private String createdBy = " "; /* 创建人*/
private String createdName = " "; /* 创建人名称*/
......@@ -126,6 +129,10 @@ public class HGSC009 extends DaoEPBase {
eiColumn.setDescName("材料计划名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PLAN_MATERIAL_DATE);
eiColumn.setDescName("材料计划日期");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_STATUS);
eiColumn.setDescName("提交状态 0-未提交 1-已提交");
eiMetadata.addMeta(eiColumn);
......@@ -423,6 +430,14 @@ public class HGSC009 extends DaoEPBase {
this.updatedTime = updatedTime;
}
public String getPlanMaterialDate() {
return planMaterialDate;
}
public void setPlanMaterialDate(String planMaterialDate) {
this.planMaterialDate = planMaterialDate;
}
@Override
public void fromMap(Map map) {
......@@ -435,6 +450,7 @@ public class HGSC009 extends DaoEPBase {
setProjName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PROJ_NAME)), projName));
setPlanMaterialCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PLAN_MATERIAL_CODE)), planMaterialCode));
setPlanMaterialName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PLAN_MATERIAL_NAME)), planMaterialName));
setPlanMaterialDate(StringUtils.defaultIfEmpty(StringUtils.toString(DateUtils.formatShort(map.get(FIELD_PLAN_MATERIAL_DATE))), planMaterialDate));
setStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_STATUS)), status));
setCreatedBy(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_BY)), createdBy));
setCreatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_NAME)), createdName));
......@@ -460,6 +476,7 @@ public class HGSC009 extends DaoEPBase {
map.put(FIELD_PROJ_NAME, StringUtils.toString(projName, eiMetadata.getMeta(FIELD_PROJ_NAME)));
map.put(FIELD_PLAN_MATERIAL_CODE, StringUtils.toString(planMaterialCode, eiMetadata.getMeta(FIELD_PLAN_MATERIAL_CODE)));
map.put(FIELD_PLAN_MATERIAL_NAME, StringUtils.toString(planMaterialName, eiMetadata.getMeta(FIELD_PLAN_MATERIAL_NAME)));
map.put(FIELD_PLAN_MATERIAL_DATE, StringUtils.toString(planMaterialDate, eiMetadata.getMeta(FIELD_PLAN_MATERIAL_DATE)));
map.put(FIELD_STATUS, StringUtils.toString(status, eiMetadata.getMeta(FIELD_STATUS)));
map.put(FIELD_CREATED_BY, StringUtils.toString(createdBy, eiMetadata.getMeta(FIELD_CREATED_BY)));
map.put(FIELD_CREATED_NAME, StringUtils.toString(createdName, eiMetadata.getMeta(FIELD_CREATED_NAME)));
......
......@@ -90,6 +90,7 @@ public class HGSC009A extends DaoEPBase {
private String companyName = " "; /* 公司名称*/
private String projCode = " "; /* 项目编码*/
private String projName = " "; /* 项目名称*/
private String planMaterialDate = " "; /* 材料计划编码*/
private String planMaterialCode = " "; /* 材料计划编码*/
private String planMaterialName = " "; /* 材料计划名称*/
private String inventCode = " "; /* 存货编码*/
......@@ -145,6 +146,10 @@ public class HGSC009A extends DaoEPBase {
eiColumn.setDescName("项目名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("planMaterialDate");
eiColumn.setDescName("材料计划日期");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PLAN_MATERIAL_CODE);
eiColumn.setDescName("材料计划编码");
eiMetadata.addMeta(eiColumn);
......@@ -154,11 +159,11 @@ public class HGSC009A extends DaoEPBase {
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INVENT_CODE);
eiColumn.setDescName("存货编码");
eiColumn.setDescName("产品编号");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INVENT_NAME);
eiColumn.setDescName("存货名称");
eiColumn.setDescName("产品名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_SPEC);
......@@ -173,21 +178,21 @@ public class HGSC009A extends DaoEPBase {
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("长");
eiColumn.setDescName("长(MM)");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_WIDTH);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("宽");
eiColumn.setDescName("宽(MM)");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_THICK);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("厚");
eiColumn.setDescName("厚(MM)");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_QUANTITY);
......@@ -201,7 +206,7 @@ public class HGSC009A extends DaoEPBase {
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("单重");
eiColumn.setDescName("单重(KG)");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_GROSS_AMOUNT);
......@@ -656,6 +661,15 @@ public class HGSC009A extends DaoEPBase {
public void setInventTypeDetail(String inventTypeDetail) {
this.inventTypeDetail = inventTypeDetail;
}
public String getPlanMaterialDate() {
return planMaterialDate;
}
public void setPlanMaterialDate(String planMaterialDate) {
this.planMaterialDate = planMaterialDate;
}
/**
* get the value from Map.
*
......@@ -671,6 +685,7 @@ public class HGSC009A extends DaoEPBase {
setCompanyName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_NAME)), companyName));
setProjCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PROJ_CODE)), projCode));
setProjName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PROJ_NAME)), projName));
setPlanMaterialDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("planMaterialDate")), planMaterialDate));
setPlanMaterialCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PLAN_MATERIAL_CODE)), planMaterialCode));
setPlanMaterialName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PLAN_MATERIAL_NAME)), planMaterialName));
setInventCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_CODE)), inventCode));
......@@ -706,6 +721,7 @@ public class HGSC009A extends DaoEPBase {
map.put(FIELD_COMPANY_NAME, StringUtils.toString(companyName, eiMetadata.getMeta(FIELD_COMPANY_NAME)));
map.put(FIELD_PROJ_CODE, StringUtils.toString(projCode, eiMetadata.getMeta(FIELD_PROJ_CODE)));
map.put(FIELD_PROJ_NAME, StringUtils.toString(projName, eiMetadata.getMeta(FIELD_PROJ_NAME)));
map.put("planMaterialDate", StringUtils.toString(planMaterialDate, eiMetadata.getMeta("planMaterialDate")));
map.put(FIELD_PLAN_MATERIAL_CODE, StringUtils.toString(planMaterialCode, eiMetadata.getMeta(FIELD_PLAN_MATERIAL_CODE)));
map.put(FIELD_PLAN_MATERIAL_NAME, StringUtils.toString(planMaterialName, eiMetadata.getMeta(FIELD_PLAN_MATERIAL_NAME)));
map.put(FIELD_INVENT_CODE, StringUtils.toString(inventCode, eiMetadata.getMeta(FIELD_INVENT_CODE)));
......
......@@ -31,6 +31,9 @@
<isNotEmpty prepend=" AND " property="planMaterialName">
PLAN_MATERIAL_NAME = #planMaterialName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="planMaterialDate">
PLAN_MATERIAL_DATE = #planMaterialDate#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status">
STATUS = #status#
</isNotEmpty>
......@@ -69,6 +72,7 @@
PROJ_NAME as "projName", <!-- 项目名称 -->
PLAN_MATERIAL_CODE as "planMaterialCode", <!-- 材料计划编码 -->
PLAN_MATERIAL_NAME as "planMaterialName", <!-- 材料计划名称 -->
PLAN_MATERIAL_DATE as "planMaterialDate", <!-- 材料计划名称 -->
STATUS as "status", <!-- 提交状态 0-未提交 1-已提交 -->
CREATED_BY as "createdBy", <!-- 创建人 -->
CREATED_NAME as "createdName", <!-- 创建人名称 -->
......@@ -106,6 +110,7 @@
PROJ_NAME, <!-- 项目名称 -->
PLAN_MATERIAL_CODE, <!-- 材料计划编码 -->
PLAN_MATERIAL_NAME, <!-- 材料计划名称 -->
PLAN_MATERIAL_DATE,
STATUS, <!-- 提交状态 0-未提交 1-已提交 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
......@@ -115,7 +120,10 @@
UPDATED_TIME <!-- 修改时间 -->
)
VALUES (#id#, #accountCode#, #depCode#, #companyCode#, #companyName#, #projCode#, #projName#, #planMaterialCode#, #planMaterialName#, #status#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#)
VALUES (#id#, #accountCode#, #depCode#, #companyCode#, #companyName#, #projCode#, #projName#, #planMaterialCode#, #planMaterialName#, #planMaterialDate#, #status#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#)
<selectKey resultClass="long" keyProperty="id">
SELECT MAX(ID) AS "id" FROM ${hggpSchema}.HGSJ003
</selectKey>
</insert>
<delete id="delete">
......@@ -134,6 +142,7 @@
PROJ_NAME = #projName#, <!-- 项目名称 -->
PLAN_MATERIAL_CODE = #planMaterialCode#, <!-- 材料计划编码 -->
PLAN_MATERIAL_NAME = #planMaterialName#, <!-- 材料计划名称 -->
PLAN_MATERIAL_DATE = #planMaterialDate#,
STATUS = #status#, <!-- 提交状态 0-未提交 1-已提交 -->
CREATED_BY = #createdBy#, <!-- 创建人 -->
CREATED_NAME = #createdName#, <!-- 创建人名称 -->
......
......@@ -9,6 +9,7 @@ import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.ds.domain.HGDS002;
import com.baosight.hggp.hg.pz.domain.HGPZ004;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.pz.domain.HGPZ005A;
import com.baosight.hggp.hg.pz.tools.HGPZTools;
......@@ -28,12 +29,12 @@ import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.baosight.hggp.common.AssignStatusEnum.*;
......@@ -1242,6 +1243,15 @@ public class HGSCTools {
AssertUtils.isEmpty(results,"材料计划不能为空!");
return results;
}
public static HGSC009 queryByCode(String projCode) {
AssertUtils.isNull(projCode, "项目Code不能为空!");
List<HGSC009> results = DaoBase.getInstance().query(HGSC009.QUERY, new HashMap<String,Object>(){
{put("projCode",projCode);}
});
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
public static List<HGSC009A> getByPlanMaterialCodes(String[] planMaterialCodes){
AssertUtils.isTrue(Objects.isNull(planMaterialCodes)||planMaterialCodes.length<=0, "材料计划编码不能为空!");
Map map = new HashMap<>();
......@@ -1261,11 +1271,92 @@ public class HGSCTools {
}
public static void add(List<Map> arrayList) {
for (Map map:arrayList) {
HGSC009A hgsc009A = new HGSC009A();
hgsc009A.fromMap(map);
List<HGSC009> hgsc009List = initHgsc009(arrayList);
List<HGSC009A> hgsc009aList = initHgsc009a(arrayList);
for (HGSC009 hgsc009:hgsc009List) {
HGSC001 hgsc001 = Hgsc001.queryByCode(hgsc009.getProjCode());
AssertUtils.isNull(hgsc001,"项目不存在,添加失败!");
HGSC009 sc009 = queryByCode(hgsc009.getProjCode());
AssertUtils.isNotNull(sc009,"材料计划项目已添加,添加失败!");
if (hgsc001.getCompanyCode() != null) {
hgsc009.setCompanyCode(hgsc001.getCompanyCode());
}
hgsc009.setCompanyName(hgsc001.getCompanyName());
hgsc009.setProjName(hgsc001.getProjName());
hgsc009.setPlanMaterialCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.PLAN_MATERIAL_CODE));
DaoUtils.insert(HGSC009.INSERT,hgsc009);
for (HGSC009A hgsc009a: hgsc009aList) {
HGPZ005 hgpz005 = HGPZTools.HgPz005.getByCode(hgsc009a.getInventCode());
AssertUtils.isEmpty(Collections.singleton(hgpz005),"产品编码不存在,添加失败!");
hgsc009a.setCompanyCode(hgsc009.getCompanyCode());
hgsc009a.setCompanyName(hgsc009.getCompanyName());
//hgsc009a.setProjCode(hgsc009.getProjCode());
hgsc009a.setProjName(hgsc009.getProjName());
hgsc009a.setPlanMaterialCode(hgsc009.getPlanMaterialCode());
//hgsc009a.setPlanMaterialName(hgsc009.getPlanMaterialName());
hgsc009a.setInventName(hgpz005.getInventName());
hgsc009a.setInventCode(hgpz005.getInventCode());
hgsc009a.setSpec(hgpz005.getSpec());
hgsc009a.setMaterial(hgpz005.getMaterial());
hgsc009a.setLength(hgpz005.getLength());
hgsc009a.setWidth(hgpz005.getWidth());
hgsc009a.setThick(hgpz005.getThick());
hgsc009a.setInventTypeDetail(hgpz005.getInventTypeDetail()+"");
if (hgsc009a.getSingleWeight().compareTo(BigDecimal.ZERO) == 0 ){
hgsc009a.setSingleWeight(HGPZTools.HgPz005.calcUnitWeight(hgpz005));
}
hgsc009a.setGrossAmount(hgsc009a.getQuantity().multiply(hgsc009a.getSingleWeight()));
DaoUtils.insert(HGSC009A.INSERT,hgsc009a);
}
}
}
public static List<HGSC009> initHgsc009(List<Map> arrayList) {
List<HGSC009> hgsc009List = new ArrayList<>();
arrayList.forEach(array -> {
AssertUtils.isEmpty(Collections.singleton(array.get("projCode")), "项目编码不能为空!");
AssertUtils.isEmpty(Collections.singleton(array.get("planMaterialName")), "材料计划名称不能为空!");
AssertUtils.isEmpty(Collections.singleton(array.get("planMaterialDate")), "材料计划日期不能为空!");
HGSC009 hgsc009 = new HGSC009();
hgsc009.setProjCode(array.get("projCode").toString());
hgsc009.setProjName(array.get("projName").toString());
hgsc009.setPlanMaterialName(array.get("planMaterialName").toString());
hgsc009.setPlanMaterialDate(DateUtils.formatShort(array.get("planMaterialDate").toString()));
hgsc009.setStatus(0);
Map hgsc009List1 = hgsc009List.stream().filter(sc009 -> sc009.getProjCode().equals(hgsc009.getProjCode())).collect(Collectors.toMap(HGSC009::getProjCode, hgsc0091 -> hgsc0091));
if (hgsc009List1.isEmpty()) {
hgsc009List.add(hgsc009);
}
});
return hgsc009List;
}
public static List<HGSC009A> initHgsc009a(List<Map> arrayList) {
List<HGSC009A> hgsc009aList = new ArrayList<>();
arrayList.forEach(array -> {
AssertUtils.isEmpty(Collections.singleton(array.get("quantity")), "材料计划数量不能为空!");
HGSC009A hgsc009A = new HGSC009A();
hgsc009A.setProjCode(array.get("projCode").toString());
hgsc009A.setProjName(array.get("projName").toString());
hgsc009A.setPlanMaterialName(array.get("planMaterialName").toString());
hgsc009A.setPlanMaterialDate(DateUtils.formatShort(array.get("planMaterialDate").toString()));
hgsc009A.setInventCode(array.get("inventCode").toString());
hgsc009A.setInventName(array.get("inventName").toString());
hgsc009A.setSpec(array.get("spec").toString());
hgsc009A.setMaterial(array.get("material").toString());
BigDecimal singleWeight = new BigDecimal(array.get("singleWeight").toString());
hgsc009A.setSingleWeight(singleWeight);
BigDecimal quantity = new BigDecimal(array.get("quantity").toString());
hgsc009A.setQuantity(quantity);
if (hgsc009A.getSingleWeight().compareTo(BigDecimal.ZERO) == 0 || hgsc009A.getQuantity().compareTo(BigDecimal.ZERO) == 0){
AssertUtils.isTrue(false,"单重和数量不能为空!");
}
hgsc009A.setGrossAmount(hgsc009A.getQuantity().multiply(hgsc009A.getSingleWeight()));
hgsc009aList.add(hgsc009A);
});
return hgsc009aList;
}
}
}
......@@ -36,6 +36,9 @@ public class ACConstants {
*/
public static final String SQL_EXPORT = "export";
/** 导入文件暂存路径 dzg */
public static final String FILE_NAME = "fileName";
/**
* 模块:仓库档案
* 用途:前后台交互下拉框字段
......
......@@ -85,7 +85,7 @@ $(function () {
filter: "contains"
});
}
}, {
},/* {
field: "createdTime",
attributes: {
class: "i-input-readonly"
......@@ -93,7 +93,7 @@ $(function () {
defaultValue: function () {
return currShortDate();
}
},
},*/
],
......
......@@ -49,7 +49,7 @@
<%-- </EF:EFComboColumn>--%>
<EF:EFColumn ename="projCode" cname="项目编码" enable="true" width="120" align="center"/>
<EF:EFColumn ename="projName" cname="项目名称" width="120" align="center" enable="false"/>
<EF:EFColumn ename="createdTime" cname="材料计划日期" width="120" enable="true" readonly="false" align="center" editType="date"
<EF:EFColumn ename="planMaterialDate" cname="材料计划日期" width="120" enable="true" readonly="false" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true"/>
<EF:EFColumn ename="planMaterialCode" cname="材料计划编码" width="120" enable="false" readonly="true" align="center"/>
<EF:EFColumn ename="planMaterialName" cname="材料计划名称" width="120" enable="true" readonly="false" align="center"/>
......
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