Browse Source

提交开源任务材料

10.0
LAPTOP-SB56SG4Q\86185 3 years ago
parent
commit
aa9ec88eb0
  1. BIN
      JSD-7615-需求确认书V1-1.docx
  2. 5
      README.md
  3. 27
      plugin.xml
  4. 22
      src/main/java/com/fr/plugin/it/config/simple/DemoInitializeMonitor.java
  5. 23
      src/main/java/com/fr/plugin/it/config/simple/PluginInitializeFilterBridge.java
  6. 10
      src/main/java/com/fr/plugin/it/config/simple/PluginLocaleFinderBridge.java
  7. 112
      src/main/java/com/fr/plugin/it/config/simple/account/PluginSimpleConfig.java
  8. 88
      src/main/java/com/fr/plugin/it/flowApi/FlowApi.java
  9. 14
      src/main/java/com/fr/plugin/it/function/PickBill.java
  10. 14
      src/main/java/com/fr/plugin/it/function/Restart.java
  11. 14
      src/main/java/com/fr/plugin/it/function/StockBill.java
  12. 13
      src/main/java/com/fr/plugin/it/handler/ExtendAttrHandlerProvider.java
  13. 100
      src/main/java/com/fr/plugin/it/handler/FlowOperate.java
  14. 45
      src/main/java/com/fr/plugin/it/handler/Test.java
  15. 14
      src/main/java/com/fr/plugin/it/handler/URLAliasProvide.java
  16. 227
      src/main/java/com/fr/plugin/it/utils/DateUtilSelf.java
  17. 158
      src/main/java/com/fr/plugin/it/utils/FRUtils.java
  18. 229
      src/main/java/com/fr/plugin/it/utils/HttpUtils.java
  19. 68
      src/main/java/com/fr/plugin/it/utils/IOUtils.java
  20. 40
      src/main/java/com/fr/plugin/it/utils/PropertiesUtils.java
  21. 80
      src/main/java/com/fr/plugin/it/utils/ResponseUtils.java
  22. 91
      src/main/java/com/fr/plugin/it/utils/Utils.java
  23. 308
      src/main/java/com/fr/plugin/it/utils/XMLUtils.java
  24. 66
      src/main/java/com/fr/plugin/it/utils/test.java
  25. 58
      src/main/resources/a.js
  26. 28
      src/main/resources/test.js
  27. BIN
      使用手册.docx

BIN
JSD-7615-需求确认书V1-1.docx

Binary file not shown.

5
README.md

@ -1,3 +1,6 @@
# open-JSD-7615
JSD-7615 开源任务材料
JSD-7615 开源任务代码\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。

27
plugin.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.fr.plugin.it2</id>
<name><![CDATA[访问接口插件]]></name>
<active>yes</active>
<version>1.0.16</version>
<env-version>10.0</env-version>
<jartime>2018-07-31</jartime>
<vendor>fr.open</vendor>
<description><![CDATA[访问接口插件]]></description>
<change-notes><![CDATA[
]]></change-notes>
<main-package>com.fr.plugin.it</main-package>
<lifecycle-monitor class="com.fr.plugin.it.config.simple.DemoInitializeMonitor"/>
<extra-core>
<LocaleFinder class="com.fr.plugin.it.config.simple.PluginLocaleFinderBridge"/>
<FunctionDefineProvider class="com.fr.plugin.it.function.PickBill" name="createProducePickBill" description="生产领料"/>
<FunctionDefineProvider class="com.fr.plugin.it.function.StockBill" name="createProduceInStockBill" description="产成品入库单"/>
<FunctionDefineProvider class="com.fr.plugin.it.function.Restart" name="commitProducePickBill" description="生产任务单开工"/>
</extra-core>
<extra-decision>
<HttpHandlerProvider class="com.fr.plugin.it.handler.ExtendAttrHandlerProvider"/>
<URLAliasProvider class="com.fr.plugin.it.handler.URLAliasProvide"/>
</extra-decision>
<function-recorder class="com.fr.plugin.it.config.simple.account.PluginSimpleConfig"/>
</plugin>

22
src/main/java/com/fr/plugin/it/config/simple/DemoInitializeMonitor.java

@ -0,0 +1,22 @@
package com.fr.plugin.it.config.simple;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.it.config.simple.account.PluginSimpleConfig;
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
/**
* @author richie
* @version 10.0
* Created by richie on 2018-12-04
*/
public class DemoInitializeMonitor extends AbstractPluginLifecycleMonitor {
@Override
public void afterRun(PluginContext pluginContext) {
PluginSimpleConfig.getInstance();
}
@Override
public void beforeStop(PluginContext pluginContext) {
}
}

23
src/main/java/com/fr/plugin/it/config/simple/PluginInitializeFilterBridge.java

@ -0,0 +1,23 @@
package com.fr.plugin.it.config.simple;
import com.fr.decision.fun.impl.AbstractEmbedRequestFilterProvider;
import com.fr.plugin.it.config.simple.account.PluginSimpleConfig;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class PluginInitializeFilterBridge extends AbstractEmbedRequestFilterProvider {
@Override
public void init(FilterConfig filterConfig) {
PluginSimpleConfig.getInstance();
}
@Override
public void filter(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
}
}

10
src/main/java/com/fr/plugin/it/config/simple/PluginLocaleFinderBridge.java

@ -0,0 +1,10 @@
package com.fr.plugin.it.config.simple;
import com.fr.stable.fun.impl.AbstractLocaleFinder;
public class PluginLocaleFinderBridge extends AbstractLocaleFinder {
@Override
public String find() {
return "conf";
}
}

112
src/main/java/com/fr/plugin/it/config/simple/account/PluginSimpleConfig.java

@ -0,0 +1,112 @@
package com.fr.plugin.it.config.simple.account;
import com.fr.config.*;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.record.analyzer.EnableMetrics;
@Visualization(category = "流程接口配置")
@EnableMetrics
public class PluginSimpleConfig extends DefaultConfiguration {
private static volatile PluginSimpleConfig config = null;
@Focus(id="com.fr.plugin.it.config.simple", text = "流程接口配置", source = Original.PLUGIN)
public static PluginSimpleConfig getInstance() {
if (config == null) {
config = ConfigContext.getConfigInstance(PluginSimpleConfig.class);
}
return config;
}
@Identifier(value = "pickBill", name = "生产领料接口", description = "CreateProducePickBill", status = Status.SHOW)
private Conf<String> pickBill = Holders.simple("http://192.168.0.197/K3WISESync/K3StockService.asmx/CreateProducePickBill");
@Identifier(value = "stockBill", name = "产成品入库单接口", description = "CreateProduceInStockBill", status = Status.SHOW)
private Conf<String> stockBill = Holders.simple("http://192.168.0.197/K3WISESync/K3StockService.asmx/CreateProduceInStockBill");
@Identifier(value = "cPickBill", name = "生产任务单开工接口", description = "CommitProducePickBill", status = Status.SHOW)
private Conf<String> cPickBill = Holders.simple("http://192.168.0.197/K3WISESync/K3StockService.asmx/CommitProducePickBill");
// @Identifier(value = "submit", name = "提交工作任务接口", description = "SubmitWorkItem", status = Status.SHOW)
// private Conf<String> submit = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/SubmitWorkItem");
//
// @Identifier(value = "cancel", name = "批量取消流程接口", description = "CancelInstances", status = Status.SHOW)
// private Conf<String> cancel = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/CancelInstances");
//
// @Identifier(value = "cancelWithRemark", name = "取消流程接口", description = "CancelInstanceWithRemark", status = Status.SHOW)
// private Conf<String> cancelWithRemark = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/CancelInstanceWithRemark");
//
// @Identifier(value = "restart", name = "重新激活流程接口", description = "ReStartWorkflow", status = Status.SHOW)
// private Conf<String> restart = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/ReStartWorkflow");
public String getPickBill() {
return pickBill.get();
}
public void setPickBill(String url) {
this.pickBill.set(url);
}
public String getStockBill() {
return stockBill.get();
}
public void setStockBill(String url) {
this.stockBill.set(url);
}
public String getCPickBill() {
return cPickBill.get();
}
public void setCPickBill(String url) {
this.cPickBill.set(url);
}
// public String getReturn1() {
// return return1.get();
// }
//
// public void setReturn1(String url) {
// this.return1.set(url);
// }
//
// public String getReturnToStart() {
// return returnToStart.get();
// }
//
// public void setReturnToStart(String url) {
// this.returnToStart.set(url);
// }
//
// public String getSubmit() {
// return submit.get();
// }
//
// public void setSubmit(String url) {
// this.submit.set(url);
// }
//
// public String getCancel() {
// return cancel.get();
// }
//
// public void setCancel(String url) {
// this.cancel.set(url);
// }
@Override
public Object clone() throws CloneNotSupportedException {
PluginSimpleConfig cloned = (PluginSimpleConfig) super.clone();
// cloned.text = (Conf<String>) text.clone();
// cloned.count = (Conf<Integer>) count.clone();
// cloned.price = (Conf<Double>) price.clone();
// cloned.time = (Conf<Long>) time.clone();
// cloned.student = (Conf<Boolean>) student.clone();
return cloned;
}
}

88
src/main/java/com/fr/plugin/it/flowApi/FlowApi.java

@ -0,0 +1,88 @@
package com.fr.plugin.it.flowApi;
import com.fr.plugin.it.config.simple.account.PluginSimpleConfig;
import com.fr.plugin.it.utils.*;
import java.util.*;
public class FlowApi {
//生产领料
public static String createProducePickBill(Object[] object){
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
String startUrl = psc.getPickBill();
String k3UserName = String.valueOf(object[0]);
String billData = String.valueOf(object[1]);
String entityData =String.valueOf(object[2]);
String billDataXml = XMLUtils.generateXml(billData,entityData);
Map<String,String> param = new HashMap<String,String>();
param.put("K3UserName",k3UserName);
param.put("BillData",billDataXml);
param.put("BillStatus","1");
String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
return XMLUtils.xmlToList(result);
}
//产成品入库单
public static String createProduceInStockBill(Object[] object){
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
String startUrl = psc.getStockBill();
// String startUrl = "http://192.168.0.197/K3WISESync/K3StockService.asmx/CreateProduceInStockBill";
String k3UserName = String.valueOf(object[0]);
String billData = String.valueOf(object[1]);
String entityData =String.valueOf(object[2]);
String billDataXml = XMLUtils.generateXml2(billData,entityData);
Map<String,String> param = new HashMap<String,String>();
param.put("K3UserName",k3UserName);
param.put("BillData",billDataXml);
param.put("BillStatus","0");
String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
return XMLUtils.xmlToList(result);
}
//3、生产任务单开工
public static String commitProducePickBill(Object[] object){
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
String startUrl = psc.getCPickBill();
String k3UserName = String.valueOf(object[0]);
String k3BillNo = String.valueOf(object[1]);
Map<String,String> param = new HashMap<String,String>();
param.put("K3UserName",k3UserName);
param.put("K3BillNo",k3BillNo);
String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
return XMLUtils.xmlToList(result);
}
//billInfo:,entityinfo
private static Map<String,String> strToMap(String str){
Map<String,String> resultMap = new HashMap<String,String>();
String[] params = str.split(",");
for(String param : params){
String[] strs = param.split("=");
String value = strs.length == 1 ? "" :strs[1];
resultMap.put(strs[0],value);
}
return resultMap;
}
}

14
src/main/java/com/fr/plugin/it/function/PickBill.java

@ -0,0 +1,14 @@
package com.fr.plugin.it.function;
import com.fr.plugin.it.flowApi.FlowApi;
import com.fr.script.AbstractFunction;
import com.fr.stable.exception.FormulaException;
public class PickBill extends AbstractFunction {
@Override
public Object run(Object[] objects) throws FormulaException {
String result = FlowApi.createProducePickBill(objects);
return result;
}
}

14
src/main/java/com/fr/plugin/it/function/Restart.java

@ -0,0 +1,14 @@
package com.fr.plugin.it.function;
import com.fr.plugin.it.flowApi.FlowApi;
import com.fr.script.AbstractFunction;
import com.fr.stable.exception.FormulaException;
public class Restart extends AbstractFunction {
@Override
public Object run(Object[] objects) throws FormulaException {
String result = FlowApi.commitProducePickBill(objects);
return result;
}
}

14
src/main/java/com/fr/plugin/it/function/StockBill.java

@ -0,0 +1,14 @@
package com.fr.plugin.it.function;
import com.fr.plugin.it.flowApi.FlowApi;
import com.fr.script.AbstractFunction;
import com.fr.stable.exception.FormulaException;
public class StockBill extends AbstractFunction {
@Override
public Object run(Object[] objects) throws FormulaException {
String result = FlowApi.createProduceInStockBill(objects);
return result;
}
}

13
src/main/java/com/fr/plugin/it/handler/ExtendAttrHandlerProvider.java

@ -0,0 +1,13 @@
package com.fr.plugin.it.handler;
import com.fr.decision.fun.HttpHandler;
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider;
public class ExtendAttrHandlerProvider extends AbstractHttpHandlerProvider {
@Override
public HttpHandler[] registerHandlers() {
return new HttpHandler[]{
new FlowOperate()
};
}
}

100
src/main/java/com/fr/plugin/it/handler/FlowOperate.java

@ -0,0 +1,100 @@
package com.fr.plugin.it.handler;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.json.JSONObject;
import com.fr.plugin.it.flowApi.FlowApi;
import com.fr.plugin.it.utils.FRUtils;
import com.fr.plugin.it.utils.ResponseUtils;
import com.fr.plugin.it.utils.Utils;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@FunctionRecorder
public class FlowOperate extends BaseHttpHandler {
public FlowOperate() {
}
@Override
public RequestMethod getMethod() {
return RequestMethod.POST;
}
@Override
public String getPath() {
return "/flowOperate";
}
@Override
public boolean isPublic() {
return true;
}
@Override
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
FRUtils.FRLogInfo("调用接口!");
String operateName = req.getParameter("operateName");
if("createProducePickBill".equals(operateName)){
Object[] param = new Object[3];
String k3UserName = req.getParameter("K3UserName");
String BillData = req.getParameter("BillData");
String entityData = req.getParameter("entityData");
param[0] =k3UserName;
param[1] =BillData;
param[2] =entityData;
String result = FlowApi.createProducePickBill(param);
if(Utils.isNullStr(result)){
ResponseUtils.failedResponse(res,"接口调用失败!");
return ;
}
ResponseUtils.successResponse(res,result);
}
else if("createProduceInStockBill".equals(operateName)){
Object[] param = new Object[3];
String k3UserName = req.getParameter("K3UserName");
String BillData = req.getParameter("BillData");
String entityData = req.getParameter("entityData");
param[0] =k3UserName;
param[1] =BillData;
param[2] =entityData;
String result = FlowApi.createProduceInStockBill(param);
if(Utils.isNullStr(result)){
ResponseUtils.failedResponse(res,"接口调用失败(500)!");
return ;
}
ResponseUtils.successResponse(res,result);
}
else if("commitProducePickBill".equals(operateName)){
Object[] param = new Object[2];
String K3UserName = req.getParameter("K3UserName");
String K3BillNo = req.getParameter("K3BillNo");
param[0] =K3UserName;
param[1] =K3BillNo;
String result = FlowApi.commitProducePickBill(param);
if(Utils.isNullStr(result)){
ResponseUtils.failedResponse(res,"接口调用失败!");
return ;
}
ResponseUtils.successResponse(res,result);
}
}
}

