|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
|
|
|
import com.dgtly.common.config.Global;
|
|
|
import com.dgtly.common.utils.DateUtils;
|
|
|
import com.dgtly.common.utils.http.HttpUtils;
|
|
|
+import com.dgtly.system.service.IMetaHanaDeliverSignService;
|
|
|
import com.dgtly.system.service.ISysUserOrderAuthorService;
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -11,7 +12,6 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.*;
|
|
|
@@ -52,6 +52,10 @@ public class HanaOrderComponent {
|
|
|
|
|
|
@Autowired
|
|
|
private ISysUserOrderAuthorService userOrderAuthorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMetaHanaDeliverSignService metaHanaDeliverSignService;
|
|
|
+
|
|
|
public HanaOrderComponent() {
|
|
|
}
|
|
|
|
|
|
@@ -217,6 +221,43 @@ public class HanaOrderComponent {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * @description: 交货单电子签收数据同步
|
|
|
+ * @param: []
|
|
|
+ * @return: void
|
|
|
+ * @author: njs
|
|
|
+ * @date: 2024/12/31 10:14
|
|
|
+ */
|
|
|
+ public void hanaSalesDeliverSignatureSync() throws Exception {
|
|
|
+ Connection con = this.getHanaConnection();
|
|
|
+ PreparedStatement pstmt = con.prepareStatement("SELECT\n" +
|
|
|
+ "\t VBELN,\n" +
|
|
|
+ "\t POSNR,\n" +
|
|
|
+ "\t MATNR,\n" +
|
|
|
+ "\t VGBEL,\n" +
|
|
|
+ "\t VGPOS, \n"+
|
|
|
+ "\t ERDAT_SO,\n" +
|
|
|
+ "\t LFIMG,\n" +
|
|
|
+ "\t MODIFIEDVALUE,\n" +
|
|
|
+ "\t LFIMG_CY,\n" +
|
|
|
+ "\t ZDATE_KH,\n" +
|
|
|
+ "\t ZTIME_KH,\n" +
|
|
|
+ "\t ZVBELN_YCHH,\n" +
|
|
|
+ "\t ZSTATUS_HH,\n" +
|
|
|
+ "\t CONTRACTID, \n" +
|
|
|
+ "\t BIZNO, \n" +
|
|
|
+ "\t MANDT \n" +
|
|
|
+ " FROM ERP.ZSDT056 where ERDAT_SO between ADD_MONTHS(CURRENT_DATE, -3) AND CURRENT_DATE");
|
|
|
+
|
|
|
+ Long startTime = System.currentTimeMillis();
|
|
|
+ ResultSet rs = pstmt.executeQuery();
|
|
|
+ Long endTime = System.currentTimeMillis();
|
|
|
+ log.info("hanaSalesDeliverSignatureSync查询用时:" + (endTime - startTime)+"毫秒");
|
|
|
+ this.createDeliverSignatureTxt(rs);
|
|
|
+ this.runLoadDeliverSignature();
|
|
|
+ this.closeConnection(con, pstmt);
|
|
|
+
|
|
|
+ }
|
|
|
/*批量插入*/
|
|
|
private void insertSalesOrderResult(ResultSet rs) throws Exception {
|
|
|
Connection conn = null;
|
|
|
@@ -397,6 +438,104 @@ public class HanaOrderComponent {
|
|
|
return j;
|
|
|
}
|
|
|
|
|
|
+//电子单签收
|
|
|
+
|
|
|
+ private int createDeliverSignatureTxt(ResultSet result) throws Exception {
|
|
|
+ File file = null;
|
|
|
+ FileWriter fw = null;
|
|
|
+ Connection conn = null;
|
|
|
+ PreparedStatement pstm =null;
|
|
|
+ int j =0;
|
|
|
+ try {
|
|
|
+ long i =0;
|
|
|
+
|
|
|
+ //创建IO需求的条件,并声明输出路径
|
|
|
+ file = new File((Global.getTemdataPath()+"deliverSignature/"));
|
|
|
+ log.info("deliverSignature数据缓存路径:" + Global.getTemdataPath()+"deliverSignature/");
|
|
|
+ if(!file.exists()){
|
|
|
+ file.mkdir();
|
|
|
+ }
|
|
|
+
|
|
|
+ file = new File(Global.getTemdataPath()+"deliverSignature/"+j+".txt");
|
|
|
+ if(!file.exists()){
|
|
|
+ file.createNewFile();
|
|
|
+ }else {
|
|
|
+ //取得这个目录下的所有子文件对象
|
|
|
+ File[] files = new File(Global.getTemdataPath()+"deliverSignature/").listFiles();
|
|
|
+
|
|
|
+ for (File f: files){
|
|
|
+ f.delete();
|
|
|
+ }
|
|
|
+ file.delete();
|
|
|
+ file.createNewFile();
|
|
|
+ }
|
|
|
+ fw = new FileWriter(file);
|
|
|
+ Long startTime = System.currentTimeMillis();
|
|
|
+ while (result.next()){
|
|
|
+
|
|
|
+ fw.write(
|
|
|
+ result.getString("VBELN")
|
|
|
+ +"$$"+ result.getString("POSNR")
|
|
|
+ +"$$"+ result.getString("MATNR")
|
|
|
+ +"$$"+ result.getString("VGBEL")
|
|
|
+ +"$$"+ result.getString("VGPOS")
|
|
|
+ +"$$"+ result.getString("ERDAT_SO")
|
|
|
+ +"$$"+ result.getString("LFIMG")
|
|
|
+ +"$$"+ result.getString("MODIFIEDVALUE")
|
|
|
+ +"$$"+ result.getString("LFIMG_CY")
|
|
|
+ +"$$"+ result.getString("ZDATE_KH")
|
|
|
+ +"$$"+ result.getString("ZTIME_KH")
|
|
|
+ +"$$"+ result.getString("ZVBELN_YCHH")
|
|
|
+ +"$$"+ result.getString("ZSTATUS_HH")
|
|
|
+ +"$$"+ result.getString("CONTRACTID")
|
|
|
+ +"$$"+ result.getString("BIZNO")
|
|
|
+ +"$$"+ result.getString("MANDT")
|
|
|
+ + "\r\n");
|
|
|
+
|
|
|
+
|
|
|
+ fw.flush();
|
|
|
+ i++;
|
|
|
+ if (i%50000==0){
|
|
|
+ j++;
|
|
|
+ //创建IO需求的条件,并声明输出路径
|
|
|
+ file = new File(Global.getTemdataPath()+"deliverSignature/"+j+".txt");
|
|
|
+ if(!file.exists()){
|
|
|
+ file.createNewFile();
|
|
|
+ }else {
|
|
|
+ file.delete();
|
|
|
+ file.createNewFile();
|
|
|
+ }
|
|
|
+ fw = new FileWriter(file);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long endTime = System.currentTimeMillis();
|
|
|
+ log.info("生成deliverSignature-TXT用时:" + (endTime - startTime) + "毫秒");
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ fw.close();
|
|
|
+ if(pstm!=null){
|
|
|
+ try {
|
|
|
+ pstm.close();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(conn!=null){
|
|
|
+ try {
|
|
|
+ conn.close();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return j;
|
|
|
+ }
|
|
|
+
|
|
|
//订单
|
|
|
private int createSalesOrderTxt(ResultSet result) throws Exception {
|
|
|
File file = null;
|
|
|
@@ -1182,8 +1321,49 @@ public class HanaOrderComponent {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ //电子单签收状态
|
|
|
+ public void runLoadDeliverSignature () throws Exception{
|
|
|
+ //生产表
|
|
|
+ Connection conn = null;
|
|
|
+ PreparedStatement pstm =null;
|
|
|
+ try{
|
|
|
+ conn = getMysqlConnection();
|
|
|
+ String sql = "TRUNCATE TABLE meta_hana_deliver_sign";
|
|
|
+ pstm = conn.prepareStatement(sql);
|
|
|
+ pstm.execute();
|
|
|
+ String testSql = "LOAD DATA LOCAL INFILE 'testIO.txt' into table meta_hana_deliver_sign fields terminated by '$$' lines terminated by '\\n'";
|
|
|
+ long beginTime=System.currentTimeMillis();
|
|
|
+ int rows=this.bulkLoadFromInputStream(testSql, mergeGetStream(new File((Global.getTemdataPath()+"deliverSignature/"))));
|
|
|
+ long endTime=System.currentTimeMillis();
|
|
|
+ log.info("importing salesOrder := "+rows+" rows data into mysql and cost "+(endTime-beginTime)+" ms!");
|
|
|
+ }catch (Exception e){
|
|
|
+ String name ="meta_hana_deliver_sign电子单签收表同步异常";
|
|
|
+ userOrderAuthorService.sendMailHanaWarning(name);
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ if(pstm!=null){
|
|
|
+ try {
|
|
|
+ pstm.close();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(conn!=null){
|
|
|
+ try {
|
|
|
+ conn.close();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//订单
|
|
|
- public void runLoadSalesOrder() throws Exception{
|
|
|
+ public void runLoadSalesOrder(){
|
|
|
//生产表
|
|
|
Connection conn = null;
|
|
|
PreparedStatement pstm =null;
|