1、客户端商品问题修改,2、客户端新增版本号9.7和商云10分开
This commit is contained in:
parent
71cef21472
commit
45469be52d
@ -36,6 +36,7 @@ public class DynamicTaskScheduler {
|
||||
|
||||
@PostConstruct
|
||||
public void initTasks() {
|
||||
try {
|
||||
//初始化 start
|
||||
CommentModel commentModel =sxDataService.getCommentModel();
|
||||
DataBaseInfo enabledTask = sxDataService.getDataBaseInfo(commentModel);
|
||||
@ -44,6 +45,10 @@ public class DynamicTaskScheduler {
|
||||
refreshTasks();
|
||||
// 每5分钟检查一次数据库更新
|
||||
taskScheduler.scheduleAtFixedRate(this::refreshTasks, Duration.ofHours(1));
|
||||
}catch (Exception e){
|
||||
log.info("系统异常:{}",e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void refreshTasks() {
|
||||
@ -104,7 +109,8 @@ public class DynamicTaskScheduler {
|
||||
refreshTime=DateUtil.formatDateTime(dataBaseInfo.getRefreshTime());
|
||||
commentModel.setSyncTime(refreshTime);
|
||||
}
|
||||
sxDataService.syncStoreData(dataBaseInfo,commentModel);
|
||||
sxDataService.syncStoreData(dataBaseInfo,commentModel);//同步网上售卖流水
|
||||
|
||||
if(StringUtils.isNotEmpty(refreshTime)){//有刷新时间,证明不是全量,需要判断是否有新商品,有新商品才同步品牌和分类
|
||||
if(sxDataService.isNewShop(dataBaseInfo,refreshTime)){
|
||||
sxDataService.SyncBranchList(dataBaseInfo,commentModel);
|
||||
@ -129,7 +135,12 @@ public class DynamicTaskScheduler {
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(refreshTime);
|
||||
}
|
||||
if("1".equals(dataBaseInfo.getIsSyncMember())){//同步会员
|
||||
sxDataService.SyncVipList(dataBaseInfo,commentModel);
|
||||
}
|
||||
|
||||
//同步活动数据,判断是否同步活动数据,有新活动,且有活动数据才同步活动
|
||||
if("1".equals(dataBaseInfo.getIsSyncActive())){
|
||||
boolean isNewActives=sxDataService.syncAtive(dataBaseInfo,commentModel);
|
||||
if(isNewActives){
|
||||
log.info("---有新增的活动,同步活动商品开始--");
|
||||
@ -137,7 +148,9 @@ public class DynamicTaskScheduler {
|
||||
}else {
|
||||
log.info("---无新增的活动,无需同步活动商品--");
|
||||
}
|
||||
}
|
||||
|
||||
sxDataService.refreshTime(commentModel);
|
||||
isRuning=false;
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ public class FileUtils {
|
||||
public static final String okEnd = "ok";//后缀
|
||||
public static final String txtEnd = "txt";//后缀
|
||||
|
||||
public static String fileFormat = "%s_%s.%s";//good_1
|
||||
public static String fileFormat = "%s_%s_%s.%s";//good_1
|
||||
|
||||
public static String getSyncTypeFlag(String syncType){
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
@ -96,12 +96,21 @@ public class FileUtils {
|
||||
* @param filePath
|
||||
*/
|
||||
public void writeFile(String filePath,String fileName,String content){
|
||||
FileWriter writer =null;
|
||||
try {
|
||||
FileWriter writer = new FileWriter(filePath+pathSeparator+fileName);
|
||||
writer = new FileWriter(filePath+pathSeparator+fileName,false);
|
||||
writer.write(content);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
log.info("文件写入成功!");
|
||||
} catch (IOException e) {
|
||||
if(writer!=null){
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
log.info("文件写入失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
@ -112,7 +121,7 @@ public class FileUtils {
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
public String getFileName(String syncType ,Integer page,String endFix){
|
||||
public String getFileName(String syncType ,Integer page,String endFix,String fileEndFix){
|
||||
String result="";
|
||||
switch (syncType){
|
||||
case "1":
|
||||
@ -130,7 +139,7 @@ public class FileUtils {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return String.format(fileFormat, result,page,endFix);
|
||||
return String.format(fileFormat, result,page,fileEndFix,endFix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,7 +179,7 @@ public class FileUtils {
|
||||
FileUtils fileUtils= new FileUtils();
|
||||
File file=fileUtils.createFile("1",1);
|
||||
System.out.printf("--"+file.getAbsoluteFile());
|
||||
fileUtils.writeFile(file.getAbsolutePath(),fileUtils.getFileName("1",2,txtEnd),"456");
|
||||
fileUtils.writeFile(file.getAbsolutePath(),fileUtils.getFileName("1",2,txtEnd,"operate"),"456");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ public class BaseDao {
|
||||
// " ls.oper_date " +
|
||||
"FROM ( " +
|
||||
" SELECT " +
|
||||
" ROW_NUMBER() OVER(ORDER BY item_clsno) AS rowId, " +
|
||||
" ROW_NUMBER() OVER(ORDER BY item_clsno,item_no) AS rowId, " +
|
||||
" * " +
|
||||
" FROM t_bd_item_info shop %s" +
|
||||
") b " +
|
||||
@ -355,21 +355,21 @@ public class BaseDao {
|
||||
" tib.oper_date," +
|
||||
" ROW_NUMBER() OVER(PARTITION BY tib.item_no ORDER BY tib.oper_date DESC) AS rn " +
|
||||
" FROM t_im_branch_stock tib " +
|
||||
") " +
|
||||
"SELECT " +
|
||||
"ROW_NUMBER() OVER (ORDER BY b.rowId) AS rowId, "+//-- 这里重新生成从1开始连续的行号
|
||||
"), " +
|
||||
"PagedData As( SELECT " +
|
||||
"ROW_NUMBER() OVER (ORDER BY b.rowId) AS rowIdA, "+//-- 这里重新生成从1开始连续的行号
|
||||
" b.*, " +
|
||||
" ls.stock_qty, " +
|
||||
" ls.oper_date " +
|
||||
"FROM ( " +
|
||||
" SELECT " +
|
||||
" ROW_NUMBER() OVER(ORDER BY item_clsno) AS rowId ," +
|
||||
" ROW_NUMBER() OVER(ORDER BY item_clsno,item_no) AS rowId ," +
|
||||
" * " +
|
||||
" FROM t_bd_item_info shop %s" +
|
||||
") b " +
|
||||
"LEFT JOIN LatestStock ls ON b.item_no = ls.item_no AND ls.rn = 1 " +
|
||||
" where b.rowId BETWEEN %s AND %s %s";
|
||||
sql=String.format(sql,where,start,end,stockOperateWhere);
|
||||
"LEFT JOIN LatestStock ls ON b.item_no = ls.item_no AND ls.rn = 1 %s) " +
|
||||
"SELECT * FROM PagedData where rowIdA BETWEEN %s AND %s ";
|
||||
sql=String.format(sql,where,stockOperateWhere,start,end);
|
||||
log.info(sql);
|
||||
ResultDto resultDto=new ResultDto();
|
||||
ResultSet rs=null;
|
||||
|
||||
@ -206,7 +206,7 @@ public class SxDataDao extends BaseDao{
|
||||
public List<SxSyncGoods> findBditemInfoListPage(DataBaseInfo dataBaseInfo,int pageNo,int pageSize){
|
||||
String stockOperateWhere="";
|
||||
if(StringUtils.isNotEmpty(dataBaseInfo.getStockOperateWhere())){
|
||||
stockOperateWhere=" and "+dataBaseInfo.getStockOperateWhere();
|
||||
stockOperateWhere=" where "+dataBaseInfo.getStockOperateWhere();
|
||||
}
|
||||
ResultDto resultDto=baseFindGoodsListJoinPage(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName()
|
||||
,pageNo,pageSize,dataBaseInfo.getWhere()==null?DEFALTWHERE:dataBaseInfo.getWhere(),stockOperateWhere);
|
||||
@ -230,6 +230,7 @@ public class SxDataDao extends BaseDao{
|
||||
}else {
|
||||
sxSyncGoods.setGross_margin(new BigDecimal("0"));//毛利率
|
||||
}
|
||||
sxSyncGoods.setId(rs.getLong("rowIdA"));
|
||||
sxSyncGoods.setItem_no(rs.getString("item_no"));//货号
|
||||
sxSyncGoods.setItem_subname(rs.getString("item_name"));//商品名称
|
||||
sxSyncGoods.setItem_subno(rs.getString("item_subno"));//商品条码
|
||||
@ -509,6 +510,7 @@ public class SxDataDao extends BaseDao{
|
||||
") " +
|
||||
" UPDATE TopStock " +
|
||||
" SET stock_qty = stock_qty+(?),oper_date=?;";
|
||||
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
||||
int batchSize = 100; // 每批处理1000条
|
||||
@ -552,7 +554,13 @@ public class SxDataDao extends BaseDao{
|
||||
int[] remainingCounts = ps.executeBatch();
|
||||
|
||||
//todo 新增流水
|
||||
if(dataBaseInfo.getClientVersion().equals(DataBaseInfo.SHANG_YUN)){
|
||||
updateStoreSaleFlow(conn,rmSaleflowList,tRmPayflowList);
|
||||
}
|
||||
if (dataBaseInfo.getClientVersion().equals(DataBaseInfo.SHANG_RUI)){
|
||||
updateStoreSaleFlowShangRui(conn,rmSaleflowList,tRmPayflowList);
|
||||
}
|
||||
|
||||
|
||||
List<String> consumIds=productQuantityConsumptionDtoList
|
||||
.stream()
|
||||
@ -605,6 +613,11 @@ public class SxDataDao extends BaseDao{
|
||||
rmSaleflow.setSaleMoney(productQuantityConsumptionDto.getSaleAmount());
|
||||
// rmSaleflow.setSourcePrice(unitPrice);
|
||||
rmSaleflow.setFlownoRand(productQuantityConsumptionDto.getOrderId());//随机子单号 设置网上订单号
|
||||
if(null!=productQuantityConsumptionDto.getSaleTime()){
|
||||
rmSaleflow.setOperDate(new Timestamp(productQuantityConsumptionDto.getSaleTime()));
|
||||
}else {
|
||||
rmSaleflow.setOperDate(new Timestamp(System.currentTimeMillis()));
|
||||
}
|
||||
return rmSaleflow;
|
||||
}
|
||||
|
||||
@ -627,7 +640,7 @@ public class SxDataDao extends BaseDao{
|
||||
|
||||
//判断取值 start
|
||||
rmSaleflow.setSellWay("B");
|
||||
rmSaleflow.setRetQnty(rmSaleflow.getSaleQnty());
|
||||
rmSaleflow.setRetQnty(BigDecimal.ZERO);
|
||||
if(rmSaleflow.getSaleQnty().compareTo(BigDecimal.ZERO)<0){
|
||||
rmSaleflow.setSellWay("A");
|
||||
BigDecimal saleQnty=rmSaleflow.getSaleQnty();//销售数量
|
||||
@ -646,7 +659,6 @@ public class SxDataDao extends BaseDao{
|
||||
if(itemInfo!=null){
|
||||
rmSaleflow.setInPrice(itemInfo.getPrice());
|
||||
rmSaleflow.setSourcePrice(itemInfo.getSalePrice());
|
||||
rmSaleflow.setOperDate(new Timestamp(System.currentTimeMillis()));
|
||||
}
|
||||
rmSaleflow.setBranchNo(branchNo);
|
||||
|
||||
@ -665,6 +677,8 @@ public class SxDataDao extends BaseDao{
|
||||
rmSaleflow.setPrefAmt(BigDecimal.ZERO);
|
||||
rmSaleflow.setComFlag("0");
|
||||
rmSaleflow.setRemoteFlag("0");
|
||||
rmSaleflow.setPaysum_flag("0");
|
||||
rmSaleflow.setKz_flag("1");
|
||||
//统一默认值 end
|
||||
return rmSaleflow;
|
||||
}
|
||||
@ -691,7 +705,7 @@ public class SxDataDao extends BaseDao{
|
||||
rmPayflow.setCoinNo("RMB");//
|
||||
rmPayflow.setCoinRate(new BigDecimal("1"));//利率
|
||||
rmPayflow.setPayAmount(rmSaleflow.getSaleMoney());
|
||||
rmPayflow.setOperDate(new Timestamp(System.currentTimeMillis()));
|
||||
rmPayflow.setOperDate(rmSaleflow.getOperDate());
|
||||
rmPayflow.setOperId(rmSaleflow.getOperId());
|
||||
rmPayflow.setCounterNo(rmSaleflow.getCounterNo());
|
||||
rmPayflow.setSaleMan(rmSaleflow.getSaleMan());
|
||||
@ -784,7 +798,7 @@ public class SxDataDao extends BaseDao{
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增销售流水
|
||||
* 批量新增销售流水 商云10
|
||||
* @param conn
|
||||
* @param rmSaleflowList
|
||||
*/
|
||||
@ -802,8 +816,8 @@ public class SxDataDao extends BaseDao{
|
||||
"sale_qnty, sale_money, sell_way, oper_id, sale_man, counter_no, " +
|
||||
"oper_date, remote_flag, shift_no, com_flag, spec_flag, pref_amt, " +
|
||||
"in_price, n_stan, chr_stan, posid, uptime, flowno_rand, ret_qnty, " +
|
||||
"flowno_type, spec_sheet_no, cic_sheet_no, share_cardid, item_no_Fresh" +
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
"flowno_type, spec_sheet_no, cic_sheet_no" +
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String sql2 = "INSERT INTO t_rm_payflow (" +
|
||||
"flow_id, flow_no, sale_amount, branch_no, pay_way, sell_way, " +
|
||||
"card_no, vip_no, coin_no, coin_rate, pay_amount, oper_date, " +
|
||||
@ -857,8 +871,8 @@ public class SxDataDao extends BaseDao{
|
||||
ps.setString(26, rmSaleflow.getFlownoType());
|
||||
ps.setString(27, rmSaleflow.getSpecSheetNo());
|
||||
ps.setString(28, "");//CicSheetNo
|
||||
ps.setString(29, rmSaleflow.getShareCardid());
|
||||
ps.setString(30, rmSaleflow.getItemNoFresh());
|
||||
// ps.setString(29, rmSaleflow.getShareCardid());
|
||||
// ps.setString(30, rmSaleflow.getItemNoFresh());
|
||||
|
||||
ps.addBatch(); // 添加至批处理
|
||||
//rmSaleflow end-------------
|
||||
@ -937,6 +951,160 @@ public class SxDataDao extends BaseDao{
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增销售流水 商瑞9.7
|
||||
* @param conn
|
||||
* @param rmSaleflowList
|
||||
*/
|
||||
public void updateStoreSaleFlowShangRui(Connection conn,List<RmSaleflow> rmSaleflowList,List<TRmPayflow> payflowList){
|
||||
if(CollectionUtil.isEmpty(rmSaleflowList)){
|
||||
log.info("销售流水记录为空");
|
||||
return;
|
||||
}
|
||||
// Connection conn =getConnection(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),
|
||||
// dataBaseInfo.getPassword(), dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName());
|
||||
//try {
|
||||
//conn.setAutoCommit(false); // 关闭自动提交,开启事务
|
||||
String sql = "INSERT INTO t_rm_saleflow (" +
|
||||
"flow_id, flow_no, branch_no, item_no, source_price, sale_price, " +
|
||||
"sale_qnty, sale_money, sell_way, oper_id, sale_man, counter_no, " +
|
||||
"oper_date, remote_flag, shift_no, com_flag, spec_flag, pref_amt, " +
|
||||
"in_price, n_stan, chr_stan, posid, uptime, " +
|
||||
"paysum_flag, spec_sheet_no,kz_flag, update_date" +
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)";
|
||||
String sql2 = "INSERT INTO t_rm_payflow (" +
|
||||
"flow_id, flow_no, sale_amount, branch_no, pay_way, sell_way, " +
|
||||
"card_no, vip_no, coin_no, coin_rate, pay_amount, oper_date, " +
|
||||
"oper_id, counter_no, sale_man, memo,remote_flag, " +
|
||||
"exchange_flag, shift_no, com_flag, uptime, " +
|
||||
"kz_no" +
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
try {
|
||||
PreparedStatement ps = conn.prepareStatement(sql);//销售流水
|
||||
PreparedStatement ps2 = conn.prepareStatement(sql2);//资金流水
|
||||
int batchSize = 10; // 每批处理10条
|
||||
int count = 0;
|
||||
for (int i=0;i<rmSaleflowList.size();i++) {
|
||||
//rmSaleflow start-------------
|
||||
RmSaleflow rmSaleflow=rmSaleflowList.get(i);
|
||||
ps.setInt(1,rmSaleflow.getFlowId());
|
||||
ps.setString(2, rmSaleflow.getFlowNo());
|
||||
ps.setString(3, rmSaleflow.getBranchNo());
|
||||
ps.setString(4, rmSaleflow.getItemNo());
|
||||
ps.setBigDecimal(5, rmSaleflow.getSourcePrice());
|
||||
ps.setBigDecimal(6, rmSaleflow.getSalePrice());
|
||||
|
||||
BigDecimal saleQnty=rmSaleflow.getSaleQnty();
|
||||
if(saleQnty.compareTo(BigDecimal.ZERO)<0){
|
||||
saleQnty=saleQnty.multiply(new BigDecimal("-1"));
|
||||
}
|
||||
ps.setBigDecimal(7,saleQnty);
|
||||
|
||||
ps.setBigDecimal(8, rmSaleflow.getSaleMoney());
|
||||
ps.setString(9, rmSaleflow.getSellWay());
|
||||
ps.setString(10, rmSaleflow.getOperId());
|
||||
ps.setString(11, rmSaleflow.getSaleMan());
|
||||
ps.setString(12, rmSaleflow.getCounterNo());
|
||||
|
||||
ps.setTimestamp(13, rmSaleflow.getOperDate());//OperDate
|
||||
ps.setString(14, rmSaleflow.getRemoteFlag());
|
||||
ps.setString(15, "");//ShiftNo
|
||||
ps.setString(16, rmSaleflow.getComFlag());
|
||||
ps.setString(17, "");//SpecFlag
|
||||
ps.setBigDecimal(18, rmSaleflow.getPrefAmt());
|
||||
|
||||
ps.setBigDecimal(19, rmSaleflow.getInPrice());
|
||||
ps.setBigDecimal(20, rmSaleflow.getNStan());
|
||||
ps.setString(21, rmSaleflow.getChrStan());
|
||||
ps.setString(22, rmSaleflow.getPosid());
|
||||
ps.setTimestamp(23, null);//Uptime
|
||||
// ps.setString(24, rmSaleflow.getFlownoRand());
|
||||
// ps.setBigDecimal(25, rmSaleflow.getRetQnty());
|
||||
|
||||
ps.setString(24, rmSaleflow.getPaysum_flag());//paysum_flag
|
||||
ps.setString(25, rmSaleflow.getSpecSheetNo());
|
||||
ps.setString(26, rmSaleflow.getKz_flag());//kz_flag
|
||||
ps.setTimestamp(27, rmSaleflow.getOperDate());//update_date
|
||||
// ps.setString(29, rmSaleflow.getShareCardid());
|
||||
// ps.setString(30, rmSaleflow.getItemNoFresh());
|
||||
|
||||
ps.addBatch(); // 添加至批处理
|
||||
//rmSaleflow end-------------
|
||||
|
||||
//rmPayflow start-------------
|
||||
TRmPayflow rmPayflow=payflowList.get(i);
|
||||
|
||||
//rmPayflow end-------------
|
||||
ps2.setInt(1,rmPayflow.getFlowId());
|
||||
ps2.setString(2, rmPayflow.getFlowNo());
|
||||
ps2.setBigDecimal(3, rmPayflow.getSaleAmount());
|
||||
ps2.setString(4, rmPayflow.getBranchNo());
|
||||
ps2.setString(5, rmPayflow.getPayWay());
|
||||
ps2.setString(6, rmPayflow.getSellWay());
|
||||
|
||||
ps2.setString(7, rmPayflow.getCardNo());
|
||||
ps2.setString(8, rmPayflow.getVipNo());
|
||||
ps2.setString(9, rmPayflow.getCoinNo());
|
||||
ps2.setBigDecimal(10, rmPayflow.getCoinRate());
|
||||
ps2.setBigDecimal(11, rmPayflow.getPayAmount());
|
||||
ps2.setTimestamp(12, rmPayflow.getOperDate());
|
||||
|
||||
ps2.setString(13, rmPayflow.getOperId());//OperDate
|
||||
ps2.setString(14, rmPayflow.getCounterNo());
|
||||
ps2.setString(15, rmPayflow.getSaleMan());
|
||||
ps2.setString(16, rmPayflow.getMemo());
|
||||
// ps2.setString(17, rmPayflow.getVoucherNo());
|
||||
ps2.setString(17, rmPayflow.getRemoteFlag());
|
||||
|
||||
ps2.setString(18, rmPayflow.getExchangeFlag());
|
||||
ps2.setString(19, rmPayflow.getShiftNo());
|
||||
ps2.setString(20, rmPayflow.getComFlag());
|
||||
//ps2.setString(22, rmPayflow.getPosid());
|
||||
ps2.setTimestamp(21, null);//Uptime
|
||||
// ps2.setString(22, rmPayflow.getFlownoRand());
|
||||
|
||||
// ps2.setString(22, rmPayflow.getCiceroniNo());
|
||||
// ps2.setString(23, rmPayflow.getCiceroniId());
|
||||
// ps2.setString(24, rmPayflow.getFlownoType());
|
||||
// ps2.setString(25, rmPayflow.getTransType());
|
||||
// ps2.setString(26, rmPayflow.getUpBatchno());
|
||||
|
||||
|
||||
// ps2.setString(30, rmPayflow.getUpVipacc());
|
||||
ps2.setString(22, rmPayflow.getKz_no());
|
||||
// ps2.setString(29, rmPayflow.getCashNo());
|
||||
// ps2.setString(33, rmPayflow.getCheckData());
|
||||
|
||||
ps2.addBatch(); // 添加至批处理
|
||||
count++;
|
||||
if (count % batchSize == 0) {
|
||||
ps.executeBatch();
|
||||
ps2.executeBatch();
|
||||
|
||||
ps.clearBatch();
|
||||
ps2.clearBatch();
|
||||
log.info("已提交批次: {}", count);
|
||||
}
|
||||
}
|
||||
// 执行剩余未满 batchSize 的批次
|
||||
int[] remainingCounts = ps.executeBatch();
|
||||
int[] remainingCounts2 = ps2.executeBatch();
|
||||
log.info("销售流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts));
|
||||
log.info("支付流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts2));
|
||||
//conn.commit(); // 最终提交事务
|
||||
log.info("销售-支付-流水记录批量更新完成,总记录数: {}" , count);
|
||||
//baseUpdateImBrancStock(dataBaseInfo);
|
||||
} catch (Exception e) {
|
||||
// conn.rollback(); // 出错时回滚整个事务
|
||||
log.info("销售支付流水记录业务失败:: {}", e.getMessage());
|
||||
throw new RuntimeException("销售支付流水记录业务失败:: {}"+e.getMessage());
|
||||
}
|
||||
// } catch (SQLException e) {
|
||||
// log.info("sql失败:: {}", e.getMessage());
|
||||
// throw new RuntimeException("sql失败:: {}"+e.getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
*获取促销活动价格 时段特价单
|
||||
* @param dataBaseInfo
|
||||
|
||||
@ -8,6 +8,10 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class DataBaseInfo {
|
||||
public static final String SHANG_YUN="1";//1 商云10
|
||||
public static final String SHANG_RUI="2";//2 商瑞9.7
|
||||
public static final String SHANG_QI="3";//3 商祺
|
||||
|
||||
@ApiModelProperty("数据库IP")
|
||||
private String ip;
|
||||
@ApiModelProperty("用户名")
|
||||
@ -50,4 +54,13 @@ public class DataBaseInfo {
|
||||
|
||||
@ApiModelProperty(value = "营业员账号")
|
||||
private String saleAccount;
|
||||
|
||||
@ApiModelProperty(value = "是否同步活动(0:否,1:是)")
|
||||
private String isSyncActive;
|
||||
|
||||
@ApiModelProperty(value = "是否同步会员(0:否,1:是)")
|
||||
private String isSyncMember;
|
||||
|
||||
@ApiModelProperty(value = "客户端版本:1商云10,2商瑞9.7,3商祺")
|
||||
private String clientVersion;
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ public class RmSaleflow {
|
||||
private String itemNo;
|
||||
private BigDecimal sourcePrice;
|
||||
private BigDecimal salePrice;
|
||||
private BigDecimal saleQnty;
|
||||
private BigDecimal saleQnty;//销售数量
|
||||
private BigDecimal saleMoney;
|
||||
private String sellWay;//A销售,B退货
|
||||
private String operId;
|
||||
@ -32,12 +32,24 @@ public class RmSaleflow {
|
||||
private String chrStan;
|
||||
private String posid;
|
||||
private Date uptime;
|
||||
private String flownoRand;
|
||||
private BigDecimal retQnty;//销售数量
|
||||
private String flownoType;
|
||||
private String specSheetNo;
|
||||
|
||||
//商云10字段
|
||||
private String flownoRand;
|
||||
private BigDecimal retQnty;
|
||||
private String flownoType;
|
||||
private String cicSheetNo;
|
||||
private String shareCardid;
|
||||
private String itemNoFresh;
|
||||
// private String itemNoFresh;
|
||||
|
||||
//商瑞9.7字段
|
||||
private String paysum_flag;
|
||||
private String voucher_no;
|
||||
private String pr_spec_sheet_no;
|
||||
private String ot_spec_sheet_no;
|
||||
private String ot_spec_pref_amt;
|
||||
private String item_no_Fresh;
|
||||
private String kz_flag;
|
||||
private Timestamp update_date;
|
||||
|
||||
}
|
||||
|
||||
@ -74,4 +74,13 @@ public class StoreDbConfig implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "营业员账号")
|
||||
private String saleAccount;
|
||||
|
||||
@ApiModelProperty(value = "是否同步活动(0:否,1:是)")
|
||||
private String isSyncActive;
|
||||
|
||||
@ApiModelProperty(value = "是否同步会员(0:否,1:是)")
|
||||
private String isSyncMember;
|
||||
|
||||
@ApiModelProperty(value = "客户端版本:1商云10,2商瑞9.7,3商祺")
|
||||
private String clientVersion;
|
||||
}
|
||||
|
||||
@ -12,6 +12,9 @@ import java.util.List;
|
||||
@Data
|
||||
public class SxGoosModel {
|
||||
|
||||
@ApiModelProperty(value = "分页编号")
|
||||
private Long rowIdA;
|
||||
|
||||
@ApiModelProperty("商品名称")
|
||||
private String product_name;
|
||||
|
||||
|
||||
@ -128,6 +128,11 @@ public class TRmPayflow {
|
||||
*/
|
||||
private Date uptime;
|
||||
|
||||
private String checkData;
|
||||
/**
|
||||
*
|
||||
* 商云10
|
||||
* **/
|
||||
/**
|
||||
* 随机流水号
|
||||
*/
|
||||
@ -170,5 +175,7 @@ public class TRmPayflow {
|
||||
|
||||
private String cashNo;
|
||||
|
||||
private String checkData;
|
||||
//商瑞9.7
|
||||
private String kz_no;
|
||||
|
||||
}
|
||||
|
||||
@ -148,6 +148,7 @@ public abstract class SxDataAbstService {
|
||||
SxGoosModel sxGoosModel=null;
|
||||
for (SxSyncGoods sxSyncGood:sxSyncGoods){
|
||||
sxGoosModel=new SxGoosModel();
|
||||
sxGoosModel.setRowIdA(sxSyncGood.getId());
|
||||
sxGoosModel.setProduct_name(sxSyncGood.getItem_subname());
|
||||
sxGoosModel.setProduct_number(sxSyncGood.getItem_no().trim());//
|
||||
sxGoosModel.setProduct_barcode(sxSyncGood.getItem_no().trim());//
|
||||
|
||||
@ -81,4 +81,10 @@ public interface SxDataService {
|
||||
* @return
|
||||
*/
|
||||
boolean isNewShop(DataBaseInfo dataBaseInfo, String refreshTime);
|
||||
|
||||
/**
|
||||
* 刷新同步时间
|
||||
* @return
|
||||
*/
|
||||
void refreshTime(CommentModel commentModel);
|
||||
}
|
||||
|
||||
@ -134,8 +134,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
break;
|
||||
case "02"://增量 todo test
|
||||
String sycnTime=commentModel.getSyncTime();
|
||||
syncIncrementAddGoods(dataBaseInfo, commentModel);//同步新商品
|
||||
// syncIncrementModifyGoods(dataBaseInfo, commentModel);
|
||||
syncIncrementAddGoods(dataBaseInfo, commentModel);//同步新商品和修改商品
|
||||
syncIncrementStock(dataBaseInfo, commentModel);//同步库存
|
||||
syncFlowPrice(dataBaseInfo, commentModel,sycnTime);//同步调价单
|
||||
break;
|
||||
@ -336,19 +335,23 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
String where="where shop.status='1'";
|
||||
Integer total =0;
|
||||
String parentId=getAndCacheTree(dataBaseInfo,dataBaseInfo.getCategoryName());//加载缓存用的
|
||||
String fileEndFix="";
|
||||
if(DicEnum.SYNCTYPE_02.getCode().equals(dataBaseInfo.getSyncType())){
|
||||
if (StringUtils.isNotEmpty(dataBaseInfo.getCategoryName())) {
|
||||
//syncGoodsSearchModel.setItemClsno(childrens);
|
||||
String childrens= commonCache.get(CommonCache.CACHE_CATEGROY+parentId);
|
||||
where += " and shop.item_clsno in ('" + childrens + "')";
|
||||
fileEndFix="category";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
|
||||
where+=" and shop.modify_date>'"+commentModel.getSyncTime()+"' ";
|
||||
where+=" or shop.build_date>'"+commentModel.getSyncTime()+"' ";
|
||||
fileEndFix="modify";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(dataBaseInfo.getOperDate())){
|
||||
String stockOperateWhere=" ls.oper_date>'"+dataBaseInfo.getOperDate()+"' ";
|
||||
dataBaseInfo.setStockOperateWhere(stockOperateWhere);
|
||||
fileEndFix="operate";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(dataBaseInfo.getPriceOperatime())){
|
||||
where+=" and EXISTS ( " +
|
||||
@ -364,6 +367,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
" and shop.item_no=tpfd.item_no " +
|
||||
" and tppfm.oper_date >'"+dataBaseInfo.getPriceOperatime()+"' " +
|
||||
" )";
|
||||
fileEndFix="price";
|
||||
}
|
||||
dataBaseInfo.setWhere(where);
|
||||
// 记录总数
|
||||
@ -401,11 +405,11 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String code= writeToFileAndUploud(i,jsonString,commentModel,DicEnum.MUAL_1.getCode());
|
||||
String code= writeToFileAndUploud(i,jsonString,commentModel,DicEnum.MUAL_1.getCode(),fileEndFix);
|
||||
if (!HttpUtils.SUCCESSCODE.equals(code)) {
|
||||
continue;
|
||||
}
|
||||
folders.add(String.valueOf(i));
|
||||
folders.add(i+"_"+fileEndFix);
|
||||
syncCount+=sxSyncGoods.size();
|
||||
}
|
||||
//通知服务器上传cos
|
||||
@ -435,15 +439,15 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
* @param commentModel
|
||||
* @return
|
||||
*/
|
||||
private String writeToFileAndUploud(Integer page,String content,CommentModel commentModel,String syncType){
|
||||
private String writeToFileAndUploud(Integer page,String content,CommentModel commentModel,String syncType,String fileEndFix){
|
||||
FileUtils fileUtils= new FileUtils();
|
||||
File file=fileUtils.createFile(syncType,page);
|
||||
String fileName=fileUtils.getFileName(syncType,page,FileUtils.txtEnd);
|
||||
String fileName=fileUtils.getFileName(syncType,page,FileUtils.txtEnd,fileEndFix);
|
||||
String filePath=file.getAbsolutePath();
|
||||
fileUtils.writeFile(filePath,fileName,content);
|
||||
String sign=CommonUtil.generateOpenSign(content,commentModel.getAppKey(),commentModel.getAppId());
|
||||
commentModel.setSign(sign);
|
||||
return webClientService.uploudSxData(filePath+FileUtils.pathSeparator+fileName,commentModel,page.toString(),syncType);
|
||||
return webClientService.uploudSxData(filePath+FileUtils.pathSeparator+fileName,commentModel,page+"_"+fileEndFix,syncType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -766,6 +770,9 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
dataBaseInfo.setIsTowSync(storeDbConfig.getIsTowSync());
|
||||
dataBaseInfo.setShopGapTime(storeDbConfig.getShopGapTime());
|
||||
dataBaseInfo.setSaleAccount(storeDbConfig.getSaleAccount());
|
||||
dataBaseInfo.setIsSyncActive(storeDbConfig.getIsSyncActive());
|
||||
dataBaseInfo.setIsSyncMember(storeDbConfig.getIsSyncMember());
|
||||
dataBaseInfo.setClientVersion(storeDbConfig.getClientVersion());
|
||||
return dataBaseInfo;
|
||||
}
|
||||
return new DataBaseInfo();
|
||||
@ -786,7 +793,8 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
+"?appKey="+commentModel.getAppKey()
|
||||
+"&sign="+commentModel.getAppId(),JSONObject.class);
|
||||
// String jsonStr="[{\"consumeId\":\"1986611923814223873\",\"orderId\":\"DD_20251107_1\",\"productNumber\":\"31011\",\"unitPrice\":10.90,\"quantity\":1.500,\"saleAmount\":16.35,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-07 01:49:26\",\"updateTime\":\"2025-11-07 01:49:26\"},{\"consumeId\":\"1986611923814223872\",\"orderId\":\"DD_20251107_2\",\"productNumber\":\"6909409023853\",\"unitPrice\":1.00,\"quantity\":1.000,\"saleAmount\":1.00,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-07 01:49:26\",\"updateTime\":\"2025-11-07 01:49:26\"},{\"consumeId\":\"1986611923814223874\",\"orderId\":\"DD_20251107_1\",\"productNumber\":\"6909409023853\",\"unitPrice\":1.00,\"quantity\":2.000,\"saleAmount\":2.00,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-07 01:49:26\",\"updateTime\":\"2025-11-07 01:49:26\"}]";
|
||||
|
||||
//String jsonObjectStr="{\"error_code\":0,\"error_msg\":\"success\",\"result\":[{\"consumeId\":\"1993254597656690689\",\"orderId\":\"DD_20251125_2\",\"productNumber\":\"10035\",\"unitPrice\":16.00,\"quantity\":-0.500,\"saleAmount\":8.00,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-25 09:45:03\",\"updateTime\":\"2025-11-25 09:45:03\",\"saleTime\":1764063651000},{\"consumeId\":\"1993254597656690688\",\"orderId\":\"DD_20251125_2\",\"productNumber\":\"6922896008127\",\"unitPrice\":8.80,\"quantity\":-1.000,\"saleAmount\":8.80,\"status\":0,\"storeId\":78,\"createTime\":\"2025-11-25 09:45:03\",\"updateTime\":\"2025-11-25 09:45:03\",\"saleTime\":1764063651000}]}";
|
||||
// JSONObject jsonObject=JSONUtil.parseObj(jsonObjectStr);
|
||||
if(null!=jsonObject.get("result")){
|
||||
// Map map=(Map)jsonObject.get("result");
|
||||
String jsonStr= jsonObject.getStr("result");
|
||||
@ -807,7 +815,6 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
productQuantityConsumptionDtoList.forEach(productQuantityConsumptionDto -> {
|
||||
productQuantityConsumptionDtoMap.put(productQuantityConsumptionDto.getOrderId()+"-"+productQuantityConsumptionDto.getProductNumber(),productQuantityConsumptionDto);
|
||||
});
|
||||
|
||||
sxDataDao.updateStoreData(dataBaseInfo,map,productQuantityConsumptionDtoMap,productQuantityConsumptionDtoList,commentModel);
|
||||
}else {
|
||||
log.info("无线上流水同步");
|
||||
@ -867,9 +874,9 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
dataBaseInfo.setWhere(where);
|
||||
total = sxDataDao.getTotalSpecShop(dataBaseInfo);
|
||||
if(total==0){
|
||||
HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_REFRESH
|
||||
+"?appKey="+commentModel.getAppKey()
|
||||
+"&sign="+commentModel.getAppId(), new JSONArray());
|
||||
// HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_REFRESH
|
||||
// +"?appKey="+commentModel.getAppKey()
|
||||
// +"&sign="+commentModel.getAppId(), new JSONArray());
|
||||
log.info("暂无活动商品同步");
|
||||
return;
|
||||
}
|
||||
@ -897,9 +904,9 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
syncCount+=activeDtos.size();
|
||||
}
|
||||
log.info("成功同步活动商品数据:"+syncCount);
|
||||
HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_REFRESH
|
||||
+"?appKey="+commentModel.getAppKey()
|
||||
+"&sign="+commentModel.getAppId(), new JSONArray());
|
||||
// HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_REFRESH
|
||||
// +"?appKey="+commentModel.getAppKey()
|
||||
// +"&sign="+commentModel.getAppId(), new JSONArray());
|
||||
|
||||
}
|
||||
|
||||
@ -913,4 +920,12 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void refreshTime(CommentModel commentModel) {
|
||||
HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_REFRESH
|
||||
+"?appKey="+commentModel.getAppKey()
|
||||
+"&sign="+commentModel.getAppId(), new JSONArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user