commit
db144df2df
@ -0,0 +1,47 @@
|
|||||||
|
package com.platform.service.thread;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.platform.dao.DataInfoMoveTmpDao;
|
||||||
|
import com.platform.entities.DataInfoEntityMoveTmp;
|
||||||
|
import com.platform.service.IMoveDataService;
|
||||||
|
import com.platform.service.impl.MoveDataServiceImpl;
|
||||||
|
import com.platform.utils.Constant;
|
||||||
|
|
||||||
|
public class TreadMoveData2Start extends Thread{
|
||||||
|
|
||||||
|
|
||||||
|
private IMoveDataService dataInfoMove= new MoveDataServiceImpl();
|
||||||
|
|
||||||
|
public TreadMoveData2Start() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
boolean isBreak = false;
|
||||||
|
while(true){
|
||||||
|
if (isBreak) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List<DataInfoEntityMoveTmp> resultlist = dataInfoMove.findAll();
|
||||||
|
for (DataInfoEntityMoveTmp moveEntity : resultlist) {
|
||||||
|
if ("1".equals(moveEntity.getCompleteStatus())) {
|
||||||
|
moveEntity.setCompleteStatus("3");
|
||||||
|
dataInfoMove.update(moveEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isBreak = true;
|
||||||
|
Thread.sleep(Constant.update_dataInfo_sleep_time);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,137 @@
|
|||||||
|
package com.platform.utils;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class DateForm {
|
||||||
|
|
||||||
|
private static final String date_format_second = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
|
private static final String date_format_second_non = "yyyy-MM-dd_HH-mm-ss";
|
||||||
|
|
||||||
|
private static final String data_format_min = "yyyy-MM-dd HH:mm";
|
||||||
|
|
||||||
|
private static final String data_format_day = "yyyy-MM-dd";
|
||||||
|
|
||||||
|
private static ThreadLocal<DateFormat> threadLocal_second = new ThreadLocal<DateFormat>();
|
||||||
|
|
||||||
|
private static ThreadLocal<DateFormat> threadLocal_second_non = new ThreadLocal<DateFormat>();
|
||||||
|
|
||||||
|
private static ThreadLocal<DateFormat> threadLocal_min = new ThreadLocal<DateFormat>();
|
||||||
|
|
||||||
|
private static ThreadLocal<DateFormat> threadLocal_day = new ThreadLocal<DateFormat>();
|
||||||
|
|
||||||
|
public static String date2StringBysecond(Date date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateFormat format = threadLocal_second.get();
|
||||||
|
if(format == null){
|
||||||
|
format = new SimpleDateFormat(date_format_second);
|
||||||
|
threadLocal_second.set(format);
|
||||||
|
}
|
||||||
|
return format.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String date2StringBysecondNon(Date date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateFormat format = threadLocal_second_non.get();
|
||||||
|
if(format == null){
|
||||||
|
format = new SimpleDateFormat(date_format_second_non);
|
||||||
|
threadLocal_second_non.set(format);
|
||||||
|
}
|
||||||
|
return format.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String date2StringByMin(Date date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateFormat format = threadLocal_min.get();
|
||||||
|
if(format == null){
|
||||||
|
format = new SimpleDateFormat(data_format_min);
|
||||||
|
threadLocal_min.set(format);
|
||||||
|
}
|
||||||
|
return format.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String date2StringByDay(Date date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateFormat format = threadLocal_day.get();
|
||||||
|
if(format == null){
|
||||||
|
format = new SimpleDateFormat(data_format_day);
|
||||||
|
threadLocal_day.set(format);
|
||||||
|
}
|
||||||
|
return format.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date string2DateBysecond(String date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
date = date.trim();
|
||||||
|
if (date.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateFormat format = threadLocal_second.get();
|
||||||
|
try {
|
||||||
|
if(format == null){
|
||||||
|
format = new SimpleDateFormat(date_format_second);
|
||||||
|
threadLocal_second.set(format);
|
||||||
|
}
|
||||||
|
return format.parse(date);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date string2DateByMin(String date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
date = date.trim();
|
||||||
|
if (date.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateFormat format = threadLocal_min.get();
|
||||||
|
try {
|
||||||
|
if(format == null){
|
||||||
|
format = new SimpleDateFormat(data_format_min);
|
||||||
|
threadLocal_min.set(format);
|
||||||
|
}
|
||||||
|
return format.parse(date);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date string2DateByDay(String date) {
|
||||||
|
if (date == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
date = date.trim();
|
||||||
|
if (date.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DateFormat format = threadLocal_day.get();
|
||||||
|
try {
|
||||||
|
if(format == null){
|
||||||
|
format = new SimpleDateFormat(data_format_day);
|
||||||
|
threadLocal_day.set(format);
|
||||||
|
}
|
||||||
|
return format.parse(date);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
package com.platform.utils;
|
|
||||||
|
|
||||||
public class ThreadMoveData extends Thread {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* : 实时更新数据库--根据查询到的 正则迁移的数据
|
|
||||||
*/
|
|
||||||
public ThreadMoveData() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Thread#run()
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.run();
|
|
||||||
//查询 表 move_data_tmp
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(Constant.update_dataInfo_sleep_time);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in new issue