Commit 1ee4a750 by wancheng

物料清单,必填项改成前台校验

parent 8f166095
...@@ -58,6 +58,8 @@ public class HPSC002 extends DaoEPBase { ...@@ -58,6 +58,8 @@ public class HPSC002 extends DaoEPBase {
public static final String FIELD_UPDATED_NAME = "updatedName"; /* 修改人名称*/ public static final String FIELD_UPDATED_NAME = "updatedName"; /* 修改人名称*/
public static final String FIELD_UPDATED_TIME = "updatedTime"; /* 更新时间*/ public static final String FIELD_UPDATED_TIME = "updatedTime"; /* 更新时间*/
public static final String FIELD_REMARK = "remark"; /* 备注*/ public static final String FIELD_REMARK = "remark"; /* 备注*/
public static final String FIELD_PGSTATUS = "pgStatus"; /* 派工状态*/
public static final String FIELD_LV = "lv"; /* 树的层级*/ public static final String FIELD_LV = "lv"; /* 树的层级*/
public static final String COL_ID = "ID"; public static final String COL_ID = "ID";
...@@ -96,6 +98,8 @@ public class HPSC002 extends DaoEPBase { ...@@ -96,6 +98,8 @@ public class HPSC002 extends DaoEPBase {
public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 修改人名称*/ public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 修改人名称*/
public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 更新时间*/ public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 更新时间*/
public static final String COL_REMARK = "REMARK"; /* 备注*/ public static final String COL_REMARK = "REMARK"; /* 备注*/
public static final String COL_PGSTATUS = "PGSTATUS"; /* 派工状态*/
public static final String COL_LV = "LV"; /* 树的层级*/ public static final String COL_LV = "LV"; /* 树的层级*/
public static final String QUERY = "HPSC002.query"; public static final String QUERY = "HPSC002.query";
...@@ -140,6 +144,8 @@ public class HPSC002 extends DaoEPBase { ...@@ -140,6 +144,8 @@ public class HPSC002 extends DaoEPBase {
private String updatedName = " "; /* 修改人名称*/ private String updatedName = " "; /* 修改人名称*/
private String updatedTime = " "; /* 更新时间*/ private String updatedTime = " "; /* 更新时间*/
private String remark = " "; /* 备注*/ private String remark = " "; /* 备注*/
private String pgStatus = " "; /* 派工状态*/
private Integer lv; /* 树的层级*/ private Integer lv; /* 树的层级*/
/** /**
...@@ -315,7 +321,9 @@ public class HPSC002 extends DaoEPBase { ...@@ -315,7 +321,9 @@ public class HPSC002 extends DaoEPBase {
eiColumn.setDescName("树的层级"); eiColumn.setDescName("树的层级");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_PGSTATUS);
eiColumn.setDescName("派工状态");
eiMetadata.addMeta(eiColumn);
} }
/** /**
...@@ -917,11 +925,30 @@ public class HPSC002 extends DaoEPBase { ...@@ -917,11 +925,30 @@ public class HPSC002 extends DaoEPBase {
public void setLv(Integer lv) { public void setLv(Integer lv) {
this.lv = lv; this.lv = lv;
} }
/**
* get the status - 状态 0-未审核,1-已审核.
* @return the status
*/
public String getPgStatus() {
return this.pgStatus;
}
/**
* set the status - 状态 0-未审核,1-已审核.
*
* @param pgStatus - 状态 0-未审核,1-已审核
*/
public void setPgStatus(String pgStatus) {
this.pgStatus = pgStatus;
}
/** /**
* get the value from Map. * get the value from Map.
* *
* @param map - source data map * @param map - source data map
*/ */
@Override @Override
public void fromMap(Map map) { public void fromMap(Map map) {
...@@ -962,6 +989,7 @@ public class HPSC002 extends DaoEPBase { ...@@ -962,6 +989,7 @@ public class HPSC002 extends DaoEPBase {
setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime)); setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime));
setRemark(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_REMARK)), remark)); setRemark(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_REMARK)), remark));
setLv(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_LV)), lv)); setLv(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_LV)), lv));
setPgStatus(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PGSTATUS)), pgStatus));
} }
/** /**
...@@ -1008,7 +1036,7 @@ public class HPSC002 extends DaoEPBase { ...@@ -1008,7 +1036,7 @@ public class HPSC002 extends DaoEPBase {
map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME))); map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME)));
map.put(FIELD_REMARK, StringUtils.toString(remark, eiMetadata.getMeta(FIELD_REMARK))); map.put(FIELD_REMARK, StringUtils.toString(remark, eiMetadata.getMeta(FIELD_REMARK)));
map.put(FIELD_LV, StringUtils.toString(lv, eiMetadata.getMeta(FIELD_LV))); map.put(FIELD_LV, StringUtils.toString(lv, eiMetadata.getMeta(FIELD_LV)));
map.put(FIELD_PGSTATUS, StringUtils.toString(pgStatus, eiMetadata.getMeta(FIELD_PGSTATUS)));
return map; return map;
} }
} }
...@@ -76,6 +76,183 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -76,6 +76,183 @@ public class ServiceHPSC002 extends ServiceBase {
} }
/** /**
* 保存操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "物料清单",operType = "保存",operDesc = "保存")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).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) {
this.add(hpsc002);
} else {
this.modify(hpsc002);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作.
*/
public EiInfo add(HPSC002 hpsc002) {
EiInfo inInfo = new EiInfo();
try {
hpsc002.setLeaf("1");
// 计算总重
BigDecimal num = hpsc002.getNum();
BigDecimal unitWt = hpsc002.getUnitWt();
DecimalFormat decimalFormat = new DecimalFormat("#.000");
BigDecimal totalWt = new BigDecimal(decimalFormat.format(Math.round(num.multiply(unitWt).floatValue())));
hpsc002.setDelStatus(CommonConstant.YesNo.NO_0.intValue());
hpsc002.setTotalWt(totalWt);
// if (StringUtils.isNotEmpty(hppz002.getPrdtCode()) && !hppz002.getParentId().equals("root")) {
// hppz002.setPrdtName(HPPZTools.getPz004ByCode(hppz002.getPrdtCode()).getInventName());
// }
hpsc002.setSpec(HPPZTools.HpPz006.jointSpec(hpsc002.getLength(),hpsc002.getWidth(),hpsc002.getThick()));
if(hpsc002.getParentId().equals("root")){
hpsc002.setLv(new Integer(1));
}else{
hpsc002.setPrdtCode(HPPZTools.HpPz004.checkAndSave(hpsc002.getPrdtType(),hpsc002.getPrdtName()));
Integer lv = (Integer) this.dao.get("HPSC002.queryLv","id",hpsc002.getParentId());
hpsc002.setLv(lv.intValue()+1);
}
DaoUtils.insert("HPSC002.insert", hpsc002.toMap());
if (!hpsc002.getParentId().equals("root")) {
this.checkTreeNodeLeaf(hpsc002.getParentId());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("新增成功!");
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("新增失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("新增失败", e.getMessage());
return inInfo;
}
return inInfo;
}
/**
* 修改操作.
*/
public EiInfo modify(HPSC002 hpsc002) {
EiInfo inInfo = new EiInfo();
try {
//处理已经派单的任务不允许修改
//如果是部件修改 LV = 2 ;零件耗材 LV = 3
if (hpsc002.getLv() == 2) {
//根据002表的ID找到003表
HPSC003 HPSC003 = HPSCTools.HpSc003.queryByMat(hpsc002.getId());
//根据生产计划单号找到对应的生产订单详情
if (HPSC003 != null) {
if (StringUtils.isNotBlank(HPSC003.getPlanInfoNo())) {
List<HPSC004> hpsc004List = HPSCTools.HpSc004.queryByParent(HPSC003.getPlanInfoNo());
if (CollectionUtils.isNotEmpty(hpsc004List)) {
List<Long> matIds = hpsc004List.stream().map(HPSC004 :: getMatId).sorted().collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(matIds)) {
List<HPSC005> hpsc005List = HPSCTools.HpSc005.listByMatId(matIds);
if (CollectionUtils.isNotEmpty(hpsc005List)) {
List<HPSC005> stausList = hpsc005List.stream().filter(
HPSC005 -> HPSC005.getStatus() > 0
).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(stausList)) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!原因参见详细错误描述!");
inInfo.setDetailMsg("部件名称为 " + hpsc002.getPrdtName() + "的生产订单已经分派,不允许进行修改!");
logError("修改失败", "部件名称为 " + hpsc002.getPrdtName() + "的生产订单已经分派,不允许进行修改!");
return inInfo;
} else {
// 只修改 003 表
this.updateHPSC002(hpsc002);
this.updateHPSC003(hpsc002, HPSC003);
//修改5表中部件的长宽厚
for (HPSC005 hpsc005 : hpsc005List) {
hpsc005.setPrdtLength(hpsc002.getLength());
hpsc005.setPrdtWidth(hpsc002.getWidth());
hpsc005.setPrdtThick(hpsc002.getThick());
hpsc005.setPrdtSpec(HPPZTools.HpPz006.jointSpec(hpsc005.getPrdtLength(),hpsc005.getPrdtWidth(),hpsc005.getPrdtThick()));
DaoUtils.update("HPSC005.update", hpsc005.toMap());
}
}
} else {
this.updateHPSC002(hpsc002);
this.updateHPSC003(hpsc002, HPSC003);
}
}
}
}
} else {
this.updateHPSC002(hpsc002);
}
} else if (hpsc002.getLv() == 3) {
HPSC004 HPSC004 = HPSCTools.HpSc004.queryByMat(hpsc002.getId());
HPSC005 HPSC005 = HPSCTools.HpSc005.queryByMat(hpsc002.getId());
if (HPSC004 != null) {
if (HPSC005 != null) {
if (HPSC005.getStatus() > 0) {
// 已经分派
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!原因参见详细错误描述!");
inInfo.setDetailMsg("零件(耗材)名称为 " + hpsc002.getPrdtName() + "的生产订单已经分派,不允许进行修改!");
logError("修改失败", "零件(耗材)名称为 " + hpsc002.getPrdtName() + "的生产订单已经分派,不允许进行修改!");
return inInfo;
} else {
this.updateHPSC002(hpsc002);
this.updateHPSC004(hpsc002, HPSC004);
HPSC005.setPartLength(hpsc002.getLength());
HPSC005.setPartWidth(hpsc002.getWidth());
HPSC005.setPartThick(hpsc002.getThick());
HPSC005.setNum(hpsc002.getNum());
HPSC005.setUnitWt(hpsc002.getUnitWt());
HPSC005.setTotalWt(hpsc002.getTotalWt());
HPSC005.setPartSpec(HPPZTools.HpPz006.jointSpec(HPSC005.getPartLength(),HPSC005.getPartWidth(),HPSC005.getPartThick()));
DaoUtils.update("HPSC005.update", HPSC005.toMap());
}
} else {
this.updateHPSC002(hpsc002);
this.updateHPSC004(hpsc002, HPSC004);
}
} else {
this.updateHPSC002(hpsc002);
}
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("修改成功!");
} catch (PlatException e) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("修改失败", e.getMessage());
return inInfo;
}
return inInfo;
}
/**
* 新增操作. * 新增操作.
*/ */
@OperationLogAnnotation(operModul = "物料清单",operType = "新增",operDesc = "新增操作") @OperationLogAnnotation(operModul = "物料清单",operType = "新增",operDesc = "新增操作")
...@@ -317,6 +494,31 @@ public class ServiceHPSC002 extends ServiceBase { ...@@ -317,6 +494,31 @@ public class ServiceHPSC002 extends ServiceBase {
} }
/** /**
* 前端校验,数据是否派工
*
* @param inInfo
* @return
*/
public EiInfo checkIsPg(EiInfo inInfo) {
List<Map> resultRows = (List<Map>) inInfo.get("result");
Boolean checkSatus = true;
String msg = null;
for (Map resultRow : resultRows) {
HPSC002 fSc002 = new HPSC002();
fSc002.fromMap(resultRow);
HPSC005 HPSC005 = HPSCTools.HpSc005.queryByMat(fSc002.getId());
if (HPSC005 != null) {
checkSatus = false;
msg = HPSC005.getPrdtName()+"已派工不能删除!";
break;
}
}
inInfo.set("checkSatus",checkSatus);
inInfo.set("msg",msg);
return inInfo;
}
/**
* 指定树节点 * 指定树节点
* *
* @param inInfo * @param inInfo
......
...@@ -40,6 +40,45 @@ ...@@ -40,6 +40,45 @@
THICK as "thick" <!-- 厚 --> THICK as "thick" <!-- 厚 -->
</sql> </sql>
<sql id="column1">
A.ID as "id",
A.COMPANY_CODE as "companyCode", <!-- 企业编码 预留 -->
A.DEP_CODE as "depCode", <!-- 部门编码 预留 -->
A.PROJ_CODE as "projCode", <!-- 项目编码 -->
A.PROJ_NAME as "projName", <!-- 项目名称 -->
A.PARENT_ID as "parentId", <!-- 父节点-部件编码 -->
A.PARENT_PRDT_NAME as "parentPrdtName", <!-- 父节点-部件名称 -->
A.TYPE as "type", <!-- 类别 -->
A.LEAF as "leaf", <!-- 是否有叶子节点 -->
A.SORT as "sort", <!-- 排序字段 -->
A.ICON as "icon", <!-- 图片地址 -->
A.PRDT_TYPE as "prdtType",
A.PRDT_CODE as "prdtCode", <!-- 部件编码 -->
A.PRDT_NAME as "prdtName", <!-- 部件名称 -->
A.INVENT_RECORD_ID as "inventRecordId", <!-- 存货档案ID -->
A.NUM as "num", <!-- 数量 -->
A.UNIT_WT as "unitWt", <!-- 单重 -->
A.TOTAL_WT as "totalWt", <!-- 总重 -->
A.FILE_PATH1 as "filePath1", <!-- 文件地址1 -->
A.FILE_PATH2 as "filePath2", <!-- 文件地址2 -->
A.FILE_PATH3 as "filePath3", <!-- 文件地址3 -->
A.FILE_PATH4 as "filePath4", <!-- 文件地址4 -->
A.FILE_PATH5 as "filePath5", <!-- 文件地址5 -->
A.STATUS as "status", <!-- 状态 0-未提交,1-已提交 -->
A.DEL_STATUS as "delStatus", <!-- 状态 1未删除,0已删除 -->
A.CREATED_BY as "createdBy", <!-- 创建人 -->
A.CREATED_TIME as "createdTime", <!-- 创建时间 -->
A.UPDATED_BY as "updatedBy", <!-- 更新人 -->
A.UPDATED_TIME as "updatedTime", <!-- 更新时间 -->
A.REMARK as "remark", <!-- 备注 -->
A.LV as "lv",
A.SPEC as "spec",
A.LENGTH as "length", <!-- 长 -->
A.WIDTH as "width", <!-- 宽 -->
A.THICK as "thick", <!-- 厚 -->
B.STATUS as "pgStatus" <!-- 派工状态 -->
</sql>
<sql id="condition"> <sql id="condition">
<isNotEmpty prepend=" AND " property="id"> <isNotEmpty prepend=" AND " property="id">
ID = #id# ID = #id#
...@@ -83,8 +122,10 @@ ...@@ -83,8 +122,10 @@
<select id="query" parameterClass="java.util.HashMap" resultClass="com.baosight.hpjx.hp.sc.domain.HPSC002"> <select id="query" parameterClass="java.util.HashMap" resultClass="com.baosight.hpjx.hp.sc.domain.HPSC002">
SELECT SELECT
<include refid="column"/> <include refid="column1"/>
FROM hpjx.t_hpsc002 WHERE 1=1 FROM hpjx.t_hpsc002 A
LEFT JOIN hpjx.t_hpsc005 B on A.ID = B.MAT_ID
WHERE 1=1
AND PARENT_ID NOT IN ('root') AND PARENT_ID NOT IN ('root')
AND DEL_STATUS = 0 AND DEL_STATUS = 0
<include refid="condition"/> <include refid="condition"/>
......
...@@ -97,8 +97,8 @@ $(function () { ...@@ -97,8 +97,8 @@ $(function () {
}); });
}, },
onSuccess: function (e) { onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'update' if(e.eiInfo.extAttr.methodName == 'save'
||e.eiInfo.extAttr.methodName == 'insert'){ ||e.eiInfo.extAttr.methodName == 'delete'){
query(); query();
} }
}, },
...@@ -176,6 +176,8 @@ $(function () { ...@@ -176,6 +176,8 @@ $(function () {
* e.sender Grid对象 * e.sender Grid对象
*/ */
onSave: function (e) { onSave: function (e) {
e.preventDefault();
saveFunc();
// 不向后台保存 // 不向后台保存
var tree = $("#materialTree").data("kendoTreeView"); var tree = $("#materialTree").data("kendoTreeView");
var inInfo = new EiInfo(); var inInfo = new EiInfo();
...@@ -191,6 +193,8 @@ $(function () { ...@@ -191,6 +193,8 @@ $(function () {
* e.sender Grid对象 * e.sender Grid对象
*/ */
onDelete: function (e) { onDelete: function (e) {
e.preventDefault();
deleteFunc();
// 不向后台保存 // 不向后台保存
console.log("DELETE -> ", e) console.log("DELETE -> ", e)
var tree = $("#materialTree").data("kendoTreeView"); var tree = $("#materialTree").data("kendoTreeView");
...@@ -540,3 +544,81 @@ function check(id, auditStatus) { ...@@ -540,3 +544,81 @@ function check(id, auditStatus) {
} }
); );
} }
/**
* 删除
*/
function deleteFunc() {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
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("result", "HPSC002", "delete", true);
}
});
}
}
function saveFunc() {
let rows = resultGrid.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(prdtType===""){
message("选中的第"+(index+1)+"行\"部件类型\",不能为空!");
flag = false;
return false;
}
if(prdtName===""){
message("选中的第"+(index+1)+"行\"部件名称\",不能为空!");
flag = false;
return false;
}
if(num===""){
message("选中的第"+(index+1)+"行\"数量\",不能为空!");
flag = false;
return false;
}
if(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("result", "HPSC002", "save", true);
}
});
}
}
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<EF:EFGrid blockId="result" autoDraw="override"> <EF:EFGrid blockId="result" autoDraw="override">
<EF:EFColumn ename="id" cname="主键" hidden="true"/> <EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="level" cname="层级" hidden="true"/> <EF:EFColumn ename="level" cname="层级" hidden="true"/>
<EF:EFColumn enable="false" ename="pgStatus" hidden="true" cname="派工状态"/>
<EF:EFColumn ename="projCode" cname="项目编码" enable="false" hidden="true"/> <EF:EFColumn ename="projCode" cname="项目编码" enable="false" hidden="true"/>
<EF:EFColumn ename="projName" cname="项目名称" enable="false" hidden="true"/> <EF:EFColumn ename="projName" cname="项目名称" enable="false" hidden="true"/>
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="120" align="center"/> <EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="120" 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