qq_32106973
qq_32106973
2018-01-18 07:11

java定时任务,现在为一天一同步,需要改为一周一同步,代码如下,本人菜鸟请大神搭救

20
  • java

public class ElectricContractServiceImpl implements ElectricContractService {
private static final Logger log = Logger.getLogger(ElectricContractServiceImpl.class);
private ElectricContractDao electricContractDao;
private InquiryContractDAO inquiryContractDAO;
@SuppressWarnings("unchecked")
public void AutoExcute() throws Exception {
String fileRealPath = "";// 附件的完整路径
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
//格式化对象
String strD = sdf.format(new Date());
//当天执行,获取前一天数据
String beginTime = DateConvertor.dateToString(DateConvertor.offsetDate(new Date(), -1, "day"), "yyyy-MM-dd HH:mm:ss");
String endTime = DateConvertor.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
List list = electricContractDao.findContract(beginTime, endTime);
// 根路径
String base = FtpPropertiesReader.getProperty("ftpElectricLocalDir");
String filename = "ContractInfo_" + strD; // 文件名
fileRealPath = base + filename + ".csv";
File file = new File(fileRealPath);// 新建文件
if (!file.exists()) {
file.createNewFile();
}
if (log.isDebugEnabled()) {
log.debug("创建文件-开始");
}
FileOutputStream outStr = new FileOutputStream(file);
BufferedOutputStream buff = new BufferedOutputStream(outStr);
// 生成新的csv文件
StringBuffer title = new StringBuffer(); // 一行数据 标题


  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答