|
@@ -16,7 +16,6 @@ import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.schedule.executor.AbstractTask;
|
|
import kd.bos.schedule.executor.AbstractTask;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
-import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import java.sql.*;
|
|
import java.sql.*;
|
|
@@ -68,10 +67,10 @@ public class AutoSynVoucher extends AbstractTask {
|
|
|
|
|
|
//查找待同步数据执行插入数据
|
|
//查找待同步数据执行插入数据
|
|
beginDate = getBeginDate();
|
|
beginDate = getBeginDate();
|
|
- log.info("[凭证反同步用友]同步数据执行插入开始");
|
|
|
|
|
|
+ log.info("[凭证同步用友]同步数据执行插入开始");
|
|
pstmt1 = conn.prepareStatement("INSERT INTO jf_voucher (" + DB_VOUCHER_FIELDS + ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
|
pstmt1 = conn.prepareStatement("INSERT INTO jf_voucher (" + DB_VOUCHER_FIELDS + ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
|
doExecuteNewData(conn,pstmt1,orgMap_numbber,orgMap_name);
|
|
doExecuteNewData(conn,pstmt1,orgMap_numbber,orgMap_name);
|
|
- log.info("[凭证反同步用友]同步数据执行插入结束");
|
|
|
|
|
|
+ log.info("[凭证同步用友]同步数据执行插入结束");
|
|
|
|
|
|
//清空汇总中间表
|
|
//清空汇总中间表
|
|
pstmt2 = conn.createStatement();
|
|
pstmt2 = conn.createStatement();
|
|
@@ -80,19 +79,19 @@ public class AutoSynVoucher extends AbstractTask {
|
|
int periodv = Integer.valueOf(sdf.format(beginDate).substring(5,7));
|
|
int periodv = Integer.valueOf(sdf.format(beginDate).substring(5,7));
|
|
String deleteSql = "DELETE FROM jf_balance WHERE yearv='"+yearv+"' AND periodv='"+periodv+"'";
|
|
String deleteSql = "DELETE FROM jf_balance WHERE yearv='"+yearv+"' AND periodv='"+periodv+"'";
|
|
int affectedRows = pstmt2.executeUpdate(deleteSql);
|
|
int affectedRows = pstmt2.executeUpdate(deleteSql);
|
|
- log.info("[凭证反同步用友]删除中间表记录数:"+affectedRows);
|
|
|
|
|
|
+ log.info("[凭证同步用友]删除中间表记录数:"+affectedRows);
|
|
conn.commit();
|
|
conn.commit();
|
|
|
|
|
|
//重新汇总数据插入汇总中间表
|
|
//重新汇总数据插入汇总中间表
|
|
- log.info("[凭证反同步用友]同步汇总数据执行插入开始");
|
|
|
|
|
|
+ log.info("[凭证同步用友]同步汇总数据执行插入开始");
|
|
pstmt3 = conn.prepareStatement("INSERT INTO jf_balance (" + DB_BALANCE_FIELDS + ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
|
pstmt3 = conn.prepareStatement("INSERT INTO jf_balance (" + DB_BALANCE_FIELDS + ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
|
doExecuteTotalData(conn,pstmt3,orgMap_numbber,orgMap_name);
|
|
doExecuteTotalData(conn,pstmt3,orgMap_numbber,orgMap_name);
|
|
- log.info("[凭证反同步用友]同步汇总数据执行插入结束");
|
|
|
|
|
|
+ log.info("[凭证同步用友]同步汇总数据执行插入结束");
|
|
}else{
|
|
}else{
|
|
- log.info("[凭证反同步用友]连接用友总账数据库失败");
|
|
|
|
|
|
+ log.info("[凭证同步用友]连接用友总账数据库失败");
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.info("[凭证反同步用友]同步凭证到用友总账数据库失败:"+e.getMessage());
|
|
|
|
|
|
+ log.info("[凭证同步用友]同步凭证到用友总账数据库失败:"+e.getMessage());
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
} finally{
|
|
} finally{
|
|
try {
|
|
try {
|
|
@@ -169,12 +168,15 @@ public class AutoSynVoucher extends AbstractTask {
|
|
"LEFT JOIN T_BD_Account ACC ON VOUE.faccountid = ACC.FID " +
|
|
"LEFT JOIN T_BD_Account ACC ON VOUE.faccountid = ACC.FID " +
|
|
"WHERE VOU.fispost='1' " +
|
|
"WHERE VOU.fispost='1' " +
|
|
"AND VOU.fk_nckd_issynyy='1' " +
|
|
"AND VOU.fk_nckd_issynyy='1' " +
|
|
- "AND VOU.Fbookeddate>='"+sdf.format(beginDate)+"'"+
|
|
|
|
|
|
+ "AND VOU.Fbookeddate>='"+sdf.format(beginDate)+"' " +
|
|
|
|
+ "AND "+
|
|
") TEMP " +
|
|
") TEMP " +
|
|
"GROUP BY TEMP.orgid,TEMP.yearv,TEMP.periodv,TEMP.subjcd,TEMP.subjnm,TEMP.currentid,TEMP.entrydc";
|
|
"GROUP BY TEMP.orgid,TEMP.yearv,TEMP.periodv,TEMP.subjcd,TEMP.subjnm,TEMP.currentid,TEMP.entrydc";
|
|
DataSet ds = DB.queryDataSet(this.getClass().getName(), new DBRoute("fi"), sql, null);
|
|
DataSet ds = DB.queryDataSet(this.getClass().getName(), new DBRoute("fi"), sql, null);
|
|
JSONArray jsonArray = new JSONArray();
|
|
JSONArray jsonArray = new JSONArray();
|
|
Map currentList = new HashMap();
|
|
Map currentList = new HashMap();
|
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String datadt = sdf1.format(new Date());
|
|
for (Row row : ds) {
|
|
for (Row row : ds) {
|
|
JSONObject jsonObj = new JSONObject();
|
|
JSONObject jsonObj = new JSONObject();
|
|
String orgcd = orgMapNumbber.get(row.getString("orgid"))!=null?orgMapNumbber.get(row.getString("orgid")).toString():"";
|
|
String orgcd = orgMapNumbber.get(row.getString("orgid"))!=null?orgMapNumbber.get(row.getString("orgid")).toString():"";
|
|
@@ -182,7 +184,7 @@ public class AutoSynVoucher extends AbstractTask {
|
|
String orgnm = orgMapName.get(row.getString("orgid"))!=null?orgMapName.get(row.getString("orgid")).toString():"";
|
|
String orgnm = orgMapName.get(row.getString("orgid"))!=null?orgMapName.get(row.getString("orgid")).toString():"";
|
|
jsonObj.put("orgnm",orgnm);
|
|
jsonObj.put("orgnm",orgnm);
|
|
jsonObj.put("yearv",row.getString("yearv"));
|
|
jsonObj.put("yearv",row.getString("yearv"));
|
|
- String periodv = tranPeriodv(row.getString("periodv"));
|
|
|
|
|
|
+ String periodv = tranPeriodv(row.getInteger("periodv"));
|
|
jsonObj.put("periodv",periodv);
|
|
jsonObj.put("periodv",periodv);
|
|
jsonObj.put("subjcd",row.getString("subjcd"));
|
|
jsonObj.put("subjcd",row.getString("subjcd"));
|
|
jsonObj.put("subjnm",row.getString("subjnm"));
|
|
jsonObj.put("subjnm",row.getString("subjnm"));
|
|
@@ -208,6 +210,7 @@ public class AutoSynVoucher extends AbstractTask {
|
|
direction = "C";
|
|
direction = "C";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ jsonObj.put("datadt",datadt);
|
|
jsonObj.put("direction",direction);
|
|
jsonObj.put("direction",direction);
|
|
jsonObj.put("creditamount",row.getString("creditamount_total"));
|
|
jsonObj.put("creditamount",row.getString("creditamount_total"));
|
|
jsonObj.put("debitamount",row.getString("debitamount_total"));
|
|
jsonObj.put("debitamount",row.getString("debitamount_total"));
|
|
@@ -221,12 +224,12 @@ public class AutoSynVoucher extends AbstractTask {
|
|
/*
|
|
/*
|
|
* 转换期间字段补0
|
|
* 转换期间字段补0
|
|
*/
|
|
*/
|
|
- private String tranPeriodv(String yearv) {
|
|
|
|
|
|
+ private String tranPeriodv(Integer yearv) {
|
|
String realyearv = "";
|
|
String realyearv = "";
|
|
- if(!yearv.contains("0")){
|
|
|
|
|
|
+ if(yearv<10){
|
|
realyearv = "0" + yearv;
|
|
realyearv = "0" + yearv;
|
|
}else{
|
|
}else{
|
|
- realyearv = yearv;
|
|
|
|
|
|
+ realyearv = String.valueOf(yearv);
|
|
}
|
|
}
|
|
return realyearv;
|
|
return realyearv;
|
|
}
|
|
}
|
|
@@ -240,7 +243,7 @@ public class AutoSynVoucher extends AbstractTask {
|
|
int count = 0;
|
|
int count = 0;
|
|
//获取待同步数据
|
|
//获取待同步数据
|
|
DynamicObject[] voucherCol = getVoucherDatas();
|
|
DynamicObject[] voucherCol = getVoucherDatas();
|
|
- log.info("[凭证反同步用友]获取待同步数据条数:"+voucherCol.length);
|
|
|
|
|
|
+ log.info("[凭证同步用友]获取待同步数据条数:"+voucherCol.length);
|
|
String ids = "";
|
|
String ids = "";
|
|
//数据日期
|
|
//数据日期
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
@@ -252,10 +255,10 @@ public class AutoSynVoucher extends AbstractTask {
|
|
if (++count % batchSize == 0) {
|
|
if (++count % batchSize == 0) {
|
|
pstmt.executeBatch(); // 执行批处理
|
|
pstmt.executeBatch(); // 执行批处理
|
|
conn.commit(); // 可以在每个批次后提交事务
|
|
conn.commit(); // 可以在每个批次后提交事务
|
|
- log.info("[凭证反同步用友]提交批次");
|
|
|
|
|
|
+ log.info("[凭证同步用友]提交批次");
|
|
pstmt.clearBatch(); // 清空批处理
|
|
pstmt.clearBatch(); // 清空批处理
|
|
updateBillSign(ids); //更新凭证同步标识
|
|
updateBillSign(ids); //更新凭证同步标识
|
|
- log.info("[凭证反同步用友]更新凭证同步标识");
|
|
|
|
|
|
+ log.info("[凭证同步用友]更新凭证同步标识");
|
|
ids = "";
|
|
ids = "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -264,10 +267,10 @@ public class AutoSynVoucher extends AbstractTask {
|
|
if (count % batchSize != 0) {
|
|
if (count % batchSize != 0) {
|
|
pstmt.executeBatch(); // 执行最后一个批次
|
|
pstmt.executeBatch(); // 执行最后一个批次
|
|
conn.commit();
|
|
conn.commit();
|
|
- log.info("[凭证反同步用友]提交最后一个批次");
|
|
|
|
|
|
+ log.info("[凭证同步用友]提交最后一个批次");
|
|
pstmt.clearBatch();
|
|
pstmt.clearBatch();
|
|
updateBillSign(ids);
|
|
updateBillSign(ids);
|
|
- log.info("[凭证反同步用友]更新凭证同步标识");
|
|
|
|
|
|
+ log.info("[凭证同步用友]更新凭证同步标识");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -409,6 +412,9 @@ public class AutoSynVoucher extends AbstractTask {
|
|
cal_1.add(Calendar.MONTH, -1);
|
|
cal_1.add(Calendar.MONTH, -1);
|
|
}
|
|
}
|
|
cal_1.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
|
|
cal_1.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
|
|
|
|
+ cal_1.set(Calendar.HOUR_OF_DAY,0);
|
|
|
|
+ cal_1.set(Calendar.MINUTE,0);
|
|
|
|
+ cal_1.set(Calendar.SECOND,0);
|
|
Date firstDay = cal_1.getTime();
|
|
Date firstDay = cal_1.getTime();
|
|
return firstDay;
|
|
return firstDay;
|
|
}
|
|
}
|