思迅同步销售流水和支付流水,调价时间查询新增
This commit is contained in:
parent
4d2649d5e9
commit
471244b8e6
@ -47,9 +47,9 @@ public class DynamicTaskScheduler {
|
||||
}
|
||||
|
||||
public void refreshTasks() {
|
||||
if(!isRuning){
|
||||
sxDataService.checkForUpdates();//检查app更新
|
||||
}
|
||||
// if(!isRuning){
|
||||
// sxDataService.checkForUpdates();//检查app更新
|
||||
// }
|
||||
CommentModel commentModel =sxDataService.getCommentModel();
|
||||
DataBaseInfo enabledTask = sxDataService.getDataBaseInfo(commentModel);
|
||||
if(enabledTask == null){
|
||||
|
||||
@ -266,7 +266,7 @@ public class BaseDao {
|
||||
return total;
|
||||
}
|
||||
|
||||
public Integer getBaseGoodsJoinTotal(String ip, String username, String password,Integer portNumber, String dataBaseName,String where){
|
||||
public Integer getBaseGoodsJoinTotal(String ip, String username, String password,Integer portNumber, String dataBaseName,String where,String stockOperateWhere){
|
||||
int total=0;
|
||||
Connection connection=getConnection(ip,username,password,portNumber,dataBaseName);
|
||||
try {
|
||||
@ -278,19 +278,18 @@ public class BaseDao {
|
||||
" ROW_NUMBER() OVER(PARTITION BY tib.item_no ORDER BY tib.oper_date DESC) AS rn " +
|
||||
" FROM t_im_branch_stock tib\n" +
|
||||
") " +
|
||||
"SELECT " +
|
||||
" b.*, " +
|
||||
" ls.stock_qty, " +
|
||||
" ls.oper_date " +
|
||||
"SELECT count(1) " +
|
||||
// " b.*, " +
|
||||
// " ls.stock_qty, " +
|
||||
// " ls.oper_date " +
|
||||
"FROM ( " +
|
||||
" SELECT " +
|
||||
" ROW_NUMBER() OVER(ORDER BY item_clsno) AS rowId, " +
|
||||
" * " +
|
||||
" FROM t_bd_item_info " +
|
||||
" FROM t_bd_item_info shop %s" +
|
||||
") b " +
|
||||
"LEFT JOIN LatestStock ls ON b.item_no = ls.item_no AND ls.rn = 1 " +
|
||||
" %s";
|
||||
sql=String.format(sql,where);
|
||||
"LEFT JOIN LatestStock ls ON b.item_no = ls.item_no AND ls.rn = 1 %s";
|
||||
sql=String.format(sql,where,stockOperateWhere);
|
||||
log.info(sql);
|
||||
PreparedStatement ps= connection.prepareStatement(sql);
|
||||
ResultSet rs=ps.executeQuery();
|
||||
@ -344,7 +343,8 @@ public class BaseDao {
|
||||
return resultDto;
|
||||
}
|
||||
|
||||
public ResultDto baseFindGoodsListJoinPage(String ip, String username, String password,Integer portNumber, String dataBaseName, int pageNo, int pageSize,String where){
|
||||
public ResultDto baseFindGoodsListJoinPage(String ip, String username, String password,Integer portNumber, String dataBaseName, int pageNo, int pageSize,
|
||||
String where,String stockOperateWhere){
|
||||
Connection connection=getConnection(ip,username,password,portNumber,dataBaseName);
|
||||
int start=(pageNo-1)*pageSize+1;
|
||||
int end=pageNo*pageSize;
|
||||
@ -357,6 +357,7 @@ public class BaseDao {
|
||||
" FROM t_im_branch_stock tib " +
|
||||
") " +
|
||||
"SELECT " +
|
||||
"ROW_NUMBER() OVER (ORDER BY b.rowId) AS rowId, "+//-- 这里重新生成从1开始连续的行号
|
||||
" b.*, " +
|
||||
" ls.stock_qty, " +
|
||||
" ls.oper_date " +
|
||||
@ -364,11 +365,11 @@ public class BaseDao {
|
||||
" SELECT " +
|
||||
" ROW_NUMBER() OVER(ORDER BY item_clsno) AS rowId ," +
|
||||
" * " +
|
||||
" FROM t_bd_item_info\n" +
|
||||
" FROM t_bd_item_info shop %s" +
|
||||
") b " +
|
||||
"LEFT JOIN LatestStock ls ON b.item_no = ls.item_no AND ls.rn = 1 " +
|
||||
" %s b.rowId BETWEEN %s AND %s ";
|
||||
sql=String.format(sql,where,start,end);
|
||||
" where b.rowId BETWEEN %s AND %s %s";
|
||||
sql=String.format(sql,where,start,end,stockOperateWhere);
|
||||
log.info(sql);
|
||||
ResultDto resultDto=new ResultDto();
|
||||
ResultSet rs=null;
|
||||
|
||||
@ -12,6 +12,7 @@ import com.small.client.Utils.HttpUtils;
|
||||
import com.small.client.Utils.SqlBuilder;
|
||||
import com.small.client.dto.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -22,6 +23,7 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.*;
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -54,6 +56,8 @@ public class SxDataDao extends BaseDao{
|
||||
|
||||
private final static String T_BD_BRANCH_INFO="t_bd_branch_info";//仓库表
|
||||
|
||||
private final static String T_RM_CASHIER="t_rm_cashier";//小发收银账号
|
||||
|
||||
private final static String T_IM_BRANCH_STOCK="(" +
|
||||
"select * from( " +
|
||||
" select ROW_NUMBER() OVER( " +
|
||||
@ -175,7 +179,7 @@ public class SxDataDao extends BaseDao{
|
||||
*/
|
||||
public int getTBditemInfoJoninTotal(DataBaseInfo dataBaseInfo){
|
||||
return getBaseGoodsJoinTotal(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName()
|
||||
,dataBaseInfo.getWhere()==null?DEFALTWHERE:dataBaseInfo.getWhere());
|
||||
,dataBaseInfo.getWhere()==null?DEFALTWHERE:dataBaseInfo.getWhere(),"where "+dataBaseInfo.getStockOperateWhere());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,7 +201,7 @@ public class SxDataDao extends BaseDao{
|
||||
*/
|
||||
public List<SxSyncGoods> findBditemInfoListPage(DataBaseInfo dataBaseInfo,int pageNo,int pageSize){
|
||||
ResultDto resultDto=baseFindGoodsListJoinPage(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName()
|
||||
,pageNo,pageSize,dataBaseInfo.getWhere()==null?DEFALTWHERE:dataBaseInfo.getWhere());
|
||||
,pageNo,pageSize,dataBaseInfo.getWhere()==null?DEFALTWHERE:dataBaseInfo.getWhere()," and "+dataBaseInfo.getStockOperateWhere());
|
||||
ResultSet rs= resultDto.getResultSet();
|
||||
List<SxSyncGoods> sxSyncGoodses=new ArrayList<>();
|
||||
SxSyncGoods sxSyncGoods=null;
|
||||
@ -515,11 +519,13 @@ public class SxDataDao extends BaseDao{
|
||||
rmSaleflow.setItemNo(itemNo);
|
||||
rmSaleflow.setSalePrice(unitPrice);
|
||||
rmSaleflow.setSaleQnty(stock_qty);
|
||||
rmSaleflow.setSourcePrice(unitPrice);
|
||||
rmSaleflow.setFlownoRand(productQuantityConsumptionDto.getOrderId());//随机子单号 设置网上订单号
|
||||
rmSaleflow= fixRmSaleFlow(rmSaleflow,brachNo,itemInfoMap);
|
||||
rmSaleflow= fixRmSaleFlow(rmSaleflow,brachNo,itemInfoMap,dataBaseInfo.getSaleAccount());
|
||||
TRmPayflow trmPayflow=fixTRmPayflow(rmSaleflow);
|
||||
|
||||
rmSaleflowList.add(rmSaleflow);
|
||||
tRmPayflowList.add(trmPayflow);
|
||||
|
||||
ps.setString(1, itemNo);
|
||||
ps.setDouble(2, stock_qty.doubleValue());
|
||||
@ -578,41 +584,47 @@ public class SxDataDao extends BaseDao{
|
||||
* @param rmSaleflow
|
||||
* @return
|
||||
*/
|
||||
public RmSaleflow fixRmSaleFlow(RmSaleflow rmSaleflow,String branchNo,Map<String,ItemInfo> itemInfoMap){
|
||||
public RmSaleflow fixRmSaleFlow(RmSaleflow rmSaleflow,String branchNo,Map<String,ItemInfo> itemInfoMap,String saleAccount){
|
||||
//自定义单号 start
|
||||
rmSaleflow.setFlowId(1);
|
||||
String orderId=rmSaleflow.getFlownoRand();
|
||||
String[] orderIdSplits= orderId.split("_");
|
||||
String DateStr=DateUtil.format(new java.util.Date(),"yyyyMMdd");
|
||||
String flowNo="99"+DateStr+orderIdSplits[orderIdSplits.length-1];
|
||||
String number= String.format("%04d", Integer.valueOf(orderIdSplits[orderIdSplits.length-1]));
|
||||
String flowNo="99"+DateStr+number;
|
||||
rmSaleflow.setFlowNo(flowNo);//订单号 todo
|
||||
//自定义 单号 end
|
||||
|
||||
//判断取值 start
|
||||
rmSaleflow.setSellWay("A");
|
||||
rmSaleflow.setSellWay("B");
|
||||
rmSaleflow.setRetQnty(rmSaleflow.getSaleQnty());
|
||||
if(rmSaleflow.getSaleQnty().compareTo(BigDecimal.ZERO)<0){
|
||||
rmSaleflow.setSellWay("B");
|
||||
rmSaleflow.setSellWay("A");
|
||||
BigDecimal saleQnty=rmSaleflow.getSaleQnty();//销售数量
|
||||
rmSaleflow.setSaleQnty(saleQnty);
|
||||
rmSaleflow.setRetQnty(BigDecimal.ZERO);
|
||||
}
|
||||
BigDecimal saleMoney=rmSaleflow.getSalePrice().multiply(rmSaleflow.getSaleQnty());
|
||||
if(rmSaleflow.getSaleQnty().compareTo(BigDecimal.ZERO)<0){
|
||||
saleMoney=saleMoney.multiply(new BigDecimal("-1"));
|
||||
}
|
||||
rmSaleflow.setSaleMoney(saleMoney);
|
||||
//判断取值 end
|
||||
|
||||
//数据库查询取值start todo
|
||||
ItemInfo itemInfo=itemInfoMap.get(rmSaleflow.getItemNo());
|
||||
if(itemInfo!=null){
|
||||
rmSaleflow.setInPrice(itemInfo.getPrice());
|
||||
rmSaleflow.setOperDate(new Date(System.currentTimeMillis()));
|
||||
rmSaleflow.setOperDate(new Timestamp(System.currentTimeMillis()));
|
||||
}
|
||||
rmSaleflow.setBranchNo(branchNo);
|
||||
|
||||
//数据库查询取值end
|
||||
|
||||
//远程配置取值start todo
|
||||
rmSaleflow.setOperId("9999");
|
||||
rmSaleflow.setSaleMan("9999");
|
||||
rmSaleflow.setCounterNo("9999");
|
||||
rmSaleflow.setOperId(saleAccount);
|
||||
rmSaleflow.setSaleMan(saleAccount);
|
||||
rmSaleflow.setCounterNo(saleAccount);
|
||||
//远程配置取值end
|
||||
|
||||
//统一默认值 start
|
||||
@ -635,6 +647,9 @@ public class SxDataDao extends BaseDao{
|
||||
rmPayflow.setFlowId(rmSaleflow.getFlowId());
|
||||
rmPayflow.setFlowNo(rmSaleflow.getFlowNo());
|
||||
BigDecimal saleAmount=rmSaleflow.getSalePrice().multiply(rmSaleflow.getSaleQnty()).setScale(2, RoundingMode.HALF_UP);
|
||||
if(saleAmount.compareTo(BigDecimal.ZERO)<0){
|
||||
saleAmount=saleAmount.multiply(new BigDecimal("-1"));
|
||||
}
|
||||
rmPayflow.setSaleAmount(saleAmount);
|
||||
rmPayflow.setBranchNo(rmSaleflow.getBranchNo());
|
||||
rmPayflow.setPayWay("RMB");//人民币
|
||||
@ -644,14 +659,14 @@ public class SxDataDao extends BaseDao{
|
||||
rmPayflow.setCoinNo("RMB");//
|
||||
rmPayflow.setCoinRate(new BigDecimal("1"));//利率
|
||||
rmPayflow.setPayAmount(saleAmount);
|
||||
rmPayflow.setOperDate(rmSaleflow.getOperDate());
|
||||
rmPayflow.setOperDate(new Timestamp(System.currentTimeMillis()));
|
||||
rmPayflow.setOperId(rmSaleflow.getOperId());
|
||||
rmPayflow.setCounterNo(rmSaleflow.getCounterNo());
|
||||
rmPayflow.setSaleMan(rmSaleflow.getSaleMan());
|
||||
rmPayflow.setMemo("");
|
||||
rmPayflow.setVoucherNo("");//退货单号 退货时要填
|
||||
rmPayflow.setRemoteFlag("0");
|
||||
rmPayflow.setExchangeFlag(null);
|
||||
rmPayflow.setExchangeFlag("0");
|
||||
rmPayflow.setShiftNo("");
|
||||
rmPayflow.setComFlag("0");
|
||||
rmPayflow.setPosid("01");
|
||||
@ -687,7 +702,7 @@ public class SxDataDao extends BaseDao{
|
||||
}
|
||||
Map<String,ItemInfo> resultMap=new HashMap<>();
|
||||
Set<Map.Entry> sme=map.entrySet();
|
||||
String where = "where 1=1";
|
||||
String where = "where 1=1 and ";
|
||||
List<String> itemNos = sme.stream()
|
||||
.map(entry -> (String) entry.getKey())
|
||||
.collect(Collectors.toList());
|
||||
@ -698,13 +713,23 @@ public class SxDataDao extends BaseDao{
|
||||
try {
|
||||
while (rs.next()) {
|
||||
ItemInfo itemInfo=new ItemInfo();
|
||||
String itemNo=rs.getString("item_no");
|
||||
String itemNo=rs.getString("item_no").trim();
|
||||
itemInfo.setItemNo(itemNo);//
|
||||
itemInfo.setItemSubno(rs.getString("item_subno"));
|
||||
itemInfo.setItemName(rs.getString("item_name"));
|
||||
itemInfo.setItemBrand(rs.getString("item_brand"));//品牌
|
||||
itemInfo.setPrice(rs.getBigDecimal("price"));//进货价
|
||||
itemInfo.setItemClsno(rs.getString("item_clsno"));
|
||||
if(StringUtils.isNotEmpty(rs.getString("item_subno"))){
|
||||
itemInfo.setItemSubno(rs.getString("item_subno").trim());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(rs.getString("item_name"))){
|
||||
itemInfo.setItemName(rs.getString("item_name").trim());
|
||||
}
|
||||
if(StringUtils.isNotEmpty(rs.getString("item_brand"))){
|
||||
itemInfo.setItemBrand(rs.getString("item_brand").trim());//品牌
|
||||
}
|
||||
if(StringUtils.isNotEmpty(rs.getString("price"))){
|
||||
itemInfo.setPrice(rs.getBigDecimal("price"));//进货价
|
||||
}
|
||||
if(StringUtils.isNotEmpty(rs.getString("item_clsno"))){
|
||||
itemInfo.setItemClsno(rs.getString("item_clsno").trim());
|
||||
}
|
||||
resultMap.put(itemNo,itemInfo);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@ -747,7 +772,7 @@ public class SxDataDao extends BaseDao{
|
||||
"exchange_flag, shift_no, com_flag, uptime, flowno_rand, " +
|
||||
"ciceroni_no, ciceroni_id, flowno_type, trans_type, up_batchno, " +
|
||||
"remark, cash_no" +
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
try {
|
||||
PreparedStatement ps = conn.prepareStatement(sql);//销售流水
|
||||
PreparedStatement ps2 = conn.prepareStatement(sql2);//资金流水
|
||||
@ -763,18 +788,23 @@ public class SxDataDao extends BaseDao{
|
||||
ps.setBigDecimal(5, rmSaleflow.getSourcePrice());
|
||||
ps.setBigDecimal(6, rmSaleflow.getSalePrice());
|
||||
|
||||
ps.setBigDecimal(7, rmSaleflow.getSaleQnty());
|
||||
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.setDate(13, rmSaleflow.getOperDate());//OperDate
|
||||
ps.setTimestamp(13, rmSaleflow.getOperDate());//OperDate
|
||||
ps.setString(14, rmSaleflow.getRemoteFlag());
|
||||
ps.setString(15, rmSaleflow.getShiftNo());
|
||||
ps.setString(15, "");//ShiftNo
|
||||
ps.setString(16, rmSaleflow.getComFlag());
|
||||
ps.setString(17, rmSaleflow.getSpecFlag());
|
||||
ps.setString(17, "");//SpecFlag
|
||||
ps.setBigDecimal(18, rmSaleflow.getPrefAmt());
|
||||
|
||||
ps.setBigDecimal(19, rmSaleflow.getInPrice());
|
||||
@ -787,7 +817,7 @@ public class SxDataDao extends BaseDao{
|
||||
|
||||
ps.setString(26, rmSaleflow.getFlownoType());
|
||||
ps.setString(27, rmSaleflow.getSpecSheetNo());
|
||||
ps.setString(28, rmSaleflow.getCicSheetNo());
|
||||
ps.setString(28, "");//CicSheetNo
|
||||
ps.setString(29, rmSaleflow.getShareCardid());
|
||||
ps.setString(30, rmSaleflow.getItemNoFresh());
|
||||
|
||||
@ -810,7 +840,7 @@ public class SxDataDao extends BaseDao{
|
||||
ps2.setString(9, rmPayflow.getCoinNo());
|
||||
ps2.setBigDecimal(10, rmPayflow.getCoinRate());
|
||||
ps2.setBigDecimal(11, rmPayflow.getPayAmount());
|
||||
ps2.setDate(12, rmPayflow.getOperDate());
|
||||
ps2.setTimestamp(12, rmPayflow.getOperDate());
|
||||
|
||||
ps2.setString(13, rmPayflow.getOperId());//OperDate
|
||||
ps2.setString(14, rmPayflow.getCounterNo());
|
||||
@ -820,7 +850,7 @@ public class SxDataDao extends BaseDao{
|
||||
ps2.setString(17, rmPayflow.getRemoteFlag());
|
||||
|
||||
ps2.setString(18, rmPayflow.getExchangeFlag());
|
||||
ps2.setString(29, rmPayflow.getShiftNo());
|
||||
ps2.setString(19, rmPayflow.getShiftNo());
|
||||
ps2.setString(20, rmPayflow.getComFlag());
|
||||
//ps2.setString(22, rmPayflow.getPosid());
|
||||
ps2.setTimestamp(21, null);//Uptime
|
||||
@ -853,7 +883,7 @@ public class SxDataDao extends BaseDao{
|
||||
int[] remainingCounts = ps.executeBatch();
|
||||
int[] remainingCounts2 = ps2.executeBatch();
|
||||
log.info("销售流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts));
|
||||
log.info("支付流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts));
|
||||
log.info("支付流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts2));
|
||||
conn.commit(); // 最终提交事务
|
||||
log.info("销售-支付-流水记录批量更新完成,总记录数: {}" , count);
|
||||
//baseUpdateImBrancStock(dataBaseInfo);
|
||||
@ -1249,4 +1279,29 @@ public class SxDataDao extends BaseDao{
|
||||
}
|
||||
return branch_no;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小发账号
|
||||
* @return
|
||||
*/
|
||||
public String getTRmCashier(DataBaseInfo dataBaseInfo,String accountNo){
|
||||
ResultDto resultDto= this.baseFindList(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),
|
||||
dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName(),T_RM_CASHIER,"where cashier_id='"+accountNo+"'");
|
||||
ResultSet rs= resultDto.getResultSet();
|
||||
String cashier_id = "";
|
||||
try {
|
||||
while (rs.next()) {
|
||||
cashier_id=rs.getString("cashier_id");//
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
resultDto.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return cashier_id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,4 +41,13 @@ public class DataBaseInfo {
|
||||
|
||||
@ApiModelProperty(value = "间隔时间")
|
||||
private String shopGapTime;
|
||||
|
||||
@ApiModelProperty(value = "调价时间")
|
||||
private String priceOperatiem;
|
||||
|
||||
@ApiModelProperty(value = "库存条件")
|
||||
private String stockOperateWhere;
|
||||
|
||||
@ApiModelProperty(value = "营业员账号")
|
||||
private String saleAccount;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Data
|
||||
public class RmSaleflow {
|
||||
@ -20,7 +21,7 @@ public class RmSaleflow {
|
||||
private String operId;
|
||||
private String saleMan;
|
||||
private String counterNo;
|
||||
private Date operDate;
|
||||
private Timestamp operDate;
|
||||
private String remoteFlag;
|
||||
private String shiftNo;
|
||||
private String comFlag;
|
||||
@ -38,4 +39,5 @@ public class RmSaleflow {
|
||||
private String cicSheetNo;
|
||||
private String shareCardid;
|
||||
private String itemNoFresh;
|
||||
|
||||
}
|
||||
|
||||
@ -71,4 +71,7 @@ public class StoreDbConfig implements Serializable {
|
||||
|
||||
@ApiModelProperty("商品同步间隔时间")
|
||||
private String shopGapTime;
|
||||
|
||||
@ApiModelProperty(value = "营业员账号")
|
||||
private String saleAccount;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Data
|
||||
public class TRmPayflow {
|
||||
@ -70,7 +71,7 @@ public class TRmPayflow {
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private Date operDate;
|
||||
private Timestamp operDate;
|
||||
|
||||
/**
|
||||
* 操作员ID
|
||||
|
||||
@ -142,9 +142,11 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
syncAllGoods(dataBaseInfo, commentModel);
|
||||
break;
|
||||
case "02"://增量 todo test
|
||||
String sycnTime=commentModel.getSyncTime();
|
||||
syncIncrementAddGoods(dataBaseInfo, commentModel);
|
||||
syncIncrementModifyGoods(dataBaseInfo, commentModel);
|
||||
// syncIncrementModifyGoods(dataBaseInfo, commentModel);
|
||||
syncIncrementStock(dataBaseInfo, commentModel);
|
||||
syncFlowPrice(dataBaseInfo, commentModel,sycnTime);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -324,21 +326,37 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
*/
|
||||
private void syncAllGoods(DataBaseInfo dataBaseInfo, CommentModel commentModel){
|
||||
//String where="where 1=1";
|
||||
String where="where b.status='1'";
|
||||
String where="where shop.status='1'";
|
||||
Integer total =0;
|
||||
String parentId=getAndCacheTree(dataBaseInfo,dataBaseInfo.getCategoryName());//加载缓存用的
|
||||
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 b.item_clsno in ('" + childrens + "')";
|
||||
where += " and shop.item_clsno in ('" + childrens + "')";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
|
||||
where+=" and b.modify_date>'"+commentModel.getSyncTime()+"' ";
|
||||
where+=" or b.build_date>'"+commentModel.getSyncTime()+"' ";
|
||||
where+=" and shop.modify_date>'"+commentModel.getSyncTime()+"' ";
|
||||
where+=" or shop.build_date>'"+commentModel.getSyncTime()+"' ";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(dataBaseInfo.getOperDate())){
|
||||
where+=" and ls.oper_date>'"+dataBaseInfo.getOperDate()+"' ";
|
||||
String stockOperateWhere=" ls.oper_date>'"+dataBaseInfo.getOperDate()+"' ";
|
||||
dataBaseInfo.setStockOperateWhere(stockOperateWhere);
|
||||
}
|
||||
if(StringUtils.isNotEmpty(dataBaseInfo.getPriceOperatiem())){
|
||||
where+=" and EXISTS ( " +
|
||||
" select " +
|
||||
" shop.item_no " +
|
||||
" from " +
|
||||
" t_pc_price_flow_detail tpfd " +
|
||||
" inner join t_pc_price_flow_master tppfm " +
|
||||
" on " +
|
||||
" tpfd.sheet_no = tppfm.sheet_no " +
|
||||
" where " +
|
||||
" tppfm.valid_flag = '1' " +//有效
|
||||
" and shop.item_no=tpfd.item_no " +
|
||||
" and tppfm.oper_date >'"+dataBaseInfo.getPriceOperatiem()+"' " +
|
||||
" )";
|
||||
}
|
||||
dataBaseInfo.setWhere(where);
|
||||
// 记录总数
|
||||
@ -351,7 +369,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
log.info("暂无商品同步");
|
||||
return;
|
||||
}
|
||||
where+=" and";
|
||||
//where+=" and";
|
||||
dataBaseInfo.setWhere(where);
|
||||
|
||||
// 总页数
|
||||
@ -458,6 +476,16 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
syncAllGoods(dataBaseInfo,commentModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增量同步 调价单变化
|
||||
*/
|
||||
private void syncFlowPrice(DataBaseInfo dataBaseInfo, CommentModel commentModel,String sycnTime){
|
||||
dataBaseInfo.setPriceOperatiem(sycnTime);
|
||||
commentModel.setSyncTime("");
|
||||
dataBaseInfo.setOperDate("");
|
||||
syncAllGoods(dataBaseInfo,commentModel);
|
||||
}
|
||||
|
||||
/**
|
||||
*获取特价商品
|
||||
* @param dataBaseInfo
|
||||
@ -726,6 +754,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
dataBaseInfo.setRefreshTime(storeDbConfig.getRefreshTime());
|
||||
dataBaseInfo.setIsTowSync(storeDbConfig.getIsTowSync());
|
||||
dataBaseInfo.setShopGapTime(storeDbConfig.getShopGapTime());
|
||||
dataBaseInfo.setSaleAccount(storeDbConfig.getSaleAccount());
|
||||
return dataBaseInfo;
|
||||
}
|
||||
return new DataBaseInfo();
|
||||
@ -737,6 +766,11 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
log.info("不做双向同步数据库");
|
||||
return;
|
||||
}
|
||||
String saleAccount= sxDataDao.getTRmCashier(dataBaseInfo,dataBaseInfo.getSaleAccount());
|
||||
if(StringUtils.isEmpty(saleAccount)){
|
||||
log.error("需要配置商城收银人员");
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject= restTemplate.getForObject(remoteIp+HttpUtils.URL_SYNC_GET_STOR_DATA_RELEASE
|
||||
+"?appKey="+commentModel.getAppKey()
|
||||
+"&sign="+commentModel.getAppId(),JSONObject.class);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user