Commit 6599ee79 by liuyang

2024-03-31 销售管理添加部件物料清单等功能

parent fcb37449
......@@ -2,10 +2,13 @@ package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sc.domain.HPSC002;
import com.baosight.hpjx.hp.sc.domain.HPSC004;
import com.baosight.hpjx.util.*;
import com.baosight.hpjx.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
......@@ -38,6 +41,11 @@ public class ServiceHPSC001 extends ServiceBase {
map.put("companyCode", UserSessionUtils.getCompanyCode());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.USER_BLOCK_ID), map,true);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.CUSTOMER_RECORD_BLOCK_ID), null);
map.clear();
map.put("itemCode", "ITEM_CODE in ('4')");
CommonMethod.initBlock(inInfo,
Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID, DdynamicEnum.CODESET_CODE_BLOCK_ID), map,
false);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
......@@ -55,6 +63,7 @@ public class ServiceHPSC001 extends ServiceBase {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSC001.FIELD_DELIVERY_DATE,
DateUtils.formatShort(inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HPSC001.FIELD_DELIVERY_DATE)));
EiInfo outInfo = super.query(inInfo, "HPSC001.query", new HPSC001());
outInfo.addBlock(HPConstants.BLOCK_DETAIL).addBlockMeta(new HPSC002().eiMetadata);
return outInfo;
}
......
......@@ -71,13 +71,27 @@ public class ServiceHPSC002 extends ServiceBase {
@Override
public EiInfo query(EiInfo inInfo) {
try {
inInfo = super.query(inInfo, "HPSC002.query", new HPSC002());
inInfo = super.query(inInfo, HPSC002.QUERY, new HPSC002());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
@OperationLogAnnotation(operModul = "物料清单",operType = "查询",operDesc = "查询明细detail")
public EiInfo queryDetail(EiInfo inInfo){
//添加返回到前台的块,块名和前台的对应
//HashMap params = new HashMap();
//params.put(HPSC002.FIELD_PROJ_CODE,inInfo.get(HPSC002.FIELD_PROJ_CODE));
//params.put(HPSC002.FIELD_LV,inInfo.get(HPSC002.FIELD_LV));
EiInfo outInfo = super.query(inInfo,HPSC002.QUERY,new HPSC002(),false,new HPSC002().eiMetadata,EiConstant.queryBlock,EiConstant.resultBlock,CommonConstant.Field.DETAIL);
//List list = dao.query(HPSC002.QUERY,params,0,-999999);
//outInfo.addBlock(CommonConstant.Field.DETAIL).addBlockMeta(new HPSC002().eiMetadata);
//outInfo.addBlock(CommonConstant.Field.DETAIL).addRows(list);
//outInfo.getBlock(CommonConstant.Field.DETAIL).set(EiConstant.limitStr, list.size());
return outInfo;
}
/**
* 查询操作物料清单选择校验.
*/
......@@ -86,13 +100,13 @@ public class ServiceHPSC002 extends ServiceBase {
try {
HashMap map = new HashMap();
HPSC001 hpsc001 = HPSCTools.HpSc001.getId(inInfo.getString("id"));
map.put("projCode",hpsc001.getProjCode());
map.put(HPSC002.FIELD_PROJ_CODE,hpsc001.getProjCode());
List<HPSC002> results = this.dao.query("HPSC002.queryTree", map);
if (results.size()>1){
inInfo.setStatus(0);
}else{
inInfo.setStatus(1);
inInfo.set("projCode",hpsc001.getProjCode());
inInfo.set(HPSC002.FIELD_PROJ_CODE,hpsc001.getProjCode());
}
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
......@@ -129,6 +143,35 @@ public class ServiceHPSC002 extends ServiceBase {
}
/**
* 保存操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "物料清单",operType = "保存",operDesc = "保存detil")
public EiInfo saveDetail(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(CommonConstant.Field.DETAIL).getRows();
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
HPSC002 hpsc002 = new HPSC002();
hpsc002.fromMap(resultRows.get(i));
if (hpsc002.getId() == null || hpsc002.getId() == 0) {
hpsc002.setDeliveryDate(DateUtils.formatShort(hpsc002.getDeliveryDate()));
this.add(hpsc002);
} else {
this.modify(hpsc002);
}
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作.
*/
public EiInfo add(HPSC002 hpsc002) {
......@@ -522,6 +565,53 @@ public class ServiceHPSC002 extends ServiceBase {
return inInfo;
}
@OperationLogAnnotation(operModul = "物料清单",operType = "删除",operDesc = "删除操作detail")
public EiInfo deleteDetail(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(CommonConstant.Field.DETAIL).getRows();
// 删除之前数据校验
for (Map resultRow : resultRows) {
HPSC002 fSc002 = new HPSC002();
fSc002.fromMap(resultRow);
// 存在子节点不能删除
List<HPSC002> dbSc002s = HPSCTools.HpSc002.queryByParent(fSc002.getId().toString());
AssertUtils.isNotEmpty(dbSc002s, String.format("部件[%s]已存在子节点不能删除", fSc002.getPrdtName()));
// 计划生产中不能删除
HPSC004 dbSc004 = HPSCTools.HpSc004.queryByMat(fSc002.getId());
HPSC005 HPSC005 = HPSCTools.HpSc005.queryByMat(fSc002.getId());
if (HPSC005 != null) {
HPSCTools.HpSc005.lock(HPSC005.getProdOrderNo());
AssertUtils.isTrue(HPSC005.getStatus() > 0,
String.format("部件[%s]已派工不能删除", fSc002.getPrdtName()));
}
}
// 删除数据
for (Map resultRow : resultRows) {
HPSC002 fSc002 = new HPSC002();
fSc002.fromMap(resultRow);
// 删除附件文件
delectDoc(fSc002.getId());
DaoUtils.update(HPSC002.DELETE, fSc002);
// 修改父级节点状态是叶子节点或非叶子节点
this.checkTreeNodeLeaf(fSc002.getParentId());
// 修改节点状态是叶子节点或非叶子节点
this.checkTreeNodeLeaf(fSc002.getId().toString());
// 同步删除生产计划
HPSCTools.HpSc003.deleteByMat(fSc002.getId());
HPSCTools.HpSc004.deleteByMat(fSc002.getId());
// 同步删除生产订单
HPSCTools.HpSc005.deleteByMat(fSc002.getId());
}
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
}
return inInfo;
}
/**
* 前端校验,数据是否派工
*
......@@ -841,4 +931,9 @@ public class ServiceHPSC002 extends ServiceBase {
this.dao.delete(HPDS002.DELETE,map);
}
}
public EiInfo queryList(EiInfo inInfo){
return super.query(inInfo,"HPSC002.queryList",new HPSC002(),false,new HPSC002().eiMetadata,EiConstant.queryBlock,EiConstant.resultBlock,CommonConstant.Field.DETAIL);
}
}
......@@ -500,4 +500,15 @@
</isNotEmpty>
</select>
<select id="queryList" parameterClass="java.util.HashMap" resultClass="com.baosight.hpjx.hp.sc.domain.HPSC002">
SELECT
<include refid="column1"/>
FROM hpjx.t_hpsc002 A
LEFT JOIN hpjx.t_hpsc005 B on A.ID = B.MAT_ID
WHERE 1=1
AND DEL_STATUS = 0
<include refid="condition1"/>
<include refid="order"/>
</select>
</sqlMap>
var prdtNameGlobalData = [];
var resultRows = [];
$(function () {
$("#QUERY").on("click", function () {
......@@ -11,10 +13,11 @@ $(function () {
IPLATUI.EFGrid.result = {
IPLATUI.EFGrid= {
"result": {
pageable: {
pageSize: 20,
pageSizes: [10, 20, 50, 70, 100],
pageSize: 5,
pageSizes: [5, 10, 20, 50, 100],
},
columns: [
{
......@@ -48,10 +51,160 @@ $(function () {
deleteFunc();
},
onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'save'
||e.eiInfo.extAttr.methodName == 'delete' ){
if (e.eiInfo.extAttr.methodName == 'save'
|| e.eiInfo.extAttr.methodName == 'delete') {
query();
}
},
onRowClick: function (e) {
if (e.model['status']==1){
var block = detailGrid.getEiBlock();
if (block != null) {
block.setRows([]);
detailGrid.setEiBlock(block);
}
resultRows = e.model;
var info = new EiInfo()
var projCode = e.model['projCode'];
info.set("inqu_status-0-projCode", projCode);
info.set("inqu_status-0-lv", 2);
queryDetail(info);
/*EiCommunicator.send("HPSC002", "queryDetail", info, {
onSuccess: function (ei) {//返回结果集
detailGrid.setEiInfo(ei);
}, onFail: function (ei) {
}
}, {async: false});*/
}
},
},
"detail":{
/*toolbarConfig: {
// hidden: false, // true时,不显示功能按钮,但保留setting导出按钮
// add: false, // 不显示新增按钮
cancel: true, // 不显示取消按钮
// save: true, // 不显示保存按钮
// delete: true, // 显示删除按钮
},*/
onAdd: function (e) {
if (resultRows['status']==1){
let detailRoot;
var info = new EiInfo()
var projCode = resultRows.projCode;
info.set("inqu_status-0-parentId","root");
info.set("inqu_status-0-projCode", projCode);
info.set("inqu_status-0-lv", 1);
EiCommunicator.send("HPSC002", "queryList", info, {
onSuccess: function (ei) {//返回结果集
detailRoot = ei.getBlock("detail").getMappedRows();
//detailGrid.setEiInfo(ei);
}, onFail: function (ei) {
}
}, {async: false});
for (let i = 0; i < e.items.length; i++) {
e.items[i]["parentId"] = detailRoot[0].id;
e.items[i]['projCode'] = resultRows.projCode;
e.items[i]['projName'] = resultRows.projName;
e.items[i]['parentPrdtName'] = resultRows.projName;
e.items[i]['deliveryDate'] = resultRows.deliveryDate;
e.items[i]['prdtType'] = 4;
e.items[i]['lv'] = 2;
$("#locked_datacell_0_"+i+" input").attr("checked",true);
}
}else {
e.preventDefault();
message("请先提交销售单");
return;
}
},
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
let btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
saveDetail(btnNode);
},
onDelete: function (e) {
e.preventDefault();
deleteDetail();
},
onSuccess: function (e) {
if (e.eiInfo.extAttr.methodName == 'update'
|| e.eiInfo.extAttr.methodName == 'insert') {
query();
}
},
columns: [
{
field: "operator",
title: "操作",
template: function (item) {
let template = '';
if (item.id){
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="showUploadFile(' + item.id + ')" >附件清单</a>';
}
return template;
}
},
{
field: "prdtType",
title: "部件类型",
filter: function (options) {
// 返回我们过滤后的数据集
return _.filter(options.values, function (item) {
return item["valueField"]==4;
})
}
},
{
field: "prdtName",
title: "部件名称",
template: function (dataItem) {
for (let i = 0; i < prdtNameGlobalData.length; i++) {
if (prdtNameGlobalData[i]['textField'] === dataItem['prdtName']) {
//dataItem["prdtCode"] = prdtNameGlobalData[i]['valueField']
detailGrid.setCellValue(0, "prdtCode", prdtNameGlobalData[i]['valueField']);
return prdtNameGlobalData[i]['textField'];
}
}
return dataItem["prdtName"];
},
editor: function (container, options) {
var grid = container.closest(".k-grid").data("kendoGrid");
var cellIndex = grid.cellIndex(container);
var input = $('<input />');
input.attr("name", options.field);
input.attr("id", options.field);
input.appendTo(container);
let eiInfo = new EiInfo();
eiInfo.set("inventType", 4);
eiInfo.set("isSplicingSymbol", false);
var dataSource;
EiCommunicator.send("HPPZ004", "queryComboBox", eiInfo, {
onSuccess: function (ei) {
dataSource = ei.getBlock("invent_name_block_id").getMappedRows();
prdtNameGlobalData = dataSource;
},
onFail: function (ei) {
}
}, {async: false});
input.kendoAutoComplete({
valuePrimitive: true,
dataSource: dataSource,
dataTextField: "textField",
dataValueField: "valueField",
required: "true",
optionLabelTemplate: "#:textField#",
valueTemplate: "#:valueField#",
template: "#:textField#",
filter: "contains"
});
}
}
]
}
}
});
......@@ -151,3 +304,134 @@ function deleteFunc() {
function query() {
resultGrid.dataSource.page(1);
}
function queryDetail(inInfo) {
EiCommunicator.send("HPSC002", "queryDetail", inInfo, {
onSuccess: function (ei) {//返回结果集
detailGrid.setEiInfo(ei);
}, onFail: function (ei) {
}
}, {async: false});
}
function saveDetail() {
let rows = detailGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let prdtType= item.get("prdtType");
let prdtName= item.get("prdtName");
let num= item.get("num");
let unitWt= item.get("unitWt");
if(isBlank(prdtType)){
message("选中的第"+(index+1)+"行\"部件类型\",不能为空!");
flag = false;
return false;
}
if(isBlank(prdtName)){
message("选中的第"+(index+1)+"行\"部件名称\",不能为空!");
flag = false;
return false;
}
if (!isPositiveInteger(num)) {
message("勾选的第" + (index + 1) + "行\"数量\"必须是大于0的整数");
flag = false;
return;
}
if(isBlank(unitWt)){
message("选中的第"+(index+1)+"行\"单重\",不能为空!");
flag = false;
return false;
}
let pgStatus= item.get("pgStatus");
if(pgStatus==="1"||pgStatus==="2"){
message("选中的第"+(index+1)+"行记录已派工,不能修改!");
flag = false;
return false;
}
});
if(flag){
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
//JSUtils.submitGridsData("detail", "HPSC002", "saveDetail", true);
var info = new EiInfo();
info.addBlock(JSUtils.checkedRows2Block("detail"));
EiCommunicator.send("HPSC002", "saveDetail", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
var info = new EiInfo()
info.set("inqu_status-0-projCode", resultRows.projCode);
info.set("inqu_status-0-lv", 2);
queryDetail(info);
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
}
});
}
}
function deleteDetail() {
let rows = detailGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let status= item.get("status");
if(status==="1"){
message("选中的第"+(index+1)+"行记录已提交,不能删除!");
flag = false;
return false;
}
});
if(flag){
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
//JSUtils.submitGridsData("detail", "HPSC002", "deleteDetail", true);
var info = new EiInfo();
info.addBlock(JSUtils.checkedRows2Block("detail"));
EiCommunicator.send("HPSC002", "deleteDetail", info, {
onSuccess: function (ei) {
if (ei.getStatus() >= 0) {
var info = new EiInfo()
info.set("inqu_status-0-projCode", resultRows.projCode);
info.set("inqu_status-0-lv", 2);
queryDetail(info);
} else {
NotificationUtil(ei, "error");
}
},
onFail: function (ei) {
// 发生异常
NotificationUtil("操作失败,原因[" + ei + "]", "error");
}
});
}
});
}
}
/**
* 显示附件清单
*
* @param id
*/
function showUploadFile(id) {
JSColorbox.open({
href: "HPSC002A?methodName=initLoad&inqu_status-0-bizType=WL&inqu_status-0-matId=" + id,
title: "<div style='text-align: center;'>附件清单</div>",
width: "80%",
height: "80%",
});
}
\ No newline at end of file
......@@ -10,7 +10,6 @@
<EF:EFPage title="销售管理">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFInput ename="inqu_status-0-projCode" cname="项目编码" colWidth="3"/>
<EF:EFInput ename="inqu_status-0-projName" cname="项目名称" colWidth="3"/>
......@@ -65,4 +64,43 @@
<EF:EFColumn ename="remark" cname="备注"/>
</EF:EFGrid>
</EF:EFRegion>
<EF:EFRegion id="detail" title="明细信息">
<EF:EFGrid blockId="detail" autoDraw="no">
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="lv" cname="层级" defaultValue="2" hidden="true"/>
<EF:EFColumn ename="projCode" cname="项目编码" enable="false" hidden="true"/>
<EF:EFColumn ename="projName" cname="项目名称" enable="false" hidden="true"/>
<EF:EFColumn ename="parentId" cname="上级部件名称" enable="false" hidden="true"/>
<EF:EFColumn ename="parentPrdtName" cname="上级部件名称" enable="false" hidden="true"/>
<EF:EFColumn ename="status" cname="提交状态" enable="false" hidden="true"/>
<EF:EFColumn ename="pgStatus" cname="派工状态" enable="false" hidden="true"/>
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="prdtType" cname="部件类型" align="center" required="true"
filter="contains" width="90" enable="false">
<EF:EFOptions blockId="codeset_code_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="prdtCode" cname="部件编码" hidden='true'/>
<EF:EFColumn ename="prdtName" cname="部件名称" width="140" align="center" maxLength="50" required="true"/>
<EF:EFColumn ename="length" cname="长(MM)" width="80" format="{0:N3}" maxLength="12" displayType="0.000"
data-regex="/^-?[0-9]{1,9}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置9位整数和3位小数!"/>
<EF:EFColumn ename="width" cname="宽(MM)" width="80" format="{0:N3}" maxLength="12" displayType="0.000"
data-regex="/^-?[0-9]{1,9}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置9位整数和3位小数!"/>
<EF:EFColumn ename="thick" cname="厚(MM)" width="80" format="{0:N3}" maxLength="12" displayType="0.000"
data-regex="/^-?[0-9]{1,9}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置9位整数和3位小数!"/>
<EF:EFColumn ename="deliveryDate" cname="交货日期" width="100" editType="date" required='true'
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<EF:EFColumn ename="num" cname="数量" maxLength="15" displayType="0.000" format="{0:N0}" required="true"
data-regex="/^-?[0-9]{1,12}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置12位整数和3位小数!"/>
<EF:EFColumn ename="unitWt" format="{0:N3}" cname="单重(T)" maxLength="15" displayType="0.000" required="true"
data-regex="/^-?[0-9]{1,12}([.][0-9]{1,3})?$/"
data-errorprompt="请输入数字,该值最大可设置12位整数和3位小数!"/>
<EF:EFColumn ename="totalWt" cname="总重(T)" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFColumn ename="remark" cname="备注" />
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
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