增加工单接口及实现

This commit is contained in:
panshuling321 2022-01-11 18:11:20 +08:00
parent fc3674d23d
commit 36b33bb252
20 changed files with 658 additions and 15 deletions

View File

@ -37,6 +37,10 @@ public class AliyunTemplate {
* 退款失败 * 退款失败
*/ */
public static final String REFUND_FAIL = "SMS_231445428"; public static final String REFUND_FAIL = "SMS_231445428";
/**
* 工单派发通知
*/
public static final String WORK_ORDER_CREATED = "SMS_232163808";
/** /**
* 更新计费模型失败 * 更新计费模型失败

View File

@ -40,4 +40,8 @@ public class AliyunTemplateKeyWord {
*/ */
public static final String CHARGING_MODEL = "计费--尊敬的用户"; public static final String CHARGING_MODEL = "计费--尊敬的用户";
/**
* 工单派送
*/
public static final String WORK_ORDER_CREATED = "新的工单待处理";
} }

View File

@ -94,6 +94,9 @@ public class XhpcSmsController extends BaseController {
}else if (content.contains(AliyunTemplateKeyWord.CHARGING_MODEL)) { }else if (content.contains(AliyunTemplateKeyWord.CHARGING_MODEL)) {
signatureName = AliyunTemplate.SIGNATURE_NAME; signatureName = AliyunTemplate.SIGNATURE_NAME;
templateId = AliyunTemplate.CHARGING_MODEL; templateId = AliyunTemplate.CHARGING_MODEL;
} else if(content.contains(AliyunTemplateKeyWord.WORK_ORDER_CREATED)){
signatureName = AliyunTemplate.SIGNATURE_NAME;
templateId = AliyunTemplate.WORK_ORDER_CREATED;
} }
xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap); xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap);

View File

@ -0,0 +1,18 @@
package com.xhpc.workorder.api;
import com.xhpc.common.api.factory.SmsFallbackFactory;
import com.xhpc.common.core.constant.ServiceNameConstants;
import com.xhpc.common.core.domain.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
@FeignClient(contextId = "smsService", value = ServiceNameConstants.XHPC_GENERAL, fallbackFactory = SmsFallbackFactory.class)
public interface SmsService {
@PostMapping("/sms/send")
R sendNotice(@RequestBody Map<String, String> paramMap);
}

View File

@ -2,18 +2,58 @@ package com.xhpc.workorder.controller;
import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.workorder.domain.XhpcWorkOrderDomain;
import com.xhpc.workorder.service.WorkOrderService; import com.xhpc.workorder.service.WorkOrderService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@RestController @RestController
@RequestMapping("/workorder") @RequestMapping("/workorder/order")
public class WorkOrderController extends BaseController { public class WorkOrderController extends BaseController {
@Resource @Resource
WorkOrderService workOrderService; WorkOrderService workOrderService;
@GetMapping("/getPage")
public TableDataInfo getOrderPage(Integer orderType,
String userName){
startPage();
Map<String, Object> params = new HashMap<>();
params.put("orderType", orderType);
params.put("userName", userName);
return getDataTable(workOrderService.getOrderPage(params));
}
@PostMapping("/")
public AjaxResult insertNewOrder(@RequestBody XhpcWorkOrderDomain domain){
return AjaxResult.success(workOrderService.insertOrder(domain));
}
@GetMapping("/{orderId}")
public AjaxResult getOrderInfo(@PathVariable("orderId")Long orderId){
return AjaxResult.success(workOrderService.selectOrderById(orderId));
}
@PutMapping("/{orderId}")
public AjaxResult updateOrderInfo(@RequestBody XhpcWorkOrderDomain domain){
return AjaxResult.success(workOrderService.updateOrder(domain));
}
@DeleteMapping("/{orderId}")
public AjaxResult deleteOrder(@PathVariable("orderId")Long orderId) throws Exception {
return AjaxResult.success(workOrderService.deleteOrder(orderId));
}
} }

View File

