Commit 46150cba by liuyang

2024-08-07 材料计划导入调整

parent c0b676f8
......@@ -5,6 +5,7 @@ import com.baosight.hggp.hg.cw.domain.HGCW003;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.sc.domain.HGSC004A;
import com.baosight.hggp.hg.sc.domain.HGSC009;
import com.baosight.hggp.hg.sc.domain.HGSC009A;
import com.baosight.hggp.hg.sj.domain.HGSJ003;
/**
......@@ -14,7 +15,7 @@ import com.baosight.hggp.hg.sj.domain.HGSJ003;
public enum DocRouteEnum {
HGSC004A("route_001", "HGSC004A", "importData", HGSC004A.class),
HGSC009("route_002", "HGSC009", "importData", HGSC009.class),
HGSC009A("route_002", "HGSC009", "importData", HGSC009A.class),
HGPZ005("route_003", "HGPZ005", "importData", HGPZ005.class),
HGCW003("route_004", "HGCW003", "importData", HGCW003.class),
HGSJ003("route_005", "HGSJ003", "importData", HGSJ003.class),
......
......@@ -10,6 +10,8 @@ import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.pz.domain.*;
import com.baosight.hggp.hg.sc.domain.HGSC001A;
import com.baosight.hggp.hg.sc.domain.HGSC005A;
import com.baosight.hggp.hg.sc.domain.HGSC009;
import com.baosight.hggp.hg.sc.domain.HGSC009A;
import com.baosight.hggp.hg.sj.domain.HGSJ003;
import com.baosight.hggp.util.*;
import com.baosight.iplat4j.common.ed.domain.TEDCM01;
......@@ -628,6 +630,33 @@ public class HGPZTools {
DaoUtils.insert(HGPZ005.INSERT,hgpz005);
}
}
public static HGPZ005 add(HGSC009A hgsc009a){
List<HGPZ004> hgpz004s = DaoBase.getInstance().query(HGPZ004.QUERY, new HashMap<String, Object>(){{
put(HGPZ004.FIELD_STATUS, CommonConstant.YesNo.YES_1);
}});
Map parmap = hgpz004s.stream().collect(Collectors.toMap(HGPZ004::getInventTypeName, HGPZ004::getInventType,(v1, v2) -> v1));
String inventType = com.baosight.hggp.util.MapUtils.getString(parmap, com.baosight.hggp.util.StringUtils.trimToEmpty(hgsc009a.getInventType()));
AssertUtils.isEmpty(inventType, String.format("存货类型[%s]代码不存在,添加失败!", hgsc009a.getInventType()));
Map<String, Object> objectMap = hgpz004s.stream().filter(item-> Objects.equals(item.getInventType(), inventType)).distinct().collect(Collectors.toMap(HGPZ004::getInventType,HGPZ004::getInventTypeDetail,(v1, v2) -> v1));
HGPZ005 pz005 = new HGPZ005();
pz005.setInventType(inventType);
pz005.setInventCode(hgsc009a.getInventCode());
pz005.setInventName(hgsc009a.getInventName());
pz005.setSpec(hgsc009a.getSpec());
pz005.setInventTypeDetail((Integer) objectMap.get(inventType));
pz005.setLength(hgsc009a.getLength());
pz005.setWidth(hgsc009a.getWidth());
pz005.setThick(hgsc009a.getThick());
pz005.setMaterial(hgsc009a.getMaterial());
pz005.setCoefficient(hgsc009a.getCoefficient());
pz005.setUnit(hgsc009a.getUnit());
pz005.setStatus(1); //默认启用
DaoUtils.insert(HGPZ005.INSERT,pz005);
return pz005;
}
}
public static class HgPz005A {
......
......@@ -89,19 +89,32 @@ public class HGSC009A extends DaoEPBase {
private String depCode = " "; /* 部门编码*/
private String companyCode = " "; /* 公司编码*/
private String companyName = " "; /* 公司名称*/
@ExcelAnno(index = 8,name = "projCode")
private String projCode = " "; /* 项目编码*/
@ExcelAnno(index = 9,name = "projName")
private String projName = " "; /* 项目名称*/
@ExcelAnno(index = 10,name = "planMaterialDate")
private String planMaterialDate = " "; /* 材料计划编码*/
private String planMaterialCode = " "; /* 材料计划编码*/
@ExcelAnno(index = 11,name = "planMaterialName")
private String planMaterialName = " "; /* 材料计划名称*/
@ExcelAnno(index = 0,name = "inventCode")
private String inventCode = " "; /* 存货编码*/
@ExcelAnno(index = 1,name = "inventName")
private String inventName = " "; /* 存货名称*/
@ExcelAnno(index = 2,name = "spec")
private String spec = " "; /* 规格*/
@ExcelAnno(index = 13,name = "material")
private String material = " "; /* 材质*/
@ExcelAnno(index = 3,name = "length")
private BigDecimal length = new BigDecimal("0"); /* 长*/
@ExcelAnno(index = 4,name = "width")
private BigDecimal width = new BigDecimal("0"); /* 宽*/
@ExcelAnno(index = 5,name = "thick")
private BigDecimal thick = new BigDecimal("0"); /* 厚*/
@ExcelAnno(index = 6,name = "quantity")
private BigDecimal quantity = new BigDecimal("0"); /* 数量*/
@ExcelAnno(index = 7,name = "singleWeight")
private BigDecimal singleWeight = new BigDecimal("0"); /* 单重*/
private BigDecimal grossAmount = new BigDecimal("0"); /* 总量*/
private String createdBy = " "; /* 创建人*/
......@@ -111,6 +124,12 @@ public class HGSC009A extends DaoEPBase {
private String updatedName = " "; /* 修改人名称*/
private String updatedTime = " "; /* 修改时间*/
private String inventTypeDetail; /*存货类型明细 1:构建 2:零件*/
@ExcelAnno(index = 12,name = "inventType")
private String inventType = " "; /* 存货类型*/
@ExcelAnno(index = 14,name = "coefficient")
private BigDecimal coefficient = new BigDecimal("0"); /* 系数*/
@ExcelAnno(index = 15,name = "unit")
private String unit = " "; /* 单位*/
/**
* initialize the metadata.
......@@ -245,6 +264,21 @@ public class HGSC009A extends DaoEPBase {
eiColumn.setDescName("存货类型明细");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("inventType");
eiColumn.setDescName("存货类型");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("coefficient");
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(12);
eiColumn.setDescName("系数");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("unit");
eiColumn.setDescName("单位");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -671,6 +705,30 @@ public class HGSC009A extends DaoEPBase {
this.planMaterialDate = planMaterialDate;
}
public String getInventType() {
return inventType;
}
public void setInventType(String inventType) {
this.inventType = inventType;
}
public BigDecimal getCoefficient() {
return coefficient;
}
public void setCoefficient(BigDecimal coefficient) {
this.coefficient = coefficient;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
/**
* get the value from Map.
*
......@@ -706,6 +764,9 @@ public class HGSC009A extends DaoEPBase {
setUpdatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_NAME)), updatedName));
setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime));
setInventTypeDetail(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_TYPE_DETAIL)), inventTypeDetail));
setInventType(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("inventType")), inventType));
setCoefficient(NumberUtils.toBigDecimal(StringUtils.toString(map.get("coefficient")), coefficient));
setUnit(StringUtils.defaultIfEmpty(StringUtils.toString(map.get("unit")), unit));
}
/**
......@@ -742,6 +803,9 @@ public class HGSC009A extends DaoEPBase {
map.put(FIELD_UPDATED_NAME, StringUtils.toString(updatedName, eiMetadata.getMeta(FIELD_UPDATED_NAME)));
map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME)));
map.put(FIELD_INVENT_TYPE_DETAIL,StringUtils.toString(inventTypeDetail, eiMetadata.getMeta(FIELD_INVENT_TYPE_DETAIL)));
map.put("inventType",StringUtils.toString(inventType, eiMetadata.getMeta("inventType")));
map.put("coefficient",StringUtils.toString(coefficient, eiMetadata.getMeta("coefficient")));
map.put("unit",StringUtils.toString(unit, eiMetadata.getMeta("unit")));
return map;
}
......
......@@ -181,13 +181,17 @@ public class ServiceHGSC009 extends ServiceEPBase {
}
@OperationLogAnnotation(operModul = "材料计划",operType = "导入",operDesc = "导入操作")
public EiInfo importDate(EiInfo inInfo) {
public EiInfo importData(EiInfo inInfo) {
try {
Map<String, Object> params = new HashMap<>(10);
String fileName = inInfo.getString("fileName");
params.put(HGSC009A.FIELD_ACCOUNT_CODE, UserSessionUtils.getAccountCode());
List<HGSC009A> dataList = (List) inInfo.get("dataList");
HGSCTools.THGSC009.add(dataList);
//Map<String, Object> params = new HashMap<>(10);
//String fileName = inInfo.getString("fileName");
//params.put(HGSC009A.FIELD_ACCOUNT_CODE, UserSessionUtils.getAccountCode());
//解析文件,将文件中数据传入到inInfo中
ExcelUtils.importFromExcel(inInfo, fileName, params, new HGSC009A());
//ExcelUtils.importFromExcel(inInfo, fileName, params, new HGSC009A());
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("导入成功" + dataList.size() + "条");
}catch (Exception e){
inInfo.setStatus(EiConstant.STATUS_FAILURE);
LogUtils.setDetailMsg(inInfo, e, "导入失败");
......
......@@ -1419,7 +1419,7 @@ public class HGSCTools {
return results;
}
public static void add(List<Map> arrayList) {
public static void add(List<HGSC009A> arrayList) {
List<HGSC009> hgsc009List = initHgsc009(arrayList);
List<HGSC009A> hgsc009aList = initHgsc009a(arrayList);
for (HGSC009 hgsc009:hgsc009List) {
......@@ -1435,9 +1435,12 @@ public class HGSCTools {
hgsc009.setPlanMaterialCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.PLAN_MATERIAL_CODE));
DaoUtils.insert(HGSC009.INSERT,hgsc009);
List<HGSC009A> hgsc009as = new ArrayList<>();
for (HGSC009A hgsc009a: hgsc009aList) {
HGPZ005 hgpz005 = HGPZTools.HgPz005.getByCode(hgsc009a.getInventCode());
AssertUtils.isEmpty(Collections.singleton(hgpz005),"产品编码不存在,添加失败!");
if (Objects.isNull(hgpz005)){
hgpz005 = HGPZTools.HgPz005.add(hgsc009a);
}
hgsc009a.setCompanyCode(hgsc009.getCompanyCode());
hgsc009a.setCompanyName(hgsc009.getCompanyName());
//hgsc009a.setProjCode(hgsc009.getProjCode());
......@@ -1455,23 +1458,25 @@ public class HGSCTools {
if (hgsc009a.getSingleWeight().compareTo(BigDecimal.ZERO) == 0 ){
hgsc009a.setSingleWeight(HGPZTools.HgPz005.calcUnitWeight(hgpz005));
}
AssertUtils.isTrue(hgsc009a.getQuantity().compareTo(BigDecimal.ZERO) == 0, "数量不能为0!");
hgsc009a.setGrossAmount(hgsc009a.getQuantity().multiply(hgsc009a.getSingleWeight()));
DaoUtils.insert(HGSC009A.INSERT,hgsc009a);
hgsc009as.add(hgsc009a);
}
DaoUtils.insertBatch(HGSC009A.INSERT,hgsc009as);
}
}
public static List<HGSC009> initHgsc009(List<Map> arrayList) {
public static List<HGSC009> initHgsc009(List<HGSC009A> hgsc009AList) {
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")), "材料计划日期不能为空!");
hgsc009AList.forEach(hgsc009A -> {
AssertUtils.isEmpty(Collections.singleton(hgsc009A.getProjCode()), "项目编码不能为空!");
AssertUtils.isEmpty(Collections.singleton(hgsc009A.getPlanMaterialName()), "材料计划名称不能为空!");
AssertUtils.isEmpty(Collections.singleton(hgsc009A.getPlanMaterialDate()), "材料计划日期不能为空!");
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.setProjCode(hgsc009A.getProjCode());
hgsc009.setProjName(hgsc009A.getProjName());
hgsc009.setPlanMaterialName(hgsc009A.getPlanMaterialName());
hgsc009.setPlanMaterialDate(DateUtils.formatShort(hgsc009A.getPlanMaterialDate()));
hgsc009.setStatus(0);
Map hgsc009List1 = hgsc009List.stream().filter(sc009 -> sc009.getProjCode().equals(hgsc009.getProjCode())).collect(Collectors.toMap(HGSC009::getProjCode, hgsc0091 -> hgsc0091));
if (hgsc009List1.isEmpty()) {
......@@ -1481,29 +1486,17 @@ public class HGSCTools {
return hgsc009List;
}
public static List<HGSC009A> initHgsc009a(List<Map> arrayList) {
public static List<HGSC009A> initHgsc009a(List<HGSC009A> 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.isEmpty(Collections.singleton(array.getQuantity()), "材料计划数量不能为空!");
array.setPlanMaterialDate(DateUtils.formatShort(array.getPlanMaterialDate()));
if (array.getSingleWeight().compareTo(BigDecimal.ZERO) == 0 || array.getQuantity().compareTo(BigDecimal.ZERO) == 0){
AssertUtils.isTrue(false,"单重和数量不能为空!");
}
hgsc009A.setGrossAmount(hgsc009A.getQuantity().multiply(hgsc009A.getSingleWeight()));
array.setGrossAmount(array.getQuantity().multiply(array.getSingleWeight()));
hgsc009aList.add(hgsc009A);
hgsc009aList.add(array);
});
return hgsc009aList;
}
......
......@@ -248,7 +248,7 @@ public class ExcelUtils {
inInfo.setMsg("导入成功" + arrayList.size() + "条");
break;
case "HGSC009":
HGSCTools.THGSC009.add(arrayList);
//HGSCTools.THGSC009.add(arrayList);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("导入成功" + arrayList.size() + "条");
break;
......
......@@ -190,7 +190,7 @@ $(function () {
});
});
grush.openImportBox();
//grush.openImportBox();
IPLATUI.EFUpload = {
fileUpload: {
......
......@@ -37,14 +37,8 @@ let upload = function () {
formData.append("parentProdName", parentPrdtName);
formData.append("materialId", materialId);
formData.append("lv", lv);
}
if(id === 'route_002'){
}else {
formData.append("id", id);
formData.append("startRow", "1"); // 第几行开始读取
formData.append("productionOrderNo", productionOrderNo);
formData.append("projCode", projCode);
formData.append("projName", projName);
formData.append("deliveryDate", deliveryDate);
}
formData.append("file", $("#inqu_status-0-file")[0].files[0]);
$.ajax({
......
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