上位机设备报修接口

master
wws 1 year ago
parent 5ce0823a49
commit 14937d6441

@ -0,0 +1,461 @@
package com.op.system.api.domain.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import java.util.Date;
public class DeviceRepairOrder extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
private String orderId;
/** 报修单号 */
@Excel(name = "报修单号")
private String orderCode;
/** 设备编码 */
@Excel(name = "设备编码")
private String equipmentCode;
/** 故障描述 */
@Excel(name = "故障描述")
private String orderDesc;
/** 故障时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "故障时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date orderBreakdownTime;
/** 报修来源 */
@Excel(name = "报修来源")
private String orderSource;
/** 报修时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "报修时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
/** 是否立即处理 */
@Excel(name = "是否立即处理")
private String orderHandle;
/** 报修人编号 */
@Excel(name = "报修人编号")
private String orderRepairmanCode;
/** 报修人名字 */
@Excel(name = "报修人名字")
private String orderRepairmanName;
/** 联系方式 */
@Excel(name = "联系方式")
private String orderConnection;
/** 处理状态 */
@Excel(name = "处理状态")
private String orderStatus;
/** 关联计划 */
@Excel(name = "关联计划")
private String orderRelevance;
/** 故障图片 */
@Excel(name = "故障图片")
private String orderPicture;
/** 备用字段1 */
@Excel(name = "备用字段1")
private String attr1;
/** 备用字段2 */
@Excel(name = "备用字段2")
private String attr2;
/** 备用字段3 */
@Excel(name = "备用字段3")
private String attr3;
/** 删除标志 */
private String delFlag;
/** 工厂编码 */
@Excel(name = "工厂编码")
private String factoryCode;
//设备
/** 设备类型名称 */
@Excel(name = "设备类型名称")
private String equipmentTypeName;
/** 设备位置 */
@Excel(name = "设备位置")
private String equipmentLocation;
/** 部门 */
@Excel(name = "部门")
private String department;
/** 规格型号 */
@Excel(name = "规格型号")
private String equipmentSpec;
/** 设备名称 */
@Excel(name = "设备名称")
private String equipmentName;
/** 创建人 */
@Excel(name = "创建人")
private String createBy;
/** 报修后去向 */
@Excel(name = "报修去向")
private String repairDestination;
/** 计划维修时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "计划维修时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date workPlanTime;
/** 计划停机时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "计划停机时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date workPlanDownTime;
/** 是否停机维修 */
@Excel(name = "是否停机维修")
private String workDownMachine;
/** 维修人员 */
@Excel(name = "维修人员")
private String workPerson;
/** 维修组 */
@Excel(name = "维修组")
private String workTeam;
//委外
/** 主键 */
private String workId;
/** 委外工单编码 */
@Excel(name = "委外工单编码")
private String workCode;
/** 维修人员 */
@Excel(name = "委外维修人员")
private String outSourcePerson;
/** 委外单位 */
@Excel(name = "委外单位")
private String workOutsourcingUnit;
/** 联系方式 */
@Excel(name = "联系方式")
private String workConnection;
/** 原因 */
@Excel(name = "原因")
private String outSourceReason;
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getEquipmentCode() {
return equipmentCode;
}
public void setEquipmentCode(String equipmentCode) {
this.equipmentCode = equipmentCode;
}
public String getOrderDesc() {
return orderDesc;
}
public void setOrderDesc(String orderDesc) {
this.orderDesc = orderDesc;
}
public Date getOrderBreakdownTime() {
return orderBreakdownTime;
}
public void setOrderBreakdownTime(Date orderBreakdownTime) {
this.orderBreakdownTime = orderBreakdownTime;
}
public String getOrderSource() {
return orderSource;
}
public void setOrderSource(String orderSource) {
this.orderSource = orderSource;
}
public Date getOrderTime() {
return orderTime;
}
public void setOrderTime(Date orderTime) {
this.orderTime = orderTime;
}
public String getOrderHandle() {
return orderHandle;
}
public void setOrderHandle(String orderHandle) {
this.orderHandle = orderHandle;
}
public String getOrderRepairmanCode() {
return orderRepairmanCode;
}
public void setOrderRepairmanCode(String orderRepairmanCode) {
this.orderRepairmanCode = orderRepairmanCode;
}
public String getOrderRepairmanName() {
return orderRepairmanName;
}
public void setOrderRepairmanName(String orderRepairmanName) {
this.orderRepairmanName = orderRepairmanName;
}
public String getOrderConnection() {
return orderConnection;
}
public void setOrderConnection(String orderConnection) {
this.orderConnection = orderConnection;
}
public String getOrderStatus() {
return orderStatus;
}
public void setOrderStatus(String orderStatus) {
this.orderStatus = orderStatus;
}
public String getOrderRelevance() {
return orderRelevance;
}
public void setOrderRelevance(String orderRelevance) {
this.orderRelevance = orderRelevance;
}
public String getOrderPicture() {
return orderPicture;
}
public void setOrderPicture(String orderPicture) {
this.orderPicture = orderPicture;
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr3() {
return attr3;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getEquipmentTypeName() {
return equipmentTypeName;
}
public void setEquipmentTypeName(String equipmentTypeName) {
this.equipmentTypeName = equipmentTypeName;
}
public String getEquipmentLocation() {
return equipmentLocation;
}
public void setEquipmentLocation(String equipmentLocation) {
this.equipmentLocation = equipmentLocation;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getEquipmentSpec() {
return equipmentSpec;
}
public void setEquipmentSpec(String equipmentSpec) {
this.equipmentSpec = equipmentSpec;
}
public String getEquipmentName() {
return equipmentName;
}
public void setEquipmentName(String equipmentName) {
this.equipmentName = equipmentName;
}
@Override
public String getCreateBy() {
return createBy;
}
@Override
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getRepairDestination() {
return repairDestination;
}
public void setRepairDestination(String repairDestination) {
this.repairDestination = repairDestination;
}
public Date getWorkPlanTime() {
return workPlanTime;
}
public void setWorkPlanTime(Date workPlanTime) {
this.workPlanTime = workPlanTime;
}
public Date getWorkPlanDownTime() {
return workPlanDownTime;
}
public void setWorkPlanDownTime(Date workPlanDownTime) {
this.workPlanDownTime = workPlanDownTime;
}
public String getWorkDownMachine() {
return workDownMachine;
}
public void setWorkDownMachine(String workDownMachine) {
this.workDownMachine = workDownMachine;
}
public String getWorkPerson() {
return workPerson;
}
public void setWorkPerson(String workPerson) {
this.workPerson = workPerson;
}
public String getWorkTeam() {
return workTeam;
}
public void setWorkTeam(String workTeam) {
this.workTeam = workTeam;
}
public String getWorkId() {
return workId;
}
public void setWorkId(String workId) {
this.workId = workId;
}
public String getWorkCode() {
return workCode;
}
public void setWorkCode(String workCode) {
this.workCode = workCode;
}
public String getOutSourcePerson() {
return outSourcePerson;
}
public void setOutSourcePerson(String outSourcePerson) {
this.outSourcePerson = outSourcePerson;
}
public String getWorkOutsourcingUnit() {
return workOutsourcingUnit;
}
public void setWorkOutsourcingUnit(String workOutsourcingUnit) {
this.workOutsourcingUnit = workOutsourcingUnit;
}
public String getWorkConnection() {
return workConnection;
}
public void setWorkConnection(String workConnection) {
this.workConnection = workConnection;
}
public String getOutSourceReason() {
return outSourceReason;
}
public void setOutSourceReason(String outSourceReason) {
this.outSourceReason = outSourceReason;
}
}

@ -0,0 +1,55 @@
package com.op.system.api.domain.device;
// 上位机报修DTO
public class EquRepairOrderDTO {
// 设备编码
private String equipmentCode;
// 工厂数据源
private String factory;
// 用户账号
private String userName;
// 用户名称
private String userNickName;
// 联系方式
private String phoneNumber;
public String getUserNickName() {
return userNickName;
}
public void setUserNickName(String userNickName) {
this.userNickName = userNickName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getFactory() {
return factory;
}
public void setFactory(String factory) {
this.factory = factory;
}
public String getEquipmentCode() {
return equipmentCode;
}
public void setEquipmentCode(String equipmentCode) {
this.equipmentCode = equipmentCode;
}
}

@ -5,6 +5,7 @@ import com.op.common.core.utils.StringUtils;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.open.service.OpenService;
import com.op.system.api.domain.device.EquRepairOrderDTO;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
import org.springframework.beans.factory.annotation.Autowired;
@ -70,6 +71,15 @@ public class OpenController extends BaseController {
return success(openService.getLGInfo(wcsDTO));
}
/**
*
* @return
*/
@PostMapping("/machineRepair")
public AjaxResult machineRepair(@RequestBody EquRepairOrderDTO equRepairOrderDTO){
return openService.machineRepair(equRepairOrderDTO);
}
public static void main(String args[]){
System.out.println(DateUtils.getDate());
}

@ -1,6 +1,7 @@
package com.op.open.mapper;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.device.DeviceRepairOrder;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.mes.MesReportWorkConsumeDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
@ -46,5 +47,19 @@ public interface OpenMapper {
List<String> getSapWorkOrder(String workorderCode);
List<MesReportWorkConsumeDTO> selectMesReportWorkConsumeList(MesReportWorkConsumeDTO consumeqo);
/**
*
* @return
*/
int selectOrderCodeSerialNumber();
/**
*
*
* @param equRepairOrder
* @return
*/
public int insertEquRepairOrder(DeviceRepairOrder equRepairOrder);
}

@ -1,6 +1,8 @@
package com.op.open.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.system.api.domain.device.EquRepairOrderDTO;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
@ -19,4 +21,6 @@ public interface OpenService {
// R reportWork(MesReportWorkDTO mesReportWork);
List<WCSDTO> getLGInfo(WCSDTO wcsDTO);
AjaxResult machineRepair(EquRepairOrderDTO equRepairOrderDTO);
}

@ -3,14 +3,19 @@ package com.op.open.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.security.utils.SecurityUtils;
import com.op.open.mapper.OpenMapper;
import com.op.open.service.OpenService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.device.DeviceRepairOrder;
import com.op.system.api.domain.device.EquRepairOrderDTO;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.dto.WCSDataDTO;
import com.op.system.api.domain.mes.MesReportWorkConsumeDTO;
@ -25,7 +30,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@ -35,6 +43,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static com.op.common.core.web.domain.AjaxResult.success;
/**
* wcs
*
@ -240,6 +250,34 @@ public class OpenServiceImpl implements OpenService {
return openMapper.getLGInfo(wcsDTO);
}
@Override
public AjaxResult machineRepair(EquRepairOrderDTO equRepairOrderDTO) {
DynamicDataSourceContextHolder.push("ds_"+equRepairOrderDTO.getFactory());// 这是数据源的key
// 创建报修单
DeviceRepairOrder equRepairOrder = new DeviceRepairOrder();
// 获取故障报修流水号
String serialNum = String.format("%03d", openMapper.selectOrderCodeSerialNumber());
equRepairOrder.setOrderCode("BX"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+equRepairOrderDTO.getEquipmentCode()+serialNum);// 报修单号
equRepairOrder.setOrderId(IdUtils.fastSimpleUUID());// id
equRepairOrder.setEquipmentCode(equRepairOrderDTO.getEquipmentCode());
equRepairOrder.setOrderSource("上位机");// 故障来源
equRepairOrder.setOrderTime(DateUtils.getNowDate());// 报修时间
equRepairOrder.setOrderBreakdownTime(DateUtils.getNowDate());// 故障时间
equRepairOrder.setOrderRepairmanCode(equRepairOrderDTO.getUserName());// 用户账号
equRepairOrder.setOrderRepairmanName(equRepairOrderDTO.getUserNickName());// 用户名称
equRepairOrder.setCreateTime(DateUtils.getNowDate());
equRepairOrder.setCreateBy(equRepairOrderDTO.getUserName());
equRepairOrder.setOrderStatus("待审核");// 报修单状态
equRepairOrder.setFactoryCode(equRepairOrderDTO.getFactory());// 工厂
equRepairOrder.setOrderConnection(equRepairOrderDTO.getPhoneNumber());// 联系方式
openMapper.insertEquRepairOrder(equRepairOrder);
return success();
}
public static void main(String args[]){
DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate today = LocalDate.now();

@ -136,4 +136,67 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
workorder_code = #{workorderCode} and del_flag = '0'
</select>
<!--流水单号-->
<select id="selectOrderCodeSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(order_id)+1 AS serialNum
FROM equ_repair_order
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time)
</select>
<insert id="insertEquRepairOrder" parameterType="DeviceRepairOrder">
insert into equ_repair_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if>
<if test="orderCode != null">order_code,</if>
<if test="equipmentCode != null">equipment_code,</if>
<if test="orderDesc != null">order_desc,</if>
<if test="orderBreakdownTime != null">order_breakdown_time,</if>
<if test="orderSource != null">order_source,</if>
<if test="orderTime != null">order_time,</if>
<if test="orderHandle != null">order_handle,</if>
<if test="orderRepairmanCode != null">order_repairman_code,</if>
<if test="orderRepairmanName != null">order_repairman_name,</if>
<if test="orderConnection != null">order_connection,</if>
<if test="orderStatus != null">order_status,</if>
<if test="orderRelevance != null">order_relevance,</if>
<if test="orderPicture != null">order_picture,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="repairDestination != null">repair_destination,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
<if test="orderCode != null">#{orderCode},</if>
<if test="equipmentCode != null">#{equipmentCode},</if>
<if test="orderDesc != null">#{orderDesc},</if>
<if test="orderBreakdownTime != null">#{orderBreakdownTime},</if>
<if test="orderSource != null">#{orderSource},</if>
<if test="orderTime != null">#{orderTime},</if>
<if test="orderHandle != null">#{orderHandle},</if>
<if test="orderRepairmanCode != null">#{orderRepairmanCode},</if>
<if test="orderRepairmanName != null">#{orderRepairmanName},</if>
<if test="orderConnection != null">#{orderConnection},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="orderRelevance != null">#{orderRelevance},</if>
<if test="orderPicture != null">#{orderPicture},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="repairDestination != null">#{repairDestination},</if>
</trim>
</insert>
</mapper>

Loading…
Cancel
Save