点/巡检、保养加小时逻辑

master
wws 1 year ago
parent 830afcd157
commit 4fa7fb9222

@ -31,6 +31,7 @@ public class DeviceTaskController {
*/ */
@PostMapping("/createSpotCheckPlanTask") @PostMapping("/createSpotCheckPlanTask")
public R createSpotCheckPlanTask() { public R createSpotCheckPlanTask() {
System.out.println("点检判断");
AjaxResult result = taskService.createSpotCheckPlanTask(); AjaxResult result = taskService.createSpotCheckPlanTask();
if(result.isSuccess()){ if(result.isSuccess()){
return R.ok("点检计划生成成功"); return R.ok("点检计划生成成功");
@ -57,6 +58,7 @@ public class DeviceTaskController {
*/ */
@PostMapping("/createMaintenancePlanTask") @PostMapping("/createMaintenancePlanTask")
public R createMaintenancePlanTask() { public R createMaintenancePlanTask() {
System.out.println("保养判断");
AjaxResult result = taskService.createMaintenancePlanTask(); AjaxResult result = taskService.createMaintenancePlanTask();
if(result.isSuccess()){ if(result.isSuccess()){
return R.ok("保养计划生成成功"); return R.ok("保养计划生成成功");

@ -102,33 +102,41 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
List<EquOrder> handleList = new ArrayList<>(); List<EquOrder> handleList = new ArrayList<>();
long nowTime = DateUtils.getNowDate().getTime(); long nowTime = DateUtils.getNowDate().getTime();
long dayMs = 86400000l; long dayMs = 86400000l;
long hourMs = 1000 * 60 * 60;
if (orderList != null) { if (orderList != null) {
for (EquOrder order : orderList) { for (EquOrder order : orderList) {
long diff = nowTime - order.getCreateTime().getTime(); long diff = nowTime - order.getCreateTime().getTime();
if (order.getPlanLoopType().equals("day")){ switch (order.getPlanLoopType()) {
if (diff < (dayMs * Long.valueOf(order.getPlanLoop()))) { case "hour":
if (diff < 1000 * 60 * 60 * Long.valueOf(order.getPlanLoop())) {
handleList.add(order); handleList.add(order);
} }
break;
case "day":
if (diff < (dayMs * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
} }
if (order.getPlanLoopType().equals("week")){ break;
case "week":
if (diff < (dayMs * 7 * Long.valueOf(order.getPlanLoop()))) { if (diff < (dayMs * 7 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order); handleList.add(order);
} }
} break;
if (order.getPlanLoopType().equals("month")){ case "month":
if (diff < (dayMs * 30 * Long.valueOf(order.getPlanLoop()))) { if (diff < (dayMs * 30 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order); handleList.add(order);
} }
} break;
if (order.getPlanLoopType().equals("season")){ case "season":
if (diff < (dayMs * 30 * 3 * Long.valueOf(order.getPlanLoop()))) { if (diff < (dayMs * 30 * 3 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order); handleList.add(order);
} }
} break;
if (order.getPlanLoopType().equals("year")){ case "year":
if (diff < (dayMs * 365 * Long.valueOf(order.getPlanLoop()))) { if (diff < (dayMs * 365 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order); handleList.add(order);
} }
break;
} }
} }
} }
@ -664,6 +672,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
/** /**
* *
*
* @param equipmentCode * @param equipmentCode
* @return * @return
*/ */
@ -992,6 +1001,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
/** /**
* *
*
* @param equipmentCode * @param equipmentCode
* @param operationType / * @param operationType /
* @param type / * @param type /

@ -180,6 +180,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
/** /**
* *
*
* @return * @return
*/ */
@Override @Override
@ -213,6 +214,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
/** /**
* *
*
* @return * @return
*/ */
@Override @Override
@ -253,7 +255,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
for (EquPlan plan : plans) { for (EquPlan plan : plans) {
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan); EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan);
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){ if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) {
//生成点检计划 //生成点检计划
int m = this.createOrderPlan(plan); int m = this.createOrderPlan(plan);
if (m == 0) { if (m == 0) {
@ -273,7 +275,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
for (EquPlan plan : plans) { for (EquPlan plan : plans) {
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan); EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan);
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){ if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) {
//生成巡检计划 //生成巡检计划
int m = this.createOrderPlan(plan); int m = this.createOrderPlan(plan);
if (m == 0) { if (m == 0) {
@ -303,7 +305,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
//单次生成保养计划 //单次生成保养计划
} }
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){ if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) {
//生成保养计划 //生成保养计划
int m = this.createOrderPlan(plan); int m = this.createOrderPlan(plan);
if (m == 0) { if (m == 0) {
@ -518,6 +520,21 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
} }
} }
// 循环类型为小时
private boolean checkHourTask(EquOrder order, EquPlan plan) {
if (order == null) {
return true;
}
Long loop = 1L;
Long diff = 0L;
if (plan.getPlanLoopType().equals("hour")) {
loop = Long.valueOf(plan.getPlanLoop()) * 60 * 60 * 1000;
diff = DateUtils.getNowDate().getTime() - order.getCreateTime().getTime();
}
return diff >= loop;
}
public static void main(String[] args) { public static void main(String[] args) {
int batchSize = 200;// 批次数量 int batchSize = 200;// 批次数量

@ -38,12 +38,12 @@
</select> </select>
<select id="getNewTaskOrder" resultType="com.op.device.domain.EquOrder"> <select id="getNewTaskOrder" resultType="com.op.device.domain.EquOrder">
select top 1 order_code orderCode, select top 1 order_code orderCode,
create_time createTime, create_time createTime
<if test='planLoopType=="day"'> DATEDIFF (day, create_time, GETDATE()) days </if> <if test="planLoopType=='day'">, DATEDIFF (day, create_time, GETDATE()) days </if>
<if test='planLoopType=="week"'> DATEDIFF (week, create_time, GETDATE()) days </if> <if test="planLoopType=='week'">, DATEDIFF (week, create_time, GETDATE()) days </if>
<if test='planLoopType=="month"'> DATEDIFF (month, create_time, GETDATE()) days </if> <if test="planLoopType=='month'">, DATEDIFF (month, create_time, GETDATE()) days </if>
<if test='planLoopType=="season"'> DATEDIFF (month, create_time, GETDATE())/3 days </if> <if test="planLoopType=='season'">, DATEDIFF (month, create_time, GETDATE())/3 days </if>
<if test='planLoopType=="year"'> DATEDIFF (year, create_time, GETDATE()) days </if> <if test="planLoopType=='year'">, DATEDIFF (year, create_time, GETDATE()) days </if>
from equ_order from equ_order
where plan_type = #{planType} and plan_code = #{planCode} and equipment_code = #{equipmentCode} where plan_type = #{planType} and plan_code = #{planCode} and equipment_code = #{equipmentCode}
order by create_time desc order by create_time desc

@ -177,7 +177,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spareInventoryFloor != null and spareInventoryFloor != ''"> and womsn.spare_inventory_floor = #{spareInventoryFloor}</if> <if test="spareInventoryFloor != null and spareInventoryFloor != ''"> and womsn.spare_inventory_floor = #{spareInventoryFloor}</if>
<if test="spareInventoryUpper != null and spareInventoryUpper != ''"> and womsn.spare_inventory_upper = #{spareInventoryUpper}</if> <if test="spareInventoryUpper != null and spareInventoryUpper != ''"> and womsn.spare_inventory_upper = #{spareInventoryUpper}</if>
<if test="spareType != null and spareType != ''"> and womsn.spare_type = #{spareType}</if> <if test="spareType != null and spareType != ''"> and womsn.spare_type = #{spareType}</if>
<if test="ownEquipmentName != null and ownEquipmentName != ''"> and womsna.own_equipment_name like concat('%', #{ownEquipmentName}, '%')</if> <if test="ownEquipmentName != null and ownEquipmentName != ''"> and womsna.own_equipment_name like concat('%', #{ownEquipmentName}, '%')</if>
and womsn.del_flag = '0' and womsn.del_flag = '0'
</where> </where>

Loading…
Cancel
Save