jingwei
parent
402082f038
commit
04a019b5ce
|
@ -688,15 +688,15 @@ $(() => {
|
|||
$(() => {
|
||||
const config = [{
|
||||
// 源字段
|
||||
sourceField: '',
|
||||
sourceField: 'htksrq',
|
||||
// 目标字段
|
||||
targetField: '',
|
||||
targetField: 'htjsrq',
|
||||
// 日期加月份字段
|
||||
numberField: ''
|
||||
numberField: 'contractperiod'
|
||||
}, {
|
||||
sourceField: '',
|
||||
targetField: '',
|
||||
numberField: ''
|
||||
sourceField: 'syqksrq',
|
||||
targetField: 'syqjsrq',
|
||||
numberField: 'probationperiod'
|
||||
}]
|
||||
|
||||
runJs();
|
||||
|
@ -711,22 +711,25 @@ $(() => {
|
|||
let fieldId = WfForm.convertFieldNameToId(configItem.numberField)
|
||||
WfForm.bindFieldChangeEvent(fieldId, (obj, id, value) => {
|
||||
if ("" == value) {
|
||||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField, {value: ""}))
|
||||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField), {value: ""})
|
||||
return
|
||||
}
|
||||
let sourceValue = WfForm.getFieldValue(WfForm.convertFieldNameToId(configItem.sourceField));
|
||||
if ("" == sourceValue) {
|
||||
setTimeout(() => {
|
||||
WfForm.changeFieldValue(fieldId, {value: ""})
|
||||
}, 10)
|
||||
}
|
||||
let date = new Date(sourceValue)
|
||||
date.setMonth(date.getMonth() + +value)
|
||||
let objectDate = new Date();
|
||||
|
||||
|
||||
let day = objectDate.getDate();
|
||||
let month = objectDate.getMonth() + 1;
|
||||
let year = objectDate.getFullYear();
|
||||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField, {
|
||||
let day = date.getDate();
|
||||
let month = date.getMonth() + 1;
|
||||
let year = date.getFullYear();
|
||||
WfForm.changeFieldValue(WfForm.convertFieldNameToId(configItem.targetField), {
|
||||
value: `${year}-${fullNum(month)}-${fullNum(day)}`
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function fullNum(i) {
|
||||
|
|
|
@ -4020,4 +4020,30 @@ public class Util extends weaver.general.Util {
|
|||
return filePath;
|
||||
}
|
||||
|
||||
public static String createTempFile(InputStream inputStream, String imageFileName) {
|
||||
String filePath = getTempFilePath("ofd", imageFileName);
|
||||
try {
|
||||
writeToFile(inputStream, filePath);
|
||||
} catch (IOException e) {
|
||||
throw new CustomerException("create temp file error!", e);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public static void writeToFile(InputStream inputStream, String filePath) throws IOException {
|
||||
Path path = Paths.get(filePath);
|
||||
Path parentDir = path.getParent();
|
||||
if (parentDir != null) {
|
||||
Files.createDirectories(parentDir);
|
||||
}
|
||||
Files.createFile(path);
|
||||
|
||||
try (FileOutputStream outputStream = new FileOutputStream(filePath)) {
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public abstract class SafeCusBaseAction implements Action {
|
|||
}
|
||||
try {
|
||||
Util.verifyRequiredField(this);
|
||||
log.info("action trigger by " + src);
|
||||
if (!Strings.isNullOrEmpty(src)) {
|
||||
src = "submit";
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ public class PdfUtil {
|
|||
FileOutputStream outputStreamTem;
|
||||
try {
|
||||
outputStreamTem = new FileOutputStream(tempPath);
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (Exception e) {
|
||||
throw new CustomerException("创建临时文件流和路径转换失败!", e);
|
||||
}
|
||||
PdfStamper pdfStamper = null;
|
||||
|
|
|
@ -75,6 +75,7 @@ public class OrgChartService {
|
|||
}).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
sortByNameFirstLetter(orgChartNodeVoList);
|
||||
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
|
||||
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
|
||||
OrgChartNodeVo::setChildren,
|
||||
|
@ -85,6 +86,13 @@ public class OrgChartService {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void sortByNameFirstLetter(List<OrgChartNodeVo> nodeList) {
|
||||
nodeList.sort((node1, node2) -> {
|
||||
String name1 = node1.getName();
|
||||
String name2 = node2.getName();
|
||||
return name1.compareToIgnoreCase(name2);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>getOrgChartTreeAll 获取所有的数据并默认展开</h2>
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.poi.xssf.streaming.SXSSFCell;
|
|||
import org.apache.poi.xssf.streaming.SXSSFRow;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.text.DateFormat;
|
||||
|
@ -46,6 +47,8 @@ public class OpenTheBillService {
|
|||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
private final RecordSet res = new RecordSet();
|
||||
|
||||
public Map<String, Object> getOpenBillListData(String startDate, String endDate, String orderNo) {
|
||||
return getData(startDate, endDate, orderNo);
|
||||
}
|
||||
|
@ -150,6 +153,7 @@ public class OpenTheBillService {
|
|||
SXSSFCell cell,
|
||||
SXSSFSheet sheet, Map<Integer, CellStyle> singularLine, Map<Integer, CellStyle> evenNumberLine) {
|
||||
|
||||
|
||||
int columnWidth = sheet.getColumnWidth(colIndex);
|
||||
String value = cell.getStringCellValue();
|
||||
/** 计算字符串中中文字符的数量 */
|
||||
|
@ -160,28 +164,18 @@ public class OpenTheBillService {
|
|||
if (length >= columnWidth && length < 256 * 256) {
|
||||
sheet.setColumnWidth(colIndex, length);
|
||||
}
|
||||
if (rowIndex % 2 == 1) {
|
||||
if (singularLine.containsKey(colIndex)) {
|
||||
return singularLine.get(colIndex);
|
||||
if (singularLine.containsKey(-1)) {
|
||||
return singularLine.get(-1);
|
||||
}
|
||||
CellStyle cellStyle = getCellStyle(workbook, rowIndex, colIndex, cell, sheet);
|
||||
singularLine.put(colIndex, cellStyle);
|
||||
return cellStyle;
|
||||
} else {
|
||||
if (evenNumberLine.containsKey(colIndex)) {
|
||||
return evenNumberLine.get(colIndex);
|
||||
}
|
||||
CellStyle cellStyle = getCellStyle(workbook, rowIndex, colIndex, cell, sheet);
|
||||
// 设置字体格式
|
||||
Font font = workbook.createFont();
|
||||
font.setFontName("微软雅黑");
|
||||
font.setFontHeightInPoints((short) 10);
|
||||
|
||||
CellStyle cellStyle = getCellStyle(workbook, rowIndex, colIndex, cell, sheet);
|
||||
cellStyle.setFont(font);
|
||||
evenNumberLine.put(colIndex, cellStyle);
|
||||
singularLine.put(-1, cellStyle);
|
||||
return cellStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private CellStyle getCellStyle(SXSSFWorkbook workbook, Integer rowIndex, Integer colIndex, SXSSFCell cell, SXSSFSheet sheet) {
|
||||
|
||||
|
@ -232,6 +226,16 @@ public class OpenTheBillService {
|
|||
return count;
|
||||
}
|
||||
|
||||
public Map<String, Object> findMapByField(String filterString, List<Map<String, Object>> list) {
|
||||
for (Map<String, Object> map : list) {
|
||||
if (map.containsKey("field") && map.get("field").equals(filterString)) {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
// 如果找不到匹配的 Map,则返回 null
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Object> getData(String startDate, String endDate, String orderNo) {
|
||||
Map<String, Object> config = Util.readProperties2Map("esteeLauderExcelExport", "export");
|
||||
Assert.notEmpty(config, "esteeLauderExcelExport.properties文件读取配置为空,请检查配置信息");
|
||||
|
@ -246,7 +250,8 @@ public class OpenTheBillService {
|
|||
Util.null2String(config.get("createDate")),
|
||||
condition);
|
||||
} else {
|
||||
dataList = mapper.selectList(Util.null2String(config.get("tableName")));
|
||||
// dataList = mapper.selectList(Util.null2String(config.get("tableName")));
|
||||
dataList = Collections.emptyList();
|
||||
}
|
||||
Object head = config.get("head");
|
||||
Map<String, Object> result = new HashMap<>(16);
|
||||
|
@ -309,6 +314,7 @@ public class OpenTheBillService {
|
|||
if (finalBgm.equals("Y")) {
|
||||
// 都过了bgm
|
||||
for (Map<String, Object> item : list) {
|
||||
item.put(Util.null2String(config.get("additional")), "");
|
||||
item.put(Util.null2String(config.get("openBillKey")), "");
|
||||
}
|
||||
} else {
|
||||
|
@ -319,6 +325,7 @@ public class OpenTheBillService {
|
|||
// 不全部都是y或者n
|
||||
for (Map<String, Object> item : list) {
|
||||
item.put(Util.null2String(config.get("openBillKey")), "全部订单总金额达到GM审批标准,拆分后无法到达GM审批节点。");
|
||||
item.put(Util.null2String(config.get("additional")), "此单为系统判定疑似拆单");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,10 +407,12 @@ public class OpenTheBillService {
|
|||
if (flag) {
|
||||
for (Map<String, Object> item : list) {
|
||||
item.put(Util.null2String(config.get("openBillKey")), "全部订单总金额达到GM审批标准,拆分后无法到达GM审批节点。");
|
||||
item.put(Util.null2String(config.get("additional")), "此单为系统判定疑似拆单");
|
||||
}
|
||||
} else {
|
||||
for (Map<String, Object> item : list) {
|
||||
item.put(Util.null2String(config.get("openBillKey")), "");
|
||||
item.put(Util.null2String(config.get("additional")), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -468,6 +477,7 @@ public class OpenTheBillService {
|
|||
|
||||
|
||||
private void calculationCondition(List<Map<String, Object>> dataList, Map<String, Object> config) {
|
||||
Map<String, Object> convert = (Map<String, Object>) config.get("convert");
|
||||
for (Map<String, Object> map : dataList) {
|
||||
// 订单分类
|
||||
String orderType = Util.null2String(map.get(Util.null2String(config.get("orderType"))));
|
||||
|
@ -500,7 +510,22 @@ public class OpenTheBillService {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
map.put(Util.null2String(config.get("additional")), "");
|
||||
map.put(Util.null2String(config.get("conditionKey")), condition);
|
||||
if (Objects.nonNull(convert)) {
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
if (convert.containsKey(entry.getKey())) {
|
||||
String sql = Util.null2String(convert.get(entry.getKey()));
|
||||
if (StrUtil.isNotBlank(sql)) {
|
||||
res.executeQuery(sql, entry.getValue());
|
||||
if (res.next()) {
|
||||
entry.setValue(res.getInt(1));
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import javax.ws.rs.GET;
|
|||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Context;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -47,8 +48,10 @@ public class SingleSignOnController {
|
|||
Map<String, Object> param = new HashMap<>(8);
|
||||
param.put("user", value);
|
||||
param.put("ts", System.currentTimeMillis());
|
||||
String encrypt = AES.encrypt(key, initVector, JSON.toJSONString(param));
|
||||
response.sendRedirect(url + "?params=" + encrypt);
|
||||
String json = JSON.toJSONString(param);
|
||||
String encrypt = AES.encrypt(key, initVector, json);
|
||||
Util.getLogger().info("加密内容: " + json + " 加密结果: " + encrypt);
|
||||
response.sendRedirect(url + "?params=" + URLEncoder.encode(encrypt, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
log.error("单点登录路径处理失败!" + e.getMessage() + "\n" + Util.getErrString(e));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
package com.engine.yunjinshan.modeDelete.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
|
||||
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
|
||||
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceBefore;
|
||||
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
|
||||
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaBeforeReplaceParam;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.Prop;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.yunjinshan.formmode.action.CostIncomeUpdate;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 云锦山
|
||||
* 建模记录删除方法拦截方法
|
||||
*/
|
||||
@WeaIocReplaceComponent("CubeExpandService")
|
||||
public class DeleteModeDataServiceImp {
|
||||
|
||||
/**
|
||||
* 定义一个当前线程
|
||||
*/
|
||||
private static final ThreadLocal<List<Map<String, String>>> threadLocal = new ThreadLocal<>();
|
||||
|
||||
private final static BaseBean bean = new BaseBean();
|
||||
|
||||
|
||||
/**
|
||||
* 调用删除前 进行方法拦截
|
||||
* 人员成本管理、合同管理建模进行处理
|
||||
*
|
||||
* @param weaBeforeReplaceParam 拦截参数
|
||||
*/
|
||||
@WeaReplaceBefore(value = "/api/cube/expand/deleteData", order = 1, description = "删除建模数据,在数据删除前进行拦截")
|
||||
public void before(WeaBeforeReplaceParam weaBeforeReplaceParam) {
|
||||
// 获取请求参数
|
||||
Map<String, Object> param = weaBeforeReplaceParam.getParamMap();
|
||||
|
||||
bean.writeLog("进入删除拦截:" + JSON.toJSONString(param));
|
||||
// 模块ID
|
||||
String modeId = Util.null2String(param.get("modeId"));
|
||||
// 具体的数据ID
|
||||
String billids = Util.null2String(param.get("billids"));
|
||||
|
||||
// 人力成本管理模块ID
|
||||
String humanCostModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "HumanCostModeId"), "4");
|
||||
// 合同管理模块ID
|
||||
String contractManagementModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "ContractManagementModeId"), "3");
|
||||
|
||||
if ("".equals(humanCostModeId)) {
|
||||
humanCostModeId = "4";
|
||||
}
|
||||
|
||||
if ("".equals(contractManagementModeId)) {
|
||||
contractManagementModeId = "3";
|
||||
}
|
||||
// 人员成本管理、合同管理 建模模块
|
||||
if (contractManagementModeId.equals(modeId) || humanCostModeId.equals(modeId)) {
|
||||
// 将待删除的记录写入临时表
|
||||
String selectData = "";
|
||||
|
||||
bean.writeLog("删除建模数据!模块id: " + modeId);
|
||||
bean.writeLog("删除的数据id: " + billids);
|
||||
|
||||
if (contractManagementModeId.equals(modeId)) {
|
||||
selectData = "select qdny,yjbm,khmc from uf_hetongguanli where id in (" + billids + ")";
|
||||
}
|
||||
|
||||
if (humanCostModeId.equals(modeId)) {
|
||||
selectData = "select ny,yjbm,kh from uf_renlichengben where id in (" + billids + ")";
|
||||
}
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
// 从当前线程中获取已删除的记录
|
||||
List<Map<String, String>> dataList = new ArrayList<>();
|
||||
|
||||
if (rs.executeQuery(selectData)) {
|
||||
while (rs.next()) {
|
||||
// 年月
|
||||
String yearMonth = Util.null2String(rs.getString(1));
|
||||
// 一级部门
|
||||
String superiorDepartment = Util.null2String(rs.getString(2));
|
||||
// 客户
|
||||
String customer = Util.null2String(rs.getString(3));
|
||||
|
||||
Map<String, String> detailMap = new HashMap<>(8);
|
||||
detailMap.put("yearMonth", yearMonth);
|
||||
detailMap.put("superiorDepartment", superiorDepartment);
|
||||
detailMap.put("customer", customer);
|
||||
detailMap.put("modeId", modeId);
|
||||
dataList.add(detailMap);
|
||||
}
|
||||
}
|
||||
|
||||
threadLocal.set(dataList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用删除后 进行方法拦截
|
||||
* 人员成本管理、合同管理建模进行处理
|
||||
*
|
||||
* @param weaAfterReplaceParam 拦截参数
|
||||
*/
|
||||
@WeaReplaceAfter(value = "/api/cube/expand/deleteData", order = 1, description = "删除建模数据,在数据删除后进行拦截,处理特殊业务")
|
||||
public void after(WeaAfterReplaceParam weaAfterReplaceParam) {
|
||||
|
||||
bean.writeLog("----------------删除拦截后!");
|
||||
try {
|
||||
// 从当前线程中获取已删除的记录
|
||||
List<Map<String, String>> dataList = threadLocal.get();
|
||||
|
||||
if (Objects.nonNull(dataList) && dataList.size() > 0) {
|
||||
bean.writeLog("删除的数据信息: " + JSON.toJSONString(dataList));
|
||||
// 人力成本管理模块ID
|
||||
String humanCostModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "HumanCostModeId"), "4");
|
||||
// 合同管理模块ID
|
||||
String contractManagementModeId = Util.null2String(Prop.getPropValue("DeleteModeData", "ContractManagementModeId"), "3");
|
||||
if ("".equals(humanCostModeId)) {
|
||||
humanCostModeId = "4";
|
||||
}
|
||||
if ("".equals(contractManagementModeId)) {
|
||||
contractManagementModeId = "3";
|
||||
}
|
||||
CostIncomeUpdate incomeUpdate = new CostIncomeUpdate();
|
||||
for (Map<String, String> detailMap : dataList) {
|
||||
// 年月
|
||||
String yearMonth = Util.null2String(detailMap.get("yearMonth"));
|
||||
// 一级部门
|
||||
String superiorDepartment = Util.null2String(detailMap.get("superiorDepartment"));
|
||||
// 客户
|
||||
String customer = Util.null2String(detailMap.get("customer"));
|
||||
|
||||
String modeId = Util.null2String(detailMap.get("modeId"));
|
||||
|
||||
if (humanCostModeId.equals(modeId)) {
|
||||
incomeUpdate.updateByHumanCost(yearMonth, superiorDepartment, customer);
|
||||
}
|
||||
if (contractManagementModeId.equals(modeId)) {
|
||||
incomeUpdate.updateByContract(yearMonth, superiorDepartment, customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
bean.writeLog("处理删除数据信息异常!异常信息:" + e.getMessage());
|
||||
} finally {
|
||||
threadLocal.remove();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import com.google.common.base.Strings;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.conn.RecordSet;
|
||||
|
@ -1521,33 +1520,6 @@ public class DealWithMapping extends ToolUtil {
|
|||
if (split.length > 1) {
|
||||
paramStr = Arrays.stream(split).skip(1).collect(Collectors.joining("?"));
|
||||
}
|
||||
/* 获取?后的参数:"weaver.aiyh_jitu.pushdata.service.toones.GetRequestValueCusGetValueImpl?" +
|
||||
"requestType=get&apiOnlyMark=getAssign&valueKey=data&assign=#{main.zd2}&" +
|
||||
"#processorClass=weaver.aiyh_jitu.pushdata.service.toones.GetAssignProcessorProcessorImpl" +
|
||||
"&afterProcessor.hrmId=#{main.zd2}&beforeProcessor.hrmId=#{main.zd2}&高=udh高殿下g" +
|
||||
"&assignValue=#sql{select workcode from hrmresource where id = #{main.zd1} and test = #{h-hah} and a in (${hrmids})}&hah=haode";
|
||||
最终获取到的map,如下
|
||||
key:requestType
|
||||
value:get
|
||||
key:apiOnlyMark
|
||||
value:getAssign
|
||||
key:valueKey
|
||||
value:data
|
||||
key:assign
|
||||
value:#{main.zd2}
|
||||
key:#processorClass
|
||||
value:weaver.aiyh_jitu.pushdata.service.toones.GetAssignProcessorProcessorImpl
|
||||
key:afterProcessor.hrmId
|
||||
value:#{main.zd2}
|
||||
key:beforeProcessor.hrmId
|
||||
value:#{main.zd2}
|
||||
key:高
|
||||
value:udh高殿下g
|
||||
key:assignValue
|
||||
value:#sql{select workcode from hrmresource where id = #{main.zd1} and test = #{h-hah} and a in (${hrmids})}
|
||||
key:hah
|
||||
value:haode*/
|
||||
// 最终通过反射调用weaver.aiyh_jitu.pushdata.service.GetAssignProcessorProcessorImpl类,将参数传递给这个类, 使用``包裹的字符串会被解析为一个字符串
|
||||
String pattern = "&?(?<key>([#.\\w\\u4E00-\\u9FA5]+))=" +
|
||||
"(?<value>((`([^`]*)`)|" +
|
||||
"((#(\\{|sql\\{))?([():/\\-$_#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?";
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package weaver.youhong.ai.geerde.action.submitfirst;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.action.SafeCusBaseAction;
|
||||
import aiyh.utils.annotation.ActionDesc;
|
||||
import aiyh.utils.annotation.ActionOptionalParam;
|
||||
import aiyh.utils.annotation.PrintParamMark;
|
||||
import aiyh.utils.annotation.RequiredMark;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.youhong.ai.geerde.action.submitfirst.mapper.AutoSubmitFirstMapper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>自动提交第一次经过节点的流程</h1>
|
||||
*
|
||||
* <p>create: 2023/5/17 18:52</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@ActionDesc(author = "youhong.ai", value = "自动流程提交,需要挂在需要提交的流程节点的节点前或者前一个节点的节点后或者两个节点的流转出口线上")
|
||||
public class AutoSubmitFirstAction extends SafeCusBaseAction {
|
||||
|
||||
private final AutoSubmitFirstMapper mapper = Util.getMapper(AutoSubmitFirstMapper.class);
|
||||
|
||||
@RequiredMark(value = "account", desc = "主表流程经过标识字段,整数或单行文本字段名都可以")
|
||||
@PrintParamMark
|
||||
private String accountField;
|
||||
|
||||
@ActionOptionalParam(value = "1", desc = "流程操作人id,默认为1-系统管理员")
|
||||
@PrintParamMark
|
||||
private String operator = "1";
|
||||
|
||||
@Override
|
||||
|
||||
public void doSubmit(String requestId, String billTable,
|
||||
int workflowId, User user,
|
||||
RequestInfo requestInfo) {
|
||||
Map<String, String> mainTableValue = getMainTableValue(requestInfo);
|
||||
log.info("do submit action!");
|
||||
if (mainTableValue.containsKey(accountField)) {
|
||||
if (StrUtil.isNotBlank(mainTableValue.get(accountField))) {
|
||||
return;
|
||||
}
|
||||
String creatorId = requestInfo.getCreatorid();
|
||||
mapper.updateMark(billTable, accountField, "1",
|
||||
mainTableValue.get("id"));
|
||||
Util.submitWorkflowThread(Integer.parseInt(requestId), Integer.parseInt(creatorId),
|
||||
"");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package weaver.youhong.ai.geerde.action.submitfirst.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
import aiyh.utils.annotation.recordset.Update;
|
||||
|
||||
/**
|
||||
* <h1>自动提交流程标识更新</h1>
|
||||
*
|
||||
* <p>create: 2023/5/17 18:56</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@SqlMapper
|
||||
public interface AutoSubmitFirstMapper {
|
||||
|
||||
@Update("update $t{tableName} set $t{fieldName} = #{value} where id = #{id}")
|
||||
boolean updateMark(@ParamMapper("tableName") String tableName,
|
||||
@ParamMapper("fieldName") String fieldName,
|
||||
@ParamMapper("value") String value,
|
||||
@ParamMapper("id") String id);
|
||||
}
|
|
@ -87,8 +87,9 @@ public class CaElectronicSignatureAction extends SafeCusBaseAction {
|
|||
throw new CustomerException(responeVo.getCode() + ", fetch ca sign fail! ");
|
||||
}
|
||||
Map<String, Object> responseMap = responeVo.getResponseMap();
|
||||
String documentNo = Util.null2String(responseMap.get("document_no"));
|
||||
String pdf = Util.null2String(responseMap.get("ofd"));
|
||||
Map<String, Object> data = (Map<String, Object>) responseMap.get("data");
|
||||
String documentNo = Util.null2String(data.get("document_no"));
|
||||
String pdf = Util.null2String(data.get("ofd"));
|
||||
InputStream inputStream = base64ContentToFile(pdf);
|
||||
String docCategorys = Util.getDocCategorysByTable(String.valueOf(workflowId), signFileField, billTable);
|
||||
String[] docCategoryArr = docCategorys.split(",");
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package weaver.youhong.ai.intellectualproperty.cusgetvalue;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.entity.DocImageInfo;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
|
||||
import weaver.youhong.ai.intellectualproperty.util.OFDReader;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>获取关键字页码</h1>
|
||||
*
|
||||
* <p>create: 2023/5/18 16:56</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class GetOfdKeywordPageValue implements CusInterfaceGetValue {
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
@Override
|
||||
public Object execute(Map<String, Object> mainMap, Map<String, Object> detailMap, String currentValue, Map<String, String> pathParam) {
|
||||
try {
|
||||
|
||||
DocImageInfo docImageInfo = Util.selectImageInfoByDocId(currentValue);
|
||||
InputStream inputStream = ImageFileManager.getInputStreamById(docImageInfo.getImageFileId());
|
||||
String filePath = Util.createTempFile(inputStream, docImageInfo.getImageFileName());
|
||||
String keywordType = pathParam.get("keywordType");
|
||||
String keywordValue = "";
|
||||
String keyword = pathParam.get("keyword");
|
||||
if (StrUtil.isNotBlank(keywordType)) {
|
||||
if ("1".equals(keywordType)) {
|
||||
keywordValue = Util.null2String(mainMap.get(keyword));
|
||||
}
|
||||
} else {
|
||||
keywordValue = keyword;
|
||||
}
|
||||
OFDReader reader = new OFDReader(filePath, keywordValue);
|
||||
List<OFDReader.KeywordInfo> keywordInfos = reader.findKeywords();
|
||||
if (keywordInfos.isEmpty()) {
|
||||
throw new CustomerException("关键字定位异常!未找到关键字");
|
||||
} else {
|
||||
return keywordInfos.get(0).getPageNumber();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("关键字定位异常: " + Util.getErrString(e));
|
||||
throw new CustomerException("关键字定位异常!", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package weaver.youhong.ai.intellectualproperty.util;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* <h2>ofd读区关键字</h2>
|
||||
*/
|
||||
public class OFDReader {
|
||||
|
||||
private final String ofdFilePath;
|
||||
private final String keyword;
|
||||
|
||||
public OFDReader(String ofdFilePath, String keyword) {
|
||||
this.ofdFilePath = ofdFilePath;
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public List<KeywordInfo> findKeywords() throws Exception {
|
||||
// 解析OFD.xml文件,获取OFD的根目录路径
|
||||
String rootDirPath = parseOFDXmlAndGetRootDirPath();
|
||||
if (rootDirPath == null) {
|
||||
throw new Exception("Failed to parse OFD.xml file!");
|
||||
}
|
||||
|
||||
// 打开OFD文件并获取ZipFile对象
|
||||
ZipFile zipFile = new ZipFile(ofdFilePath);
|
||||
|
||||
// 获取Pages目录下的所有页面文件夹
|
||||
List<String> pageFolders = getPageFolders(zipFile, rootDirPath);
|
||||
if (pageFolders == null || pageFolders.isEmpty()) {
|
||||
throw new Exception("No page found in the OFD file!");
|
||||
}
|
||||
|
||||
// 查找所有关键字的位置信息
|
||||
List<KeywordInfo> result = new ArrayList<>();
|
||||
for (String pageFolder : pageFolders) {
|
||||
KeywordInfo keywordInfo = findKeywordInPage(zipFile, pageFolder);
|
||||
if (keywordInfo != null) {
|
||||
result.add(keywordInfo);
|
||||
}
|
||||
}
|
||||
|
||||
zipFile.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
// 解析OFD.xml文件并获取OFD的根目录路径
|
||||
private String parseOFDXmlAndGetRootDirPath() throws Exception {
|
||||
ZipFile zipFile = new ZipFile(ofdFilePath);
|
||||
ZipEntry ofdXmlEntry = zipFile.getEntry("OFD.xml");
|
||||
InputStream inputStream = zipFile.getInputStream(ofdXmlEntry);
|
||||
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
|
||||
NodeList docRootNodes = doc.getElementsByTagName("ofd:DocRoot");
|
||||
if (docRootNodes.getLength() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String docRootPath = docRootNodes.item(0).getTextContent();
|
||||
String[] docRootPathSegments = docRootPath.split("/");
|
||||
if (docRootPathSegments.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return docRootPathSegments[0];
|
||||
}
|
||||
|
||||
// 获取Pages目录下的所有页面文件夹
|
||||
private List<String> getPageFolders(ZipFile zipFile, String rootDirPath) {
|
||||
List<String> pageFolders = new ArrayList<>();
|
||||
String pagesDirPath = rootDirPath + "/Pages/";
|
||||
|
||||
// 遍历OFD文件中所有的ZipEntry对象,查找所有页面文件夹
|
||||
zipFile.stream().forEach(entry -> {
|
||||
if (entry.getName().startsWith(pagesDirPath) && entry.isDirectory() && !entry.getName().equals(pagesDirPath)) {
|
||||
pageFolders.add(entry.getName());
|
||||
}
|
||||
});
|
||||
|
||||
return pageFolders;
|
||||
}
|
||||
|
||||
// 在指定页面中查找关键字
|
||||
private KeywordInfo findKeywordInPage(ZipFile zipFile, String pageFolder) throws Exception {
|
||||
ZipEntry contentXmlEntry = zipFile.getEntry(pageFolder + "Content.xml");
|
||||
InputStream inputStream = zipFile.getInputStream(contentXmlEntry);
|
||||
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
|
||||
NodeList textNodes = doc.getElementsByTagName("ofd:TextObject");
|
||||
|
||||
for (int i = 0; i < textNodes.getLength(); i++) {
|
||||
Node textNode = textNodes.item(i);
|
||||
String textContent = textNode.getTextContent();
|
||||
|
||||
if (textContent.contains(keyword)) {
|
||||
Node boundaryNode = textNode.getAttributes().getNamedItem("Boundary");
|
||||
String boundary = boundaryNode.getNodeValue();
|
||||
String[] boundarySegments = boundary.split(" ");
|
||||
|
||||
double x = Double.parseDouble(boundarySegments[0]);
|
||||
double y = Double.parseDouble(boundarySegments[1]);
|
||||
double width = Double.parseDouble(boundarySegments[2]);
|
||||
double height = Double.parseDouble(boundarySegments[3]);
|
||||
|
||||
KeywordInfo keywordInfo = new KeywordInfo(pageFolder, x, y, width, height);
|
||||
return keywordInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class KeywordInfo {
|
||||
private final String pageFolder;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double width;
|
||||
private final double height;
|
||||
|
||||
public KeywordInfo(String pageFolder, double x, double y, double width, double height) {
|
||||
this.pageFolder = pageFolder;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public String getPageNumber() {
|
||||
int pageNumber = Integer.parseInt(pageFolder.substring(pageFolder.lastIndexOf('_') + 1, pageFolder.length() - 1));
|
||||
return String.valueOf(pageNumber);
|
||||
}
|
||||
|
||||
public String getBoundingBox() {
|
||||
return "(" + x + ", " + y + ", " + width + ", " + height + ")";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package weaver.yunjinshan.formmode.action;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.soa.workflow.request.MainTableInfo;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 云锦山
|
||||
* 合同管理模块 新建、编辑保存和导入时,自定义扩展功能
|
||||
*/
|
||||
public class ContractExpandAction extends AbstractModeExpandJavaCodeNew {
|
||||
|
||||
/**
|
||||
* 模块主表名称
|
||||
*/
|
||||
private final static String modeTableName = "uf_hetongguanli";
|
||||
|
||||
/**
|
||||
* 浮点数格式化
|
||||
*/
|
||||
private final DecimalFormat df = new DecimalFormat("##############################0.0000");
|
||||
|
||||
/**
|
||||
* 执行模块扩展动作
|
||||
* @param param
|
||||
* param包含(但不限于)以下数据
|
||||
* user 当前用户
|
||||
* importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加,2覆盖,3更新,获取方式(int)param.get("importtype")
|
||||
* 导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输),比如a=1,可通过param.get("a")获取参数值
|
||||
* 页面链接拼接的参数,比如b=2,可以通过param.get("b")来获取参数
|
||||
* @return 返回执行结果
|
||||
*/
|
||||
public Map<String, String> doModeExpand(Map<String, Object> param) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
try {
|
||||
BaseBean bean = new BaseBean();
|
||||
|
||||
bean.writeLog("-------------ContractExpandAction Begin----------------");
|
||||
|
||||
bean.writeLog("param:[" + param.toString() + "]");
|
||||
|
||||
int billid;//数据id
|
||||
int modeid;//模块id
|
||||
RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo");
|
||||
if (requestInfo != null) {
|
||||
billid = Util.getIntValue(requestInfo.getRequestid());
|
||||
modeid = Util.getIntValue(requestInfo.getWorkflowid());
|
||||
|
||||
bean.writeLog("billid:[" + billid + "],modeid:[" + modeid + "]");
|
||||
|
||||
if (billid > 0 && modeid > 0) {
|
||||
//String selectData = "select * from " + modeTableName + " where id = ?";
|
||||
|
||||
//年月
|
||||
String yearMonth = "";
|
||||
//一级部门
|
||||
String superiorDepartment = "";
|
||||
//客户
|
||||
String customer = "";
|
||||
|
||||
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
|
||||
|
||||
for(Property p : mainTableInfo.getProperty()){
|
||||
if("qdny".equalsIgnoreCase(p.getName())) {
|
||||
yearMonth = p.getValue();
|
||||
}
|
||||
|
||||
if("yjbm".equalsIgnoreCase(p.getName())){
|
||||
superiorDepartment = p.getValue();
|
||||
}
|
||||
if("khmc".equalsIgnoreCase(p.getName())){
|
||||
customer = p.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
RecordSet rs = new RecordSet();
|
||||
if(rs.executeQuery(selectData,billid)){
|
||||
if(rs.next()){
|
||||
yearMonth = Util.null2String(rs.getString("qdny"));
|
||||
superiorDepartment = Util.null2String(rs.getString("yjbm"));
|
||||
customer = Util.null2String(rs.getString("khmc"));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
CostIncomeUpdate incomeUpdate = new CostIncomeUpdate();
|
||||
incomeUpdate.updateByContract(yearMonth,superiorDepartment,customer);
|
||||
}
|
||||
}
|
||||
bean.writeLog("-------------ContractExpandAction End----------------");
|
||||
result.put("flag", "true");
|
||||
} catch (Exception e) {
|
||||
result.put("errmsg",e.getMessage());
|
||||
result.put("flag", "false");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package weaver.yunjinshan.formmode.action;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* 云锦山
|
||||
* 成本收入更新操作
|
||||
*/
|
||||
public class CostIncomeUpdate {
|
||||
|
||||
private final static String contractModeTableName = "uf_hetongguanli";
|
||||
|
||||
private final static BaseBean bean = new BaseBean();
|
||||
|
||||
private final static RecordSet rs = new RecordSet();
|
||||
|
||||
/**
|
||||
* 浮点数格式化
|
||||
*/
|
||||
private final DecimalFormat df = new DecimalFormat("##############################0.0000");
|
||||
|
||||
/**
|
||||
* 根据合同管理 变更成本收入
|
||||
*
|
||||
* @param yearMonth 年月
|
||||
* @param superiorDepartment 一级部门
|
||||
* @param customer 客户
|
||||
*/
|
||||
public void updateByContract(String yearMonth, String superiorDepartment, String customer) {
|
||||
bean.writeLog("yearMonth:[" + yearMonth + "],superiorDepartment:[" + superiorDepartment + "],customer:[" + customer + "]");
|
||||
|
||||
// 合同金额合计
|
||||
double contractAmount = 0.0;
|
||||
// 收款金额合计
|
||||
double receivableAmount = 0.0;
|
||||
// 开票金额合计
|
||||
double invoiceAmount = 0.0;
|
||||
// 获取该模块相同年月、一级部门、客户的合同金额合计
|
||||
String selectData = "select sum(isnull(htje,0.0)) from " + contractModeTableName + " where qdny = ? and yjbm = ? and khmc = ?";
|
||||
|
||||
if (rs.executeQuery(selectData, yearMonth, superiorDepartment, customer)) {
|
||||
if (rs.next()) {
|
||||
contractAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
selectData = "select sum(isnull(dt.ysje,0.0)) from " + contractModeTableName + "_dt1 dt inner join " + contractModeTableName + " m on dt.mainId = m.id " +
|
||||
"where m.yjbm = ? and m.khmc = ? and (dt.skrq is not null and substring(dt.skrq,1,7) = ?)";
|
||||
|
||||
if (rs.executeQuery(selectData, superiorDepartment, customer, yearMonth) && rs.next()) {
|
||||
receivableAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||
}
|
||||
|
||||
selectData = "select sum(isnull(dt.jshjje,0.0)) from " + contractModeTableName + "_dt2 dt inner join " + contractModeTableName + " m on dt.mainId = m.id " +
|
||||
"where m.yjbm = ? and m.khmc = ? and (dt.kprq is not null and substring(dt.kprq,1,7) = ?)";
|
||||
|
||||
if (rs.executeQuery(selectData, superiorDepartment, customer, yearMonth) && rs.next()) {
|
||||
invoiceAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||
}
|
||||
|
||||
String updateSQL = "update uf_chengbenshouru set yqhtjekkpje = " + df.format(contractAmount) + "," +
|
||||
"yskje = " + df.format(receivableAmount) + "," +
|
||||
"ykpjehs = " + df.format(invoiceAmount) +
|
||||
" where ny = ? and yjbm = ? and kh = ?";
|
||||
|
||||
boolean isSuccess = rs.executeUpdate(updateSQL, yearMonth, superiorDepartment, customer);
|
||||
|
||||
bean.writeLog("updateSQL:[" + updateSQL + "],执行结果:[" + isSuccess + "]");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据人力成本更新成本收入
|
||||
*
|
||||
* @param yearMonth 年月
|
||||
* @param superiorDepartment 一级部门
|
||||
* @param customer 客户名称
|
||||
*/
|
||||
public void updateByHumanCost(String yearMonth, String superiorDepartment, String customer) {
|
||||
bean.writeLog("yearMonth:[" + yearMonth + "],superiorDepartment:[" + superiorDepartment + "],customer:[" + customer + "]");
|
||||
|
||||
double totalAmount = 0.0;
|
||||
String selectData = "select sum(isnull(gszzffy,0.0)) from uf_renlichengben where ny = ? and yjbm = ? and kh = ?";
|
||||
|
||||
if (rs.executeQuery(selectData, yearMonth, superiorDepartment, customer)) {
|
||||
if (rs.next()) {
|
||||
totalAmount = Util.getDoubleValue(rs.getString(1), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
String updateSQL = "update uf_chengbenshouru set rycb = " + df.format(totalAmount) + " where ny = ? and yjbm = ? and kh = ?";
|
||||
|
||||
boolean isSuccess = rs.executeUpdate(updateSQL, yearMonth, superiorDepartment, customer);
|
||||
|
||||
bean.writeLog("updateSQL:[" + updateSQL + "],执行结果:[" + isSuccess + "]");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package weaver.yunjinshan.formmode.action;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.soa.workflow.request.MainTableInfo;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 云锦山
|
||||
* 人力成本建模 新建、编辑保存和导入数据时,自定义扩展操作
|
||||
*/
|
||||
public class HumanCostExpandAction extends AbstractModeExpandJavaCodeNew {
|
||||
|
||||
private final DecimalFormat df = new DecimalFormat("##############################0.0000");
|
||||
|
||||
/**
|
||||
* 执行模块扩展动作
|
||||
* @param param
|
||||
* param包含(但不限于)以下数据
|
||||
* user 当前用户
|
||||
* importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加,2覆盖,3更新,获取方式(int)param.get("importtype")
|
||||
* 导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输),比如a=1,可通过param.get("a")获取参数值
|
||||
* 页面链接拼接的参数,比如b=2,可以通过param.get("b")来获取参数
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> doModeExpand(Map<String, Object> param) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
try {
|
||||
BaseBean bean = new BaseBean();
|
||||
|
||||
bean.writeLog("-------------HumanCostExpandAction Begin----------------");
|
||||
|
||||
bean.writeLog("param:[" + param.toString() + "]");
|
||||
|
||||
int billid = -1;//数据id
|
||||
int modeid = -1;//模块id
|
||||
RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
|
||||
if(requestInfo!=null){
|
||||
billid = Util.getIntValue(requestInfo.getRequestid());
|
||||
modeid = Util.getIntValue(requestInfo.getWorkflowid());
|
||||
|
||||
bean.writeLog("billid:[" + billid + "],modeid:[" + modeid + "]");
|
||||
if(billid>0&&modeid>0){
|
||||
//年月
|
||||
String yearMonth = "";
|
||||
//一级部门
|
||||
String superiorDepartment = "";
|
||||
//客户
|
||||
String customer = "";
|
||||
|
||||
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
|
||||
|
||||
for(Property p : mainTableInfo.getProperty()){
|
||||
if("ny".equalsIgnoreCase(p.getName())) {
|
||||
yearMonth = p.getValue();
|
||||
}
|
||||
|
||||
if("yjbm".equalsIgnoreCase(p.getName())){
|
||||
superiorDepartment = p.getValue();
|
||||
}
|
||||
if("kh".equalsIgnoreCase(p.getName())){
|
||||
customer = p.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//查询该记录对应的信息
|
||||
String selectData = "select * from uf_renlichengben where id = ?";
|
||||
|
||||
if(rs.executeQuery(selectData,billid)){
|
||||
if(rs.next()){
|
||||
yearMonth = Util.null2String(rs.getString("ny"));
|
||||
superiorDepartment = Util.null2String(rs.getString("yjbm"));
|
||||
customer = Util.null2String(rs.getString("kh"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bean.writeLog("yearMonth:[" + yearMonth + "],superiorDepartment:[" + superiorDepartment + "],customer:[" + customer + "]");
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
double totalAmount = 0.0;
|
||||
String selectData = "select sum(isnull(gszzffy,0.0)) from uf_renlichengben where ny = ? and yjbm = ? and kh = ?";
|
||||
|
||||
if(rs.executeQuery(selectData,yearMonth,superiorDepartment,customer)){
|
||||
if(rs.next()){
|
||||
totalAmount = Util.getDoubleValue(rs.getString(1),0.0);
|
||||
}
|
||||
}
|
||||
|
||||
String updateSQL = "update uf_chengbenshouru set rycb = " + df.format(totalAmount) + " where ny = ? and yjbm = ? and kh = ?";
|
||||
|
||||
boolean isSuccess = rs.executeUpdate(updateSQL,yearMonth,superiorDepartment,customer);
|
||||
|
||||
bean.writeLog("updateSQL:[" + updateSQL + "],执行结果:[" + isSuccess + "]");
|
||||
*/
|
||||
|
||||
CostIncomeUpdate incomeUpdate = new CostIncomeUpdate();
|
||||
incomeUpdate.updateByHumanCost(yearMonth,superiorDepartment,customer);
|
||||
}
|
||||
}
|
||||
|
||||
result.put("flag", "true");
|
||||
|
||||
bean.writeLog("-------------HumanCostExpandAction End----------------");
|
||||
} catch (Exception e) {
|
||||
result.put("errmsg","自定义出错信息");
|
||||
result.put("flag", "false");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
#修改当前配置文件后需要重启, you must restart service at change the config file after
|
||||
#
|
||||
# 当前需要同步的语言, current active language
|
||||
cus.multilingual.active=ZHS,IDN
|
||||
cus.multilingual.active="ZHS,IDN"
|
||||
#中文
|
||||
cus.multilingual.ZHS=7
|
||||
#印尼
|
||||
|
|
|
@ -18,6 +18,8 @@ export.createType=yyyy-MM-dd
|
|||
export.costCenter=cbzxyh
|
||||
# 条件key
|
||||
export.conditionKey=condition
|
||||
#附加信息
|
||||
export.additional=ddsm
|
||||
#流水号-requestId
|
||||
export.requestId=lcid
|
||||
# bgm字段
|
||||
|
@ -41,72 +43,114 @@ export.sku=sku
|
|||
#导出表头设置
|
||||
export.head.title[0]=序号
|
||||
export.head.field[0]=no
|
||||
export.head.title[1]=分组编号
|
||||
export.head.field[1]=groupId
|
||||
export.head.title[2]=ID
|
||||
export.head.field[2]=id
|
||||
export.head.title[3]=条件
|
||||
export.head.field[3]=condition
|
||||
export.head.title[4]=疑似拆单
|
||||
export.head.field[4]=openBill
|
||||
export.head.title[5]=流水号
|
||||
export.head.field[5]=lcid
|
||||
export.head.title[6]=shipTo
|
||||
export.head.field[6]=shipto
|
||||
export.head.title[7]=推送时间
|
||||
export.head.field[7]=insertTime
|
||||
export.head.title[8]=审批开始时间
|
||||
export.head.field[8]=createdate
|
||||
export.head.title[9]=申请提交时间
|
||||
export.head.field[9]=sqtjrq
|
||||
export.head.title[10]=审批开始时间
|
||||
export.head.field[10]=LASTOPERATEDATE
|
||||
export.head.title[11]=收方限制
|
||||
export.head.field[11]=ddlxms
|
||||
export.head.title[12]=部门团队
|
||||
export.head.field[12]=SPART
|
||||
export.head.title[13]=品牌部门
|
||||
export.head.field[13]=yjpp
|
||||
export.head.title[14]=订单编号
|
||||
export.head.field[14]=ddbh
|
||||
export.head.title[15]=订单说明
|
||||
export.head.field[15]=ddsm
|
||||
export.head.title[16]=备注
|
||||
export.head.field[16]=bz
|
||||
export.head.title[17]=成本中心-sap
|
||||
export.head.field[17]=KOSTL
|
||||
export.head.title[18]=成本中心-用户
|
||||
export.head.field[18]=cbzxyh
|
||||
export.head.title[19]=财务科目
|
||||
export.head.field[19]=cwkm
|
||||
export.head.title[20]=审批开始时间
|
||||
export.head.field[20]=LASTOPERATEDATE
|
||||
export.head.title[21]=活动编号
|
||||
export.head.field[21]=hdbh
|
||||
export.head.title[22]=businessKey
|
||||
export.head.field[22]=businesskey
|
||||
export.head.title[23]=申请人
|
||||
export.head.field[23]=SQRRLZY
|
||||
export.head.title[24]=订单类型
|
||||
export.head.field[24]=AUART
|
||||
export.head.title[25]=订单用途
|
||||
export.head.field[25]=VKAUS
|
||||
export.head.title[26]=收货人
|
||||
export.head.field[26]=KUNNRSHIPTO
|
||||
export.head.title[27]=收货人地址
|
||||
export.head.field[27]=shdz
|
||||
export.head.title[28]=收货编号
|
||||
export.head.field[28]=hwbh
|
||||
export.head.title[29]=收货类型
|
||||
export.head.field[29]=fl
|
||||
export.head.title[30]=收货中文名
|
||||
export.head.field[30]=ZWMS
|
||||
export.head.title[31]=数量
|
||||
export.head.field[31]=SL
|
||||
export.head.title[32]=零售总额
|
||||
export.head.field[32]=kxpmxzlsj
|
||||
export.head.title[33]=订单分类
|
||||
export.head.field[33]=ddlx
|
||||
export.head.title[34]=gbm
|
||||
export.head.field[34]=bgm
|
||||
#export.head.title[1]=分组编号
|
||||
#export.head.field[1]=groupId
|
||||
#export.head.title[2]=ID
|
||||
#export.head.field[2]=id
|
||||
export.head.title[1]=条件
|
||||
export.head.field[1]=condition
|
||||
#export.head.title[4]=疑似拆单
|
||||
export.head.title[2]=拆单方式
|
||||
export.head.field[2]=openBill
|
||||
export.head.title[3]=月份
|
||||
export.head.field[3]=sqtjrq
|
||||
export.head.title[4]=SKU
|
||||
export.head.field[4]=ZWMS
|
||||
export.head.title[5]=部门
|
||||
export.head.field[5]=SPART
|
||||
export.head.title[6]=订单编号
|
||||
export.head.field[6]=ddbh
|
||||
export.head.title[7]=备注信息
|
||||
export.head.field[7]=bz
|
||||
export.head.title[8]=附加信息
|
||||
export.head.field[8]=ddsm
|
||||
export.head.title[9]=成本中心
|
||||
export.head.field[9]=KOSTL
|
||||
export.head.title[10]=活动编号
|
||||
export.head.field[10]=hdbh
|
||||
export.head.title[11]=流水号
|
||||
export.head.field[11]=lcid
|
||||
export.head.title[12]=用户
|
||||
export.head.field[12]=cbzxyh
|
||||
export.head.title[13]=订单类型
|
||||
export.head.field[13]=AUART
|
||||
export.head.title[14]=订单用途
|
||||
export.head.field[14]=ddyt
|
||||
export.head.title[15]=shipTo
|
||||
export.head.field[15]=shipto
|
||||
export.head.title[16]=办公室员工
|
||||
export.head.field[16]=KUNNRSHIPTO
|
||||
export.head.title[17]=提交时间
|
||||
export.head.field[17]=LASTOPERATEDATE
|
||||
export.head.title[18]=总数
|
||||
export.head.field[18]=SL
|
||||
export.head.title[19]=成本总额
|
||||
export.head.field[19]=kxpmxzlsj
|
||||
export.head.title[20]=总税额
|
||||
export.head.field[20]=
|
||||
export.head.title[21]=总价格
|
||||
export.head.field[21]=
|
||||
export.head.title[22]=订单时间
|
||||
export.head.field[22]=LASTOPERATEDATE
|
||||
export.head.title[23]=到货方
|
||||
export.head.field[23]=
|
||||
#export.head.title[5]=流水号
|
||||
#export.head.field[5]=lcid
|
||||
#export.head.title[6]=shipTo
|
||||
#export.head.field[6]=shipto
|
||||
#export.head.title[7]=推送时间
|
||||
#export.head.field[7]=insertTime
|
||||
#export.head.title[8]=审批开始时间
|
||||
#export.head.field[8]=createdate
|
||||
#export.head.title[9]=申请提交时间
|
||||
#export.head.field[9]=sqtjrq
|
||||
#export.head.title[10]=审批开始时间
|
||||
#export.head.field[10]=LASTOPERATEDATE
|
||||
#export.head.title[11]=收方限制
|
||||
#export.head.field[11]=ddlxms
|
||||
#export.head.title[12]=部门团队
|
||||
#export.head.field[12]=SPART
|
||||
#export.head.title[13]=品牌部门
|
||||
#export.head.field[13]=yjpp
|
||||
#export.head.title[14]=订单编号
|
||||
#export.head.field[14]=ddbh
|
||||
#export.head.title[15]=订单说明
|
||||
#export.head.field[15]=ddsm
|
||||
#export.head.title[16]=备注
|
||||
#export.head.field[16]=bz
|
||||
#export.head.title[17]=成本中心-sap
|
||||
#export.head.field[17]=KOSTL
|
||||
#export.head.title[18]=成本中心-用户
|
||||
#export.head.field[18]=cbzxyh
|
||||
#export.head.title[19]=财务科目
|
||||
#export.head.field[19]=cwkm
|
||||
#export.head.title[20]=审批开始时间
|
||||
#export.head.field[20]=LASTOPERATEDATE
|
||||
#export.head.title[21]=活动编号
|
||||
#export.head.field[21]=hdbh
|
||||
#export.head.title[22]=businessKey
|
||||
#export.head.field[22]=businesskey
|
||||
#export.head.title[23]=申请人
|
||||
#export.head.field[23]=SQRRLZY
|
||||
#export.head.title[24]=订单类型
|
||||
#export.head.field[24]=AUART
|
||||
#export.head.title[25]=订单用途
|
||||
#export.head.field[25]=VKAUS
|
||||
#export.head.title[26]=收货人
|
||||
#export.head.field[26]=KUNNRSHIPTO
|
||||
#export.head.title[27]=收货人地址
|
||||
#export.head.field[27]=shdz
|
||||
#export.head.title[28]=收货编号
|
||||
#export.head.field[28]=hwbh
|
||||
#export.head.title[29]=收货类型
|
||||
#export.head.field[29]=fl
|
||||
#export.head.title[30]=收货中文名
|
||||
#export.head.field[30]=ZWMS
|
||||
#export.head.title[31]=数量
|
||||
#export.head.field[31]=SL
|
||||
#export.head.title[32]=零售总额
|
||||
#export.head.field[32]=kxpmxzlsj
|
||||
#export.head.title[33]=订单分类
|
||||
##xport.head.title[34]=gbm
|
||||
#export.head.field[34]=bgm
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
body{
|
||||
background-color: rgb(241, 241, 241);
|
||||
font-family: PingFangSC-Regular;
|
||||
color: #333333 ;
|
||||
}
|
||||
.box{
|
||||
width: 1000px;
|
||||
margin:0 auto;
|
||||
margin-top: 100px;
|
||||
background-color: #ffffff;
|
||||
font-size: 14px;
|
||||
|
||||
}
|
||||
.mytitle{
|
||||
width: 100%;
|
||||
background-color: #F6F6F6 ;
|
||||
height: 40px;
|
||||
font-size: 14px;
|
||||
background: #F6F6F6;
|
||||
border: 1px solid #E2E2E2;
|
||||
|
||||
}
|
||||
.clusterIp{
|
||||
display: inline-block;
|
||||
width: 120px;
|
||||
|
||||
}
|
||||
input[type='checkbox']{
|
||||
}
|
||||
|
||||
.cluster{
|
||||
border-bottom: 1px solid #E2E2E2;
|
||||
width: 80%;
|
||||
margin-left: 39px;
|
||||
height: 100px;
|
||||
padding-top: 26px;
|
||||
}
|
||||
.Button{
|
||||
color: #fff;
|
||||
background-color: #2DB7F5;
|
||||
border-color: #4cae4c;
|
||||
|
||||
display: inline-block;
|
||||
margin-bottom: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 300;
|
||||
line-height: 1.42857143;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
-ms-touch-action: manipulation;
|
||||
touch-action: manipulation;
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
background-image: none;
|
||||
border: 1px solid transparent;
|
||||
width:70px;
|
||||
height:30px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.Wdate{
|
||||
width: 150px;
|
||||
height: 30px !important;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.clusterPlan{
|
||||
margin-top: 20px;
|
||||
margin-left:30px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.contend{
|
||||
background: #FFFFFF;
|
||||
border-left: 1px solid #E2E2E2;
|
||||
border-right: 1px solid #E2E2E2;
|
||||
border-bottom: 1px solid #E2E2E2;
|
||||
width: 100%;
|
||||
}
|
||||
.messages{
|
||||
color:red;
|
||||
}
|
||||
|
||||
#start[disabled]{
|
||||
background-color: #A9A9A9;
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
<%@ page language="java" %>
|
||||
<%@ page import="org.apache.commons.httpclient.HttpClient" %>
|
||||
<%@ page import="org.apache.commons.httpclient.methods.GetMethod" %>
|
||||
<%@ page import="javax.servlet.http.HttpServletRequest" %>
|
||||
<%@ page import="javax.servlet.http.HttpServletResponse" %>
|
||||
<%@ page import="java.io.File" %>
|
||||
<%@ page import="java.io.FileInputStream" %>
|
||||
<%@ page import="java.io.InputStream" %>
|
||||
<%@ page import="java.io.OutputStream" %>
|
||||
<%@ page import="java.util.regex.Matcher" %>
|
||||
<%@ page import="java.util.regex.Pattern" %>
|
||||
<%
|
||||
|
||||
String logName = request.getParameter("logName");
|
||||
String otherIp = request.getParameter("otherIp");
|
||||
|
||||
weaver.hrm.User user = (weaver.hrm.User) request.getSession(true).getAttribute("weaver_user@bean");
|
||||
String ip = getIpAddress(request);
|
||||
if (user == null || !"sysadmin".equals(user.getLoginid())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (otherIp != null) {
|
||||
otherIp = otherIp.replace("-", ":");
|
||||
downotherlog(logName, otherIp, response);
|
||||
} else {
|
||||
deal(request, response);
|
||||
}
|
||||
%><%!
|
||||
public static boolean innerIP(String ip) {
|
||||
String pattern = "((192\\.168|172\\.([1][6-9]|[2]\\d|3[01]))"
|
||||
+ "(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){2}|"
|
||||
+ "^(\\D)*10(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){3})";
|
||||
Pattern reg = Pattern.compile(pattern);
|
||||
Matcher match = reg.matcher(ip);
|
||||
return match.find() || ip.equals("127.0.0.1");
|
||||
|
||||
}
|
||||
|
||||
public String getIpAddress(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
if (ip.contains(",")) {
|
||||
return ip.split(",")[0];
|
||||
} else {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
private void deal(HttpServletRequest request, HttpServletResponse response) {
|
||||
response.reset();
|
||||
String logName = request.getParameter("logName");
|
||||
if (!logName.endsWith(".zip") || logName.indexOf("/") != -1 || logName.indexOf("\\") != -1 || logName.indexOf("..") != -1) {
|
||||
|
||||
return;
|
||||
}
|
||||
FileInputStream in = null;
|
||||
OutputStream outs = null;
|
||||
try {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename=" + logName);
|
||||
response.setCharacterEncoding("ISO8859-1");
|
||||
String ecologyPathtmp = request.getRealPath("/");
|
||||
if (!ecologyPathtmp.endsWith(File.separator)) {
|
||||
ecologyPathtmp = ecologyPathtmp + File.separator;
|
||||
}
|
||||
if (logName.indexOf("..") != -1 || logName.indexOf("\0") != -1) {
|
||||
return;
|
||||
}
|
||||
in = new FileInputStream(ecologyPathtmp + "cus_getlog" + File.separator + "log" + File.separator + logName);
|
||||
outs = response.getOutputStream();
|
||||
outs.flush();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = in.read(buffer)) > 0) {
|
||||
outs.write(buffer, 0, len);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (outs != null) {
|
||||
outs.flush();
|
||||
outs.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void downotherlog(String logName, String otherIp, HttpServletResponse response) {
|
||||
response.reset();
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream outs = null;
|
||||
try {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("content-disposition", "attachment;filename=" + logName);
|
||||
response.setCharacterEncoding("ISO8859-1");
|
||||
HttpClient client = new HttpClient();
|
||||
GetMethod httpget = new GetMethod("http://" + otherIp + "/cus_getlog/downlog.jsp?logName=" + logName);
|
||||
client.executeMethod(httpget);
|
||||
in = httpget.getResponseBodyAsStream();
|
||||
outs = response.getOutputStream();
|
||||
outs.flush();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = in.read(buffer)) > 0) {
|
||||
outs.write(buffer, 0, len);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (outs != null) {
|
||||
outs.flush();
|
||||
outs.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
|
@ -0,0 +1,481 @@
|
|||
<%@ page language="java" contentType="text/html; charset=utf-8" %>
|
||||
<%@ page import="java.io.*" %>
|
||||
<%@ page import="java.math.BigDecimal" %>
|
||||
<%@ page import="java.math.RoundingMode" %>
|
||||
<%@ page import="java.net.InetAddress" %>
|
||||
<%@ page import="java.net.NetworkInterface" %>
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="java.util.regex.Matcher" %>
|
||||
<%@ page import="java.util.regex.Pattern" %>
|
||||
<%@ page import="java.util.zip.ZipEntry" %>
|
||||
<%@ page import="java.util.zip.ZipOutputStream" %>
|
||||
|
||||
<%
|
||||
|
||||
weaver.hrm.User user = (weaver.hrm.User) request.getSession(true).getAttribute("weaver_user@bean");
|
||||
String ip = getIpAddress(request);
|
||||
if (user == null || !"sysadmin".equals(user.getLoginid())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String startStr = request.getParameter("startDate");
|
||||
String endStr = request.getParameter("endDate");
|
||||
String logTypeStr = request.getParameter("loytype");
|
||||
messageStr = new StringBuilder();
|
||||
|
||||
|
||||
String ecologyPathtmp = request.getRealPath("/");
|
||||
if (!ecologyPathtmp.endsWith(File.separator)) {
|
||||
ecologyPathtmp = ecologyPathtmp + File.separator;
|
||||
}
|
||||
final String ecologyPath = ecologyPathtmp;
|
||||
final String ResinPath = System.getProperty("user.dir") + File.separator;
|
||||
//out.println(ResinPath+"<br>");
|
||||
String outPath = ecologyPath + File.separator + "getlog" + File.separator + "log"; // 日志输出目录
|
||||
List dates = getDateList(startStr, endStr);
|
||||
File outFile = null;
|
||||
try {
|
||||
outFile = new File(outPath);
|
||||
if (!outFile.exists()) {
|
||||
outFile.mkdirs();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String outLogPath = outFile + File.separator + getInnerIp() + "downLog.zip";
|
||||
Map logtype = new HashMap() { // 日志类型路径
|
||||
{
|
||||
put("thread", ecologyPath + "log" + File.separator + "thread");
|
||||
put("mem", ecologyPath + "log" + File.separator + "mem");
|
||||
put("ecology", ecologyPath + "log");
|
||||
put("sql", ecologyPath + "log" + File.separator + "sql");
|
||||
|
||||
put("sqllog", ecologyPath + "sqllog");
|
||||
|
||||
put("security", ecologyPath + "WEB-INF" + File.separator + "securitylog");
|
||||
put("Resin", ResinPath + "log");
|
||||
put("integration", ecologyPath + "log" + File.separator + "integration");
|
||||
|
||||
put("monitorevent", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "event"); //运维平台的事件日志
|
||||
put("monitorPool", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "pool");
|
||||
put("monitorcpu", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "cpu");
|
||||
put("resinconf", ResinPath + "conf" + File.separator + "resin.conf");
|
||||
put("ecoloyweaver", ecologyPath + "WEB-INF" + File.separator + "prop" + File.separator);
|
||||
put("monitorlog", ResinPath + "monitor" + File.separator + "resin" + File.separator + "log");
|
||||
put("monitorconcurrent", ResinPath + "monitor" + File.separator + "resin" + File.separator + "app" + File.separator + "data" + File.separator + "concurrent");
|
||||
|
||||
put("cus", ecologyPath + "log" + File.separator + "cus");
|
||||
put("util_cus", ecologyPath + "log" + File.separator + "cus" + File.separator + "util_cus");
|
||||
put("sql_log", ecologyPath + "log" + File.separator + "cus" + File.separator + "sql_log");
|
||||
put("http_util", ecologyPath + "log" + File.separator + "cus" + File.separator + "http_util");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Map logMap = getLogType(logTypeStr, logtype);
|
||||
Set keys = logMap.keySet();
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(outLogPath);
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
zos.setLevel(1);
|
||||
Iterator it = keys.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
for (int i = 0; i < dates.size(); i++) {
|
||||
String date = (String) dates.get(i);
|
||||
boolean isToDay = isToDay(date);
|
||||
List fileNames = transition(key, (String) logtype.get(key), date, isToDay);
|
||||
for (int j = 0; j < fileNames.size(); j++) {
|
||||
String fileName = (String) fileNames.get(j);
|
||||
//out.println(fileName+"<br>");
|
||||
String basePath = date + File.separator;
|
||||
if ("sqllog".equals(key)) {
|
||||
basePath += ("sqllog" + File.separator);
|
||||
}
|
||||
if ("monitorevent".equals(key)) {
|
||||
basePath += ("event" + File.separator);
|
||||
}
|
||||
if ("monitorlog".equals(key)) {
|
||||
basePath += ("monitorlog" + File.separator);
|
||||
}
|
||||
if (key.equals("cus")) {
|
||||
basePath += ("cus" + File.separator);
|
||||
}
|
||||
if (key.equals("util_cus")) {
|
||||
basePath += ("util_cus" + File.separator);
|
||||
}
|
||||
if (key.equals("sql_log")) {
|
||||
basePath += ("sql_log" + File.separator);
|
||||
}
|
||||
if (key.equals("http_util")) {
|
||||
basePath += ("http_util" + File.separator);
|
||||
}
|
||||
compressbyType(fileName, zos, basePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
zos.close();
|
||||
} catch (Exception es) {
|
||||
}
|
||||
if (fos != null)
|
||||
fos.close();
|
||||
File outLog = new File(outLogPath);
|
||||
String fileSize = getFileSize(outLog);
|
||||
out.println(fileSize + "," + messageStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
// out.println(end - start);
|
||||
%>
|
||||
<%!
|
||||
|
||||
public static boolean innerIP(String ip) {
|
||||
String pattern = "((192\\.168|172\\.([1][6-9]|[2]\\d|3[01]))"
|
||||
+ "(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){2}|"
|
||||
+ "^(\\D)*10(\\.([2][0-4]\\d|[2][5][0-5]|[01]?\\d?\\d)){3})";
|
||||
Pattern reg = Pattern.compile(pattern);
|
||||
Matcher match = reg.matcher(ip);
|
||||
return match.find() || ip.equals("127.0.0.1");
|
||||
}
|
||||
|
||||
public String getIpAddress(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
if (ip.contains(",")) {
|
||||
return ip.split(",")[0];
|
||||
} else {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private StringBuilder messageStr = new StringBuilder();
|
||||
|
||||
private Map getLogType(String logTypeStr, Map logtype) {
|
||||
Map resultmap = new HashMap();
|
||||
String[] strs = logTypeStr.split(",");
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
String str = strs[i];
|
||||
if (str.equals("monitor")) {
|
||||
resultmap.put("thread", logtype.get("thread"));
|
||||
resultmap.put("mem", logtype.get("mem"));
|
||||
resultmap.put("sql", logtype.get("sql"));
|
||||
resultmap.put("monitorevent", logtype.get("monitorevent"));
|
||||
resultmap.put("monitorPool", logtype.get("monitorPool"));
|
||||
resultmap.put("monitorcpu", logtype.get("monitorcpu"));
|
||||
resultmap.put("resinconf", logtype.get("resinconf"));
|
||||
resultmap.put("ecoloyweaver", logtype.get("ecoloyweaver"));
|
||||
resultmap.put("monitorconcurrent", logtype.get("monitorconcurrent"));
|
||||
resultmap.put("monitorlog", logtype.get("monitorlog"));
|
||||
}
|
||||
if (str.equals("Resin")) {
|
||||
resultmap.put("Resin", logtype.get("Resin"));
|
||||
}
|
||||
if (str.equals("security")) {
|
||||
resultmap.put("security", logtype.get("security"));
|
||||
}
|
||||
if (str.equals("ecology")) {
|
||||
resultmap.put("ecology", logtype.get("ecology"));
|
||||
}
|
||||
if (str.equals("sql")) {
|
||||
resultmap.put("sql", logtype.get("sql"));
|
||||
}
|
||||
if (str.equals("integration")) {
|
||||
resultmap.put("integration", logtype.get("integration"));
|
||||
}
|
||||
if (str.equals("cus")) {
|
||||
resultmap.put("cus", logtype.get("cus"));
|
||||
}
|
||||
if (str.equals("util_cus")) {
|
||||
resultmap.put("util_cus", logtype.get("util_cus"));
|
||||
}
|
||||
if (str.equals("sql_log")) {
|
||||
resultmap.put("sql_log", logtype.get("sql_log"));
|
||||
}
|
||||
if (str.equals("http_util")) {
|
||||
resultmap.put("http_util", logtype.get("http_util"));
|
||||
}
|
||||
}
|
||||
return resultmap;
|
||||
}
|
||||
|
||||
private List getDateList(String startDate, String endDate) {
|
||||
ArrayList list = new ArrayList();
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date start = sdf.parse(startDate);
|
||||
Date end = sdf.parse(endDate);
|
||||
Calendar tempStart = Calendar.getInstance();
|
||||
tempStart.setTime(start);
|
||||
while (start.getTime() <= end.getTime()) {
|
||||
list.add(sdf.format(tempStart.getTime()));
|
||||
tempStart.add(Calendar.DAY_OF_YEAR, 1);
|
||||
start = tempStart.getTime();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private boolean isToDay(String date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String toDay = sdf.format(new Date());
|
||||
return date.equals(toDay);
|
||||
}
|
||||
|
||||
public List transition(String key, String path, String date, boolean isToDay) {//转换真实的日志文件
|
||||
List list = new ArrayList();
|
||||
if ("thread".equals(key)) {
|
||||
list.add(path + File.separator + date);
|
||||
} else if ("mem".equals(key)) {
|
||||
list.add(path + File.separator + "memory_" + date + ".log");
|
||||
} else if ("ecology".equals(key)) {
|
||||
if (isToDay) {
|
||||
list.add(path + File.separator + "ecology");
|
||||
} else {
|
||||
list.add(path + File.separator + "ecology_" + getDateStr(date) + ".log");
|
||||
}
|
||||
} else if ("sql".equals(key)) {
|
||||
list.add(path + File.separator + "sqlcount_" + date + ".log");
|
||||
list.add(path + File.separator + "sqltime_" + date + ".log");
|
||||
} else if ("integration".equals(key)) {
|
||||
if (isToDay) {
|
||||
list.add(path + File.separator + "integration.log");
|
||||
} else {
|
||||
list.add(path + File.separator + "integration.log_" + getDateStr(date) + ".log");
|
||||
}
|
||||
} else if ("security".equals(key)) {
|
||||
list.add(path + File.separator + "systemRunInfo" + date + ".log");
|
||||
list.add(path + File.separator + "systemSecurity" + date + ".log");
|
||||
} else if ("Resin".equals(key)) {
|
||||
if (isToDay) {
|
||||
list.add(path + File.separator + "stdout.log");
|
||||
list.add(path + File.separator + "stderr.log");
|
||||
} else {
|
||||
list.add(path + File.separator + "stdout-" + getDateStr(date) + ".log.gz");
|
||||
list.add(path + File.separator + "stderr-" + getDateStr(date) + ".log.gz");
|
||||
}
|
||||
list.add(path + File.separator + "watchdog-manager.log");
|
||||
list.add(path + File.separator + "jvm-default.log");
|
||||
} else if ("sqllog".equals(key)) {
|
||||
list.add(path + File.separator + getSqlPathByDate(date));
|
||||
list.add(path + File.separator);
|
||||
} else if ("monitorevent".equals(key)) {
|
||||
list.addAll(eventLog(path, date));
|
||||
} else if ("monitorPool".equals(key)) {
|
||||
list.add(path + File.separator + "pool_" + getDateStr(date) + "_ecology.log");
|
||||
list.add(path + File.separator + "pool_" + getDateStr(date) + "_ecology.zip");
|
||||
} else if ("monitorlog".equals(key)) {
|
||||
if (isToDay) {
|
||||
list.add(path + File.separator + "stdout.log");
|
||||
list.add(path + File.separator + "stderr-log");
|
||||
} else {
|
||||
list.add(path + File.separator + "stdout-" + getDateStr(date) + ".log.gz");
|
||||
list.add(path + File.separator + "stderr-" + getDateStr(date) + ".log.gz");
|
||||
}
|
||||
} else if ("monitorconcurrent".equals(key)) {
|
||||
list.add(path + File.separator + "concurrent_" + getDateStr(date) + ".log");
|
||||
list.add(path + File.separator + "concurrent_" + getDateStr(date) + ".zip");
|
||||
} else if ("monitorcpu".equals(key)) {
|
||||
list.add(path + File.separator + "cpu_" + getDateStr(date) + ".log");
|
||||
list.add(path + File.separator + "cpu_" + getDateStr(date) + ".zip");
|
||||
} else if ("resinconf".equals(key)) {
|
||||
list.add(path);
|
||||
} else if ("ecoloyweaver".equals(key)) {
|
||||
dealWidthWeaverProp(path + "weaver.properties", new File(path + "weaversecurity.properties"));
|
||||
list.add(path + "weaversecurity.properties");
|
||||
} else if ("cus".equals(key) || "util_cus".equals(key) || "sql_log".equals(key) || "http_util".equals(key)) {
|
||||
if (isToDay) {
|
||||
list.add(path + File.separator + "cus.log");
|
||||
} else {
|
||||
list.add(path + File.separator + "cus.log_" + getDateStr(date) + ".log");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void dealWidthWeaverProp(String path, File outFile) {//处理weaver.prop密码问题
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
InputStreamReader reader = null;
|
||||
java.io.Writer outWriter = null;
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
Properties registerProp = new Properties();
|
||||
reader = new InputStreamReader(new FileInputStream(file));
|
||||
registerProp.load(reader);
|
||||
reader.close();
|
||||
outWriter = new FileWriter(outFile);
|
||||
registerProp.put("ecology.password", "***********");
|
||||
registerProp.store(outWriter, "");
|
||||
outWriter.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (outWriter != null) {
|
||||
outWriter.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List eventLog(String path, String date) {
|
||||
List list = new ArrayList();
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
return list;
|
||||
}
|
||||
File[] filelists = new File(path).listFiles();
|
||||
date = getDateStr(date);
|
||||
for (int i = 0; i < filelists.length; i++) {
|
||||
File filelist = filelists[i];
|
||||
if (filelist.getName().indexOf(date) != -1) {
|
||||
list.add(filelist.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String getSqlPathByDate(String date) {
|
||||
return date.replace("-", File.separator);
|
||||
}
|
||||
|
||||
public String getFileSize(File file) {
|
||||
if (!file.exists()) {
|
||||
return "0KB";
|
||||
}
|
||||
long length = file.length();
|
||||
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(length));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(1024));
|
||||
BigDecimal b3 = b1.divide(b2, 2, RoundingMode.HALF_UP);
|
||||
b3.floatValue();
|
||||
if (b3.floatValue() > 1024) {
|
||||
return b3.divide(b2, 2, RoundingMode.HALF_UP).floatValue() + "M";
|
||||
} else {
|
||||
return b3.floatValue() + "KB";
|
||||
}
|
||||
}
|
||||
|
||||
private String getInnerIp() {
|
||||
try {
|
||||
Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
while (netInterfaces.hasMoreElements()) {
|
||||
NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
|
||||
Enumeration nii = ni.getInetAddresses();
|
||||
while (nii.hasMoreElements()) {
|
||||
InetAddress inetAddress = (InetAddress) nii.nextElement();
|
||||
if (inetAddress.getHostAddress().indexOf(":") == -1) {
|
||||
String ip = inetAddress.getHostAddress();
|
||||
if (ip.startsWith("10.") || ip.startsWith("192.168.")) {// ||
|
||||
return ip;
|
||||
} else {
|
||||
if (ip.startsWith("172.")) {
|
||||
|
||||
return ip;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
private String getDateStr(String date) {
|
||||
date = date.replaceAll("-", "");
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照原路径的类型就行压缩。文件路径直接把文件压缩
|
||||
* @param src
|
||||
* @param zos
|
||||
* @param baseDir
|
||||
*/
|
||||
private void compressbyType(String src, ZipOutputStream zos, String baseDir) {
|
||||
File srcFile = new File(src);
|
||||
if (!srcFile.exists()) {
|
||||
return;
|
||||
}
|
||||
//判断文件是否是文件,如果是文件调用compressFile方法,如果是路径,则调用compressDir方法;
|
||||
if (srcFile.isFile()) {
|
||||
//src是文件,调用此方法
|
||||
compressFile(srcFile, zos, baseDir);
|
||||
} else if (srcFile.isDirectory()) {
|
||||
compressDir(srcFile, zos, baseDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩文件,取后面的80M内容
|
||||
*/
|
||||
private void compressFile(File file, ZipOutputStream zos, String baseDir) {
|
||||
if (!file.exists())
|
||||
return;
|
||||
try {
|
||||
RandomAccessFile fileRead = new RandomAccessFile(file, "r"); //用读模式
|
||||
long fileLength = fileRead.length();//获得文件长度
|
||||
if (file.getName().endsWith(".log") && fileLength > 1073741820) {//如果文件超过80M,则只取文件倒数80M内容
|
||||
messageStr.append("、").append(file.getName());
|
||||
fileRead.seek(fileLength - 1073741820);
|
||||
} else {
|
||||
fileRead.seek(0);
|
||||
}
|
||||
ZipEntry entry = new ZipEntry(baseDir + file.getName());
|
||||
zos.putNextEntry(entry);
|
||||
int hasRead;
|
||||
byte[] buf = new byte[1024];
|
||||
while ((hasRead = fileRead.read(buf)) != -1) {
|
||||
zos.write(buf, 0, hasRead);
|
||||
}
|
||||
fileRead.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩文件夹
|
||||
*/
|
||||
private void compressDir(File dir, ZipOutputStream zos, String baseDir) {
|
||||
if (!dir.exists())
|
||||
return;
|
||||
File[] files = dir.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
compressFile(file, zos, baseDir + dir.getName() + File.separator);
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -0,0 +1,469 @@
|
|||
<%@ page language="java" contentType="text/html; charset=utf-8" %>
|
||||
<%@ page import="org.apache.commons.io.IOUtils" %>
|
||||
<%@ page import="java.io.*" %>
|
||||
<%@ page import="java.net.InetAddress" %>
|
||||
<%@ page import="java.net.NetworkInterface" %>
|
||||
<%@ page import="java.util.Enumeration" %>
|
||||
<%@ page import="java.util.HashSet" %>
|
||||
<%@ page import="java.util.Properties" %>
|
||||
<%@ page import="java.util.Set" %>
|
||||
<%
|
||||
|
||||
final String ecologyPath = request.getRealPath("/");
|
||||
weaver.hrm.User user = (weaver.hrm.User) request.getSession(true).getAttribute("weaver_user@bean");
|
||||
if (user == null || !"sysadmin".equals(user.getLoginid())) {
|
||||
response.sendRedirect("/");
|
||||
return;
|
||||
}
|
||||
final String ResinPath = System.getProperty("user.dir") + File.separator;
|
||||
boolean isResin = ResinPath.toLowerCase().indexOf("resin") != -1;
|
||||
String ecologyWeaverPath = "";
|
||||
if (ecologyPath.endsWith(File.separator)) {
|
||||
ecologyWeaverPath = ecologyPath + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties";
|
||||
} else {
|
||||
ecologyWeaverPath = ecologyPath + File.separator + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties";
|
||||
}
|
||||
|
||||
File ecolpogyProp = new File(ecologyWeaverPath);
|
||||
File resinProp = new File(ResinPath + "bin" + File.separator + "startresin.sh");
|
||||
|
||||
Set ipList = readEcologyProp(ecolpogyProp);
|
||||
String localIp = getInnerIp();
|
||||
if (ipList.size() == 0) {
|
||||
ipList.addAll(readResinProp(resinProp));
|
||||
}
|
||||
boolean isCluster = true;
|
||||
if (ipList.size() == 0) {//没有集群的时候
|
||||
//ipList.add(localIp);
|
||||
isCluster = false;
|
||||
} else {
|
||||
boolean status = false;
|
||||
java.util.Iterator it = ipList.iterator();
|
||||
while (it.hasNext()) {
|
||||
String ip = (String) it.next();
|
||||
if (ip.indexOf(localIp) != -1 || "127.0.0.1".equals(ip) || "127.0.0.1".equals(localIp)) {
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
if (!status) {
|
||||
ipList.add(localIp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
/**
|
||||
* 当前机器内网ip
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getInnerIp() {
|
||||
try {
|
||||
Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
while (netInterfaces.hasMoreElements()) {
|
||||
NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
|
||||
Enumeration nii = ni.getInetAddresses();
|
||||
while (nii.hasMoreElements()) {
|
||||
InetAddress inetAddress = (InetAddress) nii.nextElement();
|
||||
if (inetAddress.getHostAddress().indexOf(":") == -1) {
|
||||
String ip = inetAddress.getHostAddress();
|
||||
if (ip.startsWith("10.") || ip.startsWith("192.168.")) {// ||
|
||||
return ip;
|
||||
} else {
|
||||
if (ip.startsWith("172.")) {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
private Set readResinProp(File startResinFile) {
|
||||
Set liststr = new HashSet();
|
||||
if (!startResinFile.exists()) {
|
||||
return liststr;
|
||||
}
|
||||
if (startResinFile.isFile() && startResinFile.length() > 0) {
|
||||
FileInputStream fileInput = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
fileInput = new FileInputStream(startResinFile);
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(fileInput));
|
||||
String str = null;
|
||||
while ((str = bufferedReader.readLine()) != null) {
|
||||
if (str.indexOf("-Dinitial_hosts") != -1 || str.indexOf("-J-Dinitial_hosts") != -1) {
|
||||
if (str.indexOf("-J-Dinitial_hosts") != -1) {
|
||||
str = str.substring(str.indexOf("-J-Dinitial_hosts") + 17);
|
||||
}
|
||||
if (str.indexOf("-Dinitial_hosts") != -1) {
|
||||
str = str.substring(str.indexOf("-Dinitial_hosts") + 15);
|
||||
}
|
||||
str = str.indexOf("=") != -1 ? str.substring(str.indexOf("=") + 1) : str;
|
||||
str = str.indexOf("-") != -1 ? str.substring(0, str.indexOf("-")) : str;
|
||||
str = str.indexOf(" ") != -1 ? str.substring(0, str.indexOf(" ")) : str;
|
||||
String[] ips = str.split(",");
|
||||
for (int i = 0; i < ips.length; i++) {
|
||||
String ip = ips[i];
|
||||
try {
|
||||
String tmpip = ip.replace(".", "").replace(":", "");
|
||||
Long.parseLong(tmpip.trim());
|
||||
liststr.add(ip.trim());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInput);
|
||||
IOUtils.closeQuietly(bufferedReader);
|
||||
}
|
||||
}
|
||||
return liststr;
|
||||
}
|
||||
|
||||
|
||||
private Set readEcologyProp(File file) {
|
||||
Set liststr = new HashSet();
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
return liststr;
|
||||
}
|
||||
Properties registerProp = new Properties();
|
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(file));
|
||||
registerProp.load(reader);
|
||||
String initial_host = registerProp.getProperty("initial_hosts");
|
||||
if (initial_host != null && !"".equals(initial_host)) {
|
||||
String[] initial_hosts = initial_host.split(",");
|
||||
for (int i = 0; i < initial_hosts.length; i++) {
|
||||
String initial_hostStr = initial_hosts[i];
|
||||
if (!initial_hostStr.isEmpty()) {
|
||||
liststr.add(initial_hostStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
IOUtils.closeQuietly(reader);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return liststr;
|
||||
}
|
||||
%>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
|
||||
<script type="text/javascript" src="js/jquery.js"></script>
|
||||
<script type="text/javascript" src="js/data.js"></script>
|
||||
<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#downstartlogDate").val(new Date().format("yyyy-MM-dd"));
|
||||
$("#downendlogDate").val(new Date().format("yyyy-MM-dd"));
|
||||
|
||||
})
|
||||
|
||||
function collectLog() {
|
||||
var clusterips = "";
|
||||
$("[name='clusterip']:checked").each(function () {
|
||||
clusterips += $(this).val() + ",";
|
||||
|
||||
})
|
||||
if (<%=isCluster%>&&
|
||||
clusterips == ''
|
||||
)
|
||||
{
|
||||
alert("请选择服务器节点!")
|
||||
return;
|
||||
}
|
||||
clusterips = clusterips.substr(0, clusterips.length - 1);
|
||||
|
||||
var loytype = "";
|
||||
$("[name='loytype']:checked").each(function () {
|
||||
loytype += $(this).val() + ",";
|
||||
})
|
||||
if (loytype == '') {
|
||||
alert("请选择日志类型!")
|
||||
return;
|
||||
}
|
||||
loytype = loytype.substr(0, loytype.length - 1);
|
||||
var startDate = $("#downstartlogDate").val();
|
||||
var endDate = $("#downendlogDate").val();
|
||||
if (startDate == '') {
|
||||
alert("请选择开始日期!")
|
||||
return;
|
||||
}
|
||||
if (endDate == '') {
|
||||
alert("请选择结束日期!")
|
||||
return;
|
||||
}
|
||||
var oDate1 = new Date(startDate);
|
||||
var oDate2 = new Date(endDate);
|
||||
if (oDate1.getTime() > oDate2.getTime()) {
|
||||
alert("结束日志不能少于开始日期!")
|
||||
return;
|
||||
}
|
||||
waitInt = 0;
|
||||
$("#start").attr("disabled", "disabled");
|
||||
var clts = clusterips.split(",");
|
||||
for (var i = 0; i < clts.length && clts.length > 0; i++) {
|
||||
var ip = clts[i];
|
||||
var clt = ip.replace(/\./g, "");
|
||||
clt = clt.replace(/\:/g, "");
|
||||
if (clt.indexOf("<%=localIp%>") != -1) {
|
||||
waitInt += 1
|
||||
getLog(clt, ip, loytype, startDate, endDate);
|
||||
} else {
|
||||
waitInt += 1
|
||||
getOtherLog(clt, ip, loytype, startDate, endDate);
|
||||
}
|
||||
|
||||
}
|
||||
if (<%=!isCluster%>) {
|
||||
waitInt += 1
|
||||
getLog('log', '<%=localIp%>', loytype, startDate, endDate);
|
||||
}
|
||||
}
|
||||
|
||||
function getold7Day() {
|
||||
var now = new Date();
|
||||
var date = new Date(now.getTime() - 7 * 24 * 3600 * 1000);
|
||||
var year = date.getFullYear();
|
||||
var month = date.getMonth() + 1;
|
||||
var day = date.getDate();
|
||||
return year + '-' + month + '-' + day;
|
||||
}
|
||||
|
||||
function getLog(div, ip, loytype, startDate, endDate) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
contentType: " charset=utf-8",
|
||||
url: '/cus_getlog/getlog.jsp?loytype=' + loytype + '&startDate=' + startDate + '&endDate=' + endDate,
|
||||
beforeSend: function () {
|
||||
$("#" + div + "div").html('<img alt="" style = "width: 20px;height: 20px;" src="img/loading.gif">')
|
||||
$("#" + div + "messagediv").html('')
|
||||
},
|
||||
success: function (data) {
|
||||
waitInt--;
|
||||
if (waitInt == 0) {
|
||||
$("#start").removeAttr("disabled");
|
||||
}
|
||||
var dataTmp = data.split(",");
|
||||
if (dataTmp[0] != '0KB' && dataTmp[0].trim() != '') {
|
||||
var iptmp = ip.indexOf(":") > 0 ? ip.substr(0, ip.indexOf(":")) : ip;
|
||||
|
||||
$("#" + div + "div").html('<a href="/getlog/downlog.jsp?logName=' + iptmp + 'downLog.zip">' + iptmp + 'downLog.zip(' + dataTmp[0] + ') 下载</a>')
|
||||
if (dataTmp[1] != null && dataTmp[1] != undefined && dataTmp[1].trim() != '') {
|
||||
var messtr = dataTmp[1];
|
||||
$("#" + div + "messagediv").html(messtr.substr(1, messtr.length) + '日志内容大于1G,此次日志收集内容只取日志后面的1G内容,如需完整日志,请在服务器器上获取.请知晓!');
|
||||
}
|
||||
} else {
|
||||
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var waitInt = 0;
|
||||
|
||||
function getOtherLog(div, clusterIp, loytype, startDate, endDate) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
contentType: " charset=utf-8",
|
||||
url: '/cus_getlog/sendUrl.jsp?clusterIp=' + clusterIp + '&loytype=' + loytype + '&startDate=' + startDate + '&endDate=' + endDate,
|
||||
beforeSend: function () {
|
||||
$("#" + div + "div").html('<img alt="" style = "width: 20px;height: 20px;" src="img/loading.gif">');
|
||||
$("#" + div + "messagediv").html('')
|
||||
},
|
||||
success: function (data) {
|
||||
var dataTmp = data.split(",");
|
||||
waitInt--;
|
||||
if (waitInt == 0) {
|
||||
$("#start").removeAttr("disabled");
|
||||
}
|
||||
if (data.trim() == '1') {
|
||||
$("#" + div + "div").html('收集失败,系统参数不全!')
|
||||
} else if (data.trim() == '2') {
|
||||
$("#" + div + "div").html(clusterIp + '请求被拦截,请将/getlog/getlog.jsp请求')
|
||||
} else if (data.trim() == '3') {
|
||||
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||
} else if (data.trim() == '4') {
|
||||
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||
} else if (data.trim() != '0KB' && dataTmp[0].trim() != '') {
|
||||
var iptmp = clusterIp.indexOf(":") > 0 ? clusterIp.substr(0, clusterIp.indexOf(":")) : clusterIp;
|
||||
var otherIp = clusterIp.replace(":", "-");
|
||||
//console.info('<a href="/getlog/downlog.jsp?logName='+iptmp+'downLog.zip&otherIp='+otherIp+'">'+iptmp+'downLog.zip('+data+') 下载</a>')
|
||||
$("#" + div + "div").html('<a href="/getlog/downlog.jsp?logName=' + iptmp + 'downLog.zip&otherIp=' + otherIp + '">' + iptmp + 'downLog.zip(' + data + ') 下载</a>')
|
||||
|
||||
if (dataTmp[1] != null && dataTmp[1] != undefined && dataTmp[1].trim() != '') {
|
||||
var messtr = dataTmp[1];
|
||||
$("#" + div + "messagediv").html(messtr.substr(1, messtr.length) + '日志内容大于1G,此次日志收集内容只取日志后面的1G内容,如需完整日志,请在服务器器上获取.请知晓!');
|
||||
}
|
||||
} else {
|
||||
$("#" + div + "div").html('收集失败,请手动收集!')
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body style="margin-top: 0px;">
|
||||
<div class="box" style="margin-top: 0px;">
|
||||
<div class="mytitle">
|
||||
<div style="padding-top: 10px;padding-left: 16px">
|
||||
ecology日志下载
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="" class="contend">
|
||||
<%if (isCluster) { %>
|
||||
<div class="cluster">
|
||||
<div>服务器节点</div>
|
||||
<div class="clusterPlan">
|
||||
<%
|
||||
java.util.Iterator it = ipList.iterator();
|
||||
while (it.hasNext()) {
|
||||
String ip = (String) it.next();
|
||||
%>
|
||||
<div class="clusterIp" style="width:180px">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="clusterip" value="<%=ip %>" checked>
|
||||
<span></span>
|
||||
<%=ip %>
|
||||
</label>
|
||||
</div>
|
||||
<%}%>
|
||||
</div>
|
||||
</div>
|
||||
<%}%>
|
||||
|
||||
|
||||
<div class="cluster">
|
||||
<div>日志类型</div>
|
||||
<div class="clusterPlan">
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="monitor">
|
||||
性能日志
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="clusterIp" style="width: 140px">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="ecology" checked>
|
||||
ecology日志
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="Resin">
|
||||
Resin日志
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="security">
|
||||
安全日志
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="integration">
|
||||
集成日志
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="sql">
|
||||
sql日志
|
||||
</label>
|
||||
</div>
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="cus" checked>
|
||||
cus日志
|
||||
</label>
|
||||
</div>
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="http_util" checked>
|
||||
http_util日志
|
||||
</label>
|
||||
</div>
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="sql_log" checked>
|
||||
sql_log日志
|
||||
</label>
|
||||
</div>
|
||||
<div class="clusterIp">
|
||||
<label>
|
||||
<input type="checkbox" class="checkbox" name="loytype" value="util_cus" checked>
|
||||
util_cus日志
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="cluster">
|
||||
<div>时间范围</div>
|
||||
<div class="clusterPlan">
|
||||
<div style="text-algin:center;font-family: PingFangSC-Regular;font-size: 12px;color: #999999;letter-spacing: -0.07px;">
|
||||
<span style="padding-right:10px;color:#6d6d6d;">开始时间</span>
|
||||
<input id="downstartlogDate" class="Wdate" type="text"
|
||||
onclick="WdatePicker({minDate:'#F{getold7Day()}',maxDate:'%y-%M-%d'})" size="16" readonly/>
|
||||
-
|
||||
<span style="padding-right:10px;color:#6d6d6d;">结束时间</span>
|
||||
<input id="downendlogDate" class="Wdate" type="text"
|
||||
onclick="WdatePicker({minDate:'#F{getold7Day()}',maxDate:'%y-%M-%d'})" size="16" readonly/>
|
||||
<span style="width: 10px;display:inline-block"></span>
|
||||
<button class="Button" id="start" onclick="collectLog()">收集日志</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cluster" style="height: 300px;max-height: 300px;overflow-y:auto ">
|
||||
<div>下载列表</div>
|
||||
<div class="clusterPlan">
|
||||
<%
|
||||
java.util.Iterator it = ipList.iterator();
|
||||
while (it.hasNext()) {
|
||||
String ip = (String) it.next();
|
||||
ip = ip.replaceAll("\\.", "");
|
||||
ip = ip.replaceAll(":", "");
|
||||
%>
|
||||
<div id="<%=ip%>div">
|
||||
</div>
|
||||
<div id="<%=ip%>messagediv" class="messages"></div>
|
||||
<%}%>
|
||||
|
||||
<%if (!isCluster) { %>
|
||||
<div id="logdiv"></div>
|
||||
<div id="logmessagediv" class="messages"></div>
|
||||
<%} %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,14 @@
|
|||
var $lang={
|
||||
errAlertMsg: "Invalid date or the date out of range,redo or not?",
|
||||
aWeekStr: ["wk", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||||
aLongWeekStr:["wk","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
|
||||
aMonStr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
aLongMonStr: ["January","February","March","April","May","June","July","August","September","October","November","December"],
|
||||
clearStr: "Clear",
|
||||
todayStr: "Today",
|
||||
okStr: "OK",
|
||||
updateStr: "OK",
|
||||
timeStr: "Time",
|
||||
quickStr: "Quick Selection",
|
||||
err_1: 'MinDate Cannot be bigger than MaxDate!'
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
var $lang={
|
||||
errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u8303\u56F4,\u9700\u8981\u64A4\u9500\u5417?",
|
||||
aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],
|
||||
aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],
|
||||
aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"],
|
||||
aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],
|
||||
clearStr: "\u6E05\u7A7A",
|
||||
todayStr: "\u4ECA\u5929",
|
||||
okStr: "\u786E\u5B9A",
|
||||
updateStr: "\u786E\u5B9A",
|
||||
timeStr: "\u65F6\u95F4",
|
||||
quickStr: "\u5FEB\u901F\u9009\u62E9",
|
||||
err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u65E5\u671F!'
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
var $lang={
|
||||
errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u7BC4\u570D,\u9700\u8981\u64A4\u92B7\u55CE?",
|
||||
aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],
|
||||
aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],
|
||||
aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"],
|
||||
aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],
|
||||
clearStr: "\u6E05\u7A7A",
|
||||
todayStr: "\u4ECA\u5929",
|
||||
okStr: "\u78BA\u5B9A",
|
||||
updateStr: "\u78BA\u5B9A",
|
||||
timeStr: "\u6642\u9593",
|
||||
quickStr: "\u5FEB\u901F\u9078\u64C7",
|
||||
err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u65BC\u6700\u5927\u65E5\u671F!'
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
.Wdate{
|
||||
border:#999 1px solid;
|
||||
height:20px;
|
||||
background:#fff url(datePicker.gif) no-repeat right;
|
||||
}
|
||||
.Wdate::-ms-clear{display:none;}
|
||||
|
||||
.WdateFmtErr{
|
||||
font-weight:bold;
|
||||
color:red;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* My97 DatePicker 4.8
|
||||
*/
|
||||
|
||||
.WdateDiv{
|
||||
width:180px;
|
||||
background-color:#FFFFFF;
|
||||
border:#bbb 1px solid;
|
||||
padding:2px;
|
||||
}
|
||||
|
||||
.WdateDiv2{
|
||||
width:360px;
|
||||
}
|
||||
.WdateDiv *{font-size:9pt;}
|
||||
|
||||
.WdateDiv .NavImg a{
|
||||
display:block;
|
||||
cursor:pointer;
|
||||
height:16px;
|
||||
width:16px;
|
||||
}
|
||||
|
||||
.WdateDiv .NavImgll a{
|
||||
float:left;
|
||||
background:transparent url(img.gif) no-repeat scroll 0 0;
|
||||
}
|
||||
.WdateDiv .NavImgl a{
|
||||
float:left;
|
||||
background:transparent url(img.gif) no-repeat scroll -16px 0;
|
||||
}
|
||||
.WdateDiv .NavImgr a{
|
||||
float:right;
|
||||
background:transparent url(img.gif) no-repeat scroll -32px 0;
|
||||
}
|
||||
.WdateDiv .NavImgrr a{
|
||||
float:right;
|
||||
background:transparent url(img.gif) no-repeat scroll -48px 0;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTitle{
|
||||
height:24px;
|
||||
margin-bottom:2px;
|
||||
padding:1px;
|
||||
}
|
||||
|
||||
.WdateDiv .yminput{
|
||||
margin-top:2px;
|
||||
text-align:center;
|
||||
height:20px;
|
||||
border:0px;
|
||||
width:50px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.WdateDiv .yminputfocus{
|
||||
margin-top:2px;
|
||||
text-align:center;
|
||||
font-weight:bold;
|
||||
height:20px;
|
||||
color:blue;
|
||||
border:#ccc 1px solid;
|
||||
width:50px;
|
||||
}
|
||||
|
||||
.WdateDiv .menuSel{
|
||||
z-index:1;
|
||||
position:absolute;
|
||||
background-color:#FFFFFF;
|
||||
border:#ccc 1px solid;
|
||||
display:none;
|
||||
}
|
||||
|
||||
.WdateDiv .menu{
|
||||
cursor:pointer;
|
||||
background-color:#fff;
|
||||
}
|
||||
|
||||
.WdateDiv .menuOn{
|
||||
cursor:pointer;
|
||||
background-color:#BEEBEE;
|
||||
}
|
||||
|
||||
.WdateDiv .invalidMenu{
|
||||
color:#aaa;
|
||||
}
|
||||
|
||||
.WdateDiv .YMenu{
|
||||
margin-top:20px;
|
||||
|
||||
}
|
||||
|
||||
.WdateDiv .MMenu{
|
||||
margin-top:20px;
|
||||
*width:62px;
|
||||
}
|
||||
|
||||
.WdateDiv .hhMenu{
|
||||
margin-top:-90px;
|
||||
margin-left:26px;
|
||||
}
|
||||
|
||||
.WdateDiv .mmMenu{
|
||||
margin-top:-46px;
|
||||
margin-left:26px;
|
||||
}
|
||||
|
||||
.WdateDiv .ssMenu{
|
||||
margin-top:-24px;
|
||||
margin-left:26px;
|
||||
}
|
||||
|
||||
.WdateDiv .Wweek {
|
||||
text-align:center;
|
||||
background:#DAF3F5;
|
||||
border-right:#BDEBEE 1px solid;
|
||||
}
|
||||
|
||||
.WdateDiv .MTitle{
|
||||
background-color:#BDEBEE;
|
||||
}
|
||||
.WdateDiv .WdayTable2{
|
||||
border-collapse:collapse;
|
||||
border:#c5d9e8 1px solid;
|
||||
}
|
||||
.WdateDiv .WdayTable2 table{
|
||||
border:0;
|
||||
}
|
||||
|
||||
.WdateDiv .WdayTable{
|
||||
line-height:20px;
|
||||
border:#c5d9e8 1px solid;
|
||||
}
|
||||
.WdateDiv .WdayTable td{
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.WdateDiv .Wday{
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.WdateDiv .WdayOn{
|
||||
cursor:pointer;
|
||||
background-color:#C0EBEF;
|
||||
}
|
||||
|
||||
.WdateDiv .Wwday{
|
||||
cursor:pointer;
|
||||
color:#FF2F2F;
|
||||
}
|
||||
|
||||
.WdateDiv .WwdayOn{
|
||||
cursor:pointer;
|
||||
color:#000;
|
||||
background-color:#C0EBEF;
|
||||
}
|
||||
.WdateDiv .Wtoday{
|
||||
cursor:pointer;
|
||||
color:blue;
|
||||
}
|
||||
.WdateDiv .Wselday{
|
||||
background-color:#A9E4E9;
|
||||
}
|
||||
.WdateDiv .WspecialDay{
|
||||
background-color:#66F4DF;
|
||||
}
|
||||
|
||||
.WdateDiv .WotherDay{
|
||||
cursor:pointer;
|
||||
color:#6A6AFF;
|
||||
}
|
||||
|
||||
.WdateDiv .WotherDayOn{
|
||||
cursor:pointer;
|
||||
background-color:#C0EBEF;
|
||||
}
|
||||
|
||||
.WdateDiv .WinvalidDay{
|
||||
color:#aaa;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime{
|
||||
float:left;
|
||||
margin-top:3px;
|
||||
margin-right:30px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime #dpTimeStr{
|
||||
margin-left:1px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime input{
|
||||
width:18px;
|
||||
height:20px;
|
||||
text-align:center;
|
||||
border:#ccc 1px solid;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime .tB{
|
||||
border-right:0px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime .tE{
|
||||
border-left:0;
|
||||
border-right:0;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime .tm{
|
||||
width:7px;
|
||||
border-left:0;
|
||||
border-right:0;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime #dpTimeUp{
|
||||
height:10px;
|
||||
width:13px;
|
||||
border:0px;
|
||||
background:url(img.gif) no-repeat -32px -16px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime #dpTimeDown{
|
||||
height:10px;
|
||||
width:13px;
|
||||
border:0px;
|
||||
background:url(img.gif) no-repeat -48px -16px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpQS {
|
||||
float:left;
|
||||
margin-right:3px;
|
||||
margin-top:3px;
|
||||
background:url(img.gif) no-repeat 0px -16px;
|
||||
width:20px;
|
||||
height:20px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.WdateDiv #dpControl {
|
||||
text-align:right;
|
||||
}
|
||||
.WdateDiv .dpButton{
|
||||
height:20px;
|
||||
width:45px;
|
||||
border:#ccc 1px solid;
|
||||
margin-top:2px;
|
||||
margin-right:1px;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 307 B |
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* My97 DatePicker 4.8 Skin:whyGreen
|
||||
*/
|
||||
.WdateDiv{
|
||||
width:180px;
|
||||
background-color:#fff;
|
||||
border:#C5E1E4 1px solid;
|
||||
padding:2px;
|
||||
}
|
||||
|
||||
.WdateDiv2{
|
||||
width:360px;
|
||||
}
|
||||
.WdateDiv *{font-size:9pt;}
|
||||
|
||||
.WdateDiv .NavImg a{
|
||||
cursor:pointer;
|
||||
display:block;
|
||||
width:16px;
|
||||
height:16px;
|
||||
margin-top:1px;
|
||||
}
|
||||
|
||||
.WdateDiv .NavImgll a{
|
||||
float:left;
|
||||
background:url(img.gif) no-repeat;
|
||||
}
|
||||
.WdateDiv .NavImgl a{
|
||||
float:left;
|
||||
background:url(img.gif) no-repeat -16px 0px;
|
||||
}
|
||||
.WdateDiv .NavImgr a{
|
||||
float:right;
|
||||
background:url(img.gif) no-repeat -32px 0px;
|
||||
}
|
||||
.WdateDiv .NavImgrr a{
|
||||
float:right;
|
||||
background:url(img.gif) no-repeat -48px 0px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTitle{
|
||||
height:24px;
|
||||
padding:1px;
|
||||
border:#c5d9e8 1px solid;
|
||||
background:url(bg.jpg);
|
||||
margin-bottom:2px;
|
||||
}
|
||||
|
||||
.WdateDiv .yminput{
|
||||
margin-top:2px;
|
||||
text-align:center;
|
||||
border:0px;
|
||||
height:20px;
|
||||
width:50px;
|
||||
color:#034c50;
|
||||
background-color:transparent;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.WdateDiv .yminputfocus{
|
||||
margin-top:2px;
|
||||
text-align:center;
|
||||
border:#939393 1px solid;
|
||||
font-weight:bold;
|
||||
color:#034c50;
|
||||
height:20px;
|
||||
width:50px;
|
||||
}
|
||||
|
||||
.WdateDiv .menuSel{
|
||||
z-index:1;
|
||||
position:absolute;
|
||||
background-color:#FFFFFF;
|
||||
border:#A3C6C8 1px solid;
|
||||
display:none;
|
||||
}
|
||||
|
||||
.WdateDiv .menu{
|
||||
cursor:pointer;
|
||||
background-color:#fff;
|
||||
color:#11777C;
|
||||
}
|
||||
|
||||
.WdateDiv .menuOn{
|
||||
cursor:pointer;
|
||||
background-color:#BEEBEE;
|
||||
}
|
||||
|
||||
.WdateDiv .invalidMenu{
|
||||
color:#aaa;
|
||||
}
|
||||
|
||||
.WdateDiv .YMenu{
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
.WdateDiv .MMenu{
|
||||
margin-top:20px;
|
||||
*width:62px;
|
||||
}
|
||||
|
||||
.WdateDiv .hhMenu{
|
||||
margin-top:-90px;
|
||||
margin-left:26px;
|
||||
}
|
||||
|
||||
.WdateDiv .mmMenu{
|
||||
margin-top:-46px;
|
||||
margin-left:26px;
|
||||
}
|
||||
|
||||
.WdateDiv .ssMenu{
|
||||
margin-top:-24px;
|
||||
margin-left:26px;
|
||||
}
|
||||
|
||||
.WdateDiv .Wweek {
|
||||
text-align:center;
|
||||
background:#DAF3F5;
|
||||
border-right:#BDEBEE 1px solid;
|
||||
}
|
||||
|
||||
.WdateDiv .MTitle{
|
||||
color:#13777e;
|
||||
background-color:#bdebee;
|
||||
}
|
||||
.WdateDiv .WdayTable2{
|
||||
border-collapse:collapse;
|
||||
border:#BEE9F0 1px solid;
|
||||
}
|
||||
.WdateDiv .WdayTable2 table{
|
||||
border:0;
|
||||
}
|
||||
|
||||
.WdateDiv .WdayTable{
|
||||
line-height:20px;
|
||||
color:#13777e;
|
||||
background-color:#edfbfb;
|
||||
border:#BEE9F0 1px solid;
|
||||
}
|
||||
.WdateDiv .WdayTable td{
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.WdateDiv .Wday{
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.WdateDiv .WdayOn{
|
||||
cursor:pointer;
|
||||
background-color:#74d2d9 ;
|
||||
}
|
||||
|
||||
.WdateDiv .Wwday{
|
||||
cursor:pointer;
|
||||
color:#ab1e1e;
|
||||
}
|
||||
|
||||
.WdateDiv .WwdayOn{
|
||||
cursor:pointer;
|
||||
background-color:#74d2d9;
|
||||
}
|
||||
.WdateDiv .Wtoday{
|
||||
cursor:pointer;
|
||||
color:blue;
|
||||
}
|
||||
.WdateDiv .Wselday{
|
||||
background-color:#A7E2E7;
|
||||
}
|
||||
.WdateDiv .WspecialDay{
|
||||
background-color:#66F4DF;
|
||||
}
|
||||
|
||||
.WdateDiv .WotherDay{
|
||||
cursor:pointer;
|
||||
color:#0099CC;
|
||||
}
|
||||
|
||||
.WdateDiv .WotherDayOn{
|
||||
cursor:pointer;
|
||||
background-color:#C0EBEF;
|
||||
}
|
||||
|
||||
.WdateDiv .WinvalidDay{
|
||||
color:#aaa;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime{
|
||||
float:left;
|
||||
margin-top:3px;
|
||||
margin-right:30px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime #dpTimeStr{
|
||||
margin-left:1px;
|
||||
color:#497F7F;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime input{
|
||||
height:20px;
|
||||
width:18px;
|
||||
text-align:center;
|
||||
color:#333;
|
||||
border:#61CAD0 1px solid;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime .tB{
|
||||
border-right:0px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime .tE{
|
||||
border-left:0;
|
||||
border-right:0;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime .tm{
|
||||
width:7px;
|
||||
border-left:0;
|
||||
border-right:0;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime #dpTimeUp{
|
||||
height:10px;
|
||||
width:13px;
|
||||
border:0px;
|
||||
background:url(img.gif) no-repeat -32px -16px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpTime #dpTimeDown{
|
||||
height:10px;
|
||||
width:13px;
|
||||
border:0px;
|
||||
background:url(img.gif) no-repeat -48px -16px;
|
||||
}
|
||||
|
||||
.WdateDiv #dpQS {
|
||||
float:left;
|
||||
margin-right:3px;
|
||||
margin-top:3px;
|
||||
background:url(img.gif) no-repeat 0px -16px;
|
||||
width:20px;
|
||||
height:20px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.WdateDiv #dpControl {
|
||||
text-align:right;
|
||||
margin-top:3px;
|
||||
}
|
||||
.WdateDiv .dpButton{
|
||||
height:20px;
|
||||
width:45px;
|
||||
margin-top:2px;
|
||||
border:#38B1B9 1px solid;
|
||||
background-color:#CFEBEE;
|
||||
color:#08575B;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -0,0 +1,19 @@
|
|||
Date.prototype.format = function(format) //author: meizz
|
||||
{
|
||||
var o = {
|
||||
"M+" : this.getMonth()+1, //month
|
||||
"d+" : this.getDate(), //day
|
||||
"h+" : this.getHours(), //hour
|
||||
"m+" : this.getMinutes(), //minute
|
||||
"s+" : this.getSeconds(), //second
|
||||
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
|
||||
"S" : this.getMilliseconds() //millisecond
|
||||
}
|
||||
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
|
||||
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
|
||||
for(var k in o)if(new RegExp("("+ k +")").test(format))
|
||||
format = format.replace(RegExp.$1,
|
||||
RegExp.$1.length==1 ? o[k] :
|
||||
("00"+ o[k]).substr((""+ o[k]).length));
|
||||
return format;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,38 @@
|
|||
<%@ page language="java"%><%@ page import="java.util.Properties" %><%@ page import="java.text.*" %><%@ page import="java.util.*" %><%@ page import="java.util.zip.*" %><%@ page import="org.apache.commons.httpclient.HttpClient" %><%@ page import="org.apache.commons.httpclient.methods.GetMethod" %><%
|
||||
|
||||
String clusterIp = request.getParameter("clusterIp");
|
||||
String loytype = request.getParameter("loytype");
|
||||
String startDate = request.getParameter("startDate");
|
||||
String endDate = request.getParameter("endDate");
|
||||
String result = ""; //0,成功,1、参数不对,2、被拦截,3、ecology不能访问
|
||||
|
||||
weaver.hrm.User user = (weaver.hrm.User)request.getSession(true).getAttribute("weaver_user@bean");
|
||||
if(user==null || !"sysadmin".equals(user.getLoginid())){
|
||||
return ;
|
||||
}
|
||||
|
||||
if(clusterIp ==null || clusterIp.equals("") || loytype ==null || loytype.equals("") || startDate ==null || startDate.equals("")){
|
||||
result = "1";
|
||||
}
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
client.getHttpConnectionManager().getParams().setSoTimeout(60000*10);
|
||||
client.getHttpConnectionManager().getParams().setConnectionTimeout(6000*10);
|
||||
try {
|
||||
String url = "http://"+clusterIp+"/cus_getlog/getlog.jsp?loytype="+loytype+"&startDate="+startDate+"&endDate="+endDate;
|
||||
GetMethod gets = new GetMethod(url);
|
||||
client.executeMethod(gets);
|
||||
int code = gets.getStatusCode();
|
||||
if(code==200){
|
||||
result = new String(gets.getResponseBody(),"UTF-8");
|
||||
}else if(code == 302){
|
||||
result="2";
|
||||
}else{
|
||||
result="3";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result = "4";
|
||||
}
|
||||
out.println(result);
|
||||
%>
|
|
@ -33,6 +33,7 @@ public class JobTitleMultilingualUtil {
|
|||
private static void extracted() {
|
||||
try {
|
||||
Map<String, Object> jituMultilingual = Util.readProperties2Map("JituMultilingual", "cus.multilingual");
|
||||
Util.getLogger().info("配置文件:" + JSON.toJSONString(jituMultilingual));
|
||||
if (!isEmpty(jituMultilingual)) {
|
||||
for (Map.Entry<String, Object> entry : jituMultilingual.entrySet()) {
|
||||
LANGUAGE_MAP.put(entry.getKey(), Util.null2String(entry.getValue()));
|
||||
|
@ -159,30 +160,29 @@ public class JobTitleMultilingualUtil {
|
|||
// 对比缓存数据,如果是上一次传递进来的总数组,则不用再次分组
|
||||
if (!jsonArray.equals(this.jsonArray)) {
|
||||
this.jsonArray = jsonArray;
|
||||
extracted();
|
||||
this.groupMap = list.stream().collect(Collectors.groupingBy(getKey));
|
||||
log.info("job title group : " + JSON.toJSONString(this.groupMap));
|
||||
}
|
||||
String active = LANGUAGE_MAP.get("active");
|
||||
if (isBlank(active)) {
|
||||
return getName.apply(JSONObject.toJavaObject(currentObj, Map.class));
|
||||
}
|
||||
// 默认添加中文
|
||||
active += ",ZHS";
|
||||
|
||||
String[] activeLanguageArray = active.split(",");
|
||||
List<String> activeList = Arrays.stream(activeLanguageArray).distinct().collect(Collectors.toList());
|
||||
log.info("active language: " + JSON.toJSONString(activeList));
|
||||
log.info("language map: " + JSON.toJSONString(LANGUAGE_MAP));
|
||||
Set<String> set = new HashSet<>();
|
||||
Collections.addAll(set, activeLanguageArray);
|
||||
set.add("ZHS");
|
||||
groupMap = this.groupMap;
|
||||
if (!isEmpty(groupMap)) {
|
||||
List<Map> maps = groupMap.get(getKey.apply(JSONObject.toJavaObject(currentObj, Map.class)));
|
||||
log.info("current job Maps: " + JSON.toJSONString(maps));
|
||||
if (!isEmpty(maps)) {
|
||||
sb.append("~`");
|
||||
for (Map map : maps) {
|
||||
String name = getName.apply(map);
|
||||
String languageCd = getLanguageCd.apply(map);
|
||||
// 当语言转换映射map中存在并且已经开启语言同步时,将对语言进行序列化
|
||||
if (LANGUAGE_MAP.containsKey(languageCd) && activeList.contains(languageCd)) {
|
||||
if (LANGUAGE_MAP.containsKey(languageCd) && set.contains(languageCd)) {
|
||||
String languageId = LANGUAGE_MAP.get(languageCd);
|
||||
sb.append("~`").append(languageId).append(" ").append(name).append("`");
|
||||
}
|
||||
|
|
|
@ -326,13 +326,6 @@ public class PdfMultipleWaterAction implements Action {
|
|||
keyword, allMark, pdfWaterConfig.getOpacity(),
|
||||
pdfWaterConfig.getPicWidth(), pdfWaterConfig.getPciHeight(),
|
||||
pdfWaterConfig.getOffsetX(), pdfWaterConfig.getOffsetY());
|
||||
} catch (CustomerException e) {
|
||||
if (e.getCode() != null) {
|
||||
if (e.getCode() == -2) {
|
||||
throw new CustomerException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
Util.getLogger().error("水印文件生成失败!" + e.getMessage());
|
||||
throw new CustomerException("水印文件生成失败!" + e.getMessage(), e);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package youhong.ai.utiltest;
|
||||
|
||||
import basetest.BaseTest;
|
||||
import org.junit.Test;
|
||||
import weaver.general.GCONST;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class FileCleanup extends BaseTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void mainTest() {
|
||||
String folderPath = GCONST.getLogPath() + "cus" + File.separator; // 文件夹路径
|
||||
int n = 1; // 要删除的月份数
|
||||
System.out.println(folderPath);
|
||||
cleanupFiles(folderPath, n);
|
||||
}
|
||||
|
||||
public static void cleanupFiles(String folderPath, int n) {
|
||||
File folder = new File(folderPath);
|
||||
if (!folder.exists() || !folder.isDirectory()) {
|
||||
System.out.println("指定的路径不是文件夹或不存在!");
|
||||
return;
|
||||
}
|
||||
|
||||
File[] files = folder.listFiles();
|
||||
if (files == null || files.length == 0) {
|
||||
System.out.println("文件夹为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.MONTH, -n);
|
||||
Date thresholdDate = calendar.getTime();
|
||||
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
cleanupFiles(file.getAbsolutePath(), n); // 递归扫描子文件夹
|
||||
} else {
|
||||
String fileName = file.getName();
|
||||
if (fileName.matches(".*_\\d{8}\\.log")) {
|
||||
String dateString = fileName.substring(fileName.length() - 12, fileName.length() - 4);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
try {
|
||||
Date fileDate = dateFormat.parse(dateString);
|
||||
if (fileDate.before(thresholdDate)) {
|
||||
System.out.println(file.getName());
|
||||
boolean deleted = file.delete();
|
||||
if (deleted) {
|
||||
System.out.println("已删除文件: " + file.getAbsolutePath());
|
||||
} else {
|
||||
System.out.println("无法删除文件: " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("无法解析文件名中的日期: " + fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,9 +12,7 @@ import org.apache.poi.xssf.streaming.SXSSFRow;
|
|||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.junit.Test;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
import weaver.youhong.ai.haripijiu.action.sapdocking.VoucherPayableNewAction;
|
||||
import weaver.youhong.ai.geerde.action.submitfirst.AutoSubmitFirstAction;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
@ -97,7 +95,7 @@ public class GenericTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void testGre() {
|
||||
GenerateFileUtil.createActionDocument(VoucherPayableNewAction.class);
|
||||
GenerateFileUtil.createActionDocument(AutoSubmitFirstAction.class);
|
||||
}
|
||||
|
||||
|
||||
|
@ -247,8 +245,11 @@ public class GenericTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void tesetAction() {
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo request = requestService.getRequest(433436);
|
||||
System.out.println(JSON.toJSONString(request));
|
||||
// RequestService requestService = new RequestService();
|
||||
// RequestInfo request = requestService.getRequest(433436);
|
||||
// System.out.println(JSON.toJSONString(request));
|
||||
Map<String, Object> config = Util.readProperties2Map("esteeLauderExcelExport", "export");
|
||||
System.out.println(JSON.toJSONString(config));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package youhong.ai.utiltest;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class OFDKeywordSearchTest {
|
||||
public static void main(String[] args) {
|
||||
String filePath = "/Users/aoey.oct.22/Downloads/测试.ofd";
|
||||
String keyword = "签章位置";
|
||||
|
||||
try {
|
||||
List<KeywordLocation> keywordLocations = findKeywordLocations(filePath, keyword);
|
||||
if (keywordLocations.isEmpty()) {
|
||||
System.out.println("No occurrences of the keyword found.");
|
||||
} else {
|
||||
for (KeywordLocation location : keywordLocations) {
|
||||
System.out.println("Page: " + location.getPageNumber());
|
||||
System.out.println("Coordinates: " + location.getBoundingBox());
|
||||
}
|
||||
}
|
||||
} catch (IOException | ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<KeywordLocation> findKeywordLocations(String filePath, String keyword) throws IOException, ParserConfigurationException {
|
||||
List<KeywordLocation> keywordLocations = new ArrayList<>();
|
||||
|
||||
try (ZipFile zipFile = new ZipFile(filePath)) {
|
||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
if (entry.isDirectory() && entry.getName().equals("Pages")) {
|
||||
|
||||
}
|
||||
if (!entry.isDirectory() && entry.getName().endsWith(".xml")) {
|
||||
try (InputStream inputStream = zipFile.getInputStream(entry)) {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document document = dBuilder.parse(inputStream);
|
||||
|
||||
NodeList textNodes = document.getElementsByTagName("Text");
|
||||
|
||||
for (int i = 0; i < textNodes.getLength(); i++) {
|
||||
Node textNode = textNodes.item(i);
|
||||
|
||||
if (textNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element textElement = (Element) textNode;
|
||||
String textContent = textElement.getTextContent();
|
||||
|
||||
if (textContent.contains(keyword)) {
|
||||
int pageNumber = getPageNumber(entry.getName());
|
||||
Rectangle boundingBox = getBoundingBox(textElement);
|
||||
KeywordLocation location = new KeywordLocation(pageNumber, boundingBox);
|
||||
keywordLocations.add(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SAXException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return keywordLocations;
|
||||
}
|
||||
|
||||
private static int getPageNumber(String entryName) {
|
||||
String[] parts = entryName.split("_");
|
||||
String lastPart = parts[parts.length - 1];
|
||||
String pageNumberStr = lastPart.substring(0, lastPart.lastIndexOf('.'));
|
||||
return Integer.parseInt(pageNumberStr);
|
||||
}
|
||||
|
||||
private static Rectangle getBoundingBox(Element textElement) {
|
||||
int x = Integer.parseInt(textElement.getAttribute("Boundary").split(" ")[0]);
|
||||
int y = Integer.parseInt(textElement.getAttribute("Boundary").split(" ")[1]);
|
||||
int width = Integer.parseInt(textElement.getAttribute("Boundary").split(" ")[2]);
|
||||
int height = Integer.parseInt(textElement.getAttribute("Boundary").split(" ")[3]);
|
||||
return new Rectangle(x, y, width, height);
|
||||
}
|
||||
|
||||
private static class KeywordLocation {
|
||||
private final int pageNumber;
|
||||
private final Rectangle boundingBox;
|
||||
|
||||
public KeywordLocation(int pageNumber, Rectangle boundingBox) {
|
||||
this.pageNumber = pageNumber;
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
public Rectangle getBoundingBox() {
|
||||
return boundingBox;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Rectangle {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public Rectangle(int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + x + ", " + y + ", " + width + ", " + height + ")";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package youhong.ai.utiltest;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class OFDReader {
|
||||
|
||||
private final String ofdFilePath;
|
||||
private final String keyword;
|
||||
|
||||
public OFDReader(String ofdFilePath, String keyword) {
|
||||
this.ofdFilePath = ofdFilePath;
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public List<KeywordInfo> findKeywords() throws Exception {
|
||||
// 解析OFD.xml文件,获取OFD的根目录路径
|
||||
String rootDirPath = parseOFDXmlAndGetRootDirPath();
|
||||
if (rootDirPath == null) {
|
||||
throw new Exception("Failed to parse OFD.xml file!");
|
||||
}
|
||||
|
||||
// 打开OFD文件并获取ZipFile对象
|
||||
ZipFile zipFile = new ZipFile(ofdFilePath);
|
||||
|
||||
// 获取Pages目录下的所有页面文件夹
|
||||
List<String> pageFolders = getPageFolders(zipFile, rootDirPath);
|
||||
if (pageFolders == null || pageFolders.isEmpty()) {
|
||||
throw new Exception("No page found in the OFD file!");
|
||||
}
|
||||
|
||||
// 查找所有关键字的位置信息
|
||||
List<KeywordInfo> result = new ArrayList<>();
|
||||
for (String pageFolder : pageFolders) {
|
||||
KeywordInfo keywordInfo = findKeywordInPage(zipFile, pageFolder);
|
||||
if (keywordInfo != null) {
|
||||
result.add(keywordInfo);
|
||||
}
|
||||
}
|
||||
|
||||
zipFile.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
// 解析OFD.xml文件并获取OFD的根目录路径
|
||||
private String parseOFDXmlAndGetRootDirPath() throws Exception {
|
||||
ZipFile zipFile = new ZipFile(ofdFilePath);
|
||||
ZipEntry ofdXmlEntry = zipFile.getEntry("OFD.xml");
|
||||
InputStream inputStream = zipFile.getInputStream(ofdXmlEntry);
|
||||
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
|
||||
NodeList docRootNodes = doc.getElementsByTagName("ofd:DocRoot");
|
||||
if (docRootNodes.getLength() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String docRootPath = docRootNodes.item(0).getTextContent();
|
||||
String[] docRootPathSegments = docRootPath.split("/");
|
||||
if (docRootPathSegments.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return docRootPathSegments[0];
|
||||
}
|
||||
|
||||
// 获取Pages目录下的所有页面文件夹
|
||||
private List<String> getPageFolders(ZipFile zipFile, String rootDirPath) {
|
||||
List<String> pageFolders = new ArrayList<>();
|
||||
String pagesDirPath = rootDirPath + "/Pages/";
|
||||
|
||||
// 遍历OFD文件中所有的ZipEntry对象,查找所有页面文件夹
|
||||
zipFile.stream().forEach(entry -> {
|
||||
if (entry.getName().startsWith(pagesDirPath) && entry.isDirectory() && !entry.getName().equals(pagesDirPath)) {
|
||||
pageFolders.add(entry.getName());
|
||||
}
|
||||
});
|
||||
|
||||
return pageFolders;
|
||||
}
|
||||
|
||||
// 在指定页面中查找关键字
|
||||
private KeywordInfo findKeywordInPage(ZipFile zipFile, String pageFolder) throws Exception {
|
||||
ZipEntry contentXmlEntry = zipFile.getEntry(pageFolder + "Content.xml");
|
||||
InputStream inputStream = zipFile.getInputStream(contentXmlEntry);
|
||||
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
|
||||
NodeList textNodes = doc.getElementsByTagName("ofd:TextObject");
|
||||
|
||||
for (int i = 0; i < textNodes.getLength(); i++) {
|
||||
Node textNode = textNodes.item(i);
|
||||
String textContent = textNode.getTextContent();
|
||||
|
||||
if (textContent.contains(keyword)) {
|
||||
Node boundaryNode = textNode.getAttributes().getNamedItem("Boundary");
|
||||
String boundary = boundaryNode.getNodeValue();
|
||||
String[] boundarySegments = boundary.split(" ");
|
||||
|
||||
double x = Double.parseDouble(boundarySegments[0]);
|
||||
double y = Double.parseDouble(boundarySegments[1]);
|
||||
double width = Double.parseDouble(boundarySegments[2]);
|
||||
double height = Double.parseDouble(boundarySegments[3]);
|
||||
|
||||
KeywordInfo keywordInfo = new KeywordInfo(pageFolder, x, y, width, height);
|
||||
return keywordInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String filePath = "/Users/aoey.oct.22/Downloads/测试.ofd";
|
||||
String keyword = "签章位置";
|
||||
|
||||
OFDReader reader = new OFDReader(filePath, keyword);
|
||||
|
||||
try {
|
||||
List<KeywordInfo> keywordInfos = reader.findKeywords();
|
||||
|
||||
if (keywordInfos.isEmpty()) {
|
||||
System.out.println("No occurrences of the keyword found.");
|
||||
} else {
|
||||
for (KeywordInfo info : keywordInfos) {
|
||||
System.out.println("Page: " + info.getPageNumber());
|
||||
System.out.println("Coordinates: " + info.getBoundingBox());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeywordInfo {
|
||||
private final String pageFolder;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double width;
|
||||
private final double height;
|
||||
|
||||
public KeywordInfo(String pageFolder, double x, double y, double width, double height) {
|
||||
this.pageFolder = pageFolder;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public String getPageNumber() {
|
||||
int pageNumber = Integer.parseInt(pageFolder.substring(pageFolder.lastIndexOf('_') + 1, pageFolder.length() - 1));
|
||||
return String.valueOf(pageNumber);
|
||||
}
|
||||
|
||||
public String getBoundingBox() {
|
||||
return "(" + x + ", " + y + ", " + width + ", " + height + ")";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package youhong.ai.utiltest;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.fileUtil.pdf.PdfPointItem;
|
||||
import aiyh.utils.fileUtil.pdf.PdfUtil;
|
||||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.youhong.ai.zhishichanquan.ssocaiwu.util.AES;
|
||||
import org.junit.Test;
|
||||
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
|
||||
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023/5/17 14:20</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class PDFODFTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testOfdKeyword() throws IOException {
|
||||
|
||||
List<PdfPointItem> pointItemList = PdfUtil.findKeywordPoints(Files.newInputStream(Paths.get("/Users/aoey.oct.22/Downloads/测试.ofd")), "签章位置");
|
||||
System.out.println(JSON.toJSONString(pointItemList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void teest() throws ClassNotFoundException {
|
||||
Map<String, String> stringStringMap = Util.parseCusInterfacePathParam("weaver.youhong.ai.intellectualproperty.cusgetvalue.GetOfdKeywordPageValue?keywordType=0&keyword=电子签章001");
|
||||
System.out.println(stringStringMap);
|
||||
Class<?> aClass = Class.forName(stringStringMap.get("_ClassPath"));
|
||||
System.out.println(aClass);
|
||||
DealWithMapping dealWithMapping = new DealWithMapping();
|
||||
dealWithMapping.getCusInterfaceObj("weaver.youhong.ai.intellectualproperty.cusgetvalue.GetOfdKeywordPageValue?keywordType=0&keyword=电子签章001", CusInterfaceGetValue.class, stringStringMap);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void teesstA() throws UnsupportedEncodingException {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("user", "nieli");
|
||||
map.put("ts", System.currentTimeMillis());
|
||||
String a = AES.encrypt("SLwjQi043sKossVe", "9nP4OQ$eQ*WugI$1", JSON.toJSONString(map));
|
||||
System.out.println(AES.decrypt("SLwjQi043sKossVe", "9nP4OQ$eQ*WugI$1", a));
|
||||
System.out.println(a);
|
||||
String encode = URLEncoder.encode(a, "UTF-8");
|
||||
System.out.println(encode);
|
||||
System.out.println(URLDecoder.decode("3CXGaVSSX6LF6rjgpQsDoFsCwZr9Yu6/apKv3z%20z%20yURxjFYMXOZITr9CmqoTS/3"));
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue