wzh преди 1 година
родител
ревизия
9d02c6acc2

+ 1 - 0
src/main/java/com/qlm/controller/UploadController.java

@@ -47,6 +47,7 @@ public class UploadController extends Controller {
 		renderJson(new Record());
 	}
 	
+	@Clear
 	public void doSync(){
 		WmesService.uploadData();
 		renderText("ok");

+ 0 - 621
src/main/java/com/qlm/job/AddUpJob.java

@@ -1,621 +0,0 @@
-package com.qlm.job;
-
-import com.jfinal.plugin.activerecord.Db;
-import com.jfinal.plugin.activerecord.Record;
-import com.qlm.entity.DayHbEntity;
-import com.qlm.entity.HbEntity;
-import com.qlm.entity.ScanHbEntity;
-import com.qlm.tools.LocalDateUtils;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @author nommpp
- * 汇总每天的扫码量和红包发放金额
- */
-public class AddUpJob implements Job {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(AddUpJob.class);
-
-    private static final String T_SCAN_HB = "t_scan_hb";
-
-    private static final String T_DAY_HB = "t_day_hb";
-
-    private static final String T_DAY_HB_DETAIL = "t_day_hb_detail";
-
-    private static final String T_DAY_SCAN_HB = "t_day_scan_hb";
-
-    private static final int SINGLE_COUNT = 100000;
-
-    private static final String SPLIT = ",";
-
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        LocalDateTime now = LocalDateTime.now();
-        LocalDateTime yestoday = now.minusDays(1);
-        String yesStart = LocalDateUtils.localToStr(LocalDateUtils.getDayStart(yestoday));
-        String yesEnd = LocalDateUtils.localToStr(LocalDateUtils.getDayEnd(yestoday));
-
-        String day = LocalDateUtils.localToDateStr(yestoday);
-
-        LOGGER.info("{} ---定时统计---",yesStart);
-
-        //查询扫码量
-        String scanCountSql = "select count(*) from t_scanrecord where scan_time >= '"+yesStart+"' and scan_time <= '"+yesEnd+"'";
-        Long scanCountDb = Db.queryLong(scanCountSql);
-        int scanCount = scanCountDb == null ? 0 : scanCountDb.intValue();
-
-        //查询发放成功的红包总个数
-        String hbCountSql = "select count(*) from t_scanrecord where send_time >= '"+yesStart+"' and send_time <= '"+yesEnd+"'";
-        Long hbCountDb = Db.queryLong(hbCountSql);
-        int hbCount = hbCountDb == null ? 0 : hbCountDb.intValue();
-
-        statisticsScanHb(yesStart,yesEnd,day,scanCount,hbCount);
-        statisticsDayScanHb(yesStart,yesEnd,day,scanCount,hbCount);
-        statisticsDayScanHbDetail(yesStart,yesEnd,day,hbCount);
-
-        LOGGER.info("{} 定时统计完成",yesStart);
-    }
-
-    /**
-     * 统计总的扫码量和发放成功的红包金额
-     * @param startTime 统计开始时间
-     * @param endTime 统计结束时间
-     * @param day 时间的yyyy-MM-dd表示
-     */
-    private void statisticsScanHb(String startTime,String endTime,String day,int scanCount,int hbTotalCount){
-        LOGGER.info("{} 号 开始统计 {} 表数据",day, T_SCAN_HB);
-
-        if(hbTotalCount > SINGLE_COUNT){
-            //总次数
-            int count = hbTotalCount / SINGLE_COUNT;
-            //剩余次数
-            int residue = hbTotalCount % SINGLE_COUNT;
-            int hbAmount = 0;
-            int len = 0;
-            for (int i = 0; i < count; i++) {
-                String sqlHb = "select send_time,amount,type_,area from t_scanrecord where send_time >='" + startTime + "' and send_time<='" + endTime + "' limit " + len + "," + SINGLE_COUNT + "";
-                List<Record> listHb = Db.find(sqlHb);
-                hbAmount += listHb.parallelStream().mapToInt(r->r.getInt("amount")).sum();
-                len += SINGLE_COUNT;
-            }
-
-            if(residue > 0){
-                String sqlHb = "select send_time,amount,type_,area from t_scanrecord where send_time >='"+startTime+"' and send_time<='"+endTime+"' limit "+len+","+ hbTotalCount +"";
-                List<Record> listHb = Db.find(sqlHb);
-                hbAmount += listHb.parallelStream().mapToInt(r->r.getInt("amount")).sum();
-            }
-            Record record = new Record();
-            record.set("day_",day);
-            record.set("scan_", scanCount);
-            record.set("hb_", hbAmount);
-            Db.save(T_SCAN_HB,record);
-        }else{
-            //查询红包发放金额
-            String hbSql = "select sum(amount) from t_scanrecord where send_time >= '"+startTime+"' and send_time <= '"+endTime+"'";
-            BigDecimal hbCountDb = Db.queryBigDecimal(hbSql);
-            int hbCount = hbCountDb == null ? 0 : hbCountDb.intValue();
-            Record record = new Record();
-            record.set("day_",day);
-            record.set("scan_", scanCount);
-            record.set("hb_", hbCount);
-            Db.save(T_SCAN_HB,record);
-        }
-        LOGGER.info("{} 号 {} 表数据 统计完成", day,T_SCAN_HB);
-    }
-
-
-    /**
-     * 获得扫码map
-     * @param startTime 统计开始日期
-     * @param endTime 统计结束日期
-     * @param day yyyy-MM-dd表示
-     * @param scanCount 总扫码次数
-     * @return Map<String,Integer>
-     */
-    private Map<String,Integer> getScanMap(String startTime,String endTime,String day,int scanCount){
-        Map<String,Integer> scanMap = new HashMap<>();
-        //总次数
-        int count = scanCount / SINGLE_COUNT;
-        //剩余次数
-        int residue = scanCount % SINGLE_COUNT;
-        int len = 0;
-        for (int i = 0; i < count; i++) {
-            String sqlScan = "select scan_time,type_,area from t_scanrecord where scan_time >='"+startTime+"' and scan_time <= '"+endTime+"' limit "+len+","+ SINGLE_COUNT +"";
-            List<Record> listScan = Db.find(sqlScan);
-            //统计扫码量
-            Map<Integer,List<Record>> typeMap = listScan.parallelStream()
-                    .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-            for(Map.Entry<Integer,List<Record>> typeEntry:typeMap.entrySet()){
-                List<Record> areaList = typeEntry.getValue();
-                if(!areaList.isEmpty()){
-                    Map<String,List<Record>> areaMap = areaList.parallelStream()
-                            .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-                    for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-
-                        List<Record> resultList = areaEntry.getValue();
-                        Integer scan = resultList.size();
-                        //拼接key day_ + type_ + area_
-                        String key = day+SPLIT+typeEntry.getKey()+SPLIT+areaEntry.getKey();
-                        if(scanMap.get(key) == null){
-                            scanMap.put(key,scan);
-                        }else{
-                            Integer oldScan = scanMap.get(key);
-                            scanMap.put(key,oldScan+scan);
-                        }
-                    }
-                }
-            }
-            len += SINGLE_COUNT;
-        }
-
-        if(residue > 0){
-            String sqlScan = "select scan_time,type_,area from t_scanrecord where scan_time >='"+startTime+"' and scan_time <= '"+endTime+"' limit "+len+","+ scanCount +"";
-            List<Record> listScan = Db.find(sqlScan);
-            //统计扫码量
-            Map<Integer,List<Record>> typeMap = listScan.parallelStream()
-                    .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-            for(Map.Entry<Integer,List<Record>> typeEntry:typeMap.entrySet()){
-                List<Record> areaList = typeEntry.getValue();
-                if(!areaList.isEmpty()){
-                    Map<String,List<Record>> areaMap = areaList.parallelStream()
-                            .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-                    for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-
-                        List<Record> resultList = areaEntry.getValue();
-                        Integer scan = resultList.size();
-                        //拼接key day_ + type_ + area_
-                        String key = day+SPLIT+typeEntry.getKey()+SPLIT+areaEntry.getKey();
-                        if(scanMap.get(key) == null){
-                            scanMap.put(key,scan);
-                        }else{
-                            Integer oldScan = scanMap.get(key);
-                            scanMap.put(key,oldScan+scan);
-                        }
-                    }
-                }
-            }
-        }
-
-        return scanMap;
-    }
-
-    /**
-     * 获得hbmap
-     * @param startTime 统计开始时间
-     * @param endTime 统计结束时间
-     * @param day yyyy-MM-dd表示
-     * @param hbCount 总红包发放个数
-     * @return Map<String, HbEntity>
-     */
-    private Map<String, HbEntity> getHbMap(String startTime, String endTime, String day, int hbCount){
-        Map<String,HbEntity> hbMap = new HashMap<>();
-        //总次数
-        int count = hbCount / SINGLE_COUNT;
-        //剩余次数
-        int residue = hbCount % SINGLE_COUNT;
-
-        int len = 0;
-        for (int i = 0; i < count; i++) {
-            String sqlHb = "select send_time,amount,type_,area from t_scanrecord where send_time >='"+startTime+"' and send_time<='"+endTime+"' limit "+len+","+ SINGLE_COUNT +"";
-            List<Record> listHb = Db.find(sqlHb);
-            //统计红包和个数
-            //对map里的list再根据 type 进行分组
-            Map<Integer,List<Record>> typeHbMap = listHb.parallelStream()
-                    .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-            for(Map.Entry<Integer,List<Record>> typeEntry:typeHbMap.entrySet()){
-                List<Record> areaList = typeEntry.getValue();
-                if(!areaList.isEmpty()){
-                    Map<String,List<Record>> areaMap = areaList.parallelStream()
-                            .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-                    for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-                        HbEntity hbEntity = new HbEntity();
-                        List<Record> resultList = areaEntry.getValue();
-                        int hb = resultList.parallelStream().mapToInt(r -> r.getInt("amount")).sum();
-                        long subHbCount = resultList.parallelStream().count();
-                        hbEntity.setHbAmount(hb);
-                        hbEntity.setHbCount((int) subHbCount);
-
-                        String key = day+SPLIT+typeEntry.getKey()+SPLIT+areaEntry.getKey();
-
-                        if(hbMap.get(key) == null){
-                            hbMap.put(key,hbEntity);
-                        }else{
-                            HbEntity oldHbEntity = hbMap.get(key);
-                            HbEntity newHbEntity = new HbEntity();
-                            newHbEntity.setHbAmount(oldHbEntity.getHbAmount()+hbEntity.getHbAmount());
-                            newHbEntity.setHbCount(oldHbEntity.getHbCount()+hbEntity.getHbCount());
-                            hbMap.put(key,newHbEntity);
-                        }
-                    }
-                }
-            }
-            len += SINGLE_COUNT;
-        }
-
-        if(residue > 0){
-            String sqlHb = "select send_time,amount,type_,area from t_scanrecord where send_time >='"+startTime+"' and send_time<='"+endTime+"' limit "+len+","+ hbCount +"";
-            List<Record> listHb = Db.find(sqlHb);
-            //统计红包和个数
-            //对map里的list再根据 type 进行分组
-            Map<Integer,List<Record>> typeHbMap = listHb.parallelStream()
-                    .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-            for(Map.Entry<Integer,List<Record>> typeEntry:typeHbMap.entrySet()){
-                List<Record> areaList = typeEntry.getValue();
-                if(!areaList.isEmpty()){
-                    Map<String,List<Record>> areaMap = areaList.parallelStream()
-                            .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-                    for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-                        HbEntity hbEntity = new HbEntity();
-                        List<Record> resultList = areaEntry.getValue();
-                        int hb = resultList.parallelStream().mapToInt(r -> r.getInt("amount")).sum();
-                        long subHbCount = resultList.parallelStream().count();
-                        hbEntity.setHbAmount(hb);
-                        hbEntity.setHbCount((int) subHbCount);
-
-                        String key = day+SPLIT+typeEntry.getKey()+SPLIT+areaEntry.getKey();
-
-                        if(hbMap.get(key) == null){
-                            hbMap.put(key,hbEntity);
-                        }else{
-                            HbEntity oldHbEntity = hbMap.get(key);
-                            HbEntity newHbEntity = new HbEntity();
-                            newHbEntity.setHbAmount(oldHbEntity.getHbAmount()+hbEntity.getHbAmount());
-                            newHbEntity.setHbCount(oldHbEntity.getHbCount()+hbEntity.getHbCount());
-                            hbMap.put(key,newHbEntity);
-                        }
-                    }
-                }
-            }
-        }
-
-        return hbMap;
-    }
-
-
-    /**
-     * 根据品相和区域分组统计扫码量,红包发放个数和红包发放金额
-     * @param startTime 统计开始时间
-     * @param endTime 统计结束时间
-     * @param day 时间的yyyy-MM-dd表示
-     * @param scanCount 总的扫码量
-     * @param hbCount 发放成功的红包数量
-     */
-    private void statisticsDayScanHb(String startTime,String endTime,String day,int scanCount,int hbCount) {
-        LOGGER.info("{} 号 开始统计 {} 表数据",day, T_DAY_SCAN_HB);
-
-        if(scanCount > SINGLE_COUNT) {
-            Map<String, ScanHbEntity> scanHbMap = new HashMap<>();
-            Map<String, Integer> scanMap = getScanMap(startTime, endTime, day, scanCount);
-
-            Map<String,HbEntity> hbMap = getHbMap(startTime,endTime,day,hbCount);
-
-            for(Map.Entry<String,Integer> scanEntry:scanMap.entrySet()){
-                ScanHbEntity scanHbEntity = new ScanHbEntity();
-                scanHbEntity.setScanCount(scanEntry.getValue());
-                scanHbMap.put(scanEntry.getKey(),scanHbEntity);
-            }
-
-            for(Map.Entry<String,HbEntity> hbEntity:hbMap.entrySet()){
-                if(scanHbMap.get(hbEntity.getKey()) != null){
-                    ScanHbEntity scanHbEntity = scanHbMap.get(hbEntity.getKey());
-                    scanHbEntity.setHbAmount(hbEntity.getValue().getHbAmount());
-                    scanHbEntity.setHbCount(hbEntity.getValue().getHbCount());
-                }
-            }
-
-            for(Map.Entry<String,ScanHbEntity> scanHbEntry:scanHbMap.entrySet()){
-                Record record = new Record();
-                String[] dta = scanHbEntry.getKey().split(SPLIT);
-                record.set("day_",dta[0]);
-                record.set("type_",dta[1]);
-                record.set("area_",dta[2]);
-                record.set("scan_",scanHbEntry.getValue().getScanCount());
-                record.set("hb_",scanHbEntry.getValue().getHbAmount());
-                record.set("hbc_",scanHbEntry.getValue().getHbCount());
-                Db.save(T_DAY_SCAN_HB,record);
-            }
-
-        }else{
-            String sqlScan = "select scan_time,type_,area from t_scanrecord where scan_time >='"+startTime+"' and scan_time<='"+endTime+"'";
-            List<Record> listScan = Db.find(sqlScan);
-            //统计扫码量
-            Map<Integer,List<Record>> typeMap = listScan.parallelStream()
-                    .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-            for(Map.Entry<Integer,List<Record>> typeEntry:typeMap.entrySet()){
-                List<Record> areaList = typeEntry.getValue();
-                if(!areaList.isEmpty()){
-                    Map<String,List<Record>> areaMap = areaList.parallelStream()
-                            .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-                    for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-                        Record typeRecord = new Record();
-                        typeRecord.set("day_",day);
-                        typeRecord.set("type_",typeEntry.getKey());
-                        typeRecord.set("area_",areaEntry.getKey());
-
-                        List<Record> resultList = areaEntry.getValue();
-                        Integer scan = resultList.size();
-                        typeRecord.set("scan_",scan);
-
-                        Db.save(T_DAY_SCAN_HB,typeRecord);
-                    }
-                }
-            }
-
-            String sqlHb = "select send_time,amount,type_,area from t_scanrecord where send_time >='"+startTime+"' and send_time<='"+endTime+"'";
-            List<Record> listHb = Db.find(sqlHb);
-            //统计红包和个数
-            //对map里的list再根据 type 进行分组
-            Map<Integer,List<Record>> typeHbMap = listHb.parallelStream()
-                    .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-            String sql = "select * from "+ T_DAY_SCAN_HB +" where day_ = ? and type_ = ? and area_ = ? limit 1";
-
-            for(Map.Entry<Integer,List<Record>> typeEntry:typeHbMap.entrySet()){
-                List<Record> areaList = typeEntry.getValue();
-                if(!areaList.isEmpty()){
-                    Map<String,List<Record>> areaMap = areaList.parallelStream()
-                            .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-                    for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-                        Record typeRecord = Db.findFirst(sql,day,typeEntry.getKey(),areaEntry.getKey());
-                        if(typeRecord == null){
-                            continue;
-                        }
-                        List<Record> resultList = areaEntry.getValue();
-                        int hb = resultList.parallelStream().mapToInt(r -> r.getInt("amount")).sum();
-                        long count = resultList.parallelStream()
-                                .count();
-                        typeRecord.set("hb_",hb);
-                        typeRecord.set("hbc_", (int) count);
-                        Db.update(T_DAY_SCAN_HB,typeRecord);
-                    }
-                }
-            }
-
-        }
-        LOGGER.info("{} 号 {} 表数据 统计完成",day,T_DAY_SCAN_HB);
-    }
-
-    /**
-     * 统计每种红包金额的发放个数和发放的金额
-     * 并统计每种红包金额在不同品相和区域发放的个数和发放的金额
-     * @param startTime 统计开始时间
-     * @param endTime 统计结束时间
-     * @param day 时间的yyyy-MM-dd表示
-     * @param hbCount 发放成功的红包数量
-     */
-    private void statisticsDayScanHbDetail(String startTime,String endTime,String day,int hbCount){
-        LOGGER.info("{} 号 开始统计 {}表 和 {} 表数据",day,T_DAY_HB,T_DAY_HB_DETAIL);
-
-        if(hbCount > SINGLE_COUNT){
-            int count = hbCount / SINGLE_COUNT;
-            int residue = hbCount % SINGLE_COUNT;
-            int len = 0;
-            Map<String, DayHbEntity> dayHbMap = new HashMap<>();
-            Map<String,DayHbEntity> dayHbDetailMap = new HashMap<>();
-            for (int i = 0; i < count; i++) {
-                String sql = "select send_time,amount,type_,area from t_scanrecord where send_time >='"+startTime+"' and send_time<='"+endTime+"' limit "+len+","+SINGLE_COUNT+"";
-                List<Record> listHb = Db.find(sql);
-
-                Map<Integer,List<Record>> amountMap = listHb.parallelStream()
-                        .collect(Collectors.groupingBy(r->r.getInt("amount"),Collectors.toList()));
-                TreeMap<Integer,List<Record>> amtTreeMap = new TreeMap<>(amountMap);
-
-                //给map按照key排序
-                List<Map.Entry<Integer,List<Record>>> amountKeyList = new ArrayList<>(amtTreeMap.entrySet());
-                amountKeyList.sort(Comparator.comparing(Map.Entry::getKey));
-
-                for(Map.Entry<Integer,List<Record>> amountEntry:amtTreeMap.entrySet()){
-                    List<Record> amountList = amountEntry.getValue();
-                    if(!amountList.isEmpty()){
-                        String dayHbKey = day +SPLIT+amountEntry.getKey();
-                        if(dayHbMap.get(dayHbKey) == null){
-                            DayHbEntity dayHbEntity = new DayHbEntity();
-                            dayHbEntity.setHb(amountEntry.getKey());
-                            dayHbEntity.setHbCount(amountList.size());
-                            dayHbMap.put(dayHbKey,dayHbEntity);
-                        }else{
-                            DayHbEntity oldDayHbEntity = dayHbMap.get(dayHbKey);
-                            DayHbEntity newDayHbEntity = new DayHbEntity();
-                            newDayHbEntity.setHb(oldDayHbEntity.getHb());
-                            newDayHbEntity.setHbCount(oldDayHbEntity.getHbCount()+amountList.size());
-                            dayHbMap.put(dayHbKey,newDayHbEntity);
-                        }
-
-                        Map<Integer,List<Record>> typeMap = amountList.parallelStream()
-                                .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-                        for(Map.Entry<Integer,List<Record>> typeEntry:typeMap.entrySet()){
-                            List<Record> typeList = typeEntry.getValue();
-                            if(!typeList.isEmpty()){
-                                Map<String,List<Record>> areaMap = typeList.parallelStream()
-                                        .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-
-                                for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-                                    List<Record> areaList = areaEntry.getValue();
-                                    if(!areaList.isEmpty()){
-
-                                        //Integer hbt = areaList.parallelStream().mapToInt(r -> r.getInt("amount")).sum();
-                                        long hbc = areaList.parallelStream().count();
-                                        String key = day +SPLIT+amountEntry.getKey()+SPLIT+typeEntry.getKey()+SPLIT+areaEntry.getKey();
-                                        if(dayHbDetailMap.get(key) == null){
-                                            DayHbEntity dayHbEntity = new DayHbEntity();
-                                            dayHbEntity.setHb(amountEntry.getKey());
-                                            dayHbEntity.setHbCount((int) hbc);
-                                            dayHbDetailMap.put(key,dayHbEntity);
-                                        }else{
-                                            DayHbEntity oldDayHbEntity = dayHbDetailMap.get(key);
-                                            DayHbEntity newDayHbEntity = new DayHbEntity();
-                                            newDayHbEntity.setHb(oldDayHbEntity.getHb());
-                                            newDayHbEntity.setHbCount((int) (oldDayHbEntity.getHbCount()+hbc));
-                                            dayHbDetailMap.put(key,newDayHbEntity);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                    }
-                }
-                len += SINGLE_COUNT;
-            }
-
-            if(residue > 0){
-                String sql = "select send_time,amount,type_,area from t_scanrecord where send_time >='"+startTime+"' and send_time<='"+endTime+"' limit "+len+","+hbCount+"";
-                List<Record> listHb = Db.find(sql);
-                Map<Integer,List<Record>> amountMap = listHb.parallelStream()
-                        .collect(Collectors.groupingBy(r->r.getInt("amount"),Collectors.toList()));
-                TreeMap<Integer,List<Record>> amtTreeMap = new TreeMap<>(amountMap);
-
-                //给map按照key排序
-                List<Map.Entry<Integer,List<Record>>> amountKeyList = new ArrayList<>(amtTreeMap.entrySet());
-                amountKeyList.sort(Comparator.comparing(Map.Entry::getKey));
-
-                for(Map.Entry<Integer,List<Record>> amountEntry:amtTreeMap.entrySet()){
-                    List<Record> amountList = amountEntry.getValue();
-                    if(!amountList.isEmpty()){
-                        String dayHbKey = day +SPLIT+amountEntry.getKey();
-                        if(dayHbMap.get(dayHbKey) == null){
-                            DayHbEntity dayHbEntity = new DayHbEntity();
-                            dayHbEntity.setHb(amountEntry.getKey());
-                            dayHbEntity.setHbCount(amountList.size());
-                            dayHbMap.put(dayHbKey,dayHbEntity);
-                        }else{
-                            DayHbEntity oldDayHbEntity = dayHbMap.get(dayHbKey);
-                            DayHbEntity newDayHbEntity = new DayHbEntity();
-                            newDayHbEntity.setHb(oldDayHbEntity.getHb());
-                            newDayHbEntity.setHbCount(oldDayHbEntity.getHbCount()+amountList.size());
-                            dayHbMap.put(dayHbKey,newDayHbEntity);
-                        }
-
-                        Map<Integer,List<Record>> typeMap = amountList.parallelStream()
-                                .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-                        for(Map.Entry<Integer,List<Record>> typeEntry:typeMap.entrySet()){
-                            List<Record> typeList = typeEntry.getValue();
-                            if(!typeList.isEmpty()){
-                                Map<String,List<Record>> areaMap = typeList.parallelStream()
-                                        .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-
-                                for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-                                    List<Record> areaList = areaEntry.getValue();
-                                    if(!areaList.isEmpty()){
-
-                                        //Integer hbt = areaList.parallelStream().mapToInt(r -> r.getInt("amount")).sum();
-                                        long hbc = areaList.parallelStream().count();
-                                        String key = day +SPLIT+amountEntry.getKey()+SPLIT+typeEntry.getKey()+SPLIT+areaEntry.getKey();
-                                        if(dayHbDetailMap.get(key) == null){
-                                            DayHbEntity dayHbEntity = new DayHbEntity();
-                                            dayHbEntity.setHb(amountEntry.getKey());
-                                            dayHbEntity.setHbCount((int) hbc);
-                                            dayHbDetailMap.put(key,dayHbEntity);
-                                        }else{
-                                            DayHbEntity oldDayHbEntity = dayHbDetailMap.get(key);
-                                            DayHbEntity newDayHbEntity = new DayHbEntity();
-                                            newDayHbEntity.setHb(oldDayHbEntity.getHb());
-                                            newDayHbEntity.setHbCount((int) (oldDayHbEntity.getHbCount()+hbc));
-                                            dayHbDetailMap.put(key,newDayHbEntity);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                    }
-                }
-            }
-
-            for(Map.Entry<String,DayHbEntity> dayHbEntry:dayHbMap.entrySet()){
-                Record amountRecord = new Record();
-                amountRecord.set("day_",day);
-                amountRecord.set("hb_",dayHbEntry.getValue().getHb());
-                amountRecord.set("hbc_",dayHbEntry.getValue().getHbCount());
-                amountRecord.set("hbt_",dayHbEntry.getValue().getHbAmount());
-                Db.save(T_DAY_HB,amountRecord);
-            }
-
-            for(Map.Entry<String,DayHbEntity> dayHbDetailEntry:dayHbDetailMap.entrySet()){
-                Record typeRecord = new Record();
-                String[] dta = dayHbDetailEntry.getKey().split(SPLIT);
-                typeRecord.set("hb_",dayHbDetailEntry.getValue().getHb());
-                typeRecord.set("day_",day);
-                typeRecord.set("type_",dta[2]);
-                typeRecord.set("area_",dta[3]);
-                typeRecord.set("hbc_",dayHbDetailEntry.getValue().getHbCount());
-                typeRecord.set("hbt_",dayHbDetailEntry.getValue().getHbAmount());
-                Db.save(T_DAY_HB_DETAIL,typeRecord);
-            }
-
-        }else{
-            String sql = "select send_time,amount,type_,area from t_scanrecord where send_time >='"+startTime+"' and send_time<='"+endTime+"'";
-            List<Record> listHb = Db.find(sql);
-            //需要过滤掉未发送成功的
-            Map<Integer,List<Record>> amountMap = listHb.parallelStream()
-                    .collect(Collectors.groupingBy(r->r.getInt("amount"),Collectors.toList()));
-
-            TreeMap<Integer,List<Record>> amtTreeMap = new TreeMap<>(amountMap);
-
-            //给map按照key排序
-            List<Map.Entry<Integer,List<Record>>> amountKeyList = new ArrayList<>(amtTreeMap.entrySet());
-            amountKeyList.sort(Comparator.comparing(Map.Entry::getKey));
-
-            for(Map.Entry<Integer,List<Record>> amountEntry:amtTreeMap.entrySet()){
-                List<Record> amountList = amountEntry.getValue();
-                if(!amountList.isEmpty()){
-                    Record amountRecord = new Record();
-                    amountRecord.set("day_",day);
-                    amountRecord.set("hb_",amountEntry.getKey());
-                    amountRecord.set("hbc_",amountList.size());
-                    amountRecord.set("hbt_",amountEntry.getKey()*amountList.size());
-                    Db.save(T_DAY_HB,amountRecord);
-
-                    Map<Integer,List<Record>> typeMap = amountList.parallelStream()
-                            .collect(Collectors.groupingBy(r->r.getInt("type_"),Collectors.toList()));
-
-                    for(Map.Entry<Integer,List<Record>> typeEntry:typeMap.entrySet()){
-                        List<Record> typeList = typeEntry.getValue();
-                        if(!typeList.isEmpty()){
-                            Map<String,List<Record>> areaMap = typeList.parallelStream()
-                                    .collect(Collectors.groupingBy(r->r.getStr("area"),Collectors.toList()));
-
-                            for(Map.Entry<String,List<Record>> areaEntry:areaMap.entrySet()){
-                                List<Record> areaList = areaEntry.getValue();
-                                if(!areaList.isEmpty()){
-                                    Record typeRecord = new Record();
-                                    typeRecord.set("hb_",amountEntry.getKey());
-                                    typeRecord.set("day_",day);
-                                    typeRecord.set("type_",typeEntry.getKey());
-                                    typeRecord.set("area_",areaEntry.getKey());
-
-                                    Integer hbt = areaList.parallelStream().mapToInt(r -> r.getInt("amount")).sum();
-                                    long hbc = areaList.parallelStream()
-                                            .count();
-                                    typeRecord.set("hbc_", (int) hbc);
-                                    typeRecord.set("hbt_",hbt);
-
-                                    Db.save(T_DAY_HB_DETAIL,typeRecord);
-
-                                }
-                            }
-                        }
-                    }
-
-                }
-            }
-        }
-        LOGGER.info("{} 号 {} 和 {} 表数据 统计完成",day,T_DAY_HB,T_DAY_HB_DETAIL);
-    }
-}

+ 0 - 88
src/main/java/com/qlm/job/CheckYuEJob.java

@@ -1,88 +0,0 @@
-package com.qlm.job;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-
-import com.jfinal.kit.HttpKit;
-import com.jfinal.plugin.activerecord.Db;
-import com.jfinal.plugin.activerecord.Record;
-import com.qlm.tools.JFinalUtil;
-import com.qlm.tools.WxUtil;
-
-public class CheckYuEJob implements Job{
-
-	static boolean running =false;
-	@Override
-	public void execute(JobExecutionContext context)
-			throws JobExecutionException {
-		if(running){
-			return;
-		}
-		running = true;
-		try{
-			checkAmount();
-		}finally{
-			running = false;
-		}
-		
-	}
-	static Record lstRecord = null;
-	private void checkAmount() {
-		Date date = new Date();
-		Calendar instance = Calendar.getInstance();
-		int hour = instance.get(Calendar.HOUR_OF_DAY);
-		if(hour>=1 && hour<7){
-			return;
-		}
-		SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
-		String format = sdf.format(date);
-		Record findFirst = Db.findFirst("select * from t_pay_amount where date_ = ?",format);
-		int amount = WxUtil.getInt("amount_", findFirst);
-		if(lstRecord == null){
-			lstRecord = new Record();
-			lstRecord.set("create_time", new Date())
-			.set("amount", amount);
-		}else{
-			int lasteramount = JFinalUtil.getInt("amount", lstRecord);
-			Date lstRunDate = lstRecord.getDate("send_time");
-			long lstLong = 0;
-			if(lstRunDate != null){
-				lstLong = lstRunDate.getTime();
-			}
-			long cur = System.currentTimeMillis();
-			long jiange = 1000 * 60* 5;
-			boolean sendMail = false;
-			if(amount==lasteramount){
-				if((cur-lstLong)>=jiange){
-					sendMail = true;
-				}
-			}
-			
-			if(sendMail){
-				sendEmail("41405217@qq.com", "胖哥异常");
-				lstRecord.set("send_time",new Date());
-			}
-			lstRecord.set("amount", amount).set("create_time", new Date());
-			
-		}
-
-	}
-	
-	public static void sendEmail(String address,String text){
-		String encode2;
-		try {
-			encode2 = URLEncoder.encode(text,"utf-8");
-			String string = HttpKit.get("http://10.24.242.248:81/huangye3/e/sendEmail?text="+encode2+"&address=41405217@qq.com", null);
-		} catch (UnsupportedEncodingException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-}

+ 0 - 426
src/main/java/com/qlm/job/MoveData.java

@@ -1,426 +0,0 @@
-package com.qlm.job;
-
-import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
-import com.jfinal.plugin.activerecord.Db;
-import com.jfinal.plugin.activerecord.Record;
-import com.jfinal.plugin.druid.DruidPlugin;
-import com.jfinal.weixin.sdk.kit.PaymentKit;
-import com.qlm.tools.LocalDateUtils;
-import com.qlm.tools.StateMentsUtils;
-import com.qlm.tools.WxUtil;
-
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-
-import java.math.BigDecimal;
-import java.nio.charset.StandardCharsets;
-import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * @author nommpp
- * 每天10点开始
- */
-public class MoveData implements Job {
-    protected final static Logger log = LoggerFactory.getLogger(MoveData.class);
-    private static final int SINGLE_C = 100000;
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) {
-		Calendar instance = Calendar.getInstance();
-		int hour = instance.get(Calendar.HOUR_OF_DAY);
-		instance.add(Calendar.DAY_OF_MONTH, -1);
-		Date time = instance.getTime();
-		SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
-		String format = sdf.format(time);
-		try {
-			if(hour>=9 && hour<=12){
-				MoveData.checkNo(format);
-			}
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-    }
-    private static void con(){
-		DruidPlugin dp = new DruidPlugin("jdbc:mysql://rm-bp1j1ibp4ra74p110to.mysql.rds.aliyuncs.com:3306/kongka?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull", "dnzc", "Wangzih2022+-");
-		ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
-		// ��web����Ψһ�IJ�ͬ��Ҫ�ֶ�����һ����ز����start()����
-		dp.start();
-		arp.start();
-	}
-    public static void main(String[] args) throws Exception {
-		con();
-		String date = "2022.06.26";
-		checkNo(date);
-	}
-	public static void checkNo(String date) throws Exception {
-		log.info("开始检查单号:"+date);
-		String startTime = date+" 00:00:00";
-         String endTime =  date+" 23:59:59";
-         readNo(date);
-		String payCountSql = "select count(*) from t_order2 where pay_time >= '"+startTime+"' and pay_time <= '"+endTime+"' and amount <=100000";
-        Long payCountDb = Db.queryLong(payCountSql);
-        if(payCountDb == null){
-        	payCountDb = 0l;
-        }
-        if(payCountDb == 0){
-        	log.info("暂无资金");
-        	return;
-        }
-        Long scanCount = Db.queryLong("select count(*) from t_scanrecord where send_time >='"+startTime+"' and send_time <='"+endTime+"'");
-        if(scanCount == null){
-        	scanCount = 0l;
-        }
-        if(!scanCount .equals(payCountDb)){
-        	Map<String,Record> maps = new HashMap<String, Record>();
-        	List<Record> find = Db.find("select * from t_order2 where pay_time >= '"+startTime+"' and pay_time <= '"+endTime + "' and amount <=100000");
-        	for (Record record : find) {
-        		String wx_no = record.getStr("wx_no");
-        		maps.put(wx_no, record);
-			}
-            List<Record> list = Db.find("select * from t_scanrecord where send_time >='"+startTime+"' and send_time <='"+endTime+"'");
-            for (Record record : list) {
-            	String weixin_no_ = record.getStr("weixin_no_");
-            	maps.remove(weixin_no_);
-			}
-            Set<String> keySet = maps.keySet();
-            for (String nos : keySet) {
-            	Record record = maps.get(nos);
-            	String pay_no = record.getStr("pay_no");
-            	Record findFirst = Db.findFirst("select * from t_qcode_hb_a where no_ = ?",pay_no);
-            	if(findFirst != null){
-            		String id = findFirst.getStr("id");
-            		Date payDate = record.getDate("pay_time");
-            		findFirst.set("send_time",payDate).set("send_state", 1);
-            		Db.update("t_qcode_hb_a", findFirst);
-            		Record findById = Db.findById("t_scanrecord", "qrcode_id", id);
-            		if(findById != null){
-            			findById.set("send_time",payDate).set("send_state", 1).set("weixin_no_", nos);
-            			Db.update("t_scanrecord", "qrcode_id", findById);
-            		}
-            		log.info(id+" 更新完成");
-            	}
-            	
-			}
-        }
-        log.info(date+" 完成");
-	}
-
-    /**
-     * 核对数据
-     */
-    private static void check(String startTime,String endTime) {
-        log.info("{}开始核对数据",startTime);
-
-        ExecutorService executors = Executors.newFixedThreadPool(4);
-
-        CompletableFuture<List<String>> c1 = CompletableFuture.supplyAsync(()->{
-            log.info("开始查询 {} 表数据","t_order2");
-            String payCountSql = "select count(*) from t_order2 where pay_time >= '"+startTime+"' and pay_time <= '"+endTime+"'";
-            Long payCountDb = Db.queryLong(payCountSql);
-            int payCount = payCountDb == null ? 0 : payCountDb.intValue();
-            if(payCount > SINGLE_C){
-                //总次数
-                int count = payCount / SINGLE_C;
-                //剩余次数
-                int residue = payCount % SINGLE_C;
-                List<String> ls1 = new ArrayList<>();
-                int len = 0;
-                for (int i = 0; i < count; i++) {
-                    String sqlPay = "select wx_no from t_order2 where pay_time >='" + startTime + "' and pay_time<='" + endTime + "' limit " + len + "," + SINGLE_C + "";
-                    List<Record> payList = Db.find(sqlPay);
-                    for (Record record : payList) {
-                        ls1.add(record.getStr("wx_no"));
-                    }
-                    len += SINGLE_C;
-                }
-
-                if(residue > 0){
-                    String sqlPay = "select wx_no from t_order2 where pay_time >='" + startTime + "' and pay_time<='" + endTime + "' limit " + len + "," + payCount + "";
-                    List<Record> payList = Db.find(sqlPay);
-                    for (Record record : payList) {
-                        ls1.add(record.getStr("wx_no"));
-                    }
-                }
-                log.info("{} 表数据查询完成","t_order2");
-                return ls1;
-            }else{
-                String sql1 = "select wx_no from t_order2 where pay_time >='"+startTime+"' and pay_time <='"+endTime+"'";
-                return Db.query(sql1);
-            }
-
-        },executors);
-
-        CompletableFuture<List<String>> c2 = CompletableFuture.supplyAsync(()->{
-            //查询发放成功的红包总个数
-            log.info("开始查询 {} 表数据","t_scanrecord");
-            String hbCountSql = "select count(*) from t_scanrecord where send_time >= '"+startTime+"' and send_time <= '"+endTime+"'";
-            Long hbCountDb = Db.queryLong(hbCountSql);
-            int hbCount = hbCountDb == null ? 0 : hbCountDb.intValue();
-            if(hbCount > SINGLE_C){
-                //总次数
-                int count = hbCount / SINGLE_C;
-                //剩余次数
-                int residue = hbCount % SINGLE_C;
-                List<String> ls2 = new ArrayList<>();
-                int len = 0;
-                for (int i = 0; i < count; i++) {
-                    String sqlHb = "select weixin_no_ from t_scanrecord where send_time >='" + startTime + "' and send_time<='" + endTime + "' limit " + len + "," + SINGLE_C + "";
-                    List<Record> hbList = Db.find(sqlHb);
-                    for (Record record : hbList) {
-                        ls2.add(record.getStr("weixin_no_"));
-                    }
-                    len += SINGLE_C;
-                }
-
-                if(residue > 0){
-                    String sqlHb = "select weixin_no_ from t_scanrecord where send_time >='" + startTime + "' and send_time<='" + endTime + "' limit " + len + "," + hbCount + "";
-                    List<Record> hbList = Db.find(sqlHb);
-                    for (Record record : hbList) {
-                        ls2.add(record.getStr("weixin_no_"));
-                    }
-                }
-                log.info("{} 表数据查询完成","t_scanrecord");
-                return ls2;
-            }else{
-                String sql2 = "select weixin_no_ from t_scanrecord where send_time >='"+startTime+"' and send_time <='"+endTime+"'";
-                return Db.query(sql2);
-            }
-        },executors);
-
-        c1.thenCombine(c2, MoveData::getDiffent).thenApplyAsync((lst3) -> {
-            if (lst3.isEmpty()) {
-                log.info("{} 数据准确,无需核对", startTime);
-                return null;
-            }
-            List<Record> records = new ArrayList<>(lst3.size());
-            lst3.parallelStream().forEach(key -> {
-                Record record = Db.findFirst("select * from t_order2 where wx_no = ?", key);
-                if (record != null) {
-                    record.set("status_", 1);
-                    Db.update("t_order2", "pay_no", record);
-                    records.add(record);
-                } else {
-                    log.info("{} 号微信对账单不存在此 wx_no:{}", startTime, key);
-                }
-            });
-            if (records.isEmpty()) {
-                log.info("{} 号微信对账单有误", startTime);
-            }
-            return records;
-        }, executors).thenApplyAsync(records -> {
-            if (records == null) {
-                return null;
-            }
-            List<Record> hbRecords = new ArrayList<>(records.size());
-            if (!records.isEmpty()) {
-                records.parallelStream().forEach(r -> {
-                    String payNo = r.getStr("pay_no");
-                    if(payNo != null && !payNo.startsWith("c")){
-                        Record unPayRecord = Db.findFirst("select * from t_unpayinfo where pay_no = ? limit 1",payNo);
-                        String code;
-                        if(unPayRecord == null || unPayRecord.getStr("id") == null){
-                            log.info("补发表没有订单号 {} 记录",payNo);
-                            /* 补发记录太多会占满cpu和内存  2020.03.12 lds
-                            String tableName = "t_qcode_hb_a";
-                            Record hbRecord = Db.findFirst("select * from t_qcode_hb_a where no_ = ? limit 1",payNo);
-                            if (hbRecord != null) {
-                                hbRecord.set("send_state", 1).set("send_time", r.getDate("pay_time"));
-                                //Db.update("update t_qcode_hb_a set send_state = ? and send_time = ? where no_ = ?",1,r.getDate("pay_time"),r.getStr("pay_no"));
-                                Db.update(tableName, hbRecord);
-                                hbRecord.set("wx_no", r.getStr("wx_no"));
-                                hbRecords.add(hbRecord);
-                            }
-                            */
-                        }else{
-                            code = unPayRecord.getStr("id");
-                            String prefix = code.substring(0,1);
-                            String tableName = "t_qcode_hb_"+prefix;
-                            Record hbRecord = Db.findById(tableName,code);
-                            if (hbRecord != null) {
-                                hbRecord.set("send_state", 1).set("send_time", r.getDate("pay_time"));
-                                //Db.update("update t_qcode_hb_a set send_state = ? and send_time = ? where no_ = ?",1,r.getDate("pay_time"),r.getStr("pay_no"));
-                                Db.update(tableName, hbRecord);
-                                hbRecord.set("wx_no", r.getStr("wx_no"));
-                                hbRecords.add(hbRecord);
-                            }
-                        }
-                    }
-                });
-                if (hbRecords.isEmpty()) {
-                    log.info("{} 红包表没有记录,不能获取二维码,无法核对", startTime);
-                }
-            }
-            return hbRecords;
-        }, executors).thenApplyAsync(hbrecords -> {
-            if (hbrecords == null) {
-                return true;
-            }
-            List<Record> scanRecords = new ArrayList<>();
-            if (!hbrecords.isEmpty()) {
-                hbrecords.parallelStream().forEach(r -> {
-                    log.info("有误差的二维码 {}", r.getStr("id"));
-                    Db.update("delete from t_unpayinfo where id = ?", r.getStr("id"));
-                    Record sr = Db.findById("t_scanrecord", "qrcode_id", r.getStr("id"));
-                    sr.set("send_state", 1).set("send_time", r.getDate("send_time")).set("weixin_no_", r.getStr("wx_no"));
-                    Db.update("t_scanrecord", "qrcode_id", sr);
-                    scanRecords.add(sr);
-                });
-                if (scanRecords.isEmpty()) {
-                    log.info("{} 扫码表没有记录,无法核对", startTime);
-                    return false;
-                }
-            }
-            return !scanRecords.isEmpty();
-        }, executors).handle((res, ex) -> {
-            if (ex != null) {
-                executors.shutdown();
-                log.info("{} 核对数据出现异常,原因 {}", startTime,ex.getMessage());
-                ex.printStackTrace();
-            } else {
-                executors.shutdown();
-                if (res) {
-                    log.info("{} 核对数据成功", startTime);
-                }else{
-                    log.info("{} 核对数据失败", startTime);
-                }
-            }
-            return res;
-        });
-    }
-
-    private static List<String> getDiffent(List<String> collmax, List<String> collmin)
-    {
-        //使用LinkeList防止差异过大时,元素拷贝
-        List<String> csReturn = new LinkedList();
-        List<String> max = collmax;
-        List<String> min = collmin;
-        //先比较大小,这样会减少后续map的if判断次数
-        if(collmax.size()<collmin.size())
-        {
-            max = collmin;
-            min = collmax;
-        }
-        //直接指定大小,防止再散列
-        Map<String,Integer> map = new HashMap<>(max.size());
-        for (String object : min) {
-            map.put(object, 1);
-        }
-        for (String object : max) {
-            if(map.get(object)==null)
-            {
-                csReturn.add(object);
-            }
-        }
-        return csReturn;
-    }
-
-    /**
-     * 从微信读取指定日期的资金账单
-     * @param date 指定的日期 yyyy.MM.dd 格式
-     * @throws Exception
-     */
-    private static void  readNo(String date) throws Exception {
-    	String startTime = date+" 00:00:00";
-        String endTime =  date+" 23:59:59";
-		String payCountSql = "select count(*) from t_order2 where pay_time >= '"+startTime+"' and pay_time <= '"+endTime+"' and amount <=100000";
-       Long payCountDb = Db.queryLong(payCountSql);
-       if(payCountDb == null){
-       	payCountDb = 0l;
-       }
-       if(payCountDb>0){
-    	   log.info("{} 资金账单已经存在",date);
-    	   return;
-       }
-        log.info("{} 开始下载资金账单",date);
-        	Record config = Db.findFirst("select * from t_pay_config");
-        	String mch_id =config.getStr("mch_id");
-            Map<String, String> params = new HashMap<String, String>();
-            params.put("appid", "wx83a34a499a3db4f1");//商户号
-            params.put("mch_id", mch_id);
-            params.put("nonce_str", System.currentTimeMillis()+"");//随机字符串
-            String partner_key = config.getStr("partner_key");
-            String[] dd = date.split("\\.");
-            StringBuilder sb = new StringBuilder();
-            for (String string : dd) {
-                sb.append(string);
-            }
-            date = sb.toString();
-            params.put("bill_date", date);
-            String certPath;
-            certPath = "/apiclient_cert.p12";
-            params.put("account_type", "Operation");//
-            String stringA = PaymentKit.packageSign(params, false);
-            String stringSignTemp = stringA + "&key=" + partner_key;
-            String sign = HMACSHA256(stringSignTemp,partner_key);
-            params.put("sign", sign);
-            java.net.URL resource = StateMentsUtils.class.getResource(certPath);
-            String file = resource.getFile();
-            String xmlStr = PaymentKit.postSSL("https://api.mch.weixin.qq.com/pay/downloadfundflow", PaymentKit.toXml(params),file,mch_id);
-            String[] split = xmlStr.split("\n");
-            int lineNo = split.length;
-            List<Record> list = new ArrayList<Record>();
-            for (int i = 1; i < lineNo-2; i++) {
-                Record r = new Record();
-                String line = split[i];
-                String[] split2 = line.split(",");
-                if(split2.length<=6){
-                    System.out.println(date);
-                    break;
-                }
-                String payTime = split2[0];
-                String payWxno = split2[2];
-                String payAmount = split2[6];
-                String payNo = split2[10];
-                String mcId = split2[8];
-                payAmount = payAmount.substring(1);
-                payNo = payNo.substring(1);
-                payWxno = payWxno.substring(1);
-                if(WxUtil.isNull(payNo)){
-                    continue;
-                }
-                BigDecimal multiply = new BigDecimal(payAmount).multiply(new BigDecimal(100));
-                int intValue = multiply.intValue();
-                payTime = payTime.substring(1);
-                r.set("pay_time", payTime).set("amount", intValue)
-                        .set("pay_no", payNo).set("mc_id", mcId).set("wx_no", payWxno);
-                list.add(r);
-            }
-
-            WxUtil.batchSave("t_order2", list);
-        log.info("{} 资金账单下载结束",date);
-    }
-
-    public static String HMACSHA256(String data,String key) throws Exception {
-
-        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
-
-        SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
-
-        sha256_HMAC.init(secret_key);
-
-        byte[] array = sha256_HMAC.doFinal(data.getBytes(StandardCharsets.UTF_8));
-
-        StringBuilder sb = new StringBuilder();
-
-        for (byte item : array) {
-
-            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
-
-        }
-
-        return sb.toString().toUpperCase();
-
-    }
-}

+ 5 - 13
src/main/java/com/qlm/job/MyJob.java

@@ -26,35 +26,27 @@ import org.slf4j.LoggerFactory;
 
 
 
+
 
 import com.jfinal.core.Controller;
 import com.jfinal.plugin.activerecord.Db;
+import com.qlm.service.UploadService;
 import com.qlm.tongji.service.ISummaryService;
 import com.qlm.tongji.service.impl.SummaryServiceImpl;
 import com.qlm.tools.DateUtils;
 
 
-public class MyJob extends Controller implements Job {
+public class MyJob  implements Job {
 	
 	private static final Logger logger = LoggerFactory.getLogger(MyJob.class);
-	private ISummaryService summaryService = enhance(SummaryServiceImpl.class);
 
 
 	@Override
 	public void execute(JobExecutionContext jobExecutionContext)
 			throws JobExecutionException {
-		logger.info("定时统计执行..." + new Date());
-		summaryService.addSummary();
+		logger.info("定时任务执行..." + new Date());
+		UploadService.update();
 //		updDayCount();
 	}
 
-	/**
-	 * 定时将t_god表中dayCount字段清零
-	 */
-	public static void updDayCount(){
-		String sql = "update t_user set day_count=0";
-		Db.update(sql);
-		logger.info(DateUtils.getStringFullDate()+" 清零dayCount");
-	}
-
 }

+ 23 - 0
src/main/java/com/qlm/job/UploadJob.java

@@ -0,0 +1,23 @@
+package com.qlm.job;
+
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.qlm.service.WmesService;
+
+public class UploadJob implements Job{
+
+	private static final Logger logger = LoggerFactory.getLogger(UploadJob.class);
+
+	
+	@Override
+	public void execute(JobExecutionContext arg0) throws JobExecutionException {
+			WmesService.uploadData();
+			logger.info("上传数据倒wmes");
+	}
+	
+
+}

+ 63 - 0
src/main/java/com/qlm/service/UploadService.java

@@ -118,6 +118,69 @@ public class UploadService {
 		}
 	}
 	
+	//同步订单到我们自己的库
+	public static void update(){
+		String udfSqlString = "select * from WMS_PROD.V_TMSO_RETURN_H WHERE ROWNUM = 1";
+//		String sql = "select * from WMS_PROD.V_SERIAL_INFO WHERE ROWNUM = 1";
+		List<Record> find = Db.use("oracle").find(udfSqlString);
+		
+		List<Record> list = new ArrayList<Record>();
+		for (Record record : find) {
+			String orderNo = record.getStr("ORDERNO");//发货单号
+			
+			String OUTWAREHOUSE = record.getStr("OUTWAREHOUSE");//工厂名称
+			
+			
+			String WAREHOUSEID = record.getStr("WAREHOUSEID");//工厂ID
+			
+			
+			Date Deliverytime = record.getDate("DELIVERYTIME");//出库时间
+			
+			String caseCode = record.getStr("CASECODE");//箱码
+			
+			String palletCode = record.getStr("PALLETCODE");//垛码
+			
+			
+			String PRODUCTNAME = record.getStr("PRODUCTNAME");//产品名称
+			
+			
+			
+			String CUSTOMERNAME = record.getStr("CUSTOMERNAME");//客户姓名
+		
+			String SKUNAME = record.getStr("SKUNAME");//SKU名称
+			
+			String LICENSEPLATE = record.getStr("LICENSEPLATE");//车牌号
+			
+			String OUTWAREHOUSENO = record.getStr("OUTWAREHOUSENO");//工厂编号
+			
+			String SKUNO = record.getStr("SKUNO");//sku编号
+			
+			String OPERATEUSER = record.getStr("OPERATEUSER");//操作人
+			
+			String PRODUCTNO = record.getStr("PRODUCTNO");//产品编号
+			
+			String CUSTOMERNO = record.getStr("CUSTOMERNO");//客户编号
+			
+			Record info = new Record();
+			
+			info.set("OrderNo", orderNo).set("OutWarehouse", OUTWAREHOUSE).set("WarehouseID", WAREHOUSEID)
+			
+			.set("DeliveryTime", Deliverytime).set("CaseCode", caseCode).set("PalletCode", palletCode)
+			
+			.set("ProductName", PRODUCTNAME).set("CustomerName", CUSTOMERNAME).set("SKUName", SKUNAME)
+			
+			
+			.set("LicensePlate", LICENSEPLATE).set("OutWarehouseNo", OUTWAREHOUSENO).set("SKUNo", SKUNO)
+			
+			.set("OperateUser", OPERATEUSER).set("ProductNo", PRODUCTNO).set("CustomerNo", CUSTOMERNO);
+			
+			
+			list.add(info);
+			
+		}
+		WxUtil.batchSaveIgnore("deliveryorders", list, "");
+	}
+	
 	private static String key = "wYG(nx%Xlc7vb%Ss1=2L#JZ*gSk^WXuV";
 
 	private boolean checksign(String code, String time, String sign) {

+ 6 - 1
src/main/resources/job.properties

@@ -1,4 +1,9 @@
 a.job=com.qlm.job.MyJob
-a.cron=0 1 0 * * ?
+a.cron=0 */5 * * * ?
 a.enable=true
 
+
+b.job=com.qlm.job.UploadJob
+b.cron=0 */5 * * * ?
+b.enable=true
+