@ -0,0 +1,86 @@
package com.xhpc.workorder.controller;
import com.xhpc.common.core.utils.poi.ExcelUtil;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import com.xhpc.workorder.service.WorkStationService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/workorder/station")
public class WorkStationController extends BaseController {
@Resource
WorkStationService stationService;
@GetMapping("/getPage")
public TableDataInfo getPage(String stationName,
String terminalName){
startPage();
Map<String, Object> params = new HashMap<>();
params.put("stationName", stationName);
params.put("terminalName", terminalName);
return getDataTable(stationService.getStationDevice(params));
}
@GetMapping("/getTree")
public TableDataInfo getTree(String stationName,
String terminalName){
startPage();
Map<String, Object> params = new HashMap<>();
params.put("stationName", stationName);
params.put("terminalName", terminalName);
return getDataTable(stationService.getStationDeviceTree(params));
}
@Log(title = "导入设备", businessType = BusinessType.INSERT)
@PostMapping("/importData")
public AjaxResult importDevice(MultipartFile file, boolean updateSupport) throws Exception {
if(file == null){
return AjaxResult.error("没有可导入的数据文件");
}
ExcelUtil<XhpcStationDeviceDomain> util = new ExcelUtil<XhpcStationDeviceDomain>(XhpcStationDeviceDomain.class);
List<XhpcStationDeviceDomain> deviceDomainList = util.importExcel(file.getInputStream());
String message = stationService.importDevice(deviceDomainList, updateSupport);
return AjaxResult.success(message);
}
@PostMapping("/")
public AjaxResult insertNewDevice(@RequestBody XhpcStationDeviceDomain domain) throws Exception{
return AjaxResult.success(stationService.insertDevice(domain));
}
@PutMapping("/{deviceId}")
public AjaxResult updateDeviceInfo(@RequestBody XhpcStationDeviceDomain domain,
@PathVariable("deviceId")Long deviceId){
domain.setDeviceId(deviceId);
return AjaxResult.success(stationService.updateDevice(domain));
}
@DeleteMapping("/{deviceId}")
public AjaxResult deleteDeviceInfo(@PathVariable("deviceId") Long deviceId) throws Exception {
return AjaxResult.success(stationService.deleteDevice(deviceId));
}
}

View File

@ -2,6 +2,8 @@ package com.xhpc.workorder.domain;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import com.xhpc.common.core.annotation.Excel;
import lombok.Data; import lombok.Data;
/** /**
@ -13,36 +15,64 @@ public class XhpcStationDeviceDomain implements Serializable {
/** /**
* 设备ID * 设备ID
*/ */
private Integer deviceId; private Long deviceId;
/** /**
* 设备名称 * 设备名称
*/ */
@Excel(name = "名称")
private String deviceName; private String deviceName;
/** /**
* 设备类型 * 设备类型
*/ */
@Excel(name = "设备类型")
private String deviceType; private String deviceType;
/**
* 电流类型直流交流
*/
@Excel(name = "电桩类型")
private String currentType;
/** /**
* 所属场站 * 所属场站
*/ */
private Long stationId; private Long stationId;
/**
* 场站名称
*/
@Excel(name = "场站名称")
private String stationName;
/**
*
*/
@Excel(name = "规格型号")
private String brandModel;
/** /**
* 上级设备ID * 上级设备ID
*/ */
private Long parentDeviceId; private Long parentDeviceId;
/**
* 上级设备编码
*/
@Excel(name = "父级设备编码")
private String parentSerialNumber;
/** /**
* 设备编码 * 设备编码
*/ */
@Excel(name = "设备编码")
private String serialNumber; private String serialNumber;
/** /**
* 设备状态0-未启用1-正常2-异常3-维修中4-待检测 * 设备状态0-未启用1-正常2-异常3-维修中4-待检测
*/ */
@Excel(name = "状态")
private Short status; private Short status;
/** /**

View File

@ -2,6 +2,8 @@ package com.xhpc.workorder.domain;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import com.xhpc.common.core.annotation.Excel;
import lombok.Data; import lombok.Data;
/** /**
@ -30,6 +32,11 @@ public class XhpcWorkOrderDomain implements Serializable {
*/ */
private String content; private String content;
/**
* 故障时间
*/
private Date faultTime;
/** /**
* 设备类型 * 设备类型
*/ */
@ -95,5 +102,11 @@ public class XhpcWorkOrderDomain implements Serializable {
*/ */
private String updateBy; private String updateBy;
private String userName;
private String userPhone;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -1,17 +1,33 @@
package com.xhpc.workorder.mapper; package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain; import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface XhpcStationDeviceMapper { public interface XhpcStationDeviceMapper {
int deleteByPrimaryKey(Integer deviceId);
List<Map<String, Object>> selectStationGunDeviceListByParams(@Param("params") Map params);
List<Map<String, Object>> selectStationGunDeviceTreeByParams(@Param("params") Map params);
List<Map<String, Object>> selectStationGunDeviceTreeByParent(@Param("parentDeviceId") String parentDeviceId);
XhpcStationDeviceDomain selectStationGunDeviceBySerialNumber(@Param("serialNumber") String serialNumber);
int deleteByPrimaryKey(Long deviceId);
int insert(XhpcStationDeviceDomain record); int insert(XhpcStationDeviceDomain record);
int insertSelective(XhpcStationDeviceDomain record); int insertSelective(XhpcStationDeviceDomain record);
XhpcStationDeviceDomain selectByPrimaryKey(Integer deviceId); XhpcStationDeviceDomain selectByPrimaryKey(Long deviceId);
int updateByPrimaryKeySelective(XhpcStationDeviceDomain record); int updateByPrimaryKeySelective(XhpcStationDeviceDomain record);
int updateByPrimaryKey(XhpcStationDeviceDomain record); int updateByPrimaryKey(XhpcStationDeviceDomain record);
} }

View File

@ -1,8 +1,21 @@
package com.xhpc.workorder.mapper; package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkOrderDomain; import com.xhpc.workorder.domain.XhpcWorkOrderDomain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface XhpcWorkOrderMapper { public interface XhpcWorkOrderMapper {
List<Map<String, Object>> findOrderListByParams(@Param("params") Map params);
XhpcWorkOrderDomain selectByTypeAndTitleAndDeviceSerialNumber(@Param("type")Integer type,
@Param("title")String title,
@Param("serialNumber")String serialNumber,
@Param("userId")Long userId,
@Param("status") Integer status);
int deleteByPrimaryKey(Long workOrderId); int deleteByPrimaryKey(Long workOrderId);
int insert(XhpcWorkOrderDomain record); int insert(XhpcWorkOrderDomain record);

View File

@ -1,8 +1,12 @@
package com.xhpc.workorder.mapper; package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkStationDomain; import com.xhpc.workorder.domain.XhpcWorkStationDomain;
import org.apache.ibatis.annotations.Param;
public interface XhpcWorkStationMapper { public interface XhpcWorkStationMapper {
XhpcWorkStationDomain selectByName(@Param("stationName") String stationName);
int deleteByPrimaryKey(Long workStationId); int deleteByPrimaryKey(Long workStationId);
int insert(XhpcWorkStationDomain record); int insert(XhpcWorkStationDomain record);

View File

@ -1,8 +1,12 @@
package com.xhpc.workorder.mapper; package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkUserDomain; import com.xhpc.workorder.domain.XhpcWorkUserDomain;
import org.apache.ibatis.annotations.Param;
public interface XhpcWorkUserMapper { public interface XhpcWorkUserMapper {
XhpcWorkUserDomain selectByUserNameAndPhone(@Param("userName")String userName, @Param("phone") String phone);
int deleteByPrimaryKey(Long workUserId); int deleteByPrimaryKey(Long workUserId);
int insert(XhpcWorkUserDomain record); int insert(XhpcWorkUserDomain record);

View File

@ -1,6 +1,20 @@
package com.xhpc.workorder.service; package com.xhpc.workorder.service;
import com.xhpc.workorder.domain.XhpcWorkOrderDomain;
import java.util.List;
import java.util.Map;
public interface WorkOrderService { public interface WorkOrderService {
List<Map<String, Object>> getOrderPage(Map<String,Object> params);
XhpcWorkOrderDomain selectOrderById(Long orderId);
Boolean updateOrder(XhpcWorkOrderDomain domain);
Boolean insertOrder(XhpcWorkOrderDomain domain);
Boolean deleteOrder(Long orderId) throws Exception;
} }

View File

@ -0,0 +1,23 @@
package com.xhpc.workorder.service;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import java.util.List;
import java.util.Map;
public interface WorkStationService {
List<Map<String, Object>> getStationDevice(Map<String, Object> params);
List<Map<String, Object>> getStationDeviceTree(Map<String, Object> params);
String importDevice(List<XhpcStationDeviceDomain> deviceDomainList, Boolean updateSupport);
Boolean insertDevice(XhpcStationDeviceDomain domain) throws Exception;
Boolean updateDevice(XhpcStationDeviceDomain domain);
Boolean deleteDevice(Long deviceId) throws Exception;
}

View File

@ -1,13 +1,96 @@
package com.xhpc.workorder.service.impl; package com.xhpc.workorder.service.impl;
import cn.hutool.core.util.StrUtil;
import com.xhpc.common.api.SmsService;
import com.xhpc.workorder.domain.XhpcWorkOrderDomain;
import com.xhpc.workorder.domain.XhpcWorkOrderPushMessageDomain;
import com.xhpc.workorder.domain.XhpcWorkUserDomain;
import com.xhpc.workorder.mapper.XhpcWorkOrderMapper;
import com.xhpc.workorder.mapper.XhpcWorkOrderPushMessageMapper;
import com.xhpc.workorder.mapper.XhpcWorkUserMapper;
import com.xhpc.workorder.service.WorkOrderService; import com.xhpc.workorder.service.WorkOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service @Service
public class WorkOrderServiceImpl implements WorkOrderService { public class WorkOrderServiceImpl implements WorkOrderService {
@Resource
XhpcWorkOrderMapper orderMapper;
@Resource
XhpcWorkUserMapper userMapper;
@Resource
XhpcWorkOrderPushMessageMapper messageMapper;
@Resource
SmsService smsService;
@Override
public List<Map<String, Object>> getOrderPage(Map<String,Object> params){
return orderMapper.findOrderListByParams(params);
}
@Override
public XhpcWorkOrderDomain selectOrderById(Long orderId){
return orderMapper.selectByPrimaryKey(orderId);
}
@Override
public Boolean updateOrder(XhpcWorkOrderDomain domain){
return orderMapper.updateByPrimaryKeySelective(domain) > 0;
}
@Override
public Boolean insertOrder(XhpcWorkOrderDomain domain){
if(!StrUtil.hasBlank(domain.getUserName()) && !StrUtil.hasBlank(domain.getUserPhone())){
XhpcWorkUserDomain userDomain = userMapper.selectByUserNameAndPhone(domain.getUserName(), domain.getUserPhone());
if(userDomain == null){
domain.setUserId(userDomain.getWorkUserId());
domain.setDeptId(userDomain.getDeptId());
} else {
// todo
}
}
orderMapper.insertSelective(domain);
XhpcWorkOrderDomain resDomain = orderMapper.selectByTypeAndTitleAndDeviceSerialNumber(domain.getType().intValue(),
domain.getTitle(),
domain.getSerialNumber(),
domain.getUserId(),
domain.getStatus().intValue());
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("orderNo", resDomain.getWorkOrderId().toString());
paramMap.put("phone", domain.getUserPhone());
paramMap.put("content", "【小华充电】您好,您有新的工单(工单号:"+ resDomain.getWorkOrderId() +")待处理,请及时登陆后台查看并处理,谢谢。");
smsService.sendNotice(paramMap);
XhpcWorkOrderPushMessageDomain messageDomain = new XhpcWorkOrderPushMessageDomain();
messageDomain.setContent(paramMap.get("content"));
messageDomain.setTarget(domain.getUserName());
messageDomain.setType(Short.valueOf("1"));
messageDomain.setStatus(Short.valueOf("1"));
messageDomain.setFailMsg("发送成功");
messageMapper.insertSelective(messageDomain);
return true;
}
@Override
public Boolean deleteOrder(Long orderId) throws Exception {
XhpcWorkOrderDomain domain = orderMapper.selectByPrimaryKey(orderId);
if(domain == null){
throw new Exception("工单不存在");
}
orderMapper.deleteByPrimaryKey(orderId);
return true;
}
} }

View File

@ -0,0 +1,124 @@
package com.xhpc.workorder.service.impl;
import cn.hutool.core.util.StrUtil;
import com.xhpc.common.core.exception.CustomException;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import com.xhpc.workorder.domain.XhpcWorkStationDomain;
import com.xhpc.workorder.mapper.XhpcStationDeviceMapper;
import com.xhpc.workorder.mapper.XhpcWorkStationMapper;
import com.xhpc.workorder.service.WorkStationService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
public class WorkStationServiceImpl implements WorkStationService {
@Resource
XhpcStationDeviceMapper deviceMapper;
@Resource
XhpcWorkStationMapper stationMapper;
@Override
public List<Map<String, Object>> getStationDevice(Map<String, Object> params){
return deviceMapper.selectStationGunDeviceListByParams(params);
}
@Override
public List<Map<String, Object>> getStationDeviceTree(Map<String, Object> params){
List<Map<String, Object>> resultData = deviceMapper.selectStationGunDeviceTreeByParams(params);
for (Map<String, Object> resultMap: resultData){
List<Map<String, Object>> childData = deviceMapper.selectStationGunDeviceTreeByParent(resultMap.get("deviceId").toString());
if(childData != null){
resultMap.put("children", childData);
}
}
return resultData;
}
@Override
public String importDevice(List<XhpcStationDeviceDomain> deviceDomainList, Boolean updateSupport){
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (XhpcStationDeviceDomain domain: deviceDomainList){
if ("".equals(domain.getStationName())){
failureNum ++;
failureMsg.append("<br/>电站名称: ").append(domain.getStationName()).append(" ,设备编码: ").append(domain.getSerialNumber()).append(" 导入失败; 失败原因: 必填字段为空。");
continue;
}
XhpcWorkStationDomain stationDomain = stationMapper.selectByName(domain.getStationName());
if (stationDomain == null){
failureNum ++;
failureMsg.append("<br/>电站名称: ").append(domain.getStationName()).append(" ,设备编码: ").append(domain.getSerialNumber()).append(" 导入失败; 失败原因: 必填字段为空。");
continue;
} else {
domain.setDeviceId(stationDomain.getWorkStationId());
}
if(!StrUtil.hasBlank(domain.getParentSerialNumber())){
XhpcStationDeviceDomain parentDomain = deviceMapper.selectStationGunDeviceBySerialNumber(domain.getParentSerialNumber());
if(parentDomain != null){
domain.setParentDeviceId(parentDomain.getDeviceId());
}
}
deviceMapper.insertSelective(domain);
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new CustomException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
@Override
public Boolean insertDevice(XhpcStationDeviceDomain domain) throws Exception{
if ("".equals(domain.getStationName())){
throw new Exception("所属场站不能为空");
}
XhpcWorkStationDomain stationDomain = stationMapper.selectByName(domain.getStationName());
if (stationDomain == null){
throw new Exception("所属场站不存在");
} else {
domain.setDeviceId(stationDomain.getWorkStationId());
}
if(!StrUtil.hasBlank(domain.getParentSerialNumber())){
XhpcStationDeviceDomain parentDomain = deviceMapper.selectStationGunDeviceBySerialNumber(domain.getParentSerialNumber());
if(parentDomain != null){
domain.setParentDeviceId(parentDomain.getDeviceId());
}
}
deviceMapper.insertSelective(domain);
return true;
}
@Override
public Boolean updateDevice(XhpcStationDeviceDomain domain){
deviceMapper.updateByPrimaryKeySelective(domain);
return true;
}
@Override
public Boolean deleteDevice(Long deviceId) throws Exception {
XhpcStationDeviceDomain deviceDomain = deviceMapper.selectByPrimaryKey(deviceId);
if(deviceDomain != null){
throw new Exception("设备不存在");
}
deviceMapper.deleteByPrimaryKey(deviceId);
return true;
}
}

View File

@ -2,11 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.workorder.mapper.XhpcStationDeviceMapper"> <mapper namespace="com.xhpc.workorder.mapper.XhpcStationDeviceMapper">
<resultMap id="BaseResultMap" type="com.xhpc.workorder.domain.XhpcStationDeviceDomain"> <resultMap id="BaseResultMap" type="com.xhpc.workorder.domain.XhpcStationDeviceDomain">
<id column="device_id" jdbcType="INTEGER" property="deviceId" /> <id column="device_id" jdbcType="BIGINT" property="deviceId" />
<result column="device_name" jdbcType="VARCHAR" property="deviceName" /> <result column="device_name" jdbcType="VARCHAR" property="deviceName" />
<result column="device_type" jdbcType="VARCHAR" property="deviceType" /> <result column="device_type" jdbcType="VARCHAR" property="deviceType" />
<result column="current_type" jdbcType="VARCHAR" property="currentType" />
<result column="station_id" jdbcType="BIGINT" property="stationId" /> <result column="station_id" jdbcType="BIGINT" property="stationId" />
<result column="parent_device_id" jdbcType="BIGINT" property="parentDeviceId" /> <result column="parent_device_id" jdbcType="BIGINT" property="parentDeviceId" />
<result column="brand_model" jdbcType="VARCHAR" property="brandModel" />
<result column="serial_number" jdbcType="VARCHAR" property="serialNumber" /> <result column="serial_number" jdbcType="VARCHAR" property="serialNumber" />
<result column="status" jdbcType="SMALLINT" property="status" /> <result column="status" jdbcType="SMALLINT" property="status" />
<result column="del_flag" jdbcType="SMALLINT" property="delFlag" /> <result column="del_flag" jdbcType="SMALLINT" property="delFlag" />
@ -16,9 +18,84 @@
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
device_id, device_name, device_type, station_id, parent_device_id, serial_number, device_id, device_name, device_type, current_type, station_id, brand_model, parent_device_id, serial_number,
`status`, del_flag, create_time, create_by, update_time, update_by `status`, del_flag, create_time, create_by, update_time, update_by
</sql> </sql>
<select id="selectStationGunDeviceBySerialNumber" resultType="com.xhpc.workorder.domain.XhpcStationDeviceDomain">
select
<include refid="Base_Column_List" />
from xhpc_station_device
where device_id = #{deviceId,jdbcType=INTEGER}
</select>
<select id="selectStationGunDeviceListByParams" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'pileId',
d1.device_name as 'pileName',
d1.serial_number as 'pileSerialNumber',
d1.brand_model as 'pileBrandModel',
d1.current_type as 'pileCurrentType',
d2.device_id as 'gunId',
d2.device_name as 'gunName',
d2.serial_number as 'gunSerialNumber',
d2.brand_model as 'gunBrandModel',
d2.current_type as 'gunCurrentType'
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
LEFT JOIN xhpc_station_device d2 on d2.parent_device_id=d1.device_id
WHERE s.del_flag=0 and d1.del_flag=0 and d1.device_type='PILE'
<if test="params.stationName!=null and params.stationName !+ ''">
and s.name like concat('%', #{params.stationName}, '%')
</if>
<if test="params.terminalName!=null and params.terminalName!=''">
and d1.device_name like concat('%', #{params.terminalName},'%')
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and s.tenant_id=#{params.tenantId}
</if>
</select>
<select id="selectStationGunDeviceTreeByParams" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
WHERE s.del_flag=0 and d1.del_flag=0
<if test="params.stationName!=null and params.stationName !+ ''">
and s.name like concat('%', #{params.stationName}, '%')
</if>
<if test="params.terminalName!=null and params.terminalName!=''">
and d1.device_name like concat('%', #{params.terminalName},'%')
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and s.tenant_id=#{params.tenantId}
</if>
</select>
<select id="selectStationGunDeviceTreeByParent" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
WHERE s.del_flag=0 and d1.del_flag=0
and d1.parent_device_id=#{parentDeviceId}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
@ -30,12 +107,12 @@
where device_id = #{deviceId,jdbcType=INTEGER} where device_id = #{deviceId,jdbcType=INTEGER}
</update> </update>
<insert id="insert" keyColumn="device_id" keyProperty="deviceId" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain" useGeneratedKeys="true"> <insert id="insert" keyColumn="device_id" keyProperty="deviceId" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain" useGeneratedKeys="true">
insert into xhpc_station_device (device_name, device_type, station_id, insert into xhpc_station_device (device_name, device_type, current_type, station_id,
parent_device_id, serial_number, `status`, parent_device_id, serial_number, brand_model, `status`,
del_flag, create_time, create_by, del_flag, create_time, create_by,
update_time, update_by) update_time, update_by)
values (#{deviceName,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR}, #{stationId,jdbcType=BIGINT}, values (#{deviceName,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR}, #{currentType,jdbcType=VARCHAR}, #{stationId,jdbcType=BIGINT},
#{parentDeviceId,jdbcType=BIGINT}, #{serialNumber,jdbcType=VARCHAR}, #{status,jdbcType=SMALLINT}, #{parentDeviceId,jdbcType=BIGINT}, #{serialNumber,jdbcType=VARCHAR}, #{brandModel,jdbcType=VARCHAR}, #{status,jdbcType=SMALLINT},
0, SYSDATE(), #{createBy,jdbcType=VARCHAR}, SYSDATE(), #{updateBy,jdbcType=VARCHAR}) 0, SYSDATE(), #{createBy,jdbcType=VARCHAR}, SYSDATE(), #{updateBy,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" keyColumn="device_id" keyProperty="deviceId" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="device_id" keyProperty="deviceId" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain" useGeneratedKeys="true">
@ -47,6 +124,9 @@
<if test="deviceType != null"> <if test="deviceType != null">
device_type, device_type,
</if> </if>
<if test="currentType != null">
current_type,
</if>
<if test="stationId != null"> <if test="stationId != null">
station_id, station_id,
</if> </if>
@ -56,6 +136,9 @@
<if test="serialNumber != null"> <if test="serialNumber != null">
serial_number, serial_number,
</if> </if>
<if test="brandModel != null">
brand_model,
</if>
<if test="status != null"> <if test="status != null">
`status`, `status`,
</if> </if>
@ -76,6 +159,9 @@
<if test="deviceType != null"> <if test="deviceType != null">
#{deviceType,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR},
</if> </if>
<if test="currentType != null">
#{currentType,jdbcType=VARCHAR},
</if>
<if test="stationId != null"> <if test="stationId != null">
#{stationId,jdbcType=BIGINT}, #{stationId,jdbcType=BIGINT},
</if> </if>
@ -85,6 +171,9 @@
<if test="serialNumber != null"> <if test="serialNumber != null">
#{serialNumber,jdbcType=VARCHAR}, #{serialNumber,jdbcType=VARCHAR},
</if> </if>
<if test="brandModel != null">
#{brandModel,jdbcType=VARCHAR},
</if>
<if test="status != null"> <if test="status != null">
#{status,jdbcType=SMALLINT}, #{status,jdbcType=SMALLINT},
</if> </if>
@ -108,6 +197,9 @@
<if test="deviceType != null"> <if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR}, device_type = #{deviceType,jdbcType=VARCHAR},
</if> </if>
<if test="currentType != null">
current_type = #{currentType,jdbcType=VARCHAR},
</if>
<if test="stationId != null"> <if test="stationId != null">
station_id = #{stationId,jdbcType=BIGINT}, station_id = #{stationId,jdbcType=BIGINT},
</if> </if>
@ -117,6 +209,9 @@
<if test="serialNumber != null"> <if test="serialNumber != null">
serial_number = #{serialNumber,jdbcType=VARCHAR}, serial_number = #{serialNumber,jdbcType=VARCHAR},
</if> </if>
<if test="brandModel != null">
brand_model = #{brandModel,jdbcType=VARCHAR},
</if>
<if test="status != null"> <if test="status != null">
`status` = #{status,jdbcType=SMALLINT}, `status` = #{status,jdbcType=SMALLINT},
</if> </if>
@ -131,9 +226,11 @@
update xhpc_station_device update xhpc_station_device
set device_name = #{deviceName,jdbcType=VARCHAR}, set device_name = #{deviceName,jdbcType=VARCHAR},
device_type = #{deviceType,jdbcType=VARCHAR}, device_type = #{deviceType,jdbcType=VARCHAR},
current_type = #{currentType,jdbcType=VARCHAR},
station_id = #{stationId,jdbcType=BIGINT}, station_id = #{stationId,jdbcType=BIGINT},
parent_device_id = #{parentDeviceId,jdbcType=BIGINT}, parent_device_id = #{parentDeviceId,jdbcType=BIGINT},
serial_number = #{serialNumber,jdbcType=VARCHAR}, serial_number = #{serialNumber,jdbcType=VARCHAR},
brand_model = #{brandModel,jdbcType=VARCHAR},
`status` = #{status,jdbcType=SMALLINT}, `status` = #{status,jdbcType=SMALLINT},
update_time = sysdate(), update_time = sysdate(),
update_by = #{updateBy,jdbcType=VARCHAR} update_by = #{updateBy,jdbcType=VARCHAR}

View File

@ -6,6 +6,7 @@
<result column="type" jdbcType="SMALLINT" property="type" /> <result column="type" jdbcType="SMALLINT" property="type" />
<result column="title" jdbcType="VARCHAR" property="title" /> <result column="title" jdbcType="VARCHAR" property="title" />
<result column="content" jdbcType="VARCHAR" property="content" /> <result column="content" jdbcType="VARCHAR" property="content" />
<result column="fault_time" jdbcType="TIMESTAMP" property="faultTime" />
<result column="device_type" jdbcType="VARCHAR" property="deviceType" /> <result column="device_type" jdbcType="VARCHAR" property="deviceType" />
<result column="serial_number" jdbcType="VARCHAR" property="serialNumber" /> <result column="serial_number" jdbcType="VARCHAR" property="serialNumber" />
<result column="dept_id" jdbcType="BIGINT" property="deptId" /> <result column="dept_id" jdbcType="BIGINT" property="deptId" />
@ -21,10 +22,49 @@
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
work_order_id, `type`, title, content, device_type, serial_number, dept_id, user_id, work_order_id, `type`, title, content, fault_time, device_type, serial_number, dept_id, user_id,
reason, disposal_method, `status`, del_flag, tenant_id, create_time, create_by, update_time, reason, disposal_method, `status`, del_flag, tenant_id, create_time, create_by, update_time,
update_by update_by
</sql> </sql>
<select id="selectByTypeAndTitleAndDeviceSerialNumber" resultType="com.xhpc.workorder.domain.XhpcWorkOrderDomain">
select
<include refid="Base_Column_List" />
from xhpc_work_order
where del_flag=0
and type =#{type}
and title=#{title}
and serial_number=#{serialNumber}
and user_id=#{userId}
and status=#{status}
</select>
<select id="findOrderListByParams" resultType="java.util.Map">
SELECT
o.work_order_id as 'workOrderId',
o.title as 'title',
o.type as 'type',
o.dept_id as 'deptId',
d.dept_name as 'deptName',
o.user_id as 'userId',
u.user_name as 'userName',
o.`status` as 'status'
from xhpc_work_order o
LEFT JOIN xhpc_work_dept d on d.work_dept_id=o.dept_id
LEFT JOIN xhpc_work_user u on o.user_id=u.work_user_id
where o.del_flag=0
<if test="params.orderType != null and params.orderType != ''">
o.type=#{params.orderType}
</if>
<if test="params.userName!=null and params.userName!=''">
u.user_name like concat ('%', #{params.userName}, '%')
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
o.tenant_id = #{params.tenantId}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
@ -36,13 +76,13 @@
where work_order_id = #{workOrderId,jdbcType=BIGINT} where work_order_id = #{workOrderId,jdbcType=BIGINT}
</update> </update>
<insert id="insert" keyColumn="work_order_id" keyProperty="workOrderId" parameterType="com.xhpc.workorder.domain.XhpcWorkOrderDomain" useGeneratedKeys="true"> <insert id="insert" keyColumn="work_order_id" keyProperty="workOrderId" parameterType="com.xhpc.workorder.domain.XhpcWorkOrderDomain" useGeneratedKeys="true">
insert into xhpc_work_order (`type`, title, content, insert into xhpc_work_order (`type`, title, content, fault_time
device_type, serial_number, dept_id, device_type, serial_number, dept_id,
user_id, reason, disposal_method, user_id, reason, disposal_method,
`status`, del_flag, tenant_id, `status`, del_flag, tenant_id,
create_time, create_by, update_time, create_time, create_by, update_time,
update_by) update_by)
values (#{type,jdbcType=SMALLINT}, #{title,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, values (#{type,jdbcType=SMALLINT}, #{title,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{faultTime, jdbc=TIMESTAMP}
#{deviceType,jdbcType=VARCHAR}, #{serialNumber,jdbcType=VARCHAR}, #{deptId,jdbcType=BIGINT}, #{deviceType,jdbcType=VARCHAR}, #{serialNumber,jdbcType=VARCHAR}, #{deptId,jdbcType=BIGINT},
#{userId,jdbcType=BIGINT}, #{reason,jdbcType=VARCHAR}, #{disposalMethod,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}, #{reason,jdbcType=VARCHAR}, #{disposalMethod,jdbcType=VARCHAR},
#{status,jdbcType=SMALLINT}, 0, #{tenantId,jdbcType=VARCHAR}, #{status,jdbcType=SMALLINT}, 0, #{tenantId,jdbcType=VARCHAR},
@ -61,6 +101,9 @@
<if test="content != null"> <if test="content != null">
content, content,
</if> </if>
<if test="faultTime != null">
fault_time,
</if>
<if test="deviceType != null"> <if test="deviceType != null">
device_type, device_type,
</if> </if>
@ -105,6 +148,9 @@
<if test="content != null"> <if test="content != null">
#{content,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},
</if> </if>
<if test="faultTIme!=null">
#{faultTime, jdbc=TIMESTAMP},
</if>
<if test="deviceType != null"> <if test="deviceType != null">
#{deviceType,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR},
</if> </if>
@ -152,6 +198,9 @@
<if test="content != null"> <if test="content != null">
content = #{content,jdbcType=VARCHAR}, content = #{content,jdbcType=VARCHAR},
</if> </if>
<if test="faultTime!=null">
fault_time = #{faultTime, jdbc=TIMESTAMP},
</if>
<if test="deviceType != null"> <if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR}, device_type = #{deviceType,jdbcType=VARCHAR},
</if> </if>
@ -188,6 +237,7 @@
set `type` = #{type,jdbcType=SMALLINT}, set `type` = #{type,jdbcType=SMALLINT},
title = #{title,jdbcType=VARCHAR}, title = #{title,jdbcType=VARCHAR},
content = #{content,jdbcType=VARCHAR}, content = #{content,jdbcType=VARCHAR},
fault_time = #{faultTime, jdbc=TIMESTAMP},
device_type = #{deviceType,jdbcType=VARCHAR}, device_type = #{deviceType,jdbcType=VARCHAR},
serial_number = #{serialNumber,jdbcType=VARCHAR}, serial_number = #{serialNumber,jdbcType=VARCHAR},
dept_id = #{deptId,jdbcType=BIGINT}, dept_id = #{deptId,jdbcType=BIGINT},

View File

@ -37,6 +37,15 @@
remark, business_instructions, reminder_instructions, img_id, station_type, service_tel, remark, business_instructions, reminder_instructions, img_id, station_type, service_tel,
park_nums, tenant_id park_nums, tenant_id
</sql> </sql>
<select id="selectByName">
select
<include refid="Base_Column_List" />
from xhpc_work_station
where name like concat('%', #{stationName}, '%')
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />

View File

@ -21,6 +21,14 @@
work_user_id, user_name, dept_id, post_name, phone, email, wechat_openid, is_leader, work_user_id, user_name, dept_id, post_name, phone, email, wechat_openid, is_leader,
`status`, del_flag, create_time, create_by, update_time, update_by `status`, del_flag, create_time, create_by, update_time, update_by
</sql> </sql>
<select id="selectByUserNameAndPhone" resultType="com.xhpc.workorder.domain.XhpcWorkUserDomain">
select
<include refid="Base_Column_List" />
from xhpc_work_user
where user_name = #{userName} and phone=#{phone}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />