|
|
@ -3,11 +3,16 @@ package org.jeecg.modules.hangerlocation.service.impl; |
|
|
|
import org.jeecg.modules.hangerlocation.entity.HangerLocation; |
|
|
|
import org.jeecg.modules.hangerlocation.entity.HangerLocation; |
|
|
|
import org.jeecg.modules.hangerlocation.mapper.HangerLocationMapper; |
|
|
|
import org.jeecg.modules.hangerlocation.mapper.HangerLocationMapper; |
|
|
|
import org.jeecg.modules.hangerlocation.service.IHangerLocationService; |
|
|
|
import org.jeecg.modules.hangerlocation.service.IHangerLocationService; |
|
|
|
|
|
|
|
import org.jeecg.modules.productplan.entity.ZyPlanProcess; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description: 衣架定位表 |
|
|
|
* @Description: 衣架定位表 |
|
|
|
* @Author: jeecg-boot |
|
|
|
* @Author: jeecg-boot |
|
|
@ -23,4 +28,140 @@ public class HangerLocationServiceImpl extends ServiceImpl<HangerLocationMapper, |
|
|
|
public HangerLocation queryByNew() { |
|
|
|
public HangerLocation queryByNew() { |
|
|
|
return hangerLocationMapper.queryByNew(); |
|
|
|
return hangerLocationMapper.queryByNew(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 自动化生产传感器记录 |
|
|
|
|
|
|
|
* @param list |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void recordAuto(List<Map<String, List<ZyPlanProcess>>> list) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//绑定
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历list
|
|
|
|
|
|
|
|
for(Map<String, List<ZyPlanProcess>> item :list) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//遍历map
|
|
|
|
|
|
|
|
for(Map.Entry<String, List<ZyPlanProcess>> entry : item.entrySet()){ |
|
|
|
|
|
|
|
//遍历List<ZyPlanProcess>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//服装进入制作工艺过程
|
|
|
|
|
|
|
|
long timeMillis = System.currentTimeMillis(); |
|
|
|
|
|
|
|
//将获取时间转为日期类型
|
|
|
|
|
|
|
|
Date start_time=longToDate(timeMillis); |
|
|
|
|
|
|
|
for(ZyPlanProcess process:entry.getValue()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
HangerLocation model=new HangerLocation(); |
|
|
|
|
|
|
|
/**衣架编码*/ |
|
|
|
|
|
|
|
String HangerCode="00087896"+randInt(10,99); |
|
|
|
|
|
|
|
model.setHangerCode(HangerCode); |
|
|
|
|
|
|
|
/**工位ID*/ |
|
|
|
|
|
|
|
model.setStationId(""); |
|
|
|
|
|
|
|
/**工位编码*/ |
|
|
|
|
|
|
|
model.setStationCode(randInt(2,32)+""); |
|
|
|
|
|
|
|
/**设备ID*/ |
|
|
|
|
|
|
|
model.setEquipmentId("1459695008524345346"); |
|
|
|
|
|
|
|
/**设备名称*/ |
|
|
|
|
|
|
|
model.setEquipmentName("20211114"); |
|
|
|
|
|
|
|
/**工序ID*/ |
|
|
|
|
|
|
|
model.setProcedureId(process.getProcessId()); |
|
|
|
|
|
|
|
/**工序名称*/ |
|
|
|
|
|
|
|
model.setProcedureName(process.getProcessName()); |
|
|
|
|
|
|
|
/**工人ID*/ |
|
|
|
|
|
|
|
model.setWorkerId("20191923"); |
|
|
|
|
|
|
|
/**工人名称*/ |
|
|
|
|
|
|
|
model.setWorkerName("曾磊"); |
|
|
|
|
|
|
|
/**到达时间*/ |
|
|
|
|
|
|
|
model.setArrivalTime(start_time); |
|
|
|
|
|
|
|
/**离开时间*/ |
|
|
|
|
|
|
|
Date end_time=returnEXtime(start_time); |
|
|
|
|
|
|
|
model.setLeaveTime(end_time); |
|
|
|
|
|
|
|
/**时长*/ |
|
|
|
|
|
|
|
model.setDuration(dateToLong(start_time,end_time)+""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//执行下一步间隔时间
|
|
|
|
|
|
|
|
start_time=returnIntervaltime(end_time); |
|
|
|
|
|
|
|
hangerLocationMapper.insert(model); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// System.out.println(entry.getKey());
|
|
|
|
|
|
|
|
// System.out.println(entry.getValue());
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取制作时间 |
|
|
|
|
|
|
|
* @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; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|