45
src/main/java/com/fr/plugin/it/handler/Test.java

@ -0,0 +1,45 @@
package com.fr.plugin.it.handler;
import com.fr.plugin.it.utils.DateUtilSelf;
import com.fr.plugin.it.utils.XMLUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) {
String t = "1618156800000";
Long timestamp = Long.parseLong(t);
Date data = new Date();
data.setTime(timestamp);
System.out.println(DateUtilSelf.DateToString(data,"yyyy-MM-dd"));
// String text = "FPURPOSENUMBER=YBLL,FCUSTNUMBER=4E01,FBILLNO=WORK024875,FDATE=[object+Object],FBILLERNAME=4E13,FFMANAGERNUMBER=admin,FSMANAGERNUMBER=admin,FROB=1,FSOURCEBILLTYPE=85,FOPERATETYPE=1,FSEQ=1,FMATERIALNUMBER=03.02.001.00002,FBATCHNO=210411001,FQTY=,FSTOCKNUMBER=老车间现场仓,FPLANMODENUMBER=MTS,FNOTE=''";
//
// String a = "1,2,3,4";
//
// Map<String,String> billDataMap = strToMap(text);
// String billDataXml = XMLUtils.generateXml(XMLUtils.pickBillXml,billDataMap);
// System.out.println();
}
private static Map<String,String> strToMap(String str){
Map<String,String> resultMap = new HashMap<String,String>();
String[] params = str.split(",");
for(String param : params){
String[] strs = param.split("=");
String value = strs.length == 1 ? "" :strs[1];
resultMap.put(strs[0],value);
}
return resultMap;
}
}

14
src/main/java/com/fr/plugin/it/handler/URLAliasProvide.java

@ -0,0 +1,14 @@
package com.fr.plugin.it.handler;
import com.fr.decision.fun.impl.AbstractURLAliasProvider;
import com.fr.decision.webservice.url.alias.URLAlias;
import com.fr.decision.webservice.url.alias.URLAliasFactory;
public class URLAliasProvide extends AbstractURLAliasProvider {
@Override
public URLAlias[] registerAlias() {
return new URLAlias[]{
URLAliasFactory.createPluginAlias("/flowOperate","/flowOperate",true),
};
}
}

227
src/main/java/com/fr/plugin/it/utils/DateUtilSelf.java

@ -0,0 +1,227 @@
package com.fr.plugin.it.utils;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class DateUtilSelf {
/**
* 日期转换为日期字符串
* @param date
* @param formatStr
* @return String
*/
public static String DateToString(Date date,String formatStr) {
SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
String dateStr = sdf.format(date).toString();
return dateStr;
}
/**
* 日期字符串转换日期
* @param dateStr
* @param formatStr
* @return Date
*/
public static Date strToDate(String dateStr,String formatStr){
SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
Date date = null;
try {
date = sdf.parse(dateStr);
}
catch(Exception e) {
}
return date;
}
/**
* Date转Timestamp
* @param date
* @return
*/
public static Timestamp dateToTimestamp(Date date) {
Date transDate = DateUtilSelf.strToDate(DateUtilSelf.DateToString(date, "yyyy-MM-dd hh:mm:ss"),"yyyy-MM-dd hh:mm:ss");
Timestamp timestamp = new Timestamp(transDate.getTime());
return timestamp;
}
/**
* Date字符串转Timestamp
* @param dateStr
* @param format
* @return
*/
public static Timestamp strToTimestamp(String dateStr,String format) {
Date date = strToDate(dateStr,format);
Timestamp timestamp = new Timestamp(date.getTime());
return timestamp;
}
/**
* 获取两个日期字符串之间的天数
* @param startDateStr
* @param endDateStr
* @param formatStr
* @return
*/
public static int getDays(String startDateStr,String endDateStr,String formatStr) {
Date startDate = strToDate(startDateStr,formatStr);
Date endDate = strToDate(endDateStr,formatStr);
long startTime = startDate.getTime();
long endTime = endDate.getTime();
int days = (int) ((endTime - startTime)/(60*60*24*1000));
return days;
}
/**
* 获取给定时间之前之后的时间
* @param type
* @param dateStr
* @param count
* @param formatStr
* @return
*/
public static String getAfterDateStr(int type,String dateStr,int count,String formatStr) {
Date startDate = strToDate(dateStr,formatStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(type, count);
String endDateStr = DateToString(calendar.getTime(),formatStr);
return endDateStr;
}
/**
* 获取给定时间之前之后的时间
* @param type
* @param date
* @param count
* @param formatStr
* @return
*/
public static String getAfterDateStr(int type,Date date,int count,String formatStr) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(type, count);
String endDateStr = DateToString(calendar.getTime(),formatStr);
return endDateStr;
}
/**
* 获取给定时间之前之后的时间
* @param type
* @param date
* @param count
* @return
*/
public static Date getAfterDateStr(int type,Date date,int count) {
Calendar dateResult = Calendar.getInstance();
dateResult.setTime(date);
dateResult.add(type, count);
return dateResult.getTime();
}
/**
* 时间戳转日期
* @param timestamp
* @return
*/
public static Date timestampToDate(Timestamp timestamp) {
Date date = new Date(timestamp.getTime());
return date;
}
/**
* 时间戳转时间字符串
* @param timestamp
* @param format 日期格式
* @return
*/
public static String timestampToStr(Timestamp timestamp,String format) {
Date date = timestampToDate(timestamp);
String timeStr = DateToString(date, format);
return timeStr;
}
/**
* 获取所给日期length天内每一天的日期
* @param date 所给日期yyyy-MM-dd
* @param length 长度
* @return
*/
public static List<String> getDateList(String date,int length){
List<String> dateList = new ArrayList<String>();
String format = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//获取length天后的日期
String targetDate = getAfterDateStr(Calendar.DATE,date,length,format);
Date start = null;
Date end = null;
if(length >= 0) {
start = strToDate(date,format);
end = strToDate(targetDate,format);
}else {
start = strToDate(targetDate,format);
end = strToDate(date,format);
}
Calendar calBegin = Calendar.getInstance();
calBegin.setTime(start);
Calendar calEnd = Calendar.getInstance();
calEnd.setTime(end);
while (end.after(calBegin.getTime())) {
calBegin.add(Calendar.DATE, 1);
String dayStr = sdf.format(calBegin.getTime());
dateList.add(dayStr);
}
return dateList;
}
/**
* 比较startDate是否在endDate之前
* @param startDate
* @param endDate
* @param format
* @return 0 两个日期相等 <0 开始日期在结束日期之前 >0 开始日期在结束日期之后
*/
public static int comparisonDate(String startDate,String endDate,String format) {
Date start = strToDate(startDate,format);
Date end = strToDate(endDate,format);
return start.compareTo(end);
}
//获取当前日期年、月、日、时、分、秒
public static int getCount(int type){
Calendar calendar = Calendar.getInstance();
return calendar.get(type);
}
}

158
src/main/java/com/fr/plugin/it/utils/FRUtils.java

@ -0,0 +1,158 @@
package com.fr.plugin.it.utils;
import com.fr.decision.authority.AuthorityContext;
import com.fr.decision.authority.data.User;
import com.fr.decision.webservice.login.LogInOutResultInfo;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.decision.webservice.v10.login.LoginService;
import com.fr.decision.webservice.v10.login.event.LogInOutEvent;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.event.EventDispatcher;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.restriction.RestrictionFactory;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
public class FRUtils {
/**
* 判断用户是否存在
* @param userName
* @return
*/
public static boolean isUserExist(String userName){
if (StringUtils.isEmpty(userName)) {
return false;
} else {
try {
List var1 = AuthorityContext.getInstance().getUserController().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", userName)));
return var1 != null && !var1.isEmpty();
} catch (Exception var2) {
FineLoggerFactory.getLogger().error(var2.getMessage());
return false;
}
}
}
/**
* 判断是否登录FR
* @param req
* @return
*/
public static boolean isLogin(HttpServletRequest req){
return LoginService.getInstance().isLogged(req);
}
/**
* 帆软登录
* @param httpServletRequest
* @param httpServletResponse
* @param userName
* @param url
*/
public static void login(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String userName,String url){
FineLoggerFactory.getLogger().info("FRLOG:用户名:"+userName);
FineLoggerFactory.getLogger().info("FRLOG:跳转链接:"+url);
//判断用户名是否为空
if(!Utils.isNullStr(userName)){
if(isUserExist(userName)){
String FRToken = "";
try {
HttpSession session = httpServletRequest.getSession(true);
FRToken = LoginService.getInstance().login(httpServletRequest, httpServletResponse, userName);
httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,FRToken);
session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, FRToken);
EventDispatcher.fire(LogInOutEvent.LOGIN,new LogInOutResultInfo(httpServletRequest,httpServletResponse,userName,true));
FineLoggerFactory.getLogger().info("FRLOG:登陆成功!");
if(!Utils.isNullStr(url)){
httpServletResponse.sendRedirect(url);
}
} catch (Exception e) {
ResponseUtils.failedResponse(httpServletResponse,"登录异常,请联系管理员!");
FineLoggerFactory.getLogger().info("FRLOG:登录异常,请联系管理员!");
FineLoggerFactory.getLogger().info("FRLOGException:"+e.getMessage());
}
}else{
ResponseUtils.failedResponse(httpServletResponse,"用户在报表系统中不存在!");
FineLoggerFactory.getLogger().info("FRLOG:用户在报表系统中不存在!");
}
}else{
ResponseUtils.failedResponse(httpServletResponse,"用户名不能为空!");
FineLoggerFactory.getLogger().info("FRLOG:用户名不能为空!");
}
}
/**
*
* @param httpServletRequest
* @param httpServletResponse
*/
public static void logout(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse)
{
if(!isLogin(httpServletRequest)){
return ;
}
try {
LoginService.getInstance().logout(httpServletRequest,httpServletResponse);
} catch (Exception e) {
ResponseUtils.failedResponse(httpServletResponse,"登出异常,请联系管理员!");
FineLoggerFactory.getLogger().info("FRLOG:登出异常,请联系管理员!");
FineLoggerFactory.getLogger().info("FRLOGException:"+e.getMessage());
}
}
/**
* 打印FR日志
* @param message
*/
public static void FRLogInfo(String message){
FineLoggerFactory.getLogger().info("FRLOG:"+message);
}
/**
* 根据用户名获取用户信息
* @param userName
* @return
*/
public static User getFRUserByUserName(String userName){
try {
return UserService.getInstance().getUserByUserName(userName);
} catch (Exception e) {
FRLogInfo("获取用户信息异常:"+e.getMessage());
}
return null;
}
/**
* 解密FR密码
* @param password
* @return
*/
// public static String decryptFRPsd(String password){
// FRLogInfo("解密密码:"+password);
// return TransmissionTool.decrypt(password);
// }
/**
* 获取带参数的访问链接
* @return
*/
public static String getAllUrl(HttpServletRequest httpServletRequest){
return WebUtils.getOriginalURL(httpServletRequest);
}
}

229
src/main/java/com/fr/plugin/it/utils/HttpUtils.java

@ -0,0 +1,229 @@
package com.fr.plugin.it.utils;
import com.fr.log.FineLoggerFactory;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.NameValuePair;
import com.fr.third.org.apache.http.client.CookieStore;
import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.client.methods.HttpPost;
import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier;
import com.fr.third.org.apache.http.entity.StringEntity;
import com.fr.third.org.apache.http.impl.client.BasicCookieStore;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.third.org.apache.http.impl.client.HttpClients;
import com.fr.third.org.apache.http.impl.cookie.BasicClientCookie;
import com.fr.third.org.apache.http.message.BasicNameValuePair;
import com.fr.third.org.apache.http.ssl.SSLContexts;
import com.fr.third.org.apache.http.ssl.TrustStrategy;
import com.fr.third.org.apache.http.util.EntityUtils;
import javax.net.ssl.SSLContext;
import javax.servlet.http.Cookie;
import java.io.UnsupportedEncodingException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class HttpUtils {
/**
* httpGet请求
* @param url
* @return
*/
public static String get(String url,Cookie[] cookies){
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--url:"+url);
//创建httpClient
CloseableHttpClient httpclient = createHttpClient(cookies);
HttpGet getMethod = new HttpGet(url);
try {
HttpResponse response = httpclient.execute(getMethod);
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--status:"+response.getStatusLine().getStatusCode());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = response.getEntity();
String returnResult = EntityUtils.toString(entity, "utf-8");
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--returnResult:"+returnResult);
return returnResult;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--exception:"+e.getMessage());
}
return "";
}
/**
* HttpPost请求
* @param postMethod
* @return
*/
private static String HttpPost(HttpPost postMethod){
CloseableHttpClient httpclient = createHttpClient(null);
try {
HttpResponse response = httpclient.execute(postMethod);
FineLoggerFactory.getLogger().info("FRLOG:HttpPost:status:"+response.getStatusLine().getStatusCode());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = response.getEntity();
String returnResult = EntityUtils.toString(entity, "utf-8");
FineLoggerFactory.getLogger().info("FRLOG:HttpPost:returnResult:"+returnResult);
return returnResult;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpPost:exception:"+e.getMessage());
}
return "";
}
public static String HttpPostXML(String url, String xmlParam){
FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:url:"+url);
HttpPost postMethod = new HttpPost(url);
postMethod.setHeader("Content-type", "text/html");
HttpEntity entity2 = null;
try {
entity2 = new StringEntity(xmlParam);
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:参数异常:"+e.getMessage());
return "";
}
postMethod.setEntity(entity2);
return HttpPost(postMethod);
}
public static String HttpPostJson(String url, String param,Map<String,String> header){
FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:url:"+url);
HttpPost postMethod = new HttpPost(url);
postMethod.setHeader("Content-Type","application/json");
if(header != null && header.size() > 0){
Set<String> keySet = header.keySet();
for(String key : keySet){
postMethod.setHeader(key,header.get(key));
}
}
if(!Utils.isNullStr(param)){
HttpEntity entity2 = null;
try {
entity2 = new StringEntity(param);
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:参数异常:"+e.getMessage());
return "";
}
postMethod.setEntity(entity2);
}
return HttpPost(postMethod);
}
public static String HttpPostWWWForm(String url, Map<String,String> header,Map<String,String> param){
FineLoggerFactory.getLogger().info("FRLOG:HttpWWWForm:url:"+url);
HttpPost postMethod = new HttpPost(url);
if(header != null && header.size() > 0){
Set<String> keySet = header.keySet();
for(String key : keySet){
postMethod.setHeader(key,header.get(key));
}
}
if(param != null && param.size() > 0){
List<NameValuePair> params = new ArrayList<NameValuePair>(param.size());
for(Map.Entry<String,String> map : param.entrySet()){
params.add(new BasicNameValuePair(map.getKey(), map.getValue()));
}
try {
postMethod.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().info("FRLOG:HttpWWWForm:异常:"+e.getMessage());
return "";
}
}
return HttpPost(postMethod);
}
private static CloseableHttpClient createHttpClient(Cookie[] cookies){
SSLContext sslContext = null;
try {
sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
return true;
}
}).build();
} catch (NoSuchAlgorithmException e) {
FRUtils.FRLogInfo("createHttpClientException:"+e.getMessage());
} catch (KeyManagementException e) {
FRUtils.FRLogInfo("createHttpClientException:"+e.getMessage());
} catch (KeyStoreException e) {
FRUtils.FRLogInfo("createHttpClientException:"+e.getMessage());
}
CloseableHttpClient httpclient = null;
if(cookies != null && cookies.length > 0){
CookieStore cookieStore = cookieToCookieStore(cookies);
httpclient = HttpClients.custom().setSslcontext(sslContext).
setSSLHostnameVerifier(new NoopHostnameVerifier()).setDefaultCookieStore(cookieStore).build();
}
else{
httpclient = HttpClients.custom().setSslcontext(sslContext).
setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
}
return httpclient;
}
/**
* cookies转cookieStore
* @param cookies
* @return
*/
public static CookieStore cookieToCookieStore(Cookie[] cookies){
CookieStore cookieStore = new BasicCookieStore();
if(cookies != null && cookies.length>0){
for(Cookie cookie : cookies){
BasicClientCookie cookie1 = new BasicClientCookie(cookie.getName(), cookie.getValue());
cookieStore.addCookie(cookie1);
}
}
return cookieStore;
}
}

68
src/main/java/com/fr/plugin/it/utils/IOUtils.java

