更新运维工单的自动分派和自动处理
This commit is contained in:
parent
8e0901d848
commit
2dfca72bb7
@ -20,7 +20,7 @@ public class XhpcWorkOrderDomain implements Serializable {
|
||||
/**
|
||||
* 工单类型
|
||||
*/
|
||||
private Short type;
|
||||
private Integer type;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,11 @@ public interface XhpcWorkOrderMapper {
|
||||
|
||||
int updateByPrimaryKey(XhpcWorkOrderDomain record);
|
||||
|
||||
int updatePressOrderByPrimaryKey(XhpcWorkOrderDomain record);
|
||||
|
||||
int deleteOrderUserByOrderId(Long orderId);
|
||||
|
||||
int workOrderMessage(@Param("type")Integer type, @Param("time")String time);
|
||||
|
||||
List<XhpcWorkOrderDomain> selectByAutoRun();
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xhpc.activity.service.impl;
|
||||
|
||||
import com.xhpc.activity.service.WorkTypeService;
|
||||
import com.xhpc.common.api.SmsService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.exception.CustomException;
|
||||
@ -37,6 +38,8 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
||||
|
||||
@Resource
|
||||
WorkUserService workUserService;
|
||||
@Resource
|
||||
WorkTypeService typeService;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getOrderPage(Map<String,Object> params){
|
||||
@ -149,11 +152,22 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
||||
|
||||
@Override
|
||||
public Boolean updateOrder(XhpcWorkOrderDomain domain){
|
||||
if(domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L){
|
||||
return insertDomain(domain);
|
||||
} else {
|
||||
return updateDomain(domain);
|
||||
// 是否自动派送
|
||||
XhpcWorkTypeDictDomain typeDictDomain = typeService.getInfoByPk(domain.getType());
|
||||
if(typeDictDomain != null){
|
||||
if(typeDictDomain.getAutoSend() == 1 && domain.getUserList().isEmpty()){
|
||||
XhpcWorkUserDomain userDomain = new XhpcWorkUserDomain();
|
||||
userDomain.setWorkUserId(Long.parseLong(typeDictDomain.getUserId() + ""));
|
||||
domain.getUserList().add(userDomain);
|
||||
domain.setStatus(Short.valueOf("1"));
|
||||
}
|
||||
}
|
||||
if(domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L){
|
||||
insertDomain(domain);
|
||||
} else {
|
||||
updateDomain(domain);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -182,11 +196,22 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
||||
|
||||
@Override
|
||||
public Boolean insertOrder(XhpcWorkOrderDomain domain){
|
||||
if(domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L){
|
||||
return insertDomain(domain);
|
||||
} else {
|
||||
return updateDomain(domain);
|
||||
// 是否自动派送
|
||||
XhpcWorkTypeDictDomain typeDictDomain = typeService.getInfoByPk(domain.getType());
|
||||
if(typeDictDomain != null){
|
||||
if(typeDictDomain.getAutoSend() == 1 && domain.getUserList().isEmpty()){
|
||||
XhpcWorkUserDomain userDomain = new XhpcWorkUserDomain();
|
||||
userDomain.setWorkUserId(Long.parseLong(typeDictDomain.getUserId() + ""));
|
||||
domain.getUserList().add(userDomain);
|
||||
domain.setStatus(Short.valueOf("1"));
|
||||
}
|
||||
}
|
||||
if(domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L){
|
||||
insertDomain(domain);
|
||||
} else {
|
||||
updateDomain(domain);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -205,7 +230,7 @@ public class WorkOrderServiceImpl implements WorkOrderService {
|
||||
public Boolean addNewOrder(String type, String title, String content, Date faultTime, String reason) {
|
||||
try{
|
||||
XhpcWorkOrderDomain domain =new XhpcWorkOrderDomain();
|
||||
domain.setType(Short.parseShort(type));
|
||||
domain.setType(Integer.parseInt(type));
|
||||
domain.setTitle(title);
|
||||
domain.setContent(content);
|
||||
domain.setFaultTime(faultTime);
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
package com.xhpc.activity.task;
|
||||
|
||||
|
||||
import com.xhpc.activity.domain.XhpcWorkOrderDomain;
|
||||
import com.xhpc.activity.domain.XhpcWorkTypeDictDomain;
|
||||
import com.xhpc.activity.mapper.XhpcWorkOrderMapper;
|
||||
import com.xhpc.activity.mapper.XhpcWorkTypeDictMapper;
|
||||
import com.xhpc.common.api.PowerPileService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动处理工单
|
||||
*/
|
||||
@Component
|
||||
public class AutoProcessOrderTask {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AutoProcessOrderTask.class);
|
||||
@Resource
|
||||
XhpcWorkOrderMapper workOrderMapper;
|
||||
|
||||
@Resource
|
||||
XhpcWorkTypeDictMapper typeDictMapper;
|
||||
|
||||
@Resource
|
||||
PowerPileService powerPileService;
|
||||
|
||||
@Scheduled(fixedRate = 60000)
|
||||
protected void run() {
|
||||
|
||||
List<XhpcWorkOrderDomain> orderList = workOrderMapper.selectByAutoRun();
|
||||
for (XhpcWorkOrderDomain orderDomain : orderList) {
|
||||
String pileNo = orderDomain.getSerialNumber();
|
||||
if (StringUtils.isEmpty(pileNo) || pileNo.length() < 14) continue;
|
||||
pileNo = pileNo.substring(0, 14);
|
||||
|
||||
XhpcWorkTypeDictDomain typeDictDomain = typeDictMapper.selectByPrimaryKey(orderDomain.getType());
|
||||
String processStr = "";
|
||||
R r = null;
|
||||
switch (typeDictDomain.getMeasure()) {
|
||||
case 1: // 自动升级
|
||||
r = powerPileService.pileSoftwareUpgrade(pileNo);
|
||||
processStr = "自动升级指令";
|
||||
break;
|
||||
case 2: // 校时校价
|
||||
case 4: // 下发新费率
|
||||
r = powerPileService.configTimeNRateModel(pileNo);
|
||||
processStr = "自动下发校时校价指令";
|
||||
break;
|
||||
case 3: // 重启
|
||||
r = powerPileService.pileReboot(pileNo);
|
||||
processStr = "自动下发重启指令";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (r != null && r.getCode() == 200) {
|
||||
orderDomain.setStatus(Short.parseShort("2"));
|
||||
orderDomain.setDisposalMethod("运维系统执行自动处理措施:" + processStr);
|
||||
workOrderMapper.updatePressOrderByPrimaryKey(orderDomain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
<mapper namespace="com.xhpc.activity.mapper.XhpcWorkOrderMapper">
|
||||
<resultMap id="BaseResultMap" type="com.xhpc.activity.domain.XhpcWorkOrderDomain">
|
||||
<id column="work_order_id" jdbcType="BIGINT" property="workOrderId" />
|
||||
<result column="type" jdbcType="SMALLINT" property="type" />
|
||||
<result column="type" property="type" />
|
||||
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||
<result column="content" jdbcType="VARCHAR" property="content" />
|
||||
<result column="fault_time" jdbcType="TIMESTAMP" property="faultTime" />
|
||||
@ -283,4 +283,24 @@
|
||||
select count(work_order_id) from xhpc_work_order where type=#{type} and create_time like concat('%', #{time}, '%') and status !=2
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectByAutoRun" resultType="com.xhpc.activity.domain.XhpcWorkOrderDomain">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from xhpc_work_order o
|
||||
inner join xhpc_work_type_dict d on o.type=d.work_type_id
|
||||
where o.del_flag=0 and o.status=1 and d.auto_run=1
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updatePressOrderByPrimaryKey" parameterType="com.xhpc.activity.domain.XhpcWorkOrderDomain">
|
||||
update xhpc_work_order
|
||||
set reason = #{reason,jdbcType=VARCHAR},
|
||||
disposal_method = #{disposalMethod,jdbcType=VARCHAR},
|
||||
`status` = #{status,jdbcType=SMALLINT},
|
||||
update_time = sysdate(),
|
||||
update_by = #{updateBy,jdbcType=VARCHAR},
|
||||
remark=#{remark}
|
||||
where work_order_id = #{workOrderId,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user