Commit b711bbf5 by yukang

生产订单增加单重

parent 15dc5ad7
......@@ -19,57 +19,57 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class BaiDuApi {
// 鉴权接口
private static final String TOKEN_URL = "https://aip.baidubce.com/oauth/2.0/token";
// 标准版接口地址
private static final String BASIC_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic";
// 办公文档版接口地址
private static final String OFFICE_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis_office";
// Api Key
private static final String API_KEY = "dkXgTCScKjfMmL7oCzAIFdgZ";
// Secret Key
private static final String SECRET_KEY = "xP5V9k23KBNHOyzc0rYkm00GdQMMxvEh";
/**
* 获取TOKEN
*
* @return
*/
public static String getToken() {
return SingletonHolder.TOKEN;
}
/**
* 刷新TOKEN
*
* @return
*/
public static void refreshToken() {
SingletonHolder.refresh();
}
public static void main(String[] args) throws IOException {
// String filePath = "e:/10001.jpg";
String filePath = "e:/新年贺词.pdf";
docAnalysisOffice(filePath);
}
/**
* 解析办公文档
*
* @param filePath 本地文件地址
*/
public static void docAnalysisOffice(String filePath) throws IOException {
byte[] fileBytes = FileUtils.readByBytes(filePath);
String fileBase64 = Base64Utils.encode(fileBytes);
String fileEncoder = URLEncoder.encode(fileBase64, "UTF-8");
String param = "pdf_file_num=2&image=" + fileEncoder;
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/x-www-form-urlencoded");
String url = OFFICE_URL + "?access_token=" + getToken();
String result = HttpUtils.post(url, header, param, HttpUtils.FORM_MEDIA_TYPE);
log.info("result->{}", result);
}
// // 鉴权接口
// private static final String TOKEN_URL = "https://aip.baidubce.com/oauth/2.0/token";
// // 标准版接口地址
// private static final String BASIC_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic";
// // 办公文档版接口地址
// private static final String OFFICE_URL = "https://aip.baidubce.com/rest/2.0/ocr/v1/doc_analysis_office";
// // Api Key
// private static final String API_KEY = "dkXgTCScKjfMmL7oCzAIFdgZ";
// // Secret Key
// private static final String SECRET_KEY = "xP5V9k23KBNHOyzc0rYkm00GdQMMxvEh";
//
// /**
// * 获取TOKEN
// *
// * @return
// */
// public static String getToken() {
// return SingletonHolder.TOKEN;
// }
//
// /**
// * 刷新TOKEN
// *
// * @return
// */
// public static void refreshToken() {
// SingletonHolder.refresh();
// }
//
// public static void main(String[] args) throws IOException {
//// String filePath = "e:/10001.jpg";
// String filePath = "e:/新年贺词.pdf";
// docAnalysisOffice(filePath);
// }
//
// /**
// * 解析办公文档
// *
// * @param filePath 本地文件地址
// */
// public static void docAnalysisOffice(String filePath) throws IOException {
// byte[] fileBytes = FileUtils.readByBytes(filePath);
// String fileBase64 = Base64Utils.encode(fileBytes);
// String fileEncoder = URLEncoder.encode(fileBase64, "UTF-8");
// String param = "pdf_file_num=2&image=" + fileEncoder;
// Map<String, String> header = new HashMap<>();
// header.put("Content-Type", "application/x-www-form-urlencoded");
// String url = OFFICE_URL + "?access_token=" + getToken();
// String result = HttpUtils.post(url, header, param, HttpUtils.FORM_MEDIA_TYPE);
// log.info("result->{}", result);
// }
/**
* 静态内部类用于初始化
......@@ -79,38 +79,38 @@ public class BaiDuApi {
*/
private static class SingletonHolder {
/**
* 默认DAO
*/
private static String TOKEN = "24.717d5b52074bdf31d0377a4afa6c97d6.2592000.1709101017.282335-48528257";//getToken();
/**
* 获取TOKEN
*
* @return
* @throws IOException
*/
private static String getToken() {
try {
String url = String.format("%s?client_id=%s&client_secret=%s&grant_type=client_credentials",
TOKEN_URL, API_KEY, SECRET_KEY);
String result = HttpUtils.post(url);
JSONObject resultJson = JSONObject.parseObject(result);
return resultJson.getString("access_token");
} catch (Exception e) {
log.error("获取百度API的TOKEN失败:{}", e.getMessage(), e);
}
return null;
}
/**
* 刷新TOKEN
*
* @return
*/
public static void refresh() {
TOKEN = getToken();
}
// /**
// * 默认DAO
// */
// private static String TOKEN = "24.717d5b52074bdf31d0377a4afa6c97d6.2592000.1709101017.282335-48528257";//getToken();
//
// /**
// * 获取TOKEN
// *
// * @return
// * @throws IOException
// */
// private static String getToken() {
// try {
// String url = String.format("%s?client_id=%s&client_secret=%s&grant_type=client_credentials",
// TOKEN_URL, API_KEY, SECRET_KEY);
// String result = HttpUtils.post(url);
// JSONObject resultJson = JSONObject.parseObject(result);
// return resultJson.getString("access_token");
// } catch (Exception e) {
// log.error("获取百度API的TOKEN失败:{}", e.getMessage(), e);
// }
// return null;
// }
//
// /**
// * 刷新TOKEN
// *
// * @return
// */
// public static void refresh() {
// TOKEN = getToken();
// }
}
......
......@@ -32,6 +32,7 @@ public class HPSC005 extends DaoEPBase {
public static final String FIELD_PRDT_NAME = "prdtName"; /* 部件名称*/
public static final String FIELD_PLAN_COMPLETION_DATE = "planCompletionDate"; /* 计划完成日期*/
public static final String FIELD_NUM = "num"; /* 计划数量*/
public static final String FIELD_UNIT_WT = "unitWt"; /* 单重*/
public static final String FIELD_TOTAL_WT = "totalWt"; /* 计划重量*/
public static final String FIELD_STATUS = "status"; /* 状态 0-未派工,1-已派工*/
public static final String FIELD_ORG_NO = "orgNo"; /* 生产组编码*/
......@@ -59,6 +60,8 @@ public class HPSC005 extends DaoEPBase {
public static final String COL_PRDT_NAME = "PRDT_NAME"; /* 部件名称*/
public static final String COL_PLAN_COMPLETION_DATE = "PLAN_COMPLETION_DATE"; /* 计划完成日期*/
public static final String COL_NUM = "NUM"; /* 计划数量*/
public static final String COL_UNIT_WT = "UNIT_WT"; /* 单重*/
public static final String COL_TOTAL_WT = "TOTAL_WT"; /* 计划重量*/
public static final String COL_STATUS = "STATUS"; /* 状态 0-未派工,1-已派工*/
public static final String COL_ORG_NO = "ORG_NO"; /* 生产组编码*/
......@@ -92,6 +95,8 @@ public class HPSC005 extends DaoEPBase {
private String prdtName = " "; /* 部件名称*/
private String planCompletionDate = " "; /* 计划完成日期*/
private BigDecimal num = new BigDecimal(0.000); /* 计划数量*/
private BigDecimal unitWt = new BigDecimal(0.000); /* 单重*/
private BigDecimal totalWt = new BigDecimal(0.000); /* 计划重量*/
private Integer status = new Integer(0); /* 状态 0-未派工,1-已派工*/
private String orgNo = " "; /* 生产组编码*/
......@@ -170,6 +175,13 @@ public class HPSC005 extends DaoEPBase {
eiColumn.setDescName("计划数量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_UNIT_WT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(15);
eiColumn.setDescName("计划单重");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_TOTAL_WT);
eiColumn.setType("N");
eiColumn.setScaleLength(3);
......@@ -303,6 +315,22 @@ public class HPSC005 extends DaoEPBase {
eiColumn.setDescName("产品-厚");
eiMetadata.addMeta(eiColumn);
}
/**
* get the unitWt - 单重.
* @return the unitWt
*/
public BigDecimal getUnitWt() {
return this.unitWt;
}
/**
* set the unitWt - 单重.
*
* @param unitWt - 单重
*/
public void setUnitWt(BigDecimal unitWt) {
this.unitWt = unitWt;
}
public String getRemark1() {
return this.remark1;
}
......@@ -906,6 +934,7 @@ public class HPSC005 extends DaoEPBase {
setPartLength(NumberUtils.toBigDecimal(StringUtils.toString(map.get("partLength")), partLength));
setPartWidth(NumberUtils.toBigDecimal(StringUtils.toString(map.get("partWidth")), partWidth));
setPartThick(NumberUtils.toBigDecimal(StringUtils.toString(map.get("partThick")), partThick));
setUnitWt(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_UNIT_WT)), unitWt));
}
......@@ -954,6 +983,7 @@ public class HPSC005 extends DaoEPBase {
map.put("partLength", StringUtils.toString(partLength, eiMetadata.getMeta("partLength")));
map.put("partWidth", StringUtils.toString(partWidth, eiMetadata.getMeta("partWidth")));
map.put("partThick", StringUtils.toString(partThick, eiMetadata.getMeta("partThick")));
map.put(FIELD_UNIT_WT, StringUtils.toString(unitWt, eiMetadata.getMeta(FIELD_UNIT_WT)));
return map;
}
......
......@@ -403,6 +403,7 @@ public class ServiceHPSC002 extends ServiceBase {
HPSC004.setRemark(HPSC002.getRemark());
HPSC004.setNum(HPSC002.getNum());
HPSC004.setUnitWt(HPSC002.getUnitWt());
HPSC004.setTotalWt(HPSC002.getTotalWt());
HPSC004.setFilePath1(HPSC002.getId().toString());
HPSC004.setPlanCommentDate("");
HPSC004.setPlanCompletionDate("");
......
......@@ -227,7 +227,8 @@ public class ServiceHPSC003 extends ServiceBase {
HPSC005.setRemark1(HPSC004.getRemark());
HPSC005.setPlanCompletionDate(HPSC004.getPlanCompletionDate());
HPSC005.setNum(HPSC004.getNum());
HPSC005.setTotalWt(HPSC004.getUnitWt());
HPSC005.setUnitWt(HPSC004.getUnitWt());
HPSC005.setTotalWt(HPSC004.getTotalWt());
HPSC005.setStatus(0);
HPSC005.setFilePath1(HPSC004.getFilePath1());
DaoUtils.insert("HPSC005.insert", HPSC005.toMap());
......
......@@ -26,7 +26,7 @@ public class ServiceHPSC098 extends ServiceBase {
EiInfo outInfo = new EiInfo();
outInfo.set("inqu_status-0-companyCode", UserSessionUtils.getCompanyCode());
outInfo.set("inqu_status-0-orgCname", inInfo.get("inqu_status-0-orgCname"));
outInfo = super.query(outInfo, "XSOG0801.queryOrgList", new XSOG01());
outInfo = super.query(outInfo, "HPPZ011.query", new XSOG01());
EiBlock r3Block = new EiBlock("result");
r3Block.setRows(outInfo.getBlock(EiConstant.resultBlock).getRows());
outInfo.addBlock(r3Block);
......@@ -42,7 +42,7 @@ public class ServiceHPSC098 extends ServiceBase {
HashMap params = new HashMap();
params.put("orgCname",inInfo.get("inqu_status-0-orgCname"));
params.put("companyCode", UserSessionUtils.getCompanyCode());
List list = dao.query("XSOG0801.queryOrgList",params,0,-999999);
List list = dao.query("query.query",params,0,-999999);
outInfo.addBlock(EiConstant.resultBlock).addBlockMeta(XSOG01.eiMetadata);
outInfo.addBlock(EiConstant.resultBlock).addRows(list);
outInfo.getBlock(EiConstant.resultBlock).set("limit", list.size());
......
......@@ -123,6 +123,7 @@
PRDT_NAME as "prdtName", <!-- 部件名称 -->
PLAN_COMPLETION_DATE as "planCompletionDate", <!-- 计划完成日期 -->
NUM as "num", <!-- 计划数量 -->
UNIT_WT as "unitWt", <!-- 单重 -->
TOTAL_WT as "totalWt", <!-- 计划重量 -->
STATUS as "status", <!-- 状态 0-未派工,1-已派工 -->
ORG_NO as "orgNo", <!-- 生产组编码 -->
......@@ -240,6 +241,7 @@
PRDT_NAME, <!-- 部件名称 -->
PLAN_COMPLETION_DATE, <!-- 计划完成日期 -->
NUM, <!-- 计划数量 -->
UNIT_WT,
TOTAL_WT, <!-- 计划重量 -->
STATUS, <!-- 状态 0-未派工,1-已派工 -->
ORG_NO, <!-- 生产组编码 -->
......@@ -269,7 +271,7 @@
PART_THICK <!-- 厚 -->
)
VALUES (#id#, #companyCode#, #projCode#, #projName#, #productionOrderNo#,#inventRecordId#, #prdtType#, #prdtCode#,
#prdtName#, #planCompletionDate#, #num#, #totalWt#, #status#, #orgNo#, #orgName#, #createdBy#, #createdTime#,
#prdtName#, #planCompletionDate#, #num#,#unitWt#, #totalWt#, #status#, #orgNo#, #orgName#, #createdBy#, #createdTime#,
#updatedBy#, #updatedTime#, #depCode#, #remark#, #filePath1#, #filePath2#, #filePath3#, #filePath4#, #filePath5#,
#prdtSpec#,#partType#,#partCode#,#partName#,#partSpec#,#remark1#,
#prdtLength#,#prdtWidth#,#prdtThick#,#partLength#,#partWidth#,#partThick#)
......@@ -292,6 +294,7 @@
PRDT_NAME = #prdtName#, <!-- 部件名称 -->
PLAN_COMPLETION_DATE = #planCompletionDate#, <!-- 计划完成日期 -->
NUM = #num#, <!-- 计划数量 -->
UNIT_WT = #unitWt#, <!-- 单重 -->
TOTAL_WT = #totalWt#, <!-- 计划重量 -->
STATUS = #status#, <!-- 状态 0-未派工,1-已派工 -->
ORG_NO = #orgNo#, <!-- 生产组编码 -->
......
......@@ -6,11 +6,11 @@ import java.io.IOException;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
//import okhttp3.Headers;
//import okhttp3.MediaType;
//import okhttp3.OkHttpClient;
//import okhttp3.Request;
//import okhttp3.RequestBody;
/**
* httpclient
......@@ -20,94 +20,94 @@ import okhttp3.RequestBody;
*/
@Slf4j
public class HttpUtils {
public static final MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
public static final MediaType FORM_MEDIA_TYPE = MediaType.get("application/x-www-form-urlencoded");
/**
* GET请求
*
* @param url
* @return
* @throws IOException
*/
public static String get(String url) throws IOException {
return get(url, null);
}
/**
* GET请求
*
* @param url
* @param header
* @return
* @throws IOException
*/
public static String get(String url, Map<String, String> header) throws IOException {
return request(RequestMethod.GET, url, header, null, JSON_MEDIA_TYPE);
}
/**
* POST请求
*
* @param url
* @return
* @throws IOException
*/
public static String post(String url) throws IOException {
return post(url, null, JSON_MEDIA_TYPE);
}
/**
* POST请求
*
* @param url
* @param param
* @return
* @throws IOException
*/
public static String post(String url, String param, MediaType mediaType) throws IOException {
return post(url, null, param, mediaType);
}
/**
* http请求(post)
*
* @param url
* @param header
* @param param
* @return
*/
public static String post(String url, Map<String, String> header, String param, MediaType mediaType)
throws IOException {
return request(RequestMethod.POST, url, header, param, mediaType);
}
/**
* 发送请求
*
* @param requestMethod 请求类型POST OR GET
* @param url
* @param header
* @param param
* @return
*/
private static String request(RequestMethod requestMethod, String url, Map<String, String> header, String param,
MediaType mediaType) throws IOException {
log.info("请求开始:{},{},{}", url, header, StringUtils.subStr(param, 500));
OkHttpClient okHttpClient = new OkHttpClient();
Request.Builder builder = new Request.Builder().url(url);
if (RequestMethod.POST.equals(requestMethod)) {
builder = builder.post(RequestBody.create(StringUtils.isBlank(param) ? "" : param, mediaType));
} else {
builder = builder.get();
}
if (MapUtils.isNotEmpty(header)) {
builder = builder.headers(Headers.of(header));
}
String result = okHttpClient.newCall(builder.build()).execute().body().string();
log.info("请求结束:{}", StringUtils.subStr(result, 500));
return result;
}
//
// public static final MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
// public static final MediaType FORM_MEDIA_TYPE = MediaType.get("application/x-www-form-urlencoded");
//
// /**
// * GET请求
// *
// * @param url
// * @return
// * @throws IOException
// */
// public static String get(String url) throws IOException {
// return get(url, null);
// }
//
// /**
// * GET请求
// *
// * @param url
// * @param header
// * @return
// * @throws IOException
// */
// public static String get(String url, Map<String, String> header) throws IOException {
// return request(RequestMethod.GET, url, header, null, JSON_MEDIA_TYPE);
// }
//
// /**
// * POST请求
// *
// * @param url
// * @return
// * @throws IOException
// */
// public static String post(String url) throws IOException {
// return post(url, null, JSON_MEDIA_TYPE);
// }
//
// /**
// * POST请求
// *
// * @param url
// * @param param
// * @return
// * @throws IOException
// */
// public static String post(String url, String param, MediaType mediaType) throws IOException {
// return post(url, null, param, mediaType);
// }
//
// /**
// * http请求(post)
// *
// * @param url
// * @param header
// * @param param
// * @return
// */
// public static String post(String url, Map<String, String> header, String param, MediaType mediaType)
// throws IOException {
// return request(RequestMethod.POST, url, header, param, mediaType);
// }
//
// /**
// * 发送请求
// *
// * @param requestMethod 请求类型POST OR GET
// * @param url
// * @param header
// * @param param
// * @return
// */
// private static String request(RequestMethod requestMethod, String url, Map<String, String> header, String param,
// MediaType mediaType) throws IOException {
// log.info("请求开始:{},{},{}", url, header, StringUtils.subStr(param, 500));
// OkHttpClient okHttpClient = new OkHttpClient();
// Request.Builder builder = new Request.Builder().url(url);
// if (RequestMethod.POST.equals(requestMethod)) {
// builder = builder.post(RequestBody.create(StringUtils.isBlank(param) ? "" : param, mediaType));
// } else {
// builder = builder.get();
// }
// if (MapUtils.isNotEmpty(header)) {
// builder = builder.headers(Headers.of(header));
// }
// String result = okHttpClient.newCall(builder.build()).execute().body().string();
// log.info("请求结束:{}", StringUtils.subStr(result, 500));
// return result;
// }
//
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment