成品bug修改
parent
0e6a6286f6
commit
3262f842a3
@ -0,0 +1,24 @@
|
|||||||
|
package com.op.system.api;
|
||||||
|
|
||||||
|
import com.op.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.op.common.core.domain.R;
|
||||||
|
import com.op.system.api.factory.RemoteDeviceFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务
|
||||||
|
*
|
||||||
|
* @author OP
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteDeviceService", value = ServiceNameConstants.DEVICE_SERVICE, fallbackFactory = RemoteDeviceFallbackFactory.class)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public interface RemoteDeviceService {
|
||||||
|
|
||||||
|
@PostMapping("/deviceTask/createSpotCheckPlanTask")
|
||||||
|
public R createSpotCheckPlanTask();
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.op.system.api.factory;
|
||||||
|
|
||||||
|
|
||||||
|
import com.op.common.core.domain.R;
|
||||||
|
import com.op.system.api.RemoteDeviceService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务降级处理
|
||||||
|
*
|
||||||
|
* @author OP
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteDeviceFallbackFactory implements FallbackFactory<RemoteDeviceService> {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteDeviceFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteDeviceService create(Throwable throwable) {
|
||||||
|
log.error("Device服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteDeviceService() {
|
||||||
|
@Override
|
||||||
|
public R createSpotCheckPlanTask() {
|
||||||
|
return R.fail("点检计划创建失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.op.device.controller;
|
||||||
|
|
||||||
|
import com.op.common.core.domain.R;
|
||||||
|
import com.op.common.core.web.domain.AjaxResult;
|
||||||
|
import com.op.device.domain.EquOrder;
|
||||||
|
import com.op.device.domain.EquPlan;
|
||||||
|
import com.op.device.domain.EquRepairOrder;
|
||||||
|
import com.op.device.domain.EquRepairWorkOrder;
|
||||||
|
import com.op.device.service.IDevicePDAService;
|
||||||
|
import com.op.device.service.IDeviceTaskService;
|
||||||
|
import com.op.device.service.IEquRepairOrderService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DeviceTaskController
|
||||||
|
*
|
||||||
|
* @author wws
|
||||||
|
* @date 2023-10-23
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/deviceTask")
|
||||||
|
public class DeviceTaskController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IDeviceTaskService taskService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点检计划生成
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/createSpotCheckPlanTask")
|
||||||
|
public R createSpotCheckPlanTask() {
|
||||||
|
EquPlan equPlan = new EquPlan();
|
||||||
|
AjaxResult result = taskService.createSpotCheckPlanTask(equPlan);
|
||||||
|
if(result.isSuccess()){
|
||||||
|
return R.ok("点检计划生成成功");
|
||||||
|
}
|
||||||
|
return R.fail("点检计划生成失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.op.device.mapper;
|
||||||
|
|
||||||
|
import com.op.common.core.domain.BaseFileData;
|
||||||
|
import com.op.device.domain.EquFile;
|
||||||
|
import com.op.device.domain.EquOrder;
|
||||||
|
import com.op.device.domain.EquPlan;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件Mapper接口
|
||||||
|
*
|
||||||
|
* @author Open Platform
|
||||||
|
* @date 2023-07-10
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DeviceTaskMapper {
|
||||||
|
|
||||||
|
List<EquPlan> getPlans(EquPlan equPlan);
|
||||||
|
|
||||||
|
EquOrder getNewTaskOrder(EquOrder equOrder);
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.op.device.service;
|
||||||
|
|
||||||
|
import com.op.common.core.domain.R;
|
||||||
|
import com.op.common.core.web.domain.AjaxResult;
|
||||||
|
import com.op.device.domain.EquPlan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TaskService
|
||||||
|
*
|
||||||
|
* @author wws
|
||||||
|
* @date 2023-10-23
|
||||||
|
*/
|
||||||
|
public interface IDeviceTaskService {
|
||||||
|
|
||||||
|
AjaxResult createSpotCheckPlanTask(EquPlan equPlan);
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.op.device.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.op.common.core.web.domain.AjaxResult;
|
||||||
|
import com.op.common.security.utils.SecurityUtils;
|
||||||
|
import com.op.device.domain.*;
|
||||||
|
import com.op.device.mapper.*;
|
||||||
|
import com.op.device.service.IDeviceTaskService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.op.common.core.web.domain.AjaxResult.error;
|
||||||
|
import static com.op.common.core.web.domain.AjaxResult.success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TaskService实现类
|
||||||
|
*
|
||||||
|
* @author wws
|
||||||
|
* @date 2023-10-23
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DeviceTaskServiceImpl implements IDeviceTaskService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceTaskMapper deviceTaskMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EquOrderMapper equOrderMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据点检计划生成点检任务
|
||||||
|
* **/
|
||||||
|
@Override
|
||||||
|
@DS("#header.poolName")
|
||||||
|
public AjaxResult createSpotCheckPlanTask(EquPlan equPlan) {
|
||||||
|
/**equ_plan equ_plan_equ**/
|
||||||
|
equPlan.setPlanType("spotInspection");
|
||||||
|
List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);
|
||||||
|
for(EquPlan plan:plans){
|
||||||
|
if("day".equals(plan.getPlanLoopType())){
|
||||||
|
EquOrder order = new EquOrder();
|
||||||
|
order.setPlanType("spotInspection");
|
||||||
|
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(order);
|
||||||
|
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
|
||||||
|
//生成点检计划
|
||||||
|
this.createSpotCheckPlan(plan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int createSpotCheckPlan(EquPlan plan){
|
||||||
|
/**equ_order**/
|
||||||
|
EquOrder order = new EquOrder();
|
||||||
|
BeanUtils.copyProperties(plan,order);
|
||||||
|
equOrderMapper.insertEquOrder(order);
|
||||||
|
/**equ_order_detail**/
|
||||||
|
List<EquOrderDetail> details = new ArrayList<>();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.op.device.mapper.DeviceTaskMapper">
|
||||||
|
|
||||||
|
<select id="getPlans" resultType="com.op.device.domain.EquPlan">
|
||||||
|
select ep.plan_code planCode,
|
||||||
|
ep.plan_name planName,
|
||||||
|
ep.plan_loop planLoop,
|
||||||
|
ep.plan_loop_type planLoopType,
|
||||||
|
ep.plan_loop_start planLoopStart,
|
||||||
|
ep.plan_loop_end planLoopEnd,
|
||||||
|
ep.plan_restrict planRestrict,
|
||||||
|
ep.plan_type planType,
|
||||||
|
ep.plan_outsource planOutsource,
|
||||||
|
epe.equipment_code equipmentCode,
|
||||||
|
epe.equipment_name equipmentName
|
||||||
|
from equ_plan ep
|
||||||
|
left join equ_plan_equ epe on ep.plan_code = epe.plan_code
|
||||||
|
where ep.del_flag = '0' and epe.del_flag = '0' and ep.plan_status = '0'
|
||||||
|
and ep.plan_type = #{planType}
|
||||||
|
and CONVERT(varchar(10),GETDATE(), 120) >= CONVERT(varchar(10),ep.plan_loop_start, 120)
|
||||||
|
</select>
|
||||||
|
<select id="getNewTaskOrder" resultType="com.op.device.domain.EquOrder">
|
||||||
|
select top 1 order_code orderCode,
|
||||||
|
create_time createTime,
|
||||||
|
DATEDIFF (day, create_time, GETDATE()) days
|
||||||
|
from equ_order
|
||||||
|
where plan_type = #{planType}
|
||||||
|
order by create_time desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue