|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package org.jeecg.modules.hangerlocation.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import org.jeecg.common.util.XJobUtils; |
|
|
|
|
import org.jeecg.modules.hangerlocation.entity.HangerLocation; |
|
|
|
|
import org.jeecg.modules.hangerlocation.mapper.HangerLocationMapper; |
|
|
|
|
import org.jeecg.modules.hangerlocation.service.IHangerLocationService; |
|
|
|
@ -16,6 +17,8 @@ import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
import static org.jeecg.common.util.XJobUtils.dateToLong; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: 衣架定位表 |
|
|
|
|
* @Author: jeecg-boot |
|
|
|
@ -56,7 +59,7 @@ public class HangerLocationServiceImpl extends ServiceImpl<HangerLocationMapper, |
|
|
|
|
//服装进入制作工艺过程
|
|
|
|
|
long timeMillis = System.currentTimeMillis(); |
|
|
|
|
//将获取时间转为日期类型
|
|
|
|
|
Date start_time=longToDate(timeMillis); |
|
|
|
|
Date start_time=XJobUtils.longToDate(timeMillis); |
|
|
|
|
QueryWrapper<HangerMaker> qwhm=new QueryWrapper(); |
|
|
|
|
qwhm.eq("order_code",entry.getKey()); |
|
|
|
|
HangerMaker hm=hangerMakerMapper.selectOne(qwhm); |
|
|
|
@ -86,13 +89,13 @@ public class HangerLocationServiceImpl extends ServiceImpl<HangerLocationMapper, |
|
|
|
|
/**到达时间*/ |
|
|
|
|
model.setArrivalTime(start_time); |
|
|
|
|
/**离开时间*/ |
|
|
|
|
Date end_time=returnEXtime(start_time); |
|
|
|
|
Date end_time= XJobUtils.randomIntervaltime(start_time,3,5); |
|
|
|
|
model.setLeaveTime(end_time); |
|
|
|
|
/**时长*/ |
|
|
|
|
model.setDuration(dateToLong(start_time,end_time)+""); |
|
|
|
|
|
|
|
|
|
//执行下一步间隔时间
|
|
|
|
|
start_time=returnIntervaltime(end_time); |
|
|
|
|
start_time=XJobUtils.randomIntervaltime(end_time,1,3); |
|
|
|
|
hangerLocationMapper.insert(model); |
|
|
|
|
} |
|
|
|
|
// System.out.println(entry.getKey());
|
|
|
|
@ -101,81 +104,4 @@ public class HangerLocationServiceImpl extends ServiceImpl<HangerLocationMapper, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取制作时间 |
|
|
|
|
* @param start_Date |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private Date returnEXtime(Date start_Date) |
|
|
|
|
{ |
|
|
|
|
//将时间转为long类型
|
|
|
|
|
long start=start_Date.getTime(); |
|
|
|
|
//获取5-20分钟对应毫秒
|
|
|
|
|
long intervalTime=randInt(300,1200)*1000; |
|
|
|
|
//总共花费时长
|
|
|
|
|
long timeMillis =start+intervalTime; |
|
|
|
|
//实例化日期对象
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
//将毫秒值传入转Date类型
|
|
|
|
|
calendar.setTimeInMillis(timeMillis); |
|
|
|
|
//Calendar --> date
|
|
|
|
|
Date time = calendar.getTime(); |
|
|
|
|
return time; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 获取间隔时间 |
|
|
|
|
* @param start_Date |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private Date returnIntervaltime(Date start_Date) |
|
|
|
|
{ |
|
|
|
|
//将时间转为long类型
|
|
|
|
|
long start=start_Date.getTime(); |
|
|
|
|
//获取30-180秒对应毫秒
|
|
|
|
|
long intervalTime=randInt(30,180)*1000; |
|
|
|
|
//总共花费时长
|
|
|
|
|
long timeMillis =start+intervalTime; |
|
|
|
|
|
|
|
|
|
return longToDate(timeMillis); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 其实这是基于一个公式 如果要取一个范围在[min,max]之间的随机整数那么公式如下 |
|
|
|
|
* @param min |
|
|
|
|
* @param max |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private int randInt(int min,int max) |
|
|
|
|
{ |
|
|
|
|
Random rand = new Random(); |
|
|
|
|
// nextInt通常不包含顶部值,因此加上1使其包含
|
|
|
|
|
int randomNum = rand.nextInt((max - min) + 1) + min; |
|
|
|
|
return randomNum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将long转为日期
|
|
|
|
|
private Date longToDate(long lo) |
|
|
|
|
{ |
|
|
|
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
//long转Date
|
|
|
|
|
Date date = null; |
|
|
|
|
try { |
|
|
|
|
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(sd.format(new Date(lo))); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
return date; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//将日期转为long
|
|
|
|
|
private long dateToLong(Date s,Date e) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
long sl=s.getTime(); |
|
|
|
|
long el=e.getTime(); |
|
|
|
|
long r=el-sl; |
|
|
|
|
return (el-sl)/1000; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|