Commit e48f6fae by liuyang

2024-04-12 设备管理功能开发

parent 44e13d25
......@@ -5,11 +5,10 @@ import com.baosight.hpjx.common.DdynamicEnum;
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.pz.domain.HPPZ002;
import com.baosight.hpjx.hp.sb.domain.HPSB003;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.ErrorCodeUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.hpjx.util.*;
import com.baosight.hpjx.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
......@@ -17,6 +16,7 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.Arrays;
import java.util.HashMap;
......@@ -126,6 +126,44 @@ public class ServiceHPSB003 extends ServiceEPBase {
return inInfo;
}
@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++) {
HPSB003 hpsb003 = new HPSB003();
hpsb003.fromMap(resultRows.get(i));
if (hpsb003.getId() == null || hpsb003.getId() == 0) {
this.add(hpsb003);
} else {
this.modify(hpsb003);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*/
public void add(HPSB003 hpsb003) {
queryDeviceCode(hpsb003);
DaoUtils.insert(HPSB003.INSERT, hpsb003);
}
/**
* 修改操作
*/
public void modify(HPSB003 hpsb003) {
DaoUtils.update(HPSB003.UPDATE, hpsb003);
}
@OperationLogAnnotation(operModul = "设备管理",operType = "新增",operDesc = "新增操作")
@Override
public EiInfo insert(EiInfo inInfo) {
......@@ -168,7 +206,7 @@ public class ServiceHPSB003 extends ServiceEPBase {
public void queryDeviceCode(HPSB003 hpsb001){
Map<String,Object> map = new HashMap<>();
map.put(HPSB003.FIELD_FACTORY_CODE,hpsb001.getFactoryCode());
map.put(HPSB003.FIELD_DEVICE_CODE,hpsb001.getDeviceCode());
map.put("deviceCodeStr",hpsb001.getDeviceCode());
map.put(HPSB003.FIELD_DELETE_FLAG,hpsb001.getDeleteFlag());
List<HPSB003> hpsb003List = this.dao.query(HPSB003.QUERY,map);
AssertUtils.isNotEmpty(hpsb003List, String.format("设备编码[%s]在当前工厂已存在,添加失败", map.get(HPSB003.FIELD_DEVICE_CODE)));
......
......@@ -69,6 +69,9 @@
<isNotEmpty prepend=" AND " property="deviceStatus">
DEVICE_STATUS = #deviceStatus#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deviceCodeStr">
DEVICE_CODE = #deviceCodeStr#
</isNotEmpty>
</sql>
<!--根据companyCode获取用户绑定的组织的工厂编码-->
......@@ -275,7 +278,7 @@
FACTORY_CODE as "factoryCode",
FACTORY_NAME as "factoryName"
FROM ${platSchema}.txsog01
WHERE IS_DELETED = '0'
WHERE IS_DELETED = '0' AND FACTORY_CODE IS NOT NULL
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
<!--and ORG_ID IN (<include refid="queryLoginNameBase"/>)-->
......
......@@ -131,8 +131,8 @@ $(function () {
},
onSave: function (e) {
// 阻止默认请求,使用自定义保存
//e.preventDefault();
//saveFunc();
e.preventDefault();
save();
},
onDelete: function (e) {
// 阻止默认请求,使用自定义删除
......@@ -203,6 +203,75 @@ let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let factoryCode= item.get("factoryCode");
let groupCode= item.get("groupCode");
let deviceType= item.get("deviceType");
let deviceCode= item.get("deviceCode");
let deviceName= item.get("deviceName");
let deviceModel= item.get("deviceModel");
let purchaseDate= item.get("purchaseDate");
let deviceUserId= item.get("deviceUserId");
if(isBlank(factoryCode)){
message("选中的第"+(index+1)+"行\"工厂\",不能为空!");
flag = false;
return false;
}
if(isBlank(groupCode)){
message("选中的第"+(index+1)+"行\"设备区域\",不能为空!");
flag = false;
return false;
}
if(isBlank(deviceType)){
message("选中的第"+(index+1)+"行\"设备类型\",不能为空!");
flag = false;
return false;
}
if(isBlank(deviceCode)){
message("选中的第"+(index+1)+"行\"设备编码\",不能为空!");
flag = false;
return false;
}
if(isBlank(deviceName)){
message("选中的第"+(index+1)+"行\"设备名称\",不能为空!");
flag = false;
return false;
}
if(isBlank(deviceModel)){
message("选中的第"+(index+1)+"行\"设备型号\",不能为空!");
flag = false;
return false;
}
if(isBlank(purchaseDate)){
message("选中的第"+(index+1)+"行\"购置日期\",不能为空!");
flag = false;
return false;
}
if(isBlank(deviceUserId)){
message("选中的第"+(index+1)+"行\"设备负责人\",不能为空!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPSB003", "save", true);
}
});
}
}
function updateStatus(id,deviceStatus) {
let inEiInfo = new EiInfo();
inEiInfo.set("result-0-id", id);
......
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