@ -0,0 +1,68 @@
package com.fr.plugin.it.utils;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
public class IOUtils {
/**
* 将inputStream写入本地文件
* @param url
* @param inputStream
*/
public static void writeFile(String url, InputStream inputStream){
int index;
byte[] bytes = new byte[1024];
FileOutputStream downloadFile = null ;
try {
downloadFile = new FileOutputStream(url);
while ((index = inputStream.read(bytes)) != -1) {
downloadFile.write(bytes, 0, index);
downloadFile.flush();
}
}catch(Exception e){
FRUtils.FRLogInfo("Exception:writeFile:"+e.getMessage());
}finally {
try {
inputStream.close();
downloadFile.close();
}
catch (Exception e){
FRUtils.FRLogInfo("Exception:writeFile:finally"+e.getMessage());
}
}
}
/**
* 字符串转输入流
* @param str
* @return
*/
public static InputStream strToInputStream(String str){
try {
return new ByteArrayInputStream(str.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
FRUtils.FRLogInfo("IOUtils-strToInputStream:exception:"+e.getMessage());
}
return null;
}
public static String inputStreamToStr(InputStream inputStream) {
StringBuffer stringBuffer = new StringBuffer();
byte[] byt = new byte[4096];
try {
for (int i; (i = inputStream.read(byt)) != -1; ) {
stringBuffer.append(new String(byt, 0, i));
}
}catch(Exception e){
FRUtils.FRLogInfo("Exception:inputStreamToStr:"+e.getMessage());
}
return stringBuffer.toString();
}
}

40
src/main/java/com/fr/plugin/it/utils/PropertiesUtils.java

@ -0,0 +1,40 @@
package com.fr.plugin.it.utils;
import com.fr.io.utils.ResourceIOUtils;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
public class PropertiesUtils {
// private static final String RESOURCES_PATH = "config";
// private static ResourceBundle bundle = null;
//
// static {
// bundle = ResourceBundle.getBundle(RESOURCES_PATH);
// }
//
// public static String getProperties(String key){
// return bundle.getString(key);
// }
/**
* 获取web-info下的配置文件
* @param path
* @return
*/
public static Properties getProperties2(String path){
Properties p = new Properties();
try{
InputStream is = ResourceIOUtils.read("/resources/wz.properties");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
p.load(bufferedReader);
}catch(Exception e){
FRUtils.FRLogInfo("获取配置文件异常");
}
return p;
}
}

80
src/main/java/com/fr/plugin/it/utils/ResponseUtils.java

@ -0,0 +1,80 @@
package com.fr.plugin.it.utils;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
public class ResponseUtils {
private static final int SUCCESS = 200;
private static final int FAILED = -1;
public static void successResponse(HttpServletResponse res, String body) {
response(res, body, SUCCESS);
}
public static void failedResponse(HttpServletResponse res, String body) {
response(res, body, FAILED);
}
private static void response(HttpServletResponse res, String body, int code) {
JSONObject object = new JSONObject();
PrintWriter pw;
try {
object.put("code", code);
object.put("data", new JSONObject(body));
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
return;
}
res.setContentType("application/json;charset=utf-8");
String result = object.toString();
pw.println(result);
pw.flush();
pw.close();
}
public static void response(HttpServletResponse res,JSONObject json){
PrintWriter pw;
try {
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
return;
}
res.setContentType("application/json;charset=utf-8");
String result = json.toString();
pw.println(result);
pw.flush();
pw.close();
}
public static void setCSRFHeader(HttpServletResponse httpServletResponse){
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,HEAD,PUT,PATCH");
httpServletResponse.setHeader("Access-Control-Max-Age", "36000");
httpServletResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,Authorization,authorization");
}
public static void responseJsonp(HttpServletRequest req, HttpServletResponse res, JSONObject json){
PrintWriter pw;
try {
pw = WebUtils.createPrintWriter(res);
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
return;
}
res.setContentType("text/javascript;charset=utf-8;charset=utf-8");
String result = json.toString();
String jsonp=req.getParameter("callback");
pw.println(jsonp+"("+result+")");
pw.flush();
pw.close();
}
}

91
src/main/java/com/fr/plugin/it/utils/Utils.java

@ -0,0 +1,91 @@
package com.fr.plugin.it.utils;
import com.fr.json.JSONObject;
import com.fr.stable.CodeUtils;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.util.UUID;
public class Utils {
/**
* 判断字符串是否为空
* @param str
* @return true 空字符串 false 非空字符串
*/
public static boolean isNullStr(String str){
return !(str != null && !str.isEmpty() && !"null".equals(str));
}
/**
* 判断字符串是否非空
* @param str
* @return
*/
public static boolean isNotNullStr(String str){
return !isNullStr(str);
}
/**
* MD5加密
* @param str
* @return
*/
public static String getMd5Str(String str)
{
return DigestUtils.md5Hex(str);
}
/**
* 获取完整的访问路径
*/
public static String getAllUrl(HttpServletRequest req, String queryStr){
String url = req.getRequestURL().toString();
if(isNullStr(queryStr)){
return url;
}
return url+"?"+queryStr;
}
/**
* 帆软shaEncode加密
*/
public static String shaEncode(String str){
return CodeUtils.sha256Encode(str);
}
/**
* 获取uuid
*/
public static String uuid(){
return UUID.randomUUID().toString();
}
public static JSONObject getRequestBody(HttpServletRequest req){
StringBuffer sb = new StringBuffer();
String line = null;
try {
BufferedReader reader = req.getReader();
while ((line = reader.readLine()) != null)
sb.append(line);
} catch (Exception e) {
FRUtils.FRLogInfo("getRequestBody:exception:"+e.getMessage());
}
//将空格和换行符替换掉避免使用反序列化工具解析对象时失败
String jsonString = sb.toString().replaceAll("\\s","").replaceAll("\n","");
JSONObject json = new JSONObject(jsonString);
return json;
}
public static String nullReplace(String str,String replace){
return isNullStr(str) ? replace:str;
}
}

308
src/main/java/com/fr/plugin/it/utils/XMLUtils.java

@ -0,0 +1,308 @@
package com.fr.plugin.it.utils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import java.util.*;
public class XMLUtils {
public static String pickBillXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<K3Wise>\n" +
"<BillInfo>\n" +
"<FPURPOSENUMBER>#FPURPOSENUMBER</FPURPOSENUMBER>\n" +
"<FCUSTNUMBER>#FCUSTNUMBER</FCUSTNUMBER>\n" +
"<FBILLNO>#FBILLNO</FBILLNO>\n" +
"<FDATE>#FDATE</FDATE>\n" +
"<FBILLERNAME>#FBILLERNAME</FBILLERNAME>\n" +
"<FFMANAGERNUMBER>#FFMANAGERNUMBER</FFMANAGERNUMBER>\n" +
"<FSMANAGERNUMBER>#FSMANAGERNUMBER</FSMANAGERNUMBER>\n" +
"<FROB>#FROB</FROB>\n" +
"<FSOURCEBILLTYPE>#FSOURCEBILLTYPE</FSOURCEBILLTYPE>\n" +
"<FOPERATETYPE>#FOPERATETYPE</FOPERATETYPE>\n" +
"<FNOTE>#FNOTE</FNOTE>\n" +
"#entityData"+
"</BillInfo>\n" +
"</K3Wise>";
public static String pickBillEntityXml =
"<EntityInfo>\n" +
"<FBILLNO>#FBILLNO</FBILLNO>\n" +
"<FSEQ>#FSEQ</FSEQ>\n" +
"<FMATERIALNUMBER>#FMATERIALNUMBER</FMATERIALNUMBER>\n" +
"<FBATCHNO>#FBATCHNO</FBATCHNO>\n" +
"<FQTY>#FQTY</FQTY>\n" +
"<FSTOCKNUMBER>#FSTOCKNUMBER</FSTOCKNUMBER>\n" +
"<FNOTE>#FNOTE</FNOTE> \n" +
"</EntityInfo>\n" ;
public static String cPickBillXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<K3Wise>\n" +
"<BillInfo>\n" +
" <FCUSTNUMBER>#FCUSTNUMBER</FCUSTNUMBER>\n" +
"<FBILLNO>#FBILLNO</FBILLNO>\n" +
"<FDATE>#FDATE</FDATE>\n" +
"<FBILLERNAME>#FBILLERNAME</FBILLERNAME>\n" +
"<FFMANAGERNUMBER>#FFMANAGERNUMBER</FFMANAGERNUMBER>\n" +
"<FSMANAGERNUMBER>#FSMANAGERNUMBER</FSMANAGERNUMBER>\n" +
"<FROB>#FROB</FROB>\n" +
"<FNOTE>#FNOTE</FNOTE>\n" +
"<FSOURCEBILLTYPE>#FSOURCEBILLTYPE</FSOURCEBILLTYPE>\n" +
"#entityData"+
"</BillInfo>\n" +
"</K3Wise>";
public static String cpickBillEntityXml =
"<EntityInfo>\n" +
"<FBILLNO>#FBILLNO</FBILLNO>\n" +
"<FSEQ>#FSEQ</FSEQ>\n" +
"<FMATERIALNUMBER>#FMATERIALNUMBER</FMATERIALNUMBER>\n" +
"<FBATCHNO>#FBATCHNO</FBATCHNO>\n" +
"<FQTY>#FQTY</FQTY>\n" +
"<FSTOCKNUMBER>#FSTOCKNUMBER</FSTOCKNUMBER>\n" +
// "<FCHKPASSITEM>#FCHKPASSITEM</FCHKPASSITEM>\n" +
"<FNOTE>#FNOTE</FNOTE>\n" +
"</EntityInfo>\n";
/**
* 生成领料entityData
* @param entityList
* @return
*/
private static String generateEntityXml(List<Map<String,String>> entityList) {
String entityData = "<EntityData>\n" ;
for(Map<String,String> entity : entityList){
String FBILLNO = Utils.nullReplace(entity.get("FBILLNO"),"");
String FSEQ = Utils.nullReplace(entity.get("FSEQ"),"");
String FMATERIALNUMBER = Utils.nullReplace(entity.get("FMATERIALNUMBER"),"");
String FBATCHNO = Utils.nullReplace(entity.get("FBATCHNO"),"");
String FQTY = Utils.nullReplace(entity.get("FQTY"),"");
String FSTOCKNUMBER = Utils.nullReplace(entity.get("FSTOCKNUMBER"),"");
String FNOTE = Utils.nullReplace(entity.get("FNOTE"),"");
entityData += pickBillEntityXml.replace("#FBILLNO",FBILLNO).replace("#FSEQ",FSEQ)
.replace("#FMATERIALNUMBER",FMATERIALNUMBER).replace("#FBATCHNO",FBATCHNO)
.replace("#FQTY",FQTY).replace("#FSTOCKNUMBER",FSTOCKNUMBER)
.replace("#FNOTE","");
}
return entityData+"</EntityData>\n";
}
public static String generateXml(String billinfo, String entityInfo) {
String xml = pickBillXml;
Map<String,String> map = strToMap(billinfo);
List<Map<String,String>> entityList = strToListM(entityInfo);
String FPURPOSENUMBER = Utils.nullReplace(map.get("FPURPOSENUMBER"),"");
String FCUSTNUMBER = Utils.nullReplace(map.get("FCUSTNUMBER"),"");
String FBILLNO = Utils.nullReplace(map.get("FBILLNO"),"");
String FDATE = Utils.nullReplace(map.get("FDATE"),"");
Long timestamp = Long.parseLong(FDATE);
Date data = new Date();
data.setTime(timestamp);
FDATE = DateUtilSelf.DateToString(data,"yyyy-MM-dd");
String FBILLERNAME = Utils.nullReplace(map.get("FBILLERNAME"),"");
String FFMANAGERNUMBER = Utils.nullReplace(map.get("FFMANAGERNUMBER"),"");
String FSMANAGERNUMBER = Utils.nullReplace(map.get("FSMANAGERNUMBER"),"");
String FROB = Utils.nullReplace(map.get("FROB"),"");
String FSOURCEBILLTYPE = Utils.nullReplace(map.get("FSOURCEBILLTYPE"),"");
String FOPERATETYPE = Utils.nullReplace(map.get("FOPERATETYPE"),"");
String FNOTE = Utils.nullReplace(map.get("FNOTE"),"");
String entityData = generateEntityXml(entityList);
xml = xml.replace("#FPURPOSENUMBER", FPURPOSENUMBER).replace("#FCUSTNUMBER", FCUSTNUMBER)
.replace("#FBILLNO", FBILLNO)
.replace("#FDATE", FDATE).replace("#FBILLERNAME", FBILLERNAME)
.replace("#FFMANAGERNUMBER", FFMANAGERNUMBER).replace("#FSMANAGERNUMBER", FSMANAGERNUMBER)
.replace("#FROB", FROB).replace("#FSOURCEBILLTYPE", FSOURCEBILLTYPE)
.replace("#FNOTE", FNOTE)
.replace("#FOPERATETYPE",FOPERATETYPE)
.replace("#entityData",entityData);
FRUtils.FRLogInfo("xml:"+xml);
return xml;
}
/**
* 生成领料entityData
* @param entityList
* @return
*/
private static String generateEntityXml2(List<Map<String,String>> entityList) {
String entityData = "<EntityData>\n" ;
for(Map<String,String> entity : entityList){
String FBILLNO = Utils.nullReplace(entity.get("FBILLNO"),"");
String FSEQ = Utils.nullReplace(entity.get("FSEQ"),"");
String FMATERIALNUMBER = Utils.nullReplace(entity.get("FMATERIALNUMBER"),"");
String FBATCHNO = Utils.nullReplace(entity.get("FBATCHNO"),"");
String FQTY = Utils.nullReplace(entity.get("FQTY"),"");
// String FCHKPASSITEM = Utils.nullReplace(entity.get("FCHKPASSITEM"),"");
String FSTOCKNUMBER = Utils.nullReplace(entity.get("FSTOCKNUMBER"),"");
entityData += cpickBillEntityXml.replace("#FBILLNO",FBILLNO).replace("#FSEQ",FSEQ)
.replace("#FMATERIALNUMBER",FMATERIALNUMBER).replace("#FBATCHNO",FBATCHNO)
.replace("#FQTY",FQTY)
// .replace("#FCHKPASSITEM",FCHKPASSITEM)
.replace("#FNOTE","").replace("#FSTOCKNUMBER",FSTOCKNUMBER);
}
return entityData+"</EntityData>\n";
}
public static String generateXml2(String billinfo, String entityInfo) {
String xml = cPickBillXml;
Map<String,String> map = strToMap(billinfo);
List<Map<String,String>> entityList = strToListM(entityInfo);
String FCUSTNUMBER = Utils.nullReplace(map.get("FCUSTNUMBER"),"");
String FBILLNO = Utils.nullReplace(map.get("FBILLNO"),"");
String FDATE = Utils.nullReplace(map.get("FDATE"),"");
Long timestamp = Long.parseLong(FDATE);
Date data = new Date();
data.setTime(timestamp);
FDATE = DateUtilSelf.DateToString(data,"yyyy-MM-dd");
String FBILLERNAME = Utils.nullReplace(map.get("FBILLERNAME"),"");
String FFMANAGERNUMBER = Utils.nullReplace(map.get("FFMANAGERNUMBER"),"");
String FSMANAGERNUMBER = Utils.nullReplace(map.get("FSMANAGERNUMBER"),"");
String FROB = Utils.nullReplace(map.get("FROB"),"");
String FSOURCEBILLTYPE = Utils.nullReplace(map.get("FSOURCEBILLTYPE"),"");
String FNOTE = Utils.nullReplace(map.get("FNOTE"),"");
String FBATCHNO = Utils.nullReplace(map.get("FBATCHNO"),"");
String FCHKPASSITEM = Utils.nullReplace(map.get("FCHKPASSITEM"),"");
String FSTOCKNUMBER = Utils.nullReplace(map.get("FSTOCKNUMBER"),"");
String entityData = generateEntityXml2(entityList);
xml = xml.replace("#FCUSTNUMBER", FCUSTNUMBER).replace("#FBATCHNO", FBATCHNO)
.replace("#FBILLNO", FBILLNO).replace("#FCHKPASSITEM", FCHKPASSITEM)
.replace("#FDATE", FDATE).replace("#FBILLERNAME", FBILLERNAME)
.replace("#FFMANAGERNUMBER", FFMANAGERNUMBER).replace("#FSMANAGERNUMBER", FSMANAGERNUMBER)
.replace("#FROB", FROB).replace("#FSOURCEBILLTYPE", FSOURCEBILLTYPE)
.replace("#FNOTE", FNOTE).replace("#FSTOCKNUMBER",FSTOCKNUMBER)
.replace("#entityData",entityData);
FRUtils.FRLogInfo("xml:"+xml);
return xml;
}
public static String xmlToList(String xml){
SAXReader reader = new SAXReader();
Document document = null;
FRUtils.FRLogInfo("xmlTolist:xml:"+xml);
try {
document = reader.read(IOUtils.strToInputStream(xml));
} catch (DocumentException e) {
FRUtils.FRLogInfo("documentException:"+e.getMessage());
}
Element feed = document.getRootElement();
String value2 = feed.getStringValue();
return value2;
}
private static Map<String,String> strToMap(String str){
Map<String,String> resultMap = new HashMap<String,String>();
String[] params = str.split(",");
for(String param : params){
String[] strs = param.split("=");
String value = strs.length == 1 ? "" :strs[1];
resultMap.put(strs[0],value);
}
return resultMap;
}
public static List<Map<String, String>> strToListM(String str) {
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
String[] entityData = colToRows(str);
for(String entity : entityData){
if(entity == null || entity.isEmpty()){
continue;
}
Map<String,String> resultMap = new HashMap<String,String>();
String[] params = entity.split(",");
resultMap.put("FBILLNO",params[0]);
resultMap.put("FSEQ",params[1]);
resultMap.put("FMATERIALNUMBER",params[2]);
resultMap.put("FBATCHNO",params[3]);
resultMap.put("FQTY",params[4]);
resultMap.put("FSTOCKNUMBER",params[5]);
list.add(resultMap);
}
return list;
}
public static List<Map<String, String>> strToListM2(String str) {
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
String[] entityData = colToRows(str);
for(String entity : entityData){
if(entity == null || entity.isEmpty()){
continue;
}
Map<String,String> resultMap = new HashMap<String,String>();
String[] params = entity.split(",");
resultMap.put("FBILLNO",params[0]);
resultMap.put("FSEQ",params[1]);
resultMap.put("FMATERIALNUMBER",params[2]);
resultMap.put("FBATCHNO",params[3]);
resultMap.put("FQTY",params[4]);
resultMap.put("FCHKPASSITEM",params[5]);
list.add(resultMap);
}
return list;
}
private static String[] colToRows(String str1){
String[] colums =str1.split(";");
String[] strList = new String[10];
for(int i =0;i<colums.length;i++){
String colum = colums[i];
String[] rows =colum.split(",");
for(int j=0; j<rows.length;j++){
String row = rows[j];
if(i==0){
strList[j] =row;
continue;
}
String str = strList[j];
str +=","+row;
strList[j]=str;
}
}
return strList;
}
}

66
src/main/java/com/fr/plugin/it/utils/test.java

@ -0,0 +1,66 @@
package com.fr.plugin.it.utils;
import com.fr.plugin.it.flowApi.FlowApi;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class test {
public static void main(String[] args) {
// String username = "桂琴";
// String billdata = "FPURPOSENUMBER=FPURPOSENUMBER,FCUSTNUMBER=FCUSTNUMBER,FBILLNO=FBILLNO," +
// "FDATE=FDATE,FBILLERNAME=FBILLERNAME,FFMANAGERNUMBER=FFMANAGERNUMBER,FSMANAGERNUMBER=FSMANAGERNUMBER," +
// "FROB=FROB,FSOURCEBILLTYPE=FSOURCEBILLTYPE,FNOTE=FNOTE,FSEQ=FSEQ,FMATERIALNUMBER=FMATERIALNUMBER," +
// "FQTY=FQTY,FSTOCKNUMBER=FSTOCKNUMBER";
// String billdata = "FPURPOSENUMBER=YBLL,FCUSTNUMBER=4E01,FBILLNO=WORK024875,FDATE=1618156800000,FBILLERNAME=4E13,FFMANAGERNUMBER=admin,FSMANAGERNUMBER=admin,FROB=1,FSOURCEBILLTYPE=85,FOPERATETYPE=1,FSEQ=1,FMATERIALNUMBER=03.02.001.00002,FBATCHNO=210411001,FQTY=,FSTOCKNUMBER=老车间现场仓,FPLANMODENUMBER=MTS,FNOTE=''";
// String entityData = "FBILLNO=FBILLNO,FSEQ=FSEQ,FMATERIALNUMBER=FMATERIALNUMBER,FBATCHNO=FBATCHNO," +
// "FQTY=FQTY,FSTOCKNUMBER=FSTOCKNUMBER,FNOTE=FNOTE;"+"FBILLNO=FBILLNO,FSEQ=FSEQ,FMATERIALNUMBER=FMATERIALNUMBER,FBATCHNO=FBATCHNO," +
// "FQTY=FQTY,FSTOCKNUMBER=FSTOCKNUMBER,FNOTE=FNOTE;";
//
// String xml = XMLUtils.generateXml(billdata,entityData);
//
// System.out.println();
//
// Object[] obj = new Object[2];
// obj[0] = username;
// obj[1] = billdata;
//
// String result = FlowApi.createProduceInStockBill(obj);
// System.out.println(result);
String entityDate = "WORK024921,WORK024921;" +
"1,2;" +
"10.01.01.002.00004,10.01.01.002.00006;" +
"00.01.001.00032,00.01.001.00004;" +
"1,2;" +
"MTS,MTS;";
List<Map<String,String>> xmlList = XMLUtils.strToListM(entityDate);
System.out.println();
// String[] colums =entityDate.split(";");
//
// String[] strList = new String[10];
//
// for(int i =0;i<colums.length;i++){
// String colum = colums[i];
// String[] rows =colum.split(",");
//
// for(int j=0; j<rows.length;j++){
// String row = rows[j];
// if(i==0){
// strList[j] =row;
// continue;
// }
//
// String str = strList[j];
// str +=","+row;
// strList[j]=str;
// }
// }
//
// System.out.println();
}
}

58
src/main/resources/a.js

@ -0,0 +1,58 @@
var tlr = contentPane.curLGP.getCellValue("D12");
var rwd = contentPane.curLGP.getCellValue("H6");
var ll_id = contentPane.curLGP.getCellValue('D15');alert(ll_id)
var zd = contentPane.curLGP.getCellValue("D11");
var fl = contentPane.curLGP.getCellValue("D11");
var ll = contentPane.curLGP.getCellValue("H11");
var xh = contentPane.curLGP.getCellValue("K15");
var cp_id = contentPane.curLGP.getCellValue("D7");
var ph = contentPane.curLGP.getCellValue("D6");
var sl = contentPane.curLGP.getCellValue("H8");
var fhck = contentPane.curLGP.getCellValue("H12");
var sj = contentPane.curLGP.getCellValue("L6").date_milliseconds;
if(sl==''){
sl = 0
}
$.ajax({
type:"POST",
async:true,
url : "http://app.onwings.com:8888/webroot/decision/url/flowOperate",
data:{
operateName:"createProducePickBill",
K3UserName:"桂琴",
BillStatus:'1',
BillData:"FPURPOSENUMBER=YBLL,FCUSTNUMBER="+ll_id+",FBILLNO="+rwd+",FDATE="+sj+",FBILLERNAME="+zd+",FFMANAGERNUMBER="+fl+",FSMANAGERNUMBER="+ll+",FROB=1,FSOURCEBILLTYPE=85,FOPERATETYPE=1,FSEQ="+xh+",FMATERIALNUMBER="+cp_id+",FBATCHNO="+ph+",FQTY="+sl+",FSTOCKNUMBER="+fhck+",FPLANMODENUMBER=MTS,FNOTE=0",
entityData:"FBILLNO=FBILLNO,FSEQ=FSEQ,FMATERIALNUMBER=FMATERIALNUMBER,FBATCHNO=FBATCHNO," +
"FQTY=FQTY,FSTOCKNUMBER=FSTOCKNUMBER,FNOTE=FNOTE;"+"FBILLNO=FBILLNO,FSEQ=FSEQ,FMATERIALNUMBER=FMATERIALNUMBER,FBATCHNO=FBATCHNO," +
"FQTY=FQTY,FSTOCKNUMBER=FSTOCKNUMBER,FNOTE=FNOTE"
},
success:function(data){
console.info(data);
if(data.code == -1){
//调用接口失败
alert("调用接口失败")
}else{
// alert('调用接口成功')
//调用接口成功
//接口返回JSON数据
//格式: {
// "STATUS": "-1",
// "INFO": "用户aaaa不存在.",
// "RESULT": ""
// }
var result = data.data;
// alert('申请领料单成功')
alert(data.data.INFO);
// window.parent.FS.tabPane.closeActiveTab();
// alert(data.data.status);
// alert(data.data.RESULT);
}
},
error:function(data){
}
})

28
src/main/resources/test.js

@ -0,0 +1,28 @@
$.ajax({
type:"POST",
async:false,
url : "localhost:8075/webroot/decision/url/flowOperate",
data:{
operateName:"commitProducePickBill",
K3UserName:"aa",
K3BillNo:"1"
},
success:function(data){
if(data.code == -1){
//调用接口失败
}else{
//调用接口成功
//接口返回JSON数据
//格式: {
// "STATUS": "-1",
// "INFO": "用户aaaa不存在.",
// "RESULT": ""
// }
var result = data.data;
}
},
error:function(data){
}
})

BIN
使用手册.docx

Binary file not shown.
Loading…
Cancel
Save