Commit 7071b7dd by 宋祥

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/com/baosight/hggp/common/DdynamicEnum.java
parents 5db0b014 02f2692a
...@@ -62,7 +62,7 @@ public enum DdynamicEnum { ...@@ -62,7 +62,7 @@ public enum DdynamicEnum {
* 用途:用户下拉框 * 用途:用户下拉框
* 编写:yk * 编写:yk
*/ */
USER_BLOCK_ID("user_block_id","loginName","userName","HPXSUser.queryComboBox"), USER_BLOCK_ID("user_block_id","loginName","userName","HGXSUser.queryComboBox"),
/** /**
* 模块:系统管理 * 模块:系统管理
...@@ -86,6 +86,20 @@ public enum DdynamicEnum { ...@@ -86,6 +86,20 @@ public enum DdynamicEnum {
* 编写:ly * 编写:ly
*/ */
COMPANY_CODE_BLOCK_ID("company_code_block_id", "orgId", "orgCname", "HGXSOrg.queryAll"), COMPANY_CODE_BLOCK_ID("company_code_block_id", "orgId", "orgCname", "HGXSOrg.queryAll"),
/**
* 模块:公司名称
* 用途:工序设计下拉框
* 编写:ly
*/
COMPANY_BOX_BLOCK_ID("companyBox_block_id","orgEname","orgCname","HGSJ001.queryCompany"),
/**
* 模块:工序编码
* 用途:工序编码下拉框
* 编写:ly
*/
PROCESS_CODE_BLOCK_ID("processCode_block_id","processCode","processName","HGSJ001.queryProcessCode")
; ;
/** 将结果集放入的块名 */ /** 将结果集放入的块名 */
......
...@@ -64,6 +64,10 @@ public class HGConstant { ...@@ -64,6 +64,10 @@ public class HGConstant {
public static final String HPPZ017_SALES_CODE = "HPPZ017_SALES_CODE"; public static final String HPPZ017_SALES_CODE = "HPPZ017_SALES_CODE";
//销售计划单号 //销售计划单号
public static final String PLAN_SALES_CODE = "PLAN_SALES_CODE"; public static final String PLAN_SALES_CODE = "PLAN_SALES_CODE";
//工序编码
public static final String PROCESS_CODE = "PROCESS_CODE";
//工艺流程编码
public static final String FLOW_CODE = "FLOW_CODE";
} }
/** /**
......
package com.baosight.hggp.hg.sj.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.sj.domain.HGSJ001;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.ErrorCodeUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
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;
import java.util.List;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/5/6
*/
public class ServiceHGSJ001 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGSJ001.FIELD_DELETE_FLAG,CommonConstant.YesNo.NO_0);
inInfo = super.query(inInfo, HGSJ001.QUERY, new HGSJ001());
CommonMethod.initBlock(inInfo,
Arrays.asList(DdynamicEnum.COMPANY_BOX_BLOCK_ID,DdynamicEnum.USER_BLOCK_ID),
new HashMap<String,Object>(){{put("orgType", OrgTypeEnum.COMPANY.getCode());}}
);
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGSJ001.FIELD_DELETE_FLAG,CommonConstant.YesNo.NO_0);
return super.query(inInfo, HGSJ001.QUERY);
}
@OperationLogAnnotation(operModul = "工序设置",operType = "删除",operDesc = "删除操作")
@Override
public EiInfo delete(EiInfo inInfo) {
int i = 0;
try {
HGSJ001 hpsc012 = new HGSJ001();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hpsc012.fromMap(map);
hpsc012.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.update(HGSJ001.DELETE_FLAG, hpsc012.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
ErrorCodeUtils.handleDeleteException(inInfo,i,e);
logError("删除失败", e.getMessage());
return inInfo;
}
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++) {
HGSJ001 hpsc012 = new HGSJ001();
hpsc012.fromMap(resultRows.get(i));
if (hpsc012.getId() == null || hpsc012.getId() == 0) {
this.add(hpsc012);
} else {
this.modify(hpsc012);
}
}
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(HGSJ001 hpsc012) {
//生成工序编码
hpsc012.setProcessCode(SequenceGenerator.getNextSequence(HGConstant.SequenceId.PROCESS_CODE));
DaoUtils.insert(HGSJ001.INSERT, hpsc012);
}
/**
* 修改操作
*/
public void modify(HGSJ001 hpsc012) {
DaoUtils.update(HGSJ001.UPDATE, hpsc012);
}
public EiInfo updateStatus(EiInfo inInfo){
int i = 0;
try {
HGSJ001 hpsc012 = new HGSJ001();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
hpsc012.fromMap(map);
DaoUtils.update(HGSJ001.UPDATE_STATUS, hpsc012);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.update", "修改")});
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
ErrorCodeUtils.handleUpdateException(inInfo,i,e);
logError("修改失败", e.getMessage());
return inInfo;
}
return inInfo;
}
}
package com.baosight.hggp.hg.sj.tools;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.sj.domain.HGSJ003;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.iplat4j.common.ed.domain.TEDCM01;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
* @version 1.0 2024/5/7
*/
public class HGSJTools {
/**
* Hgsj003公共DAO方法定义
*
*/
public static class Hgsj003 {
/**
* 查询
*
* @param id
* @return
*/
public static HGSJ003 get(Long id) {
AssertUtils.isNull(id, "规格ID不能为空");
Map queryMap = new HashMap();
queryMap.put("id", id);
List<HGSJ003> results = DaoBase.getInstance().query(HGSJ003.QUERY, queryMap);
AssertUtils.isEmpty(results, String.format("规格[%s]不存在", id));
return results.get(0);
}
/**
* 查询
*
* @param ids
* @return
*/
public static List<HGSJ003> list(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("ids", ids);
return DaoBase.getInstance().query(HGSJ003.QUERY, queryMap);
}
/**
* 查询
*
* @param ids
* @return
*/
public static Map<Long, HGSJ003> map(List<Long> ids) {
List<HGSJ003> results = list(ids);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.toMap(HGSJ003::getId, item -> item));
}
/**
* 拼接规格
*
* @param hgsj003
*/
public static void jointSpec(HGSJ003 hgsj003) {
if (StringUtils.isNotBlank(hgsj003.getSpec())) {
return;
}
hgsj003.setSpec(jointSpec(hgsj003.getLength(), hgsj003.getWidth(), hgsj003.getThick()));
}
/**
* 拼接规格
*
* @param length
* @param width
* @param thick
* @return
*/
public static String jointSpec(BigDecimal length, BigDecimal width, BigDecimal thick) {
StringBuffer sb = new StringBuffer();
if (length != null && length.compareTo(BigDecimal.ZERO) != 0) {
sb.append(length.stripTrailingZeros().toPlainString());
}
if (width != null && width.compareTo(BigDecimal.ZERO) != 0) {
if (StringUtils.isNotBlank(sb)) {
sb.append("*");
}
sb.append(width.stripTrailingZeros().toPlainString());
}
if (thick != null && thick.compareTo(BigDecimal.ZERO) != 0) {
if (StringUtils.isNotBlank(sb)) {
sb.append("*");
}
sb.append(thick.stripTrailingZeros().toPlainString());
}
return sb.toString();
}
public static Map getCompany(String loginName,String orgType){
AssertUtils.isEmpty(loginName, "用户不能为空");
Map queryMap = new HashMap();
queryMap.put("loginName", loginName);
queryMap.put("orgType", orgType);
queryMap.put(HGSJ003.FIELD_ACCOUNT_CODE, UserSessionUtils.getAccountCode());
List<Map<String,Object>> results = DaoBase.getInstance().query("HGSJ003.queryCompanyCode", queryMap);
if(results.size()==0){
results = null;
}
AssertUtils.isEmpty(results, String.format("用户[%s]没有绑定公司", loginName));
return results.get(0);
}
public static Map getSmallCode(String codesetCode){
AssertUtils.isEmpty(codesetCode, "代码分类不能为空");
return getSmallCode(codesetCode,null);
}
public static Map<String,Object> getSmallCode(String codesetCode,String itemCode){
Map param = new HashMap();
param.put("codesetCode",codesetCode);
param.put("itemCode",itemCode);
List<TEDCM01> results = listSmall(codesetCode,itemCode);
return results.stream().collect(Collectors.toMap(TEDCM01::getItemCname, TEDCM01::getItemCode));
}
public static List<TEDCM01> listSmall(String codesetCode, String itemCode){
AssertUtils.isEmpty(codesetCode, "代码分类不能为空");
Map param = new HashMap();
param.put("codesetCode",codesetCode);
param.put("itemCode",itemCode);
return DaoBase.getInstance().query("EDCM01.queryByCodesetCode", param);
}
}
}
...@@ -2,16 +2,23 @@ package com.baosight.hggp.util; ...@@ -2,16 +2,23 @@ package com.baosight.hggp.util;
import com.baosight.hggp.core.constant.CommonConstant; import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils; import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.sj.domain.HGSJ003;
import com.baosight.hggp.hg.sj.tools.HGSJTools;
import com.baosight.hggp.util.importer.Importer; import com.baosight.hggp.util.importer.Importer;
import com.baosight.hggp.util.importer.impl.XlsImporter; import com.baosight.hggp.util.importer.impl.XlsImporter;
import com.baosight.iplat4j.common.ed.domain.TEDCM01;
import com.baosight.iplat4j.core.data.DaoEPBase; import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.data.ibatis.SqlMapClientTemplate; import com.baosight.iplat4j.core.data.ibatis.SqlMapClientTemplate;
import com.baosight.iplat4j.core.data.ibatis.dao.Dao;
import com.baosight.iplat4j.core.ei.EiBlock; import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.web.threadlocal.UserSession; import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
...@@ -22,9 +29,7 @@ import java.io.OutputStream; ...@@ -22,9 +29,7 @@ import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
/** /**
* @author:songx * @author:songx
...@@ -32,6 +37,17 @@ import java.util.Map; ...@@ -32,6 +37,17 @@ import java.util.Map;
*/ */
public class ExcelUtils { public class ExcelUtils {
private static Dao dao = (Dao) PlatApplicationContext.getBean("dao");
private static final int QUERY_LIMIT = 1_000_000;
/**
* 导出最大值50*1000
*/
private static final int MAX_PAGE_NUMBER = 100;
private static final String COUNT_METHOD_NAME = "count";
private static final String QUERY_METHOD_NAME = "query";
public static final String SQL_OK_BLOCK = "sql_ok_block"; public static final String SQL_OK_BLOCK = "sql_ok_block";
public static final String CHECK_OK_BLOCK = "check_ok_block"; public static final String CHECK_OK_BLOCK = "check_ok_block";
/** /**
...@@ -59,7 +75,8 @@ public class ExcelUtils { ...@@ -59,7 +75,8 @@ public class ExcelUtils {
*/ */
public static final String FLAG_ONLY_NOT_NULL = "onlyNotNull"; public static final String FLAG_ONLY_NOT_NULL = "onlyNotNull";
public static final String SQL_OK_LINE = "sql_ok_line"; public static final String SQL_OK_LINE = "sql_ok_line";
private static SqlMapClientTemplate sqlMapClientTemplate = new SqlMapClientTemplate(); //private static SqlMapClientTemplate sqlMapClientTemplate = new SqlMapClientTemplate();
private static SqlMapClientTemplate sqlMapClientTemplate = (SqlMapClientTemplate) PlatApplicationContext.getBean("sqlMapClientTemplate");
protected static Logger logger = LogManager.getLogger(ExcelUtils.class); protected static Logger logger = LogManager.getLogger(ExcelUtils.class);
...@@ -154,7 +171,7 @@ public class ExcelUtils { ...@@ -154,7 +171,7 @@ public class ExcelUtils {
} }
String className = insertSql.substring(0,7); String className = insertSql.substring(0,7);
List arrayList = inInfo.getBlock(SQL_OK_BLOCK).getRows(); List<Map> arrayList = inInfo.getBlock(SQL_OK_BLOCK).getRows();
// 数据校验 // 数据校验
switch (className){ switch (className){
/** /**
...@@ -199,6 +216,28 @@ public class ExcelUtils { ...@@ -199,6 +216,28 @@ public class ExcelUtils {
} else { } else {
inInfo.setStatus(EiConstant.STATUS_FAILURE); inInfo.setStatus(EiConstant.STATUS_FAILURE);
} }
break;
case "HGSJ003":
HGSJ003 hgsj003 = new HGSJ003();
Map<String, String> mapSmall = HGSJTools.Hgsj003.getSmallCode("hggp.hgsj.processClass");
for (Map<?, ?> map : arrayList) {
String processClass = MapUtils.getString(mapSmall,map.get(HGSJ003.FIELD_PROCESS_CLASS_NAME));
AssertUtils.isEmpty(processClass,String.format("工序分类[%s]代码不存在,添加失败!",map.get(HGSJ003.FIELD_PROCESS_CLASS_NAME)));
hgsj003.fromMap(map);
// 设置规格
if (org.apache.commons.lang3.StringUtils.isBlank(hgsj003.getSpec())) {
hgsj003.setSpec(HGSJTools.Hgsj003.jointSpec(hgsj003.getLength(), hgsj003.getWidth(), hgsj003.getThick()));
}
// 去除空格
hgsj003.setSpec(StringUtils.trimToEmpty(hgsj003.getSpec()));
hgsj003.setProcessClass(Integer.valueOf(processClass));
//校验
checkAddData(hgsj003);
DaoUtils.insert(HGSJ003.INSERT, hgsj003);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("导入成功"+arrayList.size()+"条");
default:
} }
return inInfo; return inInfo;
...@@ -234,6 +273,117 @@ public class ExcelUtils { ...@@ -234,6 +273,117 @@ public class ExcelUtils {
return inInfo; return inInfo;
} }
/**
* Excel导出功能
*
* @param param 查询参数
* @param columnList 导出时显示的列名
* @param bean 对应的对象
* @return
*/
public static EiInfo exportToExcel(Map param, List columnList, DaoEPBase bean) {
return exportToExcel(COUNT_METHOD_NAME, QUERY_METHOD_NAME, param, columnList, bean);
}
/**
* Excel导出功能
*
* @param queryMethodName 查询方法名
* @param param 查询参数
* @param bean 对应的对象
* @return
*/
public static EiInfo exportToExcel(String queryMethodName, Map param, DaoEPBase bean) {
return exportToExcel(COUNT_METHOD_NAME, queryMethodName, param, null, bean);
}
/**
* Excel导出功能
*
* @param param 查询参数
* @param bean 对应的对象
* @return
*/
public static EiInfo exportToExcel(Map param, DaoEPBase bean) {
return exportToExcel(COUNT_METHOD_NAME, QUERY_METHOD_NAME, param, null, bean);
}
/**
* Excel导出功能
*
* @param countMethodName 总和方法名
* @param queryMethodName 查询方法名
* @param param 查询参数
* @param columnList 导出时显示的列名
* @param bean 对应的对象
*/
public static EiInfo exportToExcel(String countMethodName, String queryMethodName, Map param, List columnList, DaoEPBase bean) {
String className = bean.getClass().getSimpleName();
EiInfo outInfo = new EiInfo();
int offset = 0;
List queryList;
//2019年6月17日 防止jdbc内存溢出处理
try {
queryList = dao.query(className + "." + countMethodName, param, offset, 1);
int count = ((Integer) queryList.get(0)).intValue();
//跳过平台的查询限制
queryList = sqlMapClientTemplate.queryForList(className + "." + queryMethodName, param, offset, QUERY_LIMIT);
for (int i = 1; i < (count / QUERY_LIMIT); i++) {
int start = Double.valueOf(Math.ceil(i * QUERY_LIMIT) + 1).intValue();
queryList.addAll(sqlMapClientTemplate.queryForList(className + "." + queryMethodName, param, start, QUERY_LIMIT));
}
} catch (RuntimeException e1) {
queryList = dao.query(className + "." + queryMethodName, param, offset, -999999);
}
outInfo.addBlock(EiConstant.resultBlock).setRows(queryList);
outInfo.getBlocks().put("detail", outInfo.getBlock(EiConstant.resultBlock)); // 增加block:detail
outInfo.getBlocks().remove(EiConstant.resultBlock); // 移除block:result
EiBlock transformBlock = outInfo.addBlock(EiConstant.resultBlock);
//自定义行
List list;
if (!(columnList == null || columnList.isEmpty())) {
list = columnList;
} else {
Map metas = bean.eiMetadata.getMetas();
list = new LinkedList();
Iterator keySet = metas.keySet().iterator();
while (keySet.hasNext()) {
list.add(((EiColumn) metas.get(keySet.next())).getName());
}
}
List list2 = new LinkedList();
Map map = new LinkedHashMap();
for (int i = 0; i < list.size(); i++) {
map.put(list.get(i), i);
list2.add(map);
}
for (int i = 0; i < list2.size(); i++) {
HashMap<String, String> newMap = (HashMap) list2.get(i);
for (Map.Entry<String, String> entry : newMap.entrySet()) {
EiColumn eiColumn = bean.eiMetadata.getMeta(entry.getKey());
transformBlock.addMeta(eiColumn);
}
}
//将查询结果放入块中
transformBlock.addRows(queryList);
//防止平台空指针异常报错
transformBlock.set("groupColumns", new HashMap<>(2));
transformBlock.set("groupColumnsCname", new HashMap<>(2));
transformBlock.set("groupedColumns", new ArrayList<>(2));
return outInfo;
}
public static void checkTreeNodeLeaf(String id) { public static void checkTreeNodeLeaf(String id) {
//1 获取参数 //1 获取参数
Map queryMap = new HashMap(); Map queryMap = new HashMap();
...@@ -327,4 +477,30 @@ public class ExcelUtils { ...@@ -327,4 +477,30 @@ public class ExcelUtils {
inInfo.set("checkStatus",checkStatus); inInfo.set("checkStatus",checkStatus);
return inInfo; return inInfo;
} }
/**
* 校验规格
* @param hgsj003
*/
private static void checkAddData(HGSJ003 hgsj003) {
AssertUtils.isNull(hgsj003.getProcessCode(), "工序名称不能为空");
AssertUtils.isNull(hgsj003.getProcessClass(), "工序分类不能为空");
// 重复校验
String msg;
Map queryParam = new HashMap();
queryParam.put(HGSJ003.FIELD_ACCOUNT_CODE,hgsj003.getAccountCode());
queryParam.put(HGSJ003.FIELD_FACTORY_CODE,hgsj003.getFactoryCode());
queryParam.put(HGSJ003.FIELD_PROCESS_CODE, hgsj003.getProcessCode());
queryParam.put(HGSJ003.FIELD_PROCESS_CLASS,hgsj003.getProcessClass());
queryParam.put(HGSJ003.FIELD_DELETE_FLAG,CommonConstant.YesNo.NO_0);
if (StringUtils.isBlank(hgsj003.getSpec())) {
queryParam.put("notSpec", CommonConstant.YesNo.YES);
msg = String.format("工序编码[%s]已存在无规格,请勿重复添加!", hgsj003.getProcessCode());
} else {
queryParam.put("spec", hgsj003.getSpec());
msg = String.format("工厂[%s]工序编码[%s]已存在规格[%s],请勿重复添加!", hgsj003.getFactoryCode(), hgsj003.getProcessCode(), hgsj003.getSpec());
}
List<HGSJ003> hgsj003List = dao.query(HGSJ003.QUERY, queryParam);
AssertUtils.isNotEmpty(hgsj003List, msg);
}
} }
...@@ -12,6 +12,21 @@ public class ACConstants { ...@@ -12,6 +12,21 @@ public class ACConstants {
public static final char ROW_CODE_0 = 0; public static final char ROW_CODE_0 = 0;
/** /**
* sql 条件统计数目方法
*/
public static final String SQL_COUNT = "count";
/**
* sql 条件模板查询方法
*/
public static final String SQL_TEMPLATE = "template";
/**
* sql 条件导出方法
*/
public static final String SQL_EXPORT = "export";
/**
* 模块:仓库档案 * 模块:仓库档案
* 用途:前后台交互下拉框字段 * 用途:前后台交互下拉框字段
* 编写:yk * 编写:yk
......
$(function (){
var factoryCodes = __eiInfo.getBlock("companyBox_block_id").getMappedRows();
$(".row").children().attr("class", "col-md-3");
$("#QUERY").on("click", query);
/* 页面查询框的尺寸设置 */
$.extend(true, IPLATUI.Config, {
EFGrid: {
height: $(document).height() - $("#inqu").height() - $("#ef_form_head").height() - 100,
}
});
IPLATUI.EFGrid = {
"result": {
pageable: {
pageSize: 10,
pageSizes: [10, 20, 50, 100],
},
columns: [
{
field: "operator",
title: "操作",
template: function (item) {
let status = item.status;
let template = '';
if (item.id){
if (status == 0) {
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="updateStatus(' + item.id + ',1)" >启用</a>';
} else if (status == 1) {
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" ' +
'onclick="updateStatus(' + item.id + ',0)" >停止</a>';
}
}
return template;
}
},{
field: "factoryCode",
template: function (dataItem) {
for (let i = 0; i < factoryCodes.length; i++) {
if (factoryCodes[i]['valueField'] === dataItem['factoryCode']) {
dataItem['factoryName'] = factoryCodes[i]['textField'];
return factoryCodes[i]['textField'];
}
}
return dataItem['factoryCode'];
},
},{
field: "createdName",
template: function (options) {
return showUserName(options.createdBy, options.createdName);
}
}
],
loadComplete: function(grid) {
// 此 grid 对象
// 处理父子级联动,通过监听 change 事件,判断父级节点是否发生变化
/*grid.dataSource.bind("change", function(e) {
let items = e.items
// 判断父级节点是否发生变化
if (e.field == "factoryCode") {
for (let i = 0; i <items.length ; i++) {
if (items[i]["factoryCode"].length > 0 && items[i]["factoryName"].length <= 0){
}
}
//loadChange(grid,e,"groupCode");
}else if (e.field == "groupCode") {
if (e.items[0].factoryCode.length===0){
loadChange(grid,e,"factoryCode");
}
loadChange(grid,e,"userId");
}else if (e.field == "deviceCode"){
}
});*/
},
afterEdit:function (e) {
//下拉框选中回写
/*if (e.field === "groupCode" && e.model["factoryCode"].length === 0){
for (let i = 0; i < groupCodeBox.length; i++) {
if (e.model[e.field] === groupCodeBox[i]["valueField"]){
e.model["factoryCode"]=groupCodeBox[i]["param1Field"]
break;
}
}
}*/
},
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
let btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
save(btnNode);
},
onDelete: function (e) {
// 阻止默认请求,使用自定义删除
//e.preventDefault();
//deleteFunc();
},
onSuccess: function (e) {
if (e.eiInfo.extAttr.methodName == 'save' || e.eiInfo.extAttr.methodName == 'delete') {
query();
}
},
onRowClick: function (e) {
},
exportGrid : {
exportFileName: function (gridInstance) {
// 导出的文件名包含时间戳 yyyy-MM-dd HH:mm:ss
return "工序设置_" + kendo.toString(new Date(), IPLAT.FORMAT.DATE_14_PR);
},
exportFileType: "xls",
exportBlockId: "result",
}
}
}
})
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function (btnNode) {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let factoryCode= item.get("factoryCode");
let processName= item.get("processName");
let standardJob= item.get("standardJob");
let standardDays= item.get("standardDays");
let standardNum= item.get("standardNum");
let princ= item.get("princ");
if(isBlank(factoryCode)){
message("选中的第"+(index+1)+"行\"工厂\",不能为空!");
flag = false;
return false;
}
if(isBlank(processName)){
message("选中的第"+(index+1)+"行\"工序名称\",不能为空!");
flag = false;
return false;
}
if(isBlank(standardJob)){
message("选中的第"+(index+1)+"行\"标准作业\",不能为空!");
flag = false;
return false;
}
if(isBlank(standardDays)){
message("选中的第"+(index+1)+"行\"标准人天\",不能为空!");
flag = false;
return false;
}
if(isBlank(standardNum)){
message("选中的第"+(index+1)+"行\"标准工序人数\",不能为空!");
flag = false;
return false;
}
if(isBlank(princ)){
message("选中的第"+(index+1)+"行\"负责人\",不能为空!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGSJ001", "save", true,
function (e) {
query();
});
btnNode.attr("disabled", false);
}
});
}
}
function updateStatus(id,status) {
let inEiInfo = new EiInfo();
inEiInfo.set("result-0-id", id);
inEiInfo.set("result-0-status", status);
EiCommunicator.send('HGSJ001', 'updateStatus', inEiInfo, {
onSuccess(response) {
NotificationUtil(response.msg);
query();
},
onFail(errorMessage, status, e) {
NotificationUtil("执行失败!", "error");
}
}, {
async: false
}
);
}
function loadChange(grid,e,field) {
var cell_label = field,that = grid;
// locked 表示是否为固定列
var locked = that.isCellLocked(cell_label);
// tr 表示 locked 和非 locked 的行,index 表示此行的第几列
var tr,index;
// 获取此 model 元素信息
var item = e.items[0];
var _uid = item.uid;
if (locked) {
tr = $(".k-grid-content-locked tr[data-uid="+ _uid +"]");
index = $("th[data-field='"+cell_label+"']").data("index");
} else {
tr = $(".k-grid-content tr[data-uid="+ _uid +"]");
index = parseInt($("th[data-field='"+cell_label+"']").data("index")) - that.lockedHeader.find("th").length;
}
// 获取子 cell(td)
var td = tr.children("td:eq("+index+")");
// 触发 td.click 事件,
td.trigger("click");
}
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: 1
Date: 2024/5/6
Time: 9:39
To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="工序设置">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFSelect blockId="inqu_status" row="0" ename="factoryCode" cname="公司名称" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="companyBox_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFInput blockId="inqu_status" row="0" ename="processName" cname="工序名称" colWidth="3"/>
<EF:EFInput blockId="inqu_status" row="0" ename="princ" cname="负责人" colWidth="3"/>
<EF:EFSelect blockId="inqu_status" row="0" ename="status" cname="状态" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="hpjx.hpjx.status"/>
</EF:EFSelect>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true">
<EF:EFColumn ename="id" primaryKey="true" cname="内码" hidden="true"/>
<EF:EFColumn ename="companyCode" cname="企业编码" hidden="true"/>
<EF:EFColumn ename="operator" cname="操作" locked="true" enable="false" width="80" align="center"/>
<EF:EFComboColumn ename="factoryCode" cname="公司名称"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" width="120" required="true"
align="center" filter="contains" sort="true">
<EF:EFOptions blockId="companyBox_block_id" textField="textField" valueField="valueField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="factoryName" cname="公司名称" hidden="true"/>
<EF:EFColumn ename="processCode" cname="工序编码" enable="false" width="100" align="center"/>
<EF:EFColumn ename="processName" cname="工序名称" width="120" enable="true" readonly="false" align="center" required="true"/>
<EF:EFColumn ename="unit" cname="单位" width="80" enable="true" readonly="false" align="center"/>
<EF:EFColumn ename="standardJob" cname="标准作业" width="120" enable="true" format="{0:N0}" editType="number"
displayType="0" sort="true" align="right" required="true"
data-regex="/^-?[0-9]{1,15}?$/" maxLength="15"
data-errorprompt="请输入数字,该值最大可设置15位整数!"
/>
<EF:EFColumn ename="standardDays" cname="标准人天" width="120" enable="true" format="{0:N0}" editType="number"
displayType="0" sort="true" align="right"
data-regex="/^-?[0-9]{1,15}?$/" maxLength="20" required="true"
data-errorprompt="请输入数字,该值最大可设置15位整数!"
/>
<EF:EFColumn ename="standardNum" cname="标准工序人数" width="120" enable="true" format="{0:N0}" editType="number"
displayType="0" sort="true" align="right"
data-regex="/^-?[0-9]{1,15}?$/" maxLength="20" required="true"
data-errorprompt="请输入数字,该值最大可设置15位整数!"
/>
<EF:EFComboColumn ename="princ" cname="负责人"
columnTemplate="#=textField#" itemTemplate="#=textField#"
textField="textField" valueField="valueField"
maxLength="16" width="120" required="true"
align="center" filter="contains" sort="true">
<EF:EFOptions blockId="user_block_id" textField="textField" valueField="valueField"/>
</EF:EFComboColumn>
<%--<EF:EFColumn ename="princ" cname="负责人" width="120" enable="true" readonly="false" align="center" required="true"/>--%>
<EF:EFComboColumn ename="status" cname="状态" width="80" enable="true" readonly="false" align="center" required="true" defaultValue="1">
<EF:EFCodeOption codeName="hpjx.hpjx.status"/>
</EF:EFComboColumn>
<EF:EFColumn cname="创建人" ename="createdName" align="center" width="100" readonly="true" required="false"
enable="false"/>
<EF:EFColumn cname="创建时间" ename="createdTime" parseFormats="['yyyyMMddHHmmss']" editType="datetime"
dateFormat="yyyy-MM-dd HH:mm:ss" align="center" width="120" readonly="true" required="false"
enable="false"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
...@@ -444,4 +444,80 @@ function downKeyUp() { ...@@ -444,4 +444,80 @@ function downKeyUp() {
} }
}) })
}
const grush = {
openImportBox(importBoxDomId) {
if (!($ || jQuery)) {
throw new Error('jQuery引入失败...找不到对外暴露的$和jQuery');
}
importBoxDomId = importBoxDomId || '#IMPORT';
if (!importBoxDomId) {
throw new Error(
`ID为{${importBoxDomId}的导入框元素找不到, 请查看是否在平台上注册或是其它问题导致`);
}
$(importBoxDomId).on("click", function (e) {
openFileWindow.open();
});
},
downloadFile(fileUrl, downloadDomId) {
if (!($ || jQuery)) {
throw new Error('jQuery引入失败...找不到对外暴露的$和jQuery');
}
downloadDomId = downloadDomId || '#DOWNLOAD';
if (!downloadDomId) {
throw new Error(
`ID为{${downloadDomId}的导入框元素找不到, 请查看是否在平台上注册或是其它问题导致`);
}
$(downloadDomId).on("click", function (e) {
window.location.href = fileUrl;
});
},
IExport(validatorDom, exportEiInfo, exportDomId, eventName) {
if (!($ || jQuery)) {
throw new Error('jQuery引入失败...找不到对外暴露的$和jQuery');
}
exportDomId = exportDomId || '#EXPORT';
if (!exportDomId) {
throw new Error(
`ID为{${exportDomId}的导出元素找不到, 请查看是否在平台上注册或是其它问题导致`);
}
eventName = eventName || 'click';
$(exportDomId).on(eventName, function (e) {
if (!validatorDom.val()) {
return settingValidator();
}
exportEiInfo['queryInfo'] = resultGrid.getQueryInfo().toJSONString();
IPLAT.Util.exportGrid(exportEiInfo);
});
},
settingValidator(validatorDomId) {
validatorDomId = validatorDomId || 'inqu';
const validator = IPLAT.Validator({
id: validatorDomId
});
if (!validator.validate()) {
const errorMessage = validator.errors().toString().split(',');
IPLAT.alert(
{
title: '错误',
message: '<b>错误:<br>' + errorMessage.join('<br>') + '</b>',
okFn(e) {
}
}
);
return false;
}
return true;
},
}
function isExcelFile(uploadFileUrl) {
return uploadFileUrl.indexOf("xls") === -1
&& uploadFileUrl.indexOf("xlsx") === -1
&& uploadFileUrl.indexOf("XLS") === -1
&& uploadFileUrl.indexOf("XLSX") === -1;
} }
\ No newline at end of file
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