Commit 4af9b530 by liuyang

2024-08-01 物料清单详情添加导入功能

parent 91645de0
...@@ -130,7 +130,7 @@ public class HGSC004A extends DaoEPBase { ...@@ -130,7 +130,7 @@ public class HGSC004A extends DaoEPBase {
private BigDecimal thick = new BigDecimal("0"); /* 厚*/ private BigDecimal thick = new BigDecimal("0"); /* 厚*/
private Integer productStatus = new Integer(0); /* 产品状态 0:未提交,1:已提交*/ private Integer productStatus = new Integer(0); /* 产品状态 0:未提交,1:已提交*/
private Integer changeType = new Integer(0); /* 变更类型:默认0,1:增加,2:替换,3:删除*/ private Integer changeType = new Integer(0); /* 变更类型:默认0,1:增加,2:替换,3:删除*/
private Integer quantity = new Integer(0); /* 数量*/ private BigDecimal quantity = new BigDecimal(0); /* 数量*/
private BigDecimal singleWeight = new BigDecimal(0.000); /* 单重*/ private BigDecimal singleWeight = new BigDecimal(0.000); /* 单重*/
private BigDecimal totalWeight = new BigDecimal(0.000); /* 总重*/ private BigDecimal totalWeight = new BigDecimal(0.000); /* 总重*/
private Integer approvalStatus = new Integer(0); /* 审批状态\t0:待审;1:审核中;2:已审*/ private Integer approvalStatus = new Integer(0); /* 审批状态\t0:待审;1:审核中;2:已审*/
...@@ -281,7 +281,7 @@ public class HGSC004A extends DaoEPBase { ...@@ -281,7 +281,7 @@ public class HGSC004A extends DaoEPBase {
eiColumn = new EiColumn(FIELD_quantity); eiColumn = new EiColumn(FIELD_quantity);
eiColumn.setType("N"); eiColumn.setType("N");
eiColumn.setScaleLength(0); eiColumn.setScaleLength(0);
eiColumn.setFieldLength(8); eiColumn.setFieldLength(20);
eiColumn.setDescName("数量"); eiColumn.setDescName("数量");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
...@@ -579,7 +579,7 @@ public class HGSC004A extends DaoEPBase { ...@@ -579,7 +579,7 @@ public class HGSC004A extends DaoEPBase {
* get the quantity - 数量. * get the quantity - 数量.
* @return the quantity * @return the quantity
*/ */
public Integer getQuantity() { public BigDecimal getQuantity() {
return this.quantity; return this.quantity;
} }
...@@ -588,7 +588,7 @@ public class HGSC004A extends DaoEPBase { ...@@ -588,7 +588,7 @@ public class HGSC004A extends DaoEPBase {
* *
* @param quantity - 数量 * @param quantity - 数量
*/ */
public void setQuantity(Integer quantity) { public void setQuantity(BigDecimal quantity) {
this.quantity = quantity; this.quantity = quantity;
} }
/** /**
...@@ -871,7 +871,7 @@ public class HGSC004A extends DaoEPBase { ...@@ -871,7 +871,7 @@ public class HGSC004A extends DaoEPBase {
setThick(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_thick)), thick)); setThick(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_thick)), thick));
setProductStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_product_status)), productStatus)); setProductStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_product_status)), productStatus));
setChangeType(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_change_type)), changeType)); setChangeType(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_change_type)), changeType));
setQuantity(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_quantity)), quantity)); setQuantity(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_quantity)), quantity));
setSingleWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_single_weight)), singleWeight)); setSingleWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_single_weight)), singleWeight));
setTotalWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_total_weight)), totalWeight)); setTotalWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_total_weight)), totalWeight));
setApprovalStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_approval_status)), approvalStatus)); setApprovalStatus(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_approval_status)), approvalStatus));
......
...@@ -551,5 +551,32 @@ public class ServiceHGSC004A extends ServiceBase { ...@@ -551,5 +551,32 @@ public class ServiceHGSC004A extends ServiceBase {
} }
} }
@OperationLogAnnotation(operModul = "物料清单详情",operType = "导入",operDesc = "导入操作")
public EiInfo importDate(EiInfo inInfo) {
try {
Map<String, Object> params = new HashMap<>(10);
String fileName = inInfo.getString(ACConstants.FILE_NAME);
String projCode = inInfo.getString(HGSC004A.FIELD_proj_code);
String projName = inInfo.getString(HGSC004A.FIELD_proj_name);
String parentProdCode = inInfo.getString(HGSC004A.FIELD_parent_prod_code);
String parentProdName = inInfo.getString(HGSC004A.FIELD_parent_prod_name);
String lv = inInfo.getString(HGSC004A.FIELD_lv);
String materialId = inInfo.getString(HGSC004A.FIELD_material_id);
params.put(HGSC004A.FIELD_account_code, UserSessionUtils.getAccountCode());
params.put(HGSC004A.FIELD_proj_code, projCode);
params.put(HGSC004A.FIELD_proj_name, projName);
params.put(HGSC004A.FIELD_parent_prod_code, parentProdCode);
params.put(HGSC004A.FIELD_parent_prod_name, parentProdName);
params.put(HGSC004A.FIELD_lv, lv);
params.put(HGSC004A.FIELD_material_id, materialId);
//解析文件,将文件中数据传入到inInfo中
ExcelUtils.importFromExcel(inInfo, fileName, params, new HGSC004A());
}catch (Exception e){
inInfo.setStatus(EiConstant.STATUS_FAILURE);
LogUtils.setDetailMsg(inInfo, e, "导入失败");
}
return inInfo;
}
} }
...@@ -304,6 +304,9 @@ ...@@ -304,6 +304,9 @@
#productCode#, #productName#,#inventType#, #productStatus#, #changeType#, #quantity#, #singleWeight#, #totalWeight#, #productCode#, #productName#,#inventType#, #productStatus#, #changeType#, #quantity#, #singleWeight#, #totalWeight#,
#approvalStatus#, #accountCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #approvalStatus#, #accountCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#,
#updatedName#, #updatedTime#, #length#, #width#, #thick#) #updatedName#, #updatedTime#, #length#, #width#, #thick#)
<selectKey resultClass="java.lang.Long" keyProperty="id">
SELECT MAX(ID) FROM ${hggpSchema}.HGSC004A
</selectKey>
</insert> </insert>
<delete id="delete"> <delete id="delete">
......
...@@ -203,6 +203,14 @@ public class HGSCTools { ...@@ -203,6 +203,14 @@ public class HGSCTools {
HGSC003 results = (HGSC003)DaoBase.getInstance().get(HGSC003.QUERY, HGSC003.FIELD_blueprint_code, blueprintCode); HGSC003 results = (HGSC003)DaoBase.getInstance().get(HGSC003.QUERY, HGSC003.FIELD_blueprint_code, blueprintCode);
return results; return results;
} }
public static HGSC003 getId(Long id){
AssertUtils.isNull(id, "蓝图ID不能为空!");
Map paramMap = new HashMap();
paramMap.put(HGSC003.FIELD_id, id);
List<HGSC003> results = DaoBase.getInstance().query(HGSC003.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
} }
public static class THGSC001A{ public static class THGSC001A{
...@@ -288,11 +296,110 @@ public class HGSCTools { ...@@ -288,11 +296,110 @@ public class HGSCTools {
DaoUtils.update(HGSC001A.DELETE_BY_PROJID, new HashMap<String,Object>(){{put(HGSC001A.FIELD_proj_id,projId);}}); DaoUtils.update(HGSC001A.DELETE_BY_PROJID, new HashMap<String,Object>(){{put(HGSC001A.FIELD_proj_id,projId);}});
} }
} }
public static class Hgsc004 {
public static HGSC004 getId(String id) {
AssertUtils.isNull(id, "物料清单id不能为空!");
List<HGSC004> results = DaoBase.getInstance().query(HGSC004.QUERY, new HashMap<String,Object>(){
{put("id",id);}
});
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
}
public static class THGSC004A{ public static class THGSC004A{
public static void checkFatherSubmitStatus(Long matId) { public static void checkFatherSubmitStatus(Long matId) {
HGSC005 hgsc005 = THGSC005.queryByMatId(matId); HGSC005 hgsc005 = THGSC005.queryByMatId(matId);
AssertUtils.isTrue(hgsc005.getCommitStatus().compareTo(CommonConstant.YesNo.NO_0)==1, "生产计划已提交,不能操作!"); AssertUtils.isTrue(hgsc005.getCommitStatus().compareTo(CommonConstant.YesNo.NO_0)==1, "生产计划已提交,不能操作!");
} }
public static void add(List<Map> arrayList, String materialId) {
HGSC004 hgsc004 = Hgsc004.getId(materialId);
AssertUtils.isEmpty(Collections.singleton(hgsc004), "物料清单不存在!");
for (Map resultRow : arrayList){
HGSC004A hgsc004a = new HGSC004A();
hgsc004a.fromMap(resultRow);
hgsc004a.setCompanyCode(hgsc004.getCompanyCode());
hgsc004a.setCompanyName(hgsc004.getCompanyName());
hgsc004a.setDepCode(hgsc004.getDepCode());
hgsc004a.setDepName(hgsc004.getDepName());
hgsc004a.setMaterialId(hgsc004.getId());
checkSaveData(hgsc004a, hgsc004);
addEntity(hgsc004a, hgsc004);
}
}
public static void addEntity(HGSC004A hgsc004a, HGSC004 hgsc004) {
//不为4级都有叶子节点,父节点需要+1
if(hgsc004a.getLv().intValue() < 4){
hgsc004a.setLv(hgsc004a.getLv() + 1);
}
if(hgsc004a.getLv().intValue() == 3){
hgsc004a.setLeaf(2);
}else{
hgsc004a.setLeaf(1);
}
hgsc004a.setProductStatus(HGConstant.ProductStatus.WTJ);
if(hgsc004a.getLv().intValue() == 3){
hgsc004a.setProductType(ProductTypeEnum.STRUCT.getCode().toString());
}else{
hgsc004a.setProductType(ProductTypeEnum.PART.getCode().toString());
}
if (hgsc004a.getQuantity().compareTo(BigDecimal.ZERO) == 0){
AssertUtils.isTrue(false, "数量不能为0!");
}
hgsc004a.setTotalWeight(hgsc004a.getQuantity().multiply(hgsc004a.getSingleWeight()));
HGPZ005 hgpz005= HGPZTools.HgPz005.get(hgsc004a.getProductCode());
if (Objects.isNull(hgpz005)){
AssertUtils.isTrue(false, "产品编号不存在!");
}
hgsc004a.setProductId(hgpz005.getId());
hgsc004a.setInventType(hgpz005.getInventType()+"");
hgsc004a.setProductType(hgpz005.getInventTypeDetail()+"");
hgsc004a.setLength(hgpz005.getLength());
hgsc004a.setWidth(hgpz005.getWidth());
hgsc004a.setThick(hgpz005.getThick());
//主表全部提交时需要有改变状态
if(hgsc004.getMaterialStatus().intValue() == HGConstant.MaterialStatus.QBTJ){
hgsc004a.setChangeType(HGConstant.ChangeType.ZJ);
//Long maxId = (Long) super.dao.get(HGSC004A.MAX_ID,null,null);
//hgsc004a.setId(maxId+1);
DaoUtils.insert(HGSC004A.INSERT, hgsc004a);
HGSCTools.THGSC004B.save(null,hgsc004a);
}else {
DaoUtils.insert(HGSC004A.INSERT, hgsc004a);
}
}
/**
* 校验保存的数据
* @param hgsc004a 物料清单详情
* @param hgsc004 物料清单
*/
public static void checkSaveData(HGSC004A hgsc004a,HGSC004 hgsc004) {
if(Objects.nonNull(hgsc004a.getId())&&hgsc004a.getId()>0){
//蓝图信息,用于蓝图状态校验
HGSC003 hgsc003 = Hgsc003.getId(hgsc004.getBlueprintId());
AssertUtils.isTrue(hgsc003.getBlueprintStatus().compareTo(HGConstant.EnablingStatus.TY) == 0,"蓝图已停用不可修改!");
}
//为构件的需要验证是否已经存在了,不能重复添加
if(hgsc004a.getLv().intValue() == 3){
Map<String,Object> mapA = new HashMap<>();
mapA.put("materialId",hgsc004a.getMaterialId());
mapA.put("productId",hgsc004a.getProductId());
mapA.put("parentProdCode",hgsc004a.getParentProdCode());
mapA.put("notId",hgsc004a.getId());
List<HGSC004A> hgsc004AList = DaoBase.getInstance().query(HGSC004A.QUERY,mapA);
AssertUtils.isTrue(!org.springframework.util.CollectionUtils.isEmpty(hgsc004AList), "已存在构建"+hgsc004a.getProductCode()+"-"+hgsc004a.getProductName());
}
AssertUtils.isEmpty(UserSessionUtils.getAccountCode(), "当前用户未绑定公司,无法操作数据,请联系管理员!");
AssertUtils.isEmpty(UserSessionUtils.getOrgId(), "当前用户未绑定部门,无法操作数据,请联系管理员!");
AssertUtils.isEmpty(hgsc004a.getCompanyCode(), "请选择公司!");
AssertUtils.isEmpty(hgsc004a.getProjCode(), "请填写项目编号!");
AssertUtils.isEmpty(hgsc004a.getProjName(), "请填写项目名称!");
AssertUtils.isTrue(hgsc004a.getSingleWeight().compareTo(BigDecimal.ZERO) <= 0, "单重不能小于等于0!");
}
} }
public static class THGSC004B{ public static class THGSC004B{
public static void save(HGSC004A oldHGSC004A,HGSC004A newHGSC004A) { public static void save(HGSC004A oldHGSC004A,HGSC004A newHGSC004A) {
......
...@@ -252,6 +252,11 @@ public class ExcelUtils { ...@@ -252,6 +252,11 @@ public class ExcelUtils {
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("导入成功" + arrayList.size() + "条"); inInfo.setMsg("导入成功" + arrayList.size() + "条");
break; break;
case "HGSC004":
HGSCTools.THGSC004A.add(arrayList, params.get("materialId").toString());
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("导入成功" + arrayList.size() + "条");
break;
default: default:
} }
......
...@@ -33,7 +33,7 @@ $(function (){ ...@@ -33,7 +33,7 @@ $(function (){
let template = ''; let template = '';
if (item.id){ if (item.id){
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" ' template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="showDetail(' + item.id +',\''+item.companyCode+'\',\''+item.projCode+'\')" >物料清单</a>'; + 'onclick="showDetail(' + item.id +',\''+item.companyCode+'\',\''+item.projCode+'\',\''+item.materialStatus+'\')" >物料清单</a>';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" ' + template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" ' +
'onclick="showUploadFile(' + item.id + ')" >附件</a>'; 'onclick="showUploadFile(' + item.id + ')" >附件</a>';
} }
...@@ -227,9 +227,9 @@ let save = function (btnNode) { ...@@ -227,9 +227,9 @@ let save = function (btnNode) {
/** /**
* 显示详情 * 显示详情
*/ */
function showDetail(id,companyCode,projCode) { function showDetail(id,companyCode,projCode,status) {
JSColorbox.open({ JSColorbox.open({
href: "HGSC004A?companyCode="+companyCode+"&projCode="+projCode+"&methodName=initLoad&inqu_status-0-materialId=" + id, href: "HGSC004A?companyCode="+companyCode+"&projCode="+projCode+"&methodName=initLoad&inqu_status-0-materialId=" + id+"&inqu_status-0-status="+status,
title: "<div style='text-align: center;'>物料清单详情</div>", title: "<div style='text-align: center;'>物料清单详情</div>",
width: "80%", width: "80%",
height: "80%", height: "80%",
......
...@@ -429,6 +429,93 @@ $(function () { ...@@ -429,6 +429,93 @@ $(function () {
} }
}; };
$("#IMPORT").on("click", function (e) {
let status = $("#inqu_status-0-status").val();
if (status == 2){
IPLAT.alert({
message: '<b>物料清单全部提交,无法导入!</b>',
okFn: function (e) {
},
title: '提示'
});
return false;
}
var logic = IPLATUI.EFTree.materialTree.selectTreeNode.nodeId ? false : true;
if (logic) { // 通过业务逻辑判断, 控制是否进行新增
IPLAT.alert({
message: '<b>请选择项目列表</b>',
okFn: function (e) {
},
title: '提示'
});
return false;
}
var logicLv = IPLATUI.EFTree.materialTree.selectTreeNode.lv === '1';
if (logicLv) { // 通过业务逻辑判断, 控制是否进行新增
IPLAT.alert({
message: '<b>请选择项目或产品层级</b>',
okFn: function (e) {
},
title: '提示'
});
return false;
}
openFileWindow.open();
});
//grush.openImportBox();
IPLATUI.EFUpload = {
fileUpload: {
showFileList: false,
upload: function (e) {
openFileWindow.close();
IPLAT.progress($("body"), true);
},
success: function (e) {
var src = e.response.docUrl;
let selectTreeNode = IPLATUI.EFTree.materialTree.selectTreeNode;
var eiInfo = new EiInfo();
let notIsExcelFile = isExcelFile(src);
eiInfo.set("fileName", src);
eiInfo.set("projCode", selectTreeNode.projCode);
eiInfo.set("projName", selectTreeNode.projName);
eiInfo.set("parentProdCode", selectTreeNode.nodeId);
eiInfo.set("parentProdName", selectTreeNode.pName);
eiInfo.set("lv", selectTreeNode.lv);
eiInfo.set("materialId", $("#inqu_status-0-materialId").val())
EiCommunicator.send("HGSC004A", "importDate", eiInfo, {
onSuccess(ei) {
if (notIsExcelFile) {
NotificationUtil("请导入xls或xlsx文件", "error");
return;
}
if (ei.status == "-1") {
NotificationUtil(
{msg: ei.msg, detailMsg: ei.detailMsg}, "error");
} else {
NotificationUtil(ei.msg);
refreshTree();
query();
}
},
onFail(ei) {
NotificationUtil("调用失败,原因[" + ei + "]", "error");
}
},
{
async: false
});
IPLAT.progress($("body"), false);
},
fail(e) {
IPLAT.NotificationUtil('导入失败!', "error");
}
}
}
grush.downloadFile(`${ctx}\\common\\template\\SC\\HGSC004A_物料清单.xls`);
//产品类型下拉联动 //产品类型下拉联动
$('input[name="inqu_status-0-prdtType"]').change(function () { $('input[name="inqu_status-0-prdtType"]').change(function () {
var inInfo=new EiInfo(); var inInfo=new EiInfo();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<EF:EFRegion id="inqu" title="查询条件"> <EF:EFRegion id="inqu" title="查询条件">
<EF:EFInput ename="inqu_status-0-materialId" type="hidden"/> <EF:EFInput ename="inqu_status-0-materialId" type="hidden"/>
<EF:EFInput ename="inqu_status-0-parentProdCode" type="hidden"/> <EF:EFInput ename="inqu_status-0-parentProdCode" type="hidden"/>
<EF:EFInput ename="inqu_status-0-status" type="hidden"/>
<div class="row"> <div class="row">
<EF:EFInput ename="inqu_status-0-productName" cname="产品名称" colWidth="3"/> <EF:EFInput ename="inqu_status-0-productName" cname="产品名称" colWidth="3"/>
<EF:EFSelect cname="变更类型" ename="inqu_status-0-changeType" colWidth="3" filter="contains"> <EF:EFSelect cname="变更类型" ename="inqu_status-0-changeType" colWidth="3" filter="contains">
...@@ -76,8 +77,13 @@ ...@@ -76,8 +77,13 @@
</div> </div>
</div> </div>
</EF:EFPage> </EF:EFPage>
<EF:EFWindow id="openFile">
<EF:EFRegion id="upload" title="文件导入区">
<div id="button"></div>
<EF:EFUpload ename="fileUpload" cname="导入" docTag="HGSC004" path="sc"/>
</EF:EFRegion>
</EF:EFWindow>
<script> <script>
let ctx="${ctx}"; let ctx="${ctx}";
</script> </script>
<script src="${ctx}/HG/SC/HGSC004A.js"></script>
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