Commit 201a113f by 宋祥

1.厂区管理

2.出库单打印
parent cabb2d63
......@@ -138,6 +138,23 @@
<artifactId>lowcode-plugin</artifactId>
<version>1.0.8</version>
</dependency>
<!-- okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.6.20</version>
</dependency>
<!-- excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
</dependencies>
<build>
......
......@@ -107,7 +107,20 @@ public enum DdynamicEnum {
* 编写:yk
*/
USER_BLOCK_ID("user_block_id","loginName","userName","HPXSUser.queryComboBox"),
/**
* 模块:厂区管理
* 用途:厂区管理下拉框
* 编写:songx
*/
FACTORY_RECORD_BLOCK_ID("factory_record_block_id","factoryCode","factoryName","HPPZ011.queryComboBox"),
/**
* 模块:组管理
* 用途:组管理下拉框
* 编写:songx
*/
GROUP_RECORD_BLOCK_ID("group_record_block_id","groupCode","groupName","HPPZ011.queryGroupComboBox"),
//------------------------------------生产管理-----------------------------------
/**
......@@ -115,10 +128,19 @@ public enum DdynamicEnum {
* 用途:项目档案下拉框
* 编写:wwl
*/
PROJ_RECORD_BLOCK_ID("proj_record_block_id","projCode","projName","HPSC001.queryComboBox");
/** 将结果集放入的块名 */
PROJ_RECORD_BLOCK_ID("proj_record_block_id","projCode","projName","HPSC001.queryComboBox"),
//------------------------------------用户管理-----------------------------------
/**
* 模块:组织机构
* 用途:项目档案下拉框
* 编写:wwl
*/
ORG_RECORD_BLOCK_ID("org_record_block_id","orgId","orgCname","HPXSOrg.queryComboBox");
/** 将结果集放入的块名 */
private final String blockId;
/** 字段名 */
private final String value;
......
package com.baosight.hpjx.core.api;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hpjx.util.Base64Utils;
import com.baosight.hpjx.util.FileUtils;
import com.baosight.hpjx.util.HttpUtils;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2024/1/29,9:16
*/
@Slf4j
public class BaiDuApi {
// 鉴权接口
private static final String TOKEN_URL = "https://aip.baidubce.com/oauth/2.0/token";
// 标准版接口地址
private static final String BASIC_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic";
// 办公文档版接口地址
private static final String OFFICE_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis_office";
// Api Key
private static final String API_KEY = "dkXgTCScKjfMmL7oCzAIFdgZ";
// Secret Key
private static final String SECRET_KEY = "xP5V9k23KBNHOyzc0rYkm00GdQMMxvEh";
/**
* 获取TOKEN
*
* @return
*/
public static String getToken() {
return SingletonHolder.TOKEN;
}
/**
* 刷新TOKEN
*
* @return
*/
public static void refreshToken() {
SingletonHolder.refresh();
}
public static void main(String[] args) throws IOException {
// String filePath = "e:/10001.jpg";
String filePath = "e:/新年贺词.pdf";
docAnalysisOffice(filePath);
}
/**
* 解析办公文档
*
* @param filePath 本地文件地址
*/
public static void docAnalysisOffice(String filePath) throws IOException {
byte[] fileBytes = FileUtils.readByBytes(filePath);
String fileBase64 = Base64Utils.encode(fileBytes);
String fileEncoder = URLEncoder.encode(fileBase64, "UTF-8");
String param = "pdf_file_num=2&image=" + fileEncoder;
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/x-www-form-urlencoded");
String url = OFFICE_URL + "?access_token=" + getToken();
String result = HttpUtils.post(url, header, param, HttpUtils.FORM_MEDIA_TYPE);
log.info("result->{}", result);
}
/**
* 静态内部类用于初始化
*
* @author:songx
* @date:2022/5/9,15:48
*/
private static class SingletonHolder {
/**
* 默认DAO
*/
private static String TOKEN = "24.717d5b52074bdf31d0377a4afa6c97d6.2592000.1709101017.282335-48528257";//getToken();
/**
* 获取TOKEN
*
* @return
* @throws IOException
*/
private static String getToken() {
try {
String url = String.format("%s?client_id=%s&client_secret=%s&grant_type=client_credentials",
TOKEN_URL, API_KEY, SECRET_KEY);
String result = HttpUtils.post(url);
JSONObject resultJson = JSONObject.parseObject(result);
return resultJson.getString("access_token");
} catch (Exception e) {
log.error("获取百度API的TOKEN失败:{}", e.getMessage(), e);
}
return null;
}
/**
* 刷新TOKEN
*
* @return
*/
public static void refresh() {
TOKEN = getToken();
}
}
}
/*
* 武汉理工数字传播工程有限公司源代码,版权归武汉理工数字传播工程有限公司所有.
* 项目名称 : pcloud-common
* 创建日期 : 2017年3月3日
* 修改历史 :
* 1. [2017年3月3日]创建文件 by xnxqs
*/
package com.baosight.hpjx.core.constant;
/**
* 与操作系统 有关的一些常量.
*
* @author:songx
* @date:2019/12/12,16:32
*/
public class OSConstant {
/**
* 文件夹分隔符,不同OS下分隔符不同
*/
public final static String SEPARATOR = System.getProperty("file.separator");
/**
* 程序运行目录
*/
public final static String USER_DIR = System.getProperty("user.dir");
/**
* 逗号
*/
public final static String COMMA = ",";
/**
* 程序运行目录
*/
public final static String DOWN_DIR = USER_DIR + SEPARATOR + "download";
}
......@@ -14,6 +14,10 @@ public class HPConstant {
*/
public class SequenceId {
// 组编码
public static final String GROUP_CODE = "GROUP_CODE";
// 厂区编码
public static final String FACTORY_CODE = "FACTORY_CODE";
// 企业编码
public static final String COMPANY_CODE = "COMPANY_CODE";
//项目档案编号
......
......@@ -176,4 +176,16 @@ public class HPSqlConstant {
public static final String QUERY = "HPPZ010.query";
}
/**
* HPPZ011 SQL 定义
*
* @author:songx
* @date:2024/1/18,17:17
*/
public class HPPZ011 {
// 查询
public static final String GET = "HPPZ011.get";
}
}
......@@ -28,7 +28,6 @@ public class HPKC003 extends DaoEPBase {
public static final String FIELD_DOCUMENT_DATE = "documentDate"; /* 单据日期*/
public static final String FIELD_PROD_NO = "prodNo"; /* 生产入库单号*/
public static final String FIELD_PROD_NO_OLD = "prodNoOld"; /* 生产入库单号(旧)*/
public static final String FIELD_PRODUCTION_ORDER_NO = "productionOrderNo"; /* 生产订单号*/
public static final String FIELD_WH_CODE = "whCode"; /* 仓库编码*/
public static final String FIELD_WH_NAME = "whName"; /* 仓库名称*/
......@@ -47,14 +46,12 @@ public class HPKC003 extends DaoEPBase {
public static final String FIELD_UPDATED_NAME = "updatedName"; /* 修改人名称*/
public static final String FIELD_DELETE_FLAG = "deleteFlag"; /* 是否删除0:否1.是*/
public static final String COL_ID = "ID";
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/
public static final String COL_DEP_CODE = "DEP_CODE"; /* 部门编码*/
public static final String COL_DOCUMENT_DATE = "DOCUMENT_DATE"; /* 单据日期*/
public static final String COL_PROD_NO = "PROD_NO"; /* 生产入库单号*/
public static final String COL_PROD_NO_OLD = "PROD_NO_OLD"; /* 生产入库单号*/
public static final String COL_PRODUCTION_ORDER_NO = "PRODUCTION_ORDER_NO"; /* 生产订单号*/
public static final String COL_WH_CODE = "WH_CODE"; /* 仓库编码*/
public static final String COL_WH_NAME = "WH_NAME"; /* 仓库名称*/
......@@ -72,7 +69,13 @@ public class HPKC003 extends DaoEPBase {
public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 更新时间*/
public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 修改人名称*/
public static final String COL_DELETE_FLAG = "DELETE_FLAG"; /* 存货类型*/
public static final String QUERY = "HPKC003.query";
public static final String COUNT = "HPKC003.count";
public static final String INSERT = "HPKC003.insert";
public static final String UPDATE = "HPKC003.update";
public static final String DELETE = "HPKC003.delete";
private Long id = null;
private String companyCode = " "; /* 企业编码 预留*/
private String depCode = " "; /* 部门编码*/
......
......@@ -88,10 +88,9 @@ public class ServiceHPKC003 extends ServiceBase {
fKc003.setInventName(HPPZTools.getPz004ByCode(fKc003.getInventCode()).getInventName());
// 生成入库单号
fKc003.setProdNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC003_PROD_NO));
DaoUtils.insert("HPKC003.insert", fKc003);
DaoUtils.insert(HPKC003.INSERT, fKc003);
//同步生产计划
DaoUtils.update("HPSC004.update",this.synchronousPlan(fKc003));
DaoUtils.update(HPSC004.UPDATE,this.synchronousPlan(fKc003));
// 修改库存
HPKCTools.updateStock(fKc003.getWhCode(), fKc003.getInventRecordId(), fKc003.getAmount(),
fKc003.getWeight());
......
package com.baosight.hpjx.hp.kc.tools;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* 出库单Excel
*
* @author:songx
* @date:2021/3/20,21:22
*/
@Slf4j
public class CKExcelTools {
public static void main(String[] args) {
List<Map<String, Object>> items = new ArrayList<>();
Map<String, Object> itemMap1 = new HashMap<>();
itemMap1.put("groupName", "内膜");
List<Map<String, String>> itemChildren1 = new ArrayList<>();
Map<String, String> childMap1_1 = new HashMap<>();
childMap1_1.put("itemName", "内模封板");
childMap1_1.put("quantity", "4");
itemChildren1.add(childMap1_1);
Map<String, String> childMap1_2 = new HashMap<>();
childMap1_2.put("itemName", "加长定位稍");
childMap1_2.put("spec", "1200");
childMap1_2.put("length", "120");
childMap1_2.put("quantity", "700");
childMap1_2.put("remark", "含螺母");
itemChildren1.add(childMap1_2);
itemMap1.put("itemChildren", itemChildren1);
items.add(itemMap1);
Map<String, Object> itemMap2 = new HashMap<>();
itemMap2.put("groupName", "外模");
List<Map<String, String>> itemChildren2 = new ArrayList<>();
Map<String, String> childMap2_1 = new HashMap<>();
childMap2_1.put("itemName", "中梁底边3米");
childMap2_1.put("spec", "3000");
childMap2_1.put("length", "3000");
childMap2_1.put("quantity", "3");
itemChildren2.add(childMap2_1);
Map<String, String> childMap2_2 = new HashMap<>();
childMap2_2.put("itemName", "中梁底边2米");
childMap2_2.put("spec", "2000");
childMap2_2.put("length", "2000");
childMap2_2.put("quantity", "1");
itemChildren2.add(childMap2_2);
itemMap2.put("itemChildren", itemChildren2);
items.add(itemMap2);
Map dataMap = new HashMap();
dataMap.put("projectName", "20米液压箱梁");
dataMap.put("items", items);
try {
HSSFWorkbook workbook = build(dataMap);
FileOutputStream fout = new FileOutputStream("d:/出库单.xls");
workbook.write(fout);
fout.close();
} catch (Exception e) {
log.error("生成出库单失败:{}", e.getMessage(), e);
}
}
/**
* 下载文件
*
* @param pageContext
*/
public static void downloadFile(PageContext pageContext) throws IOException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
// String docId = request.getParameter("docId");
// HSSFWorkbook workbook = build(dataMap);
// String fileName = "出库单-" + DateUtils.shortYmdhmss() + ".xls";
// ExcelUtils.download(fileName, workbook, response);
}
/**
* 导出Excel
*
* @param dataMap 数据集
*/
public static HSSFWorkbook build(Map dataMap) {
HSSFWorkbook workbook = new HSSFWorkbook();
// 在Workbook中,创建一个sheet,对应Excel中的工作薄(sheet)
HSSFSheet sheet = workbook.createSheet("出库单");
sheet.autoSizeColumn(0);
// 设置列宽
sheet.setColumnWidth(1, 30 * 256);
sheet.setColumnWidth(5, 15 * 256);
sheet.setColumnWidth(6, 15 * 256);
// 第1行
buildRow1(workbook, sheet, dataMap);
// 第2行:标题栏
buildRow2(workbook, sheet);
// 遍历数据行,excel行从第3行开始
int headRow = 2;
int lastRow = 2;
List<Map<String, Object>> items = (List<Map<String, Object>>) dataMap.get("items");
for (int i = 0; i < items.size(); i++) {
Map<String, Object> itemMap = items.get(i);
// 组名称
lastRow = buildGroupRow(workbook, sheet, itemMap, lastRow, headRow);
// 明细数据,返回末尾行数
lastRow = buildChildRow(workbook, sheet, itemMap, lastRow, headRow);
}
// 页脚
buildFoot(workbook, sheet, lastRow);
return workbook;
}
/**
* 构建页脚
*
* @param workbook
* @param sheet
* @param lastRow
*/
private static void buildFoot(HSSFWorkbook workbook, HSSFSheet sheet, int lastRow) {
// 页脚第一行
int currRow = lastRow + 1;
HSSFRow row1 = sheet.createRow(currRow);
row1.setHeight((short) (20 * 20));
// 1.1
HSSFCell cell1_1 = row1.createCell(0);
cell1_1.setCellValue("模版重量:");
cell1_1.setCellStyle(getCellStyle(workbook, HorizontalAlignment.LEFT, VerticalAlignment.CENTER, true, false));
// 1.2
HSSFCell cell1_2 = row1.createCell(2);
cell1_2.setCellValue("承运车号:");
cell1_2.setCellStyle(getCellStyle(workbook, HorizontalAlignment.LEFT, VerticalAlignment.CENTER, true, false));
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(currRow, currRow, 0, 1));
sheet.addMergedRegion(new CellRangeAddress(currRow, currRow, 2, 4));
// 页脚第二行
currRow = currRow + 1;
HSSFRow row2 = sheet.createRow(currRow);
row2.setHeight((short) (20 * 20));
// 1.1
HSSFCell cell2_1 = row2.createCell(0);
cell2_1.setCellValue("收货人签字:");
cell2_1.setCellStyle(getCellStyle(workbook, HorizontalAlignment.LEFT, VerticalAlignment.CENTER, true, false));
// 1.2
HSSFCell cell2_2 = row2.createCell(2);
cell2_2.setCellValue("发货人签字:");
cell2_2.setCellStyle(getCellStyle(workbook, HorizontalAlignment.LEFT, VerticalAlignment.CENTER, true, false));
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(currRow, currRow, 0, 1));
sheet.addMergedRegion(new CellRangeAddress(currRow, currRow, 2, 4));
}
/**
* 构建明细数据行
*
* @param workbook
* @param sheet
* @param itemMap
* @param lastRow
* @param headRow
*/
private static int buildChildRow(HSSFWorkbook workbook, HSSFSheet sheet, Map<String, Object> itemMap,
int lastRow, int headRow) {
List<Map<String, String>> children = MapUtils.getList(itemMap, "itemChildren");
int currRow = lastRow + 1;
for (int i = 0; i < children.size(); i++) {
Map<String, String> childMap = children.get(i);
currRow = currRow + i;
HSSFRow row = sheet.createRow(currRow);
row.setHeight((short) (20 * 20));
// 序号
HSSFCell cell1_0 = row.createCell(0);
cell1_0.setCellValue(currRow - headRow);
cell1_0.setCellStyle(getCellStyle(workbook));
// 名称
HSSFCell cell1_1 = row.createCell(1);
cell1_1.setCellValue(MapUtils.getString(childMap, "itemName"));
cell1_1.setCellStyle(getCellStyle(workbook));
// 规格
// HSSFCell cell1_2 = row.createCell(2);
// cell1_2.setCellValue(MapUtils.getString(childMap, "spec"));
// cell1_2.setCellStyle(getCellStyle(workbook));
// 长
HSSFCell cell1_2 = row.createCell(2);
cell1_2.setCellValue(MapUtils.getString(childMap, "length"));
cell1_2.setCellStyle(getCellStyle(workbook));
// 宽
HSSFCell cell1_3 = row.createCell(3);
cell1_3.setCellValue(MapUtils.getString(childMap, "width"));
cell1_3.setCellStyle(getCellStyle(workbook));
// 高
HSSFCell cell1_4 = row.createCell(4);
cell1_4.setCellValue(MapUtils.getString(childMap, "height"));
cell1_4.setCellStyle(getCellStyle(workbook));
// 数量
HSSFCell cell1_5 = row.createCell(5);
cell1_5.setCellValue(MapUtils.getString(childMap, "quantity"));
cell1_5.setCellStyle(getCellStyle(workbook));
// 备注
HSSFCell cell1_6 = row.createCell(6);
cell1_6.setCellValue(MapUtils.getString(childMap, "remark"));
cell1_6.setCellStyle(getCellStyle(workbook));
}
return currRow;
}
/**
* 构建组名称行
*
* @param workbook
* @param sheet
* @param itemMap
* @param lastRow
* @param headRow
*/
private static int buildGroupRow(HSSFWorkbook workbook, HSSFSheet sheet, Map<String, Object> itemMap,
int lastRow, int headRow) {
int currRow = lastRow + 1;
String groupName = MapUtils.getString(itemMap, "groupName");
HSSFRow row = sheet.createRow(currRow);
row.setHeight((short) (20 * 20));
// 序号
HSSFCell cell1_0 = row.createCell(0);
cell1_0.setCellValue(currRow - headRow);
cell1_0.setCellStyle(getCellStyle(workbook));
// 名称
HSSFCell cell1_1 = row.createCell(1);
cell1_1.setCellValue(groupName);
cell1_1.setCellStyle(getCellStyle(workbook));
// 补位使用
HSSFCell cell1_2 = row.createCell(2);
cell1_2.setCellStyle(getCellStyle(workbook));
HSSFCell cell1_3 = row.createCell(3);
cell1_3.setCellStyle(getCellStyle(workbook));
HSSFCell cell1_4 = row.createCell(4);
cell1_4.setCellStyle(getCellStyle(workbook));
HSSFCell cell1_5 = row.createCell(5);
cell1_5.setCellStyle(getCellStyle(workbook));
HSSFCell cell1_6 = row.createCell(6);
cell1_6.setCellStyle(getCellStyle(workbook));
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(currRow, currRow, 1, 6));
return currRow;
}
/**
* 构建第1行
*
* @param workbook
* @param sheet
* @param dataMap
*/
private static void buildRow1(HSSFWorkbook workbook, HSSFSheet sheet, Map dataMap) {
// 在sheet中添加第0行,注意老版本poi对Excel的行数列数有限制short
HSSFRow row1 = sheet.createRow(0);
row1.setHeight((short) (20 * 20));
// 1.1、表头:项目名
HSSFCell cell1_1 = row1.createCell(0);
cell1_1.setCellValue("项目:" + dataMap.get("projectName"));
cell1_1.setCellStyle(getCellStyle(workbook, HorizontalAlignment.LEFT, VerticalAlignment.CENTER, true, false));
// 1.2、表头日期
HSSFCell cell1_2 = row1.createCell(5);
cell1_2.setCellValue(DateUtils.chinaDate());
cell1_2.setCellStyle(getCellStyle(workbook, HorizontalAlignment.RIGHT, VerticalAlignment.CENTER, true, false));
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 4));
sheet.addMergedRegion(new CellRangeAddress(0, 0, 5, 6));
}
/**
* 构建第2~3行
*
* @param workbook
* @param sheet
*/
private static void buildRow2(HSSFWorkbook workbook, HSSFSheet sheet) {
// 2.第2行标题行
HSSFRow row2 = sheet.createRow(1);
row2.setHeight((short) (20 * 20));
// 2.0、序号
HSSFCell cell2_0 = row2.createCell(0);
cell2_0.setCellValue("序号");
cell2_0.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.1、名称
HSSFCell cell2_1 = row2.createCell(1);
cell2_1.setCellValue("名称");
cell2_1.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.2、规格
HSSFCell cell2_2 = row2.createCell(2);
cell2_2.setCellValue("规格(mm)");
cell2_2.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.3~4、补位
HSSFCell cell2_3 = row2.createCell(3);
cell2_3.setCellStyle(getCellStyle(workbook, true));
HSSFCell cell2_4 = row2.createCell(4);
cell2_4.setCellStyle(getCellStyle(workbook, true));
// 2.5、数量
HSSFCell cell2_5 = row2.createCell(5);
cell2_5.setCellValue("数量");
cell2_5.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.6、备注
HSSFCell cell2_6 = row2.createCell(6);
cell2_6.setCellValue("备注");
cell2_6.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 3.第3行标题行
HSSFRow row3 = sheet.createRow(2);
row3.setHeight((short) (20 * 20));
// 3.0~1、补位
HSSFCell cell3_0 = row3.createCell(0);
cell3_0.setCellStyle(getCellStyle(workbook, true));
HSSFCell cell3_1 = row3.createCell(1);
cell3_1.setCellStyle(getCellStyle(workbook, true));
// 3.2、长
HSSFCell cell3_2 = row3.createCell(2);
cell3_2.setCellValue("长");
cell3_2.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.3、宽
HSSFCell cell3_3 = row3.createCell(3);
cell3_3.setCellValue("宽");
cell3_3.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.4、高
HSSFCell cell3_4 = row3.createCell(4);
cell3_4.setCellValue("高");
cell3_4.setCellStyle(getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, true,
true));
// 2.5~6、补位
HSSFCell cell3_5 = row3.createCell(5);
cell3_5.setCellStyle(getCellStyle(workbook, true));
HSSFCell cell3_6 = row3.createCell(6);
cell3_6.setCellStyle(getCellStyle(workbook, true));
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 4));
sheet.addMergedRegion(new CellRangeAddress(1, 2, 5, 5));
sheet.addMergedRegion(new CellRangeAddress(1, 2, 6, 6));
}
/**
* 默认:居中+边框
*
* @param workbook
* @return
*/
private static HSSFCellStyle getCellStyle(HSSFWorkbook workbook) {
return getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, false, true);
}
/**
* 边框
*
* @param workbook
* @param isBorder
* @return
*/
private static HSSFCellStyle getCellStyle(HSSFWorkbook workbook, boolean isBorder) {
return getCellStyle(workbook, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, false, isBorder);
}
/**
* 居中+边框
*
* @param workbook
* @param alignment
* @param verticalAlignment
* @param isBorder
* @return
*/
private static HSSFCellStyle getCellStyle(HSSFWorkbook workbook, HorizontalAlignment alignment,
VerticalAlignment verticalAlignment, boolean isBorder) {
return getCellStyle(workbook, alignment, verticalAlignment, false, isBorder);
}
/**
* 居中+加粗+边框
*
* @param workbook
* @param alignment
* @param verticalAlignment
* @param isBold
* @param isBorder
* @return
*/
private static HSSFCellStyle getCellStyle(HSSFWorkbook workbook, HorizontalAlignment alignment,
VerticalAlignment verticalAlignment, boolean isBold, boolean isBorder) {
return getCellStyle(workbook, alignment, verticalAlignment, isBold, isBorder, null);
}
/**
* 居中+加粗+边框+字体
*
* @param workbook
* @param alignment
* @param verticalAlignment
* @param isBold
* @param isBorder
* @param fontName
* @return
*/
private static HSSFCellStyle getCellStyle(HSSFWorkbook workbook, HorizontalAlignment alignment,
VerticalAlignment verticalAlignment, boolean isBold, boolean isBorder, String fontName) {
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(alignment);
cellStyle.setVerticalAlignment(verticalAlignment);
// 字体样式
HSSFFont font = workbook.createFont();
// 加粗
font.setBold(isBold);
// 字体
if (StringUtils.isNotNull(fontName)) {
font.setFontName(fontName);
}
cellStyle.setFont(font);
// 边框
if (isBorder) {
//下边框
cellStyle.setBorderBottom(BorderStyle.THIN);
//左边框
cellStyle.setBorderLeft(BorderStyle.THIN);
//上边框
cellStyle.setBorderTop(BorderStyle.THIN);
//右边框
cellStyle.setBorderRight(BorderStyle.THIN);
}
return cellStyle;
}
}
package com.baosight.hpjx.hp.pz.domain;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.core.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* Project: <br>
* Title:THppz011.java <br>
* Description: <br>
*
* Copyrigth:Baosight Software LTD.co Copyright (c) 2019. <br>
*
* @version 1.0
* @history 2024-01-18 17:09:53 create
*/
public class HPPZ011 extends DaoEPBase {
public static final String FIELD_ID = "id";
public static final String FIELD_COMPANY_CODE = "companyCode"; /* 企业编码 预留*/
public static final String FIELD_DEP_CODE = "depCode"; /* 部门编码*/
public static final String FIELD_CREATED_BY = "createdBy"; /* 创建人*/
public static final String FIELD_CREATED_NAME = "createdName"; /* 创建人名称*/
public static final String FIELD_CREATED_TIME = "createdTime"; /* 创建时间*/
public static final String FIELD_UPDATED_BY = "updatedBy"; /* 更新人*/
public static final String FIELD_UPDATED_NAME = "updatedName"; /* 更新人名称*/
public static final String FIELD_UPDATED_TIME = "updatedTime"; /* 更新时间*/
public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 厂区编码*/
public static final String FIELD_FACTORY_NAME = "factoryName"; /* 厂区名称*/
public static final String FIELD_GROUP_CODE = "groupCode"; /* 生产组编码*/
public static final String FIELD_GROUP_NAME = "groupName"; /* 生产组名称*/
public static final String FIELD_GROUP_TYPE = "groupType"; /* 组类型*/
public static final String FIELD_DELETE_FLAG = "deleteFlag"; /* 是否删除0.否1.是*/
public static final String COL_ID = "ID";
public static final String COL_COMPANY_CODE = "COMPANY_CODE"; /* 企业编码 预留*/
public static final String COL_DEP_CODE = "DEP_CODE"; /* 部门编码 预留*/
public static final String COL_CREATED_BY = "CREATED_BY"; /* 创建人*/
public static final String COL_CREATED_NAME = "CREATED_NAME"; /* 创建人名称*/
public static final String COL_CREATED_TIME = "CREATED_TIME"; /* 创建时间*/
public static final String COL_UPDATED_BY = "UPDATED_BY"; /* 更新人*/
public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 更新人名称*/
public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 更新时间*/
public static final String COL_FACTORY_CODE = "FACTORY_CODE"; /* 厂区编码*/
public static final String COL_FACTORY_NAME = "FACTORY_NAME"; /* 厂区名称*/
public static final String COL_GROUP_CODE = "GROUP_CODE"; /* 生产组编码*/
public static final String COL_GROUP_NAME = "GROUP_NAME"; /* 生产组名称*/
public static final String COL_GROUP_TYPE = "GROUP_TYPE"; /* 组类型*/
public static final String COL_DELETE_FLAG = "DELETE_FLAG"; /* 是否删除0.否1.是*/
public static final String QUERY = "HPPZ011.query";
public static final String COUNT = "HPPZ011.count";
public static final String INSERT = "HPPZ011.insert";
public static final String UPDATE = "HPPZ011.update";
public static final String DELETE = "HPPZ011.delete";
private static final long serialVersionUID = 1L;
private Long id = null;
private String companyCode = " "; /* 企业编码 预留*/
private String depCode = " "; /* 部门编码 预留*/
private String createdBy = " "; /* 创建人*/
private String createdName = " "; /* 创建人名称*/
private String createdTime = " "; /* 创建时间*/
private String updatedBy = " "; /* 更新人*/
private String updatedName = " "; /* 更新人名称*/
private String updatedTime = " "; /* 更新时间*/
private String factoryCode = " "; /* 厂区编码*/
private String factoryName = " "; /* 厂区名称*/
private String groupCode = " "; /* 生产组编码*/
private String groupName = " "; /* 生产组名称*/
private String groupType = " "; /* 组类型*/
private Integer deleteFlag; /* 是否删除0.否1.是*/
/**
* the constructor.
*/
public HPPZ011() {
initMetaData();
}
/**
* initialize the metadata.
*/
public void initMetaData() {
EiColumn eiColumn;
eiColumn = new EiColumn(FIELD_ID);
eiColumn.setPrimaryKey(true);
eiColumn.setDescName("ID");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_COMPANY_CODE);
eiColumn.setDescName("企业编码 预留");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_DEP_CODE);
eiColumn.setDescName("部门编码 预留");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CREATED_BY);
eiColumn.setDescName("创建人");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CREATED_NAME);
eiColumn.setDescName("创建人名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_CREATED_TIME);
eiColumn.setDescName("创建时间");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_UPDATED_BY);
eiColumn.setDescName("更新人");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_UPDATED_NAME);
eiColumn.setDescName("更新人名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_UPDATED_TIME);
eiColumn.setDescName("更新时间");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_FACTORY_CODE);
eiColumn.setDescName("厂区编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_FACTORY_NAME);
eiColumn.setDescName("厂区名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_GROUP_CODE);
eiColumn.setDescName("生产组编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_GROUP_NAME);
eiColumn.setDescName("生产组名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_GROUP_TYPE);
eiColumn.setDescName("组类型");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_DELETE_FLAG);
eiColumn.setDescName("是否删除0.否1.是");
eiMetadata.addMeta(eiColumn);
}
/**
* get the id .
*
* @return the id
*/
public Long getId() {
return this.id;
}
/**
* set the id .
*
* @param id
*/
public void setId(Long id) {
this.id = id;
}
/**
* get the companyCode - 企业编码 预留.
*
* @return the companyCode
*/
public String getCompanyCode() {
return this.companyCode;
}
/**
* set the companyCode - 企业编码 预留.
*
* @param companyCode - 企业编码 预留
*/
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
/**
* get the depCode - 部门编码 预留.
*
* @return the depCode
*/
public String getDepCode() {
return this.depCode;
}
/**
* set the depCode - 部门编码 预留.
*
* @param depCode - 部门编码 预留
*/
public void setDepCode(String depCode) {
this.depCode = depCode;
}
/**
* get the createdBy - 创建人.
*
* @return the createdBy
*/
public String getCreatedBy() {
return this.createdBy;
}
/**
* set the createdBy - 创建人.
*
* @param createdBy - 创建人
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
/**
* get the createdName - 创建人名称.
*
* @return the createdName
*/
public String getCreatedName() {
return this.createdName;
}
/**
* set the createdName - 创建人名称.
*
* @param createdName - 创建人名称
*/
public void setCreatedName(String createdName) {
this.createdName = createdName;
}
/**
* get the createdTime - 创建时间.
*
* @return the createdTime
*/
public String getCreatedTime() {
return this.createdTime;
}
/**
* set the createdTime - 创建时间.
*
* @param createdTime - 创建时间
*/
public void setCreatedTime(String createdTime) {
this.createdTime = createdTime;
}
/**
* get the updatedBy - 更新人.
*
* @return the updatedBy
*/
public String getUpdatedBy() {
return this.updatedBy;
}
/**
* set the updatedBy - 更新人.
*
* @param updatedBy - 更新人
*/
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
/**
* get the updatedName - 更新人名称.
*
* @return the updatedName
*/
public String getUpdatedName() {
return this.updatedName;
}
/**
* set the updatedName - 更新人名称.
*
* @param updatedName - 更新人名称
*/
public void setUpdatedName(String updatedName) {
this.updatedName = updatedName;
}
/**
* get the updatedTime - 更新时间.
*
* @return the updatedTime
*/
public String getUpdatedTime() {
return this.updatedTime;
}
/**
* set the updatedTime - 更新时间.
*
* @param updatedTime - 更新时间
*/
public void setUpdatedTime(String updatedTime) {
this.updatedTime = updatedTime;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryName() {
return factoryName;
}
public void setFactoryName(String factoryName) {
this.factoryName = factoryName;
}
public String getGroupCode() {
return groupCode;
}
public void setGroupCode(String groupCode) {
this.groupCode = groupCode;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getGroupType() {
return groupType;
}
public void setGroupType(String groupType) {
this.groupType = groupType;
}
/**
* get the deleteFlag - 是否删除0.否1.是.
*
* @return the deleteFlag
*/
public Integer getDeleteFlag() {
return this.deleteFlag;
}
/**
* set the deleteFlag - 是否删除0.否1.是.
*
* @param deleteFlag - 是否删除0.否1.是
*/
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
/**
* get the value from Map.
*
* @param map - source data map
*/
@Override
public void fromMap(Map map) {
setId(NumberUtils.toLong(StringUtils.toString(map.get(FIELD_ID)), id));
setCompanyCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_CODE)), companyCode));
setDepCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_DEP_CODE)), depCode));
setCreatedBy(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_BY)), createdBy));
setCreatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_NAME)), createdName));
setCreatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_CREATED_TIME)), createdTime));
setUpdatedBy(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_BY)), updatedBy));
setUpdatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_NAME)), updatedName));
setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime));
setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode));
setFactoryName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_NAME)), factoryName));
setGroupCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_GROUP_CODE)), groupCode));
setGroupName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_GROUP_NAME)), groupName));
setGroupType(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_GROUP_TYPE)), groupType));
setDeleteFlag(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_DELETE_FLAG)), deleteFlag));
}
/**
* set the value to Map.
*/
@Override
public Map toMap() {
Map map = new HashMap();
map.put(FIELD_ID, StringUtils.toString(id, eiMetadata.getMeta(FIELD_ID)));
map.put(FIELD_COMPANY_CODE, StringUtils.toString(companyCode, eiMetadata.getMeta(FIELD_COMPANY_CODE)));
map.put(FIELD_DEP_CODE, StringUtils.toString(depCode, eiMetadata.getMeta(FIELD_DEP_CODE)));
map.put(FIELD_CREATED_BY, StringUtils.toString(createdBy, eiMetadata.getMeta(FIELD_CREATED_BY)));
map.put(FIELD_CREATED_NAME, StringUtils.toString(createdName, eiMetadata.getMeta(FIELD_CREATED_NAME)));
map.put(FIELD_CREATED_TIME, StringUtils.toString(createdTime, eiMetadata.getMeta(FIELD_CREATED_TIME)));
map.put(FIELD_UPDATED_BY, StringUtils.toString(updatedBy, eiMetadata.getMeta(FIELD_UPDATED_BY)));
map.put(FIELD_UPDATED_NAME, StringUtils.toString(updatedName, eiMetadata.getMeta(FIELD_UPDATED_NAME)));
map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME)));
map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE)));
map.put(FIELD_FACTORY_NAME, StringUtils.toString(factoryName, eiMetadata.getMeta(FIELD_FACTORY_NAME)));
map.put(FIELD_GROUP_CODE, StringUtils.toString(groupCode, eiMetadata.getMeta(FIELD_GROUP_CODE)));
map.put(FIELD_GROUP_NAME, StringUtils.toString(groupName, eiMetadata.getMeta(FIELD_GROUP_NAME)));
map.put(FIELD_GROUP_TYPE, StringUtils.toString(groupType, eiMetadata.getMeta(FIELD_GROUP_TYPE)));
map.put(FIELD_DELETE_FLAG, StringUtils.toString(deleteFlag, eiMetadata.getMeta(FIELD_DELETE_FLAG)));
return map;
}
}
package com.baosight.hpjx.hp.pz.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
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.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 厂区管理
*
* @author:songx
* @date:2024/1/18,17:15
*/
public class ServiceHPPZ011 extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
public EiInfo initLoad(EiInfo inInfo) {
try {
Map queryMap = new HashMap();
queryMap.put("orgType", "dept");
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.ORG_RECORD_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.GROUP_RECORD_BLOCK_ID), null);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPPZ011().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询数据列表
*
* @param inInfo
* @return
*/
@Override
public EiInfo query(EiInfo inInfo) {
try {
inInfo = super.query(inInfo, HPPZ011.QUERY, new HPPZ011());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 保存操作.
*
* @param inInfo
* @return
*/
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 数据校验
this.checkSaveData(resultRows);
// 写入数据
for (Map resultRow : resultRows) {
HPPZ011 fPz011 = new HPPZ011();
fPz011.fromMap(resultRow);
if (fPz011.getId() == null || fPz011.getId() == 0) {
this.add(fPz011);
} else {
this.modify(fPz011);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 校验保存的数据
*
* @param resultRows
*/
private void checkSaveData(List<Map> resultRows) {
// 数据校验
for (int i = 0; i < resultRows.size(); i++) {
HPPZ011 fPz011 = new HPPZ011();
fPz011.fromMap(resultRows.get(i));
AssertUtils.isEmpty(fPz011.getFactoryName(), "厂区名称不能为空");
AssertUtils.isEmpty(fPz011.getGroupCode(), "生产组名不能为空");
}
}
/**
* 新增企业信息
*
* @param fPz011
*/
private void add(HPPZ011 fPz011) {
// 校验厂区名是否存在
HPPZ011 dbPz011 = HPPZTools.getPz011ByName(fPz011.getFactoryName());
if (dbPz011 != null) {
fPz011.setFactoryCode(dbPz011.getFactoryCode());
} else {
// 生成厂区编码
fPz011.setFactoryCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.FACTORY_CODE));
}
fPz011.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPPZ011.INSERT, fPz011);
}
/**
* 修改数据
*
* @param fPz011
*/
private void modify(HPPZ011 fPz011) {
DaoUtils.update(HPPZ011.UPDATE, fPz011);
}
/**
* 删除操作
*
* @param inInfo
* @return
*/
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
for (int i = 0; i < resultRows.size(); i++) {
HPPZ011 fPz011 = new HPPZ011();
fPz011.fromMap(resultRows.get(i));
DaoUtils.update(HPPZ011.DELETE, fPz011);
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "修改失败");
}
return inInfo;
}
/**
* @param inInfo
* @return
*/
public EiInfo queryComboBox(EiInfo inInfo) {
try {
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.FACTORY_RECORD_BLOCK_ID);
CommonMethod.initBlock(inInfo, list, new HashMap<>(), false);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询厂区失败");
}
return inInfo;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HPPZ011">
<sql id="column">
ID as "id",
COMPANY_CODE as "companyCode", <!-- 企业编码 预留 -->
DEP_CODE as "depCode", <!-- 部门编码 预留 -->
CREATED_BY as "createdBy", <!-- 创建人 -->
CREATED_NAME as "createdName", <!-- 创建人名称 -->
CREATED_TIME as "createdTime", <!-- 创建时间 -->
UPDATED_BY as "updatedBy", <!-- 更新人 -->
UPDATED_NAME as "updatedName", <!-- 更新人名称 -->
UPDATED_TIME as "updatedTime", <!-- 更新时间 -->
FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
FACTORY_NAME as "factoryName", <!-- 厂区名称 -->
GROUP_CODE as "groupCode", <!-- 生产组编码 -->
GROUP_NAME as "groupName", <!-- 生产组名称 -->
GROUP_TYPE as "groupType" <!-- 组类型 -->
</sql>
<sql id="condition">
AND DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="factoryCode">
FACTORY_CODE = #factoryCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="groupCode">
GROUP_CODE = #groupCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="groupName">
GROUP_NAME LIKE CONCAT('%', #groupName#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="groupType">
GROUP_TYPE = #groupType#
</isNotEmpty>
</sql>
<sql id="getCondition">
<isNotEmpty prepend=" AND " property="factoryName">
FACTORY_NAME = #factoryName#
</isNotEmpty>
</sql>
<sql id="queryCondition">
<isNotEmpty prepend=" AND " property="factoryName">
FACTORY_NAME LIKE CONCAT('%', #factoryName#, '%')
</isNotEmpty>
</sql>
<sql id="order">
<dynamic prepend="ORDER BY">
<isNotEmpty property="order">
$orderBy$
</isNotEmpty>
<isEmpty property="order">
ID ASC
</isEmpty>
</dynamic>
</sql>
<select id="query" resultClass="com.baosight.hpjx.hp.pz.domain.HPPZ011">
SELECT
<include refid="column"/>
FROM ${hpjxSchema}.T_HPPZ011
WHERE 1=1
<include refid="condition"/>
<include refid="queryCondition"/>
<include refid="order"/>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hpjxSchema}.T_HPPZ011 WHERE 1=1
<include refid="condition"/>
<include refid="queryCondition"/>
</select>
<!-- 精确查询 -->
<select id="get" resultClass="com.baosight.hpjx.hp.pz.domain.HPPZ011">
SELECT
<include refid="column"/>
FROM ${hpjxSchema}.T_HPPZ011
WHERE 1=1
<include refid="getCondition"/>
</select>
<insert id="insert">
INSERT INTO ${hpjxSchema}.T_HPPZ011 (
COMPANY_CODE, <!-- 企业编码 预留 -->
DEP_CODE, <!-- 部门编码 预留 -->
FACTORY_CODE, <!-- 厂区编码 -->
FACTORY_NAME, <!-- 厂区名称 -->
GROUP_CODE, <!-- 生产组编码 -->
GROUP_NAME, <!-- 生产组名称 -->
GROUP_TYPE, <!-- 组类型 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 -->
DELETE_FLAG
) VALUES (
#companyCode#, #depCode#, #factoryCode#, #factoryName#, #groupCode#, #groupName#,
#groupType#, #createdBy#, #createdName#, #createdTime#, #deleteFlag#
)
</insert>
<!-- 逻辑删除 -->
<delete id="delete">
UPDATE ${hpjxSchema}.T_HPPZ011 SET DELETE_FLAG = 1 WHERE ID = #id#
</delete>
<update id="update">
UPDATE ${hpjxSchema}.T_HPPZ011
SET
FACTORY_NAME = #factoryName#, <!-- 厂区名称 -->
GROUP_CODE = #groupCode#, <!-- 组编码 -->
GROUP_NAME = #groupName#, <!-- 组名称 -->
GROUP_TYPE = #groupType#, <!-- 组类型 -->
UPDATED_BY = #updatedBy#, <!-- 更新人 -->
UPDATED_NAME = #updatedName#, <!-- 更新人名称 -->
UPDATED_TIME = #updatedTime# <!-- 更新时间 -->
WHERE ID = #id#
</update>
<!-- 厂区下拉框 -->
<select id="queryComboBox" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT DISTINCT
FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
FACTORY_NAME as "factoryName" <!-- 厂区名称 -->
FROM ${hpjxSchema}.T_HPPZ011
WHERE DELETE_FLAG = 0
<include refid="condition"/>
ORDER BY FACTORY_CODE ASC
</select>
<!-- 生产组拉框 -->
<select id="queryGroupComboBox" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT DISTINCT
A.GROUP_CODE as "groupCode", <!-- 组编码 -->
B.ORG_CNAME as "groupName" <!-- 组名称 -->
FROM ${hpjxSchema}.T_HPPZ011 A, ${platSchema}.TXSOG01 B
WHERE A.DELETE_FLAG = 0
AND A.GROUP_CODE = B.ORG_ID
<isNotEmpty prepend=" AND " property="factoryCode">
A.FACTORY_CODE = #factoryCode#
</isNotEmpty>
ORDER BY A.GROUP_CODE ASC
</select>
</sqlMap>
......@@ -2,9 +2,11 @@ package com.baosight.hpjx.hp.pz.tools;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ004;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.domain.HPPZ004;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.util.AssertUtils;
import org.springframework.util.CollectionUtils;
......@@ -122,6 +124,20 @@ public class HPPZTools {
}
/**
* 查询厂区信息
*
* @param factoryName
* @return
*/
public static HPPZ011 getPz011ByName(String factoryName) {
AssertUtils.isEmpty(factoryName, "厂区名称不能为空");
Map queryMap = new HashMap();
queryMap.put("factoryName", factoryName);
List<HPPZ011> dbPz011s = DaoBase.getInstance().query(HPSqlConstant.HPPZ011.GET, queryMap);
return CollectionUtils.isEmpty(dbPz011s) ? null : dbPz011s.get(0);
}
/**
* 企业是否启用
*
* @param companyCode
......
......@@ -98,11 +98,11 @@ public class HPSC004 extends DaoEPBase {
public static final String COL_REMARK = "REMARK"; /* 备注*/
public static final String COL_INVENT_RECORD_ID = "INVENT_RECORD_ID";
public static final String QUERY = "t_hpsc004.query";
public static final String COUNT = "t_hpsc004.count";
public static final String INSERT = "t_hpsc004.insert";
public static final String UPDATE = "t_hpsc004.update";
public static final String DELETE = "t_hpsc004.delete";
public static final String QUERY = "HPSC004.query";
public static final String COUNT = "HPSC004.count";
public static final String INSERT = "HPSC004.insert";
public static final String UPDATE = "HPSC004.update";
public static final String DELETE = "HPSC004.delete";
private Long id = new Long(0);
private String companyCode = " "; /* 企业编码 预留*/
......@@ -495,9 +495,9 @@ public class HPSC004 extends DaoEPBase {
}
/**
* set the prdtCode - 产品编码.
* set the prdtType - 产品编码.
*
* @param prdtCode - 产品编码
* @param prdtType - 产品编码
*/
public void setPrdtType(Integer prdtType) {
this.prdtType = prdtType;
......@@ -662,6 +662,7 @@ public class HPSC004 extends DaoEPBase {
public void setFilePath5(String filePath5) {
this.filePath5 = filePath5;
}
/**
* get the planCommentDate - 计划开始时间.
* @return the planCommentDate
......
package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sc.domain.HPSC003;
import com.baosight.hpjx.hp.sc.domain.HPSC004;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.util.CommonMethod;
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.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.util.DateUtil;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
*
*/
public class ServiceHPSC003 extends ServiceBase {
/**
* 画面初始化.
*/
public EiInfo initLoad(EiInfo inInfo) {
HPSC003 HPSC003 = new HPSC003();
EiInfo outInfo = super.initLoad(inInfo, HPSC003);
outInfo.addBlock(EiConstant.resultBlock).addBlockMeta(HPSC003.eiMetadata);
return inInfo;
}
/**
* 画面初始化.
*
* @param inInfo
* @return
*/
public EiInfo initLoad(EiInfo inInfo) {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_RECORD_BLOCK_ID), null);
HPSC003 HPSC003 = new HPSC003();
EiInfo outInfo = super.initLoad(inInfo, HPSC003);
outInfo.addBlock(EiConstant.resultBlock).addBlockMeta(HPSC003.eiMetadata);
return inInfo;
}
/**
* 查询操作.
......
......@@ -4,38 +4,38 @@
Version : 1.0
schema : hpjx
tableName : T_HPSC004
ID BIGINT NOT NULL primarykey,
COMPANY_CODE VARCHAR NOT NULL,
DEPT_CODE VARCHAR NOT NULL,
PROJ_CODE VARCHAR,
PROJ_NAME VARCHAR,
ID BIGINT NOT NULL primarykey,
COMPANY_CODE VARCHAR NOT NULL,
DEPT_CODE VARCHAR NOT NULL,
PROJ_CODE VARCHAR,
PROJ_NAME VARCHAR,
PARENT_ID VARCHAR,
PARENT_PRDT_NAME VARCHAR,
TYPE VARCHAR NOT NULL,
LEAF VARCHAR NOT NULL,
SORT VARCHAR NOT NULL,
ICON VARCHAR NOT NULL,
PRDT_CODE VARCHAR,
PRDT_NAME VARCHAR,
NUM INTEGER NOT NULL,
UNIT_WT DECIMAL NOT NULL,
TOTAL_WT DECIMAL NOT NULL,
FILE_PATH1 VARCHAR,
FILE_PATH2 VARCHAR,
FILE_PATH3 VARCHAR,
FILE_PATH4 VARCHAR,
FILE_PATH5 VARCHAR,
PLAN_COMMENT_DATE VARCHAR,
PLAN_COMPLETION_DATE VARCHAR,
ACTUAL_COMPLETION_DATE VARCHAR,
ACTUAL_COMPLETION_NUM INTEGER,
ACTUAL_COMPLETION_UNIT_WT DECIMAL,
STATUS TINYINT,
DEL_STATUS TINYINT,
CREATED_BY VARCHAR,
CREATED_TIME DATETIME,
UPDATED_BY VARCHAR,
UPDATED_TIME DATETIME,
PARENT_PRDT_NAME VARCHAR,
TYPE VARCHAR NOT NULL,
LEAF VARCHAR NOT NULL,
SORT VARCHAR NOT NULL,
ICON VARCHAR NOT NULL,
PRDT_CODE VARCHAR,
PRDT_NAME VARCHAR,
NUM INTEGER NOT NULL,
UNIT_WT DECIMAL NOT NULL,
TOTAL_WT DECIMAL NOT NULL,
FILE_PATH1 VARCHAR,
FILE_PATH2 VARCHAR,
FILE_PATH3 VARCHAR,
FILE_PATH4 VARCHAR,
FILE_PATH5 VARCHAR,
PLAN_COMMENT_DATE VARCHAR,
PLAN_COMPLETION_DATE VARCHAR,
ACTUAL_COMPLETION_DATE VARCHAR,
ACTUAL_COMPLETION_NUM INTEGER,
ACTUAL_COMPLETION_UNIT_WT DECIMAL,
STATUS TINYINT,
DEL_STATUS TINYINT,
CREATED_BY VARCHAR,
CREATED_TIME DATETIME,
UPDATED_BY VARCHAR,
UPDATED_TIME DATETIME,
REMARK VARCHAR
-->
<sqlMap namespace="HPSC004">
......@@ -151,7 +151,7 @@
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hpjx.hp.sc.domain.HPSC004">
SELECT
ID as "id",
ID as "id",
COMPANY_CODE as "companyCode", <!-- 企业编码 预留 -->
DEPT_CODE as "deptCode", <!-- 部门编码 预留 -->
PROJ_CODE as "projCode", <!-- 项目编码 -->
......@@ -343,7 +343,11 @@
UPDATED_TIME, <!-- 更新时间 -->
REMARK <!-- 备注 -->
)
VALUES (#id#, #companyCode#, #deptCode#, #projCode#, #projName#, #parentId#, #parentPrdtName#, #type#, #leaf#, #sort#, #icon#,#inventRecordId#, #prdtType#, #prdtCode#, #prdtName#, #num#, #unitWt#, #totalWt#, #filePath1#, #filePath2#, #filePath3#, #filePath4#, #filePath5#, #planCommentDate#, #planCompletionDate#, #actualCompletionDate#, #actualCompletionNum#, #actualCompletionUnitWt#, #status#, #delStatus#, #createdBy#, #createdTime#, #updatedBy#, #updatedTime#, #remark#)
VALUES (#id#, #companyCode#, #deptCode#, #projCode#, #projName#, #parentId#,
#parentPrdtName#, #type#, #leaf#, #sort#, #icon#,#inventRecordId#,
#prdtType#, #prdtCode#, #prdtName#, #num#, #unitWt#, #totalWt#,
#filePath1#, #filePath2#, #filePath3#, #filePath4#, #filePath5#,
#planCommentDate#, #planCompletionDate#, #actualCompletionDate#, #actualCompletionNum#, #actualCompletionUnitWt#, #status#, #delStatus#, #createdBy#, #createdTime#, #updatedBy#, #updatedTime#, #remark#)
</insert>
<delete id="delete">
......
package com.baosight.hpjx.hp.xs.domain;
import java.io.Serializable;
/**
* @author:songx
* @date:2024/1/15,14:50
*/
public class Org implements Serializable {
/**
* 组织ID
*/
private String orgId;
/**
* 组织英文名
*/
private String orgEname;
/**
* 组织中文名
*/
private String orgCname;
/**
* 组织类型
*/
private String orgType;
/**
* 父级组织ID
*/
private String parentOrgId;
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public String getOrgEname() {
return orgEname;
}
public void setOrgEname(String orgEname) {
this.orgEname = orgEname;
}
public String getOrgCname() {
return orgCname;
}
public void setOrgCname(String orgCname) {
this.orgCname = orgCname;
}
public String getOrgType() {
return orgType;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
public String getParentOrgId() {
return parentOrgId;
}
public void setParentOrgId(String parentOrgId) {
this.parentOrgId = parentOrgId;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HPXSOrg">
<sql id="condition">
<isNotEmpty prepend=" AND " property="orgEname">
ORG_ENAME = #orgEname#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgCname">
ORG_CNAME LIKE CONCAT('%', #orgCname#, '%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgId">
ORG_ID = #orgId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgIds">
ORG_ID IN <iterate close=")" open="(" conjunction="," property="orgIds">#orgIds[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgType">
ORG_TYPE = #orgType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="parentOrgId">
PARENT_ORG_ID = #parentOrgId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
</sql>
<sql id="order">
<dynamic prepend="ORDER BY">
<isNotEmpty property="order">
$orderBy$
</isNotEmpty>
<isEmpty property="order">
ORG_ID ASC
</isEmpty>
</dynamic>
</sql>
<!-- 查询组织信息 -->
<select id="query" resultClass="com.baosight.hpjx.hp.xs.domain.Org">
SELECT
ORG_ID as "orgId",
ORG_ENAME as "orgEname",
ORG_CNAME as "orgCname",
ORG_TYPE as "orgType",
PARENT_ORG_ID as "parentOrgId"
FROM ${platSchema}.TXSOG01
WHERE 1=1
<include refid="condition"/>
<include refid="order"/>
</select>
<!-- 统计用户 -->
<select id="count" resultClass="int">
SELECT COUNT(1)
FROM ${platSchema}.TXSOG01
WHERE 1=1
<include refid="condition"/>
</select>
<!-- 查询组织信息 -->
<select id="queryComboBox" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT
ORG_ID as "orgId",
ORG_CNAME as "orgCname"
FROM ${platSchema}.TXSOG01
WHERE 1=1
AND ORG_TYPE IN ('company', 'dept')
<include refid="condition"/>
<include refid="order"/>
</select>
</sqlMap>
package com.baosight.hpjx.util;
/**
* Base64 工具类
*
* @author:songx
* @date:2024/1/29,13:58
*/
public class Base64Utils {
private static final char last2byte = (char) Integer.parseInt("00000011", 2);
private static final char last4byte = (char) Integer.parseInt("00001111", 2);
private static final char last6byte = (char) Integer.parseInt("00111111", 2);
private static final char lead6byte = (char) Integer.parseInt("11111100", 2);
private static final char lead4byte = (char) Integer.parseInt("11110000", 2);
private static final char lead2byte = (char) Integer.parseInt("11000000", 2);
private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
/**
* 编码
*
* @param from
* @return
*/
public static String encode(byte[] from) {
StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
int num = 0;
char currentByte = 0;
int i;
for (i = 0; i < from.length; ++i) {
for (num %= 8; num < 8; num += 6) {
switch (num) {
case 0:
currentByte = (char) (from[i] & lead6byte);
currentByte = (char) (currentByte >>> 2);
case 1:
case 3:
case 5:
default:
break;
case 2:
currentByte = (char) (from[i] & last6byte);
break;
case 4:
currentByte = (char) (from[i] & last4byte);
currentByte = (char) (currentByte << 2);
if (i + 1 < from.length) {
currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
}
break;
case 6:
currentByte = (char) (from[i] & last2byte);
currentByte = (char) (currentByte << 4);
if (i + 1 < from.length) {
currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
}
}
to.append(encodeTable[currentByte]);
}
}
if (to.length() % 4 != 0) {
for (i = 4 - to.length() % 4; i > 0; --i) {
to.append("=");
}
}
return to.toString();
}
}
......@@ -29,6 +29,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static final DateTimeFormatter DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd");
public static final DateTimeFormatter SHORT_MONTH = DateTimeFormatter.ofPattern("yyyyMM");
public static final DateTimeFormatter YEAR_MONTH = DateTimeFormatter.ofPattern("yyyy-MM");
public static final DateTimeFormatter CHINA_DATE = DateTimeFormatter.ofPattern("yyyy年MM月dd月");
/**
* 获取上个月的1号日期
......@@ -79,6 +80,15 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
}
/**
* 获取当前日期
*
* @return
*/
public static String chinaDate() {
return LocalDate.now().format(CHINA_DATE);
}
/**
* 获取日期字符串(yyyyMMdd)
*
* @return
......
package com.baosight.hpjx.util;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
/**
* @author:songx
* @date:2024/1/31,10:36
*/
public class ExcelUtils {
/**
* 下载文件
*
* @param fileName 文件名
* @param workbook excel数据集
* @param response
*/
public static void download(String fileName, HSSFWorkbook workbook, HttpServletResponse response)
throws IOException {
if (workbook == null) {
return;
}
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename*=utf-8''"
+ URLEncoder.encode(fileName, "UTF-8"));
OutputStream os = response.getOutputStream();
workbook.write(os);
os.flush();
os.close();
}
}
package com.baosight.hpjx.util;
import com.baosight.hpjx.core.constant.OSConstant;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 文件工具类
*
* @author:songx
* @date:2016/3/26,11:54
*/
public class FileUtils extends org.apache.commons.io.FileUtils {
/**
* 检查文件是否存在
*
* @param filePath
* @return
*/
public static boolean exists(String filePath) {
Objects.requireNonNull(filePath);
File file = new File(filePath);
return file.exists();
}
/**
* 检查文件是否存在,文件大小等于0不存在
*
* @param filePath
* @return
*/
public static boolean existsEmpty(String filePath) {
Objects.requireNonNull(filePath);
File file = new File(filePath);
return file.exists() && file.length() > 0;
}
/**
* 创建完整的目录
*
* @param filePath
*/
public static boolean createDirs(String filePath) {
Objects.requireNonNull(filePath);
File file = new File(filePath);
if (!file.exists()) {
return file.mkdirs();
}
return true;
}
/**
* 该方法用来判断文件是否存在,如果不存在则创建,该方法能够实现创建整个路径
*
* @param filePath
*/
public static boolean creatFiles(final String filePath) throws IOException {
Objects.requireNonNull(filePath);
String newFilePath = filePath.replace(File.separator, "/");
String dirPath = newFilePath.substring(0, newFilePath.lastIndexOf("/"));
File dirFile = new File(dirPath);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
File file = new File(newFilePath);
if (!file.exists()) {
return file.createNewFile();
}
return true;
}
/**
* 获取文件名称
*
* @param filePath
*/
public static String getFileName(final String filePath) {
Objects.requireNonNull(filePath);
String fileName;
String newFilePath = filePath.replace("/", OSConstant.SEPARATOR);
int index1 = newFilePath.lastIndexOf(".");
if (index1 > -1) {
int index2 = newFilePath.lastIndexOf("?");
if (index2 > index1) {
newFilePath = newFilePath.substring(0, newFilePath.lastIndexOf("?"));
}
int index3 = newFilePath.lastIndexOf(OSConstant.SEPARATOR);
if (index3 > index1) {
fileName = newFilePath.substring(newFilePath.lastIndexOf(OSConstant.SEPARATOR) + 1);
} else {
fileName = newFilePath.substring(newFilePath.lastIndexOf(OSConstant.SEPARATOR) + 1,
newFilePath.lastIndexOf("."));
}
} else {
fileName = newFilePath.substring(newFilePath.lastIndexOf(OSConstant.SEPARATOR) + 1);
}
return fileName;
}
/**
* 获取文件名称包括后缀
*
* @param filePath
* @return
*/
public static String getFileNameAll(final String filePath) {
Objects.requireNonNull(filePath);
String fileName = getFileName(filePath);
if (StringUtils.isEmpty(fileName)) {
return null;
}
String fileType = getFileType(filePath);
return StringUtils.isEmpty(fileType) ? fileName : fileName + "." + fileType;
}
/**
* 获取文件类型
*
* @param filePath
*/
public static String getFileType(final String filePath) {
Objects.requireNonNull(filePath);
int index1 = filePath.lastIndexOf(".");
if (index1 < 1) {
return null;
}
String newFilePath = filePath;
int index2 = newFilePath.lastIndexOf("?");
if (index2 > index1) {
newFilePath = newFilePath.substring(0, newFilePath.lastIndexOf("?"));
}
newFilePath = newFilePath.replace("/", OSConstant.SEPARATOR);
int index3 = newFilePath.lastIndexOf(OSConstant.SEPARATOR);
if (index3 > index1) {
return null;
}
return newFilePath.substring(newFilePath.lastIndexOf(".") + 1).toLowerCase();
}
/**
* 获取文件最后更新时间
*
* @param filePath
* @return
*/
public static String getLastTime(String filePath) {
if (StringUtils.isBlank(filePath)) {
return null;
}
File file = new File(filePath);
long lastModified = file.lastModified();
LocalDateTime dateTime = LocalDateTime.ofEpochSecond(lastModified / 1000, 0, ZoneOffset.ofHours(8));
return dateTime.format(DateUtils.SHORT_DATETIME);
}
/**
* 删除目录及文件
*
* @param file
* @return
*/
public static boolean deleteFiles(File file) {
if (file == null) {
return false;
}
if (file.isDirectory()) {
File[] childless = file.listFiles();
// 递归删除目录中的子目录下
for (File child : childless) {
deleteFiles(child);
}
}
// 删除file
return deleteFile(file);
}
/**
* 删除单个文件或目录
*
* @param path 被删除的文件名
* @return 单个文件删除成功返回true,否则返回false
*/
public static boolean deleteFile(String path) {
Objects.requireNonNull(path);
// 路径为文件且不为空则进行删除
return deleteFile(new File(path));
}
/**
* 删除单个文件或目录
*
* @param file 被删除d的文件
* @return
*/
public static boolean deleteFile(File file) {
Objects.requireNonNull(file);
// 路径为文件且不为空则进行删除
return file.exists() ? file.delete() : false;
}
/**
* java 8 读取文本内容
*
* @param url
* @return
*/
public static List<String> getText8(String url) throws IOException {
try (Stream<String> lines = Files.lines(Paths.get(url))) {
return lines.collect(Collectors.toList());
} catch (IOException e) {
throw e;
}
}
/**
* 写入数据到日志文件
*/
public static void writeLogFile(String filePath, String record) throws IOException {
File file = new File(filePath);
File fileParent = file.getParentFile();
if (!fileParent.exists()) {
fileParent.mkdirs();
}
try (FileWriter fileWriter = new FileWriter(filePath, true);) {
fileWriter.write(record + "\n");
} catch (Exception e) {
throw e;
}
}
/**
* 复制文件
*
* @param filePath
* @param targetPath
* @throws IOException
*/
public static void fileCope(String filePath, String targetPath) throws IOException {
// 获得流
FileInputStream fileInputStream = null;
//新文件输出流
FileOutputStream fileOutputStream = null;
try {
fileInputStream = new FileInputStream(filePath);
File targetFile = new File(targetPath);
//获取父目录
File parentFile = targetFile.getParentFile();
//判断是否存在
if (!parentFile.exists()) {
// 创建父目录文件夹
parentFile.mkdirs();
}
//判断文件是否存在
if (!targetFile.exists()) {
//创建文件
targetFile.createNewFile();
}
fileOutputStream = new FileOutputStream(targetFile);
byte[] buffer = new byte[1024];
int len;
//将文件流信息读取文件缓存区,如果读取结果不为-1就代表文件没有读取完毕,反之已经读取完毕
while ((len = fileInputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, len);
fileOutputStream.flush();
}
} catch (Exception e) {
throw e;
} finally {
if (fileInputStream != null) {
fileInputStream.close();
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
}
}
/**
* 将新的内容加入到文件尾部;是在文件最后一行加入数据
*
* @param filePath
* @param content
*/
public static void append(String filePath, String content) throws IOException {
if (StringUtils.isBlank(content)) {
return;
}
File file = new File(filePath);
try (BufferedWriter output = new BufferedWriter(new FileWriter(file, true))) {
// 空文件的话第一行不用加换行符
if (file.length() == 0) {
output.write(content);
} else {
output.write(System.getProperty("line.separator") + content);
}
} catch (IOException e) {
throw e;
}
}
/**
* 读取文件的内容
*
* @param fileName
* @return
* @throws IOException
*/
public static List<String> readLines(String fileName) throws IOException {
List<String> lines = new ArrayList();
BufferedReader reader = null;
try {
InputStream inputStream = new FileInputStream(fileName);
reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 1024 * 1024 * 5);
String tempString = null;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
lines.add(tempString);
}
reader.close();
inputStream.close();
} catch (Exception e) {
throw e;
} finally {
if (reader != null) {
reader.close();
}
}
return lines;
}
/**
* 获取路径下的所有文件/文件夹
*
* @param rootDir 需要遍历的文件夹路径
* @param isAddDir
* @return
*/
public static List<String> listFilePaths(String rootDir, boolean isAddDir) {
List<String> results = new ArrayList();
File baseFile = new File(rootDir);
if (baseFile.isFile()) {
results.add(rootDir);
return results;
}
File[] files = baseFile.listFiles();
if (files == null || files.length == 0) {
return results;
}
for (File file : files) {
if (file.isDirectory()) {
if (isAddDir) {
results.add(file.getAbsolutePath());
}
results.addAll(listFilePaths(file.getAbsolutePath(), isAddDir));
} else {
results.add(file.getAbsolutePath());
}
}
return results;
}
/**
* 获取路径下的所有文件/文件夹
*
* @param rootDir 需要遍历的文件夹路径
* @param isAddDir
* @return
*/
public static List<File> listFiles(String rootDir, boolean isAddDir) {
List<File> results = new ArrayList();
File baseFile = new File(rootDir);
if (baseFile.isFile()) {
results.add(baseFile);
return results;
}
File[] files = baseFile.listFiles();
if (files == null || files.length == 0) {
return results;
}
for (File file : files) {
if (file.isDirectory()) {
if (isAddDir) {
results.add(file);
}
results.addAll(listFiles(file.getAbsolutePath(), isAddDir));
} else {
results.add(file);
}
}
return results;
}
/**
* 文件大小转换
*
* @param size
* @return
*/
public static String readableFileSize(long size) {
if (size <= 0) {
return "0B";
}
final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#,##0.##").format(size / Math.pow(1024, digitGroups)) + units[digitGroups];
}
/**
* 根据文件路径读取byte[] 数组
*
* @param filePath
* @return
* @throws IOException
*/
public static byte[] readByBytes(String filePath) throws IOException {
File file = new File(filePath);
if (!file.exists()) {
throw new FileNotFoundException(filePath);
}
ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length());
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(file))) {
int bufSize = 1024;
byte[] buffer = new byte[bufSize];
int len1;
while (-1 != (len1 = in.read(buffer, 0, bufSize))) {
bos.write(buffer, 0, len1);
}
return bos.toByteArray();
} finally {
bos.close();
}
}
}
package com.baosight.hpjx.util;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
/**
* httpclient
*
* @author:songx
* @date:2020/6/16,9:48
*/
@Slf4j
public class HttpUtils {
public static final MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
public static final MediaType FORM_MEDIA_TYPE = MediaType.get("application/x-www-form-urlencoded");
/**
* GET请求
*
* @param url
* @return
* @throws IOException
*/
public static String get(String url) throws IOException {
return get(url, null);
}
/**
* GET请求
*
* @param url
* @param header
* @return
* @throws IOException
*/
public static String get(String url, Map<String, String> header) throws IOException {
return request(RequestMethod.GET, url, header, null, JSON_MEDIA_TYPE);
}
/**
* POST请求
*
* @param url
* @return
* @throws IOException
*/
public static String post(String url) throws IOException {
return post(url, null, JSON_MEDIA_TYPE);
}
/**
* POST请求
*
* @param url
* @param param
* @return
* @throws IOException
*/
public static String post(String url, String param, MediaType mediaType) throws IOException {
return post(url, null, param, mediaType);
}
/**
* http请求(post)
*
* @param url
* @param header
* @param param
* @return
*/
public static String post(String url, Map<String, String> header, String param, MediaType mediaType)
throws IOException {
return request(RequestMethod.POST, url, header, param, mediaType);
}
/**
* 发送请求
*
* @param requestMethod 请求类型POST OR GET
* @param url
* @param header
* @param param
* @return
*/
private static String request(RequestMethod requestMethod, String url, Map<String, String> header, String param,
MediaType mediaType) throws IOException {
log.info("请求开始:{},{},{}", url, header, StringUtils.subStr(param, 500));
OkHttpClient okHttpClient = new OkHttpClient();
Request.Builder builder = new Request.Builder().url(url);
if (RequestMethod.POST.equals(requestMethod)) {
builder = builder.post(RequestBody.create(StringUtils.isBlank(param) ? "" : param, mediaType));
} else {
builder = builder.get();
}
if (MapUtils.isNotEmpty(header)) {
builder = builder.headers(Headers.of(header));
}
String result = okHttpClient.newCall(builder.build()).execute().body().string();
log.info("请求结束:{}", StringUtils.subStr(result, 500));
return result;
}
}
package com.baosight.hpjx.util;
import java.util.UUID;
/**
* String 工具类
*
* @author:songx
* @date:2022/8/10,14:17
*/
public class StringUtils extends org.apache.commons.lang3.StringUtils {
/**
* "" is true
* " " is true
* null is true
* "null" or "NULL" is true
*
* @param cs
* @return
*/
public static boolean isNullBlank(CharSequence cs) {
return isBlank(cs) || "null".equalsIgnoreCase(cs.toString());
}
/**
* "" is false
* " " is false
* null is false
* "null" or "NULL" is false
*
* @param cs
* @return
*/
public static boolean isNotNullBlank(CharSequence cs) {
return !isNullBlank(cs);
}
/**
* @param arg0
* @return
*/
public static boolean isNotNull(String arg0) {
if (null != arg0 && arg0.length() > 0) {
return true;
} else {
return false;
}
}
/**
* @param arg0
* @return
*/
public static boolean isNull(String arg0) {
if (null == arg0 || arg0.length() < 1) {
return true;
} else {
return false;
}
}
/**
* 字符串转boolean
*
* @param str
* @return
*/
public static boolean castToBoolean(String str) {
return Boolean.parseBoolean(str);
}
/**
* 字符串转Double
*
* @param str
* @return
*/
public static Double castToDouble(String str) {
Double value;
try {
value = Double.parseDouble(str);
} catch (Exception e) {
value = 0.0;
}
return value;
}
/**
* UUID
*
* @return
*/
public static String uuid() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
/**
* 截取字符串
*
* @param str
* @param endIndex
* @return
*/
public static String subStr(String str, int endIndex) {
if (isBlank(str)) {
return str;
}
return str.length() > endIndex ? str.substring(0, endIndex) : str;
}
}
......@@ -157,7 +157,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
private void initParam(String name, Object parameters) {
// 查询登录用户信息时不设置企业编码,否则会形成死循环
// 仅限业务模块的查询需要设置企业编码
if (name.startsWith("HPXS") || !name.startsWith("HP") || !(parameters instanceof Map)) {
if (name.startsWith("HPXSUser") || !name.startsWith("HP") || !(parameters instanceof Map)) {
return;
}
if (parameters == null) {
......
......@@ -36,7 +36,7 @@
</AsyncLogger>
<logger name="org.springframework" level="ERROR" />
<logger name="org.thymeleaf" level="ERROR" />
<Root level="WARN">
<Root level="INFO">
<AppenderRef ref="Console" />
<AppenderRef ref="MyFile" />
<AppenderRef ref="platLogAppender" />
......
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.baosight.hpjx.hp.kc.tools.CKExcelTools" %>
<%
try {
CKExcelTools.downloadFile(pageContext);
out.clear();
out = pageContext.pushBody();
} catch (Exception e) {
request.setAttribute("iplat_msgKey", "ES001");
request.setAttribute("iplat_msg", "出库单下载失败");
request.setAttribute("iplat_msgDetail", e.toString());
request.getRequestDispatcher("/EU/DM/EUDM30.jsp").forward(request, response);
}
%>
$(function () {
IPLATUI.EFGrid.result = {
pageable: {
pageSize: 20,
pageSizes: [10, 20, 50, 70, 100],
},
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
save();
},
onDelete: function (e) {
// 阻止默认请求,使用自定义删除
e.preventDefault();
deleteFunc();
}
}
// 查询
$("#QUERY").on("click", query);
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 查询
query();
});
/**
* 查询
*/
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPPZ011", "save", true);
}
});
}
/**
* 删除
*/
let deleteFunc = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPPZ011", "delete", true);
}
});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ 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:EFInput cname="厂区名称:" ename="factoryName" blockId="inqu_status" row="0" colWidth="3"/>
<EF:EFSelect cname="生产组名称" ename="groupCode" blockId="inqu_status" row="0" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="group_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="记录集">
<EF:EFGrid blockId="result" autoDraw="override" checkMode="row">
<EF:EFColumn ename="id" cname="主键" hidden="true"/>
<EF:EFColumn ename="factoryCode" cname="厂区编码" enable="false" width="120" align="center"/>
<EF:EFPopupColumn ename="factoryName" cname="厂区名称" width="120" popupType="ServiceGrid"
popupTitle="厂区列表" serviceName="HPPZ011" methodName="queryComboBox"
resultId="factory_record_block_id"
columnEnames="valueField,textField" columnCnames="厂区代码,厂区名称"
backFillColumnIds="valueField,textField" backFillFieldIds="factoryCode,factoryName"
valueField="textField" textField="textField" required="true"/>
<EF:EFComboColumn ename="groupCode" cname="生产组名称" width="120" align="center"
blockName="org_record_block_id" textField="textField" valueField="valueField"
columnTemplate="#=textField#" itemTemplate="#=textField#"
required="true">
</EF:EFComboColumn>
<EF:EFComboColumn ename="groupType" cname="组类型" width="100" align="center" required="true">
<EF:EFCodeOption codeName="hpjx.hppz.groupType"/>
</EF:EFComboColumn>
<EF:EFColumn ename="createdName" cname="创建人" enable="false" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']"/>
<EF:EFColumn ename="updatedName" cname="修改人" enable="false" align="center"/>
<EF:EFColumn ename="updatedTime" cname="修改时间" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
......@@ -72,12 +72,12 @@
<EF:EFOption label="启用" value="1"/>
</EF:EFComboColumn>
<EF:EFColumn enable="false" ename="num" readonly="true" cname="计划数量"/>
<EF:EFColumn enable="false" ename="unitWt" readonly="true" cname="计划重量"/>
<EF:EFColumn ename="planCommentDate" required='true' cname="计划开始时间" editType="date" dateFormat="yyyy/MM/dd" width="150"
/>
<EF:EFColumn ename="planCompletionDate" required='true' cname="计划结束时间" editType="date" dateFormat="yyyy/MM/dd" width="150"
/>
<EF:EFColumn ename="actualCompletionDate" cname="实际完成时间" editType="date" dateFormat="yyyy/MM/dd" width="150"
<EF:EFColumn enable="false" ename="unitWt" readonly="true" cname="计划重量"/>
<EF:EFColumn ename="planCommentDate" required='true' cname="计划开始时间" editType="date" dateFormat="yyyy/MM/dd"
width="150"/>
<EF:EFColumn ename="planCompletionDate" required='true' cname="计划结束时间" editType="date"
dateFormat="yyyy/MM/dd" width="150"/>
<EF:EFColumn ename="actualCompletionDate" cname="实际完成时间" editType="date" dateFormat="yyyy/MM/dd" width="150"
enable="false"/>
<EF:EFColumn enable="false" ename="actualCompletionNum" cname="实际完工数量" readonly="true"/>
<EF:EFColumn enable="false" ename="actualCompletionUnitWt" cname="实际完工重量" readonly="true"/>
......@@ -90,4 +90,4 @@
<script>
var ctx = "${ctx}";
</script>
<script src="${ctx}/HP/SC/HPSC003.js"></script>
\ No newline at end of file
<script src="${ctx}/HP/SC/HPSC003.js"></script>
......@@ -6,20 +6,20 @@
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="组织机构">
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFInput ename="orgCname" cname="组织名称" blockId="inqu_status" row="0"/>
</div>
<%-- <EF:EFButton ename="QUERY" cname="查询" row="1" class="btn-align-right"></EF:EFButton>--%>
</EF:EFRegion>
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFInput ename="factoryCname" cname="厂区名称" blockId="inqu_status" row="0"/>
<EF:EFInput ename="groupName" cname="组织名称" blockId="inqu_status" row="0"/>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="single,row">
<EF:EFColumn ename="orgId" cname="内码" hidden="true"/>
<EF:EFColumn ename="orgEname" cname="组织编码" enable="false" width="130" align="center"/>
<EF:EFColumn cname="组织名称" ename="orgCname" width="100" readonly="false" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="single,row">
<EF:EFColumn ename="orgId" cname="内码" hidden="true"/>
<EF:EFColumn ename="orgEname" cname="组织编码" enable="false" width="130" align="center"/>
<EF:EFColumn ename="orgCname" cname="组织名称" enable="false" width="130" align="center"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
<script>
var ctx = "${ctx}";
......
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