对接运维模块

This commit is contained in:
panshuling321 2022-02-21 09:35:37 +08:00
parent 62bc906011
commit 715c4a777c
25 changed files with 522 additions and 117 deletions

View File

@ -269,6 +269,7 @@ CREATE TABLE `xhpc_station_device`
`brand_model` varchar(100) DEFAULT NULL COMMENT '品牌型号',
`parent_device_id` bigint(20) DEFAULT NULL COMMENT '上级设备ID',
`serial_number` varchar(50) DEFAULT NULL COMMENT '设备编码',
`sorted` smallint(4) DEFAULT 0 COMMENT '排序',
`status` smallint(4) DEFAULT NULL COMMENT '设备状态0-未启用1-正常2-异常3-维修中4-待检测)',
`del_flag` smallint(2) DEFAULT NULL COMMENT '是否删除0-正常2-删除)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
@ -314,8 +315,6 @@ CREATE TABLE `xhpc_work_order`
`fault_time` datetime DEFAULT NULL COMMENT '故障时间',
`device_type` varchar(32) DEFAULT NULL COMMENT '设备类型',
`serial_number` varchar(100) DEFAULT NULL COMMENT '设备编码',
`dept_id` bigint(20) DEFAULT NULL COMMENT '指派处理部门',
`user_id` bigint(20) DEFAULT NULL COMMENT '指派处理人',
`reason` varchar(200) DEFAULT NULL COMMENT '故障原因',
`disposal_method` varchar(500) DEFAULT NULL COMMENT '详细处理描述',
`status` smallint(4) DEFAULT NULL COMMENT '状态, 0-编辑1-派发处理2-处理完成',
@ -325,6 +324,7 @@ CREATE TABLE `xhpc_work_order`
`create_by` varchar(100) DEFAULT NULL COMMENT '创建人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`update_by` varchar(100) DEFAULT NULL COMMENT '更新人',
`remark` text COMMENT '备注',
PRIMARY KEY (`work_order_id`)
) ENGINE=InnoDB
COMMENT = '工单详情表'
@ -333,6 +333,19 @@ CREATE TABLE `xhpc_work_order`
COLLATE='utf8mb4_general_ci'
ROW_FORMAT=DYNAMIC;
CREATE TABLE `xhpc_work_order_user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分派ID',
`order_id` bigint(20) NOT NULL COMMENT '工单ID',
`user_id` bigint(20) NOT NULL COMMENT '分配人ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB
COMMENT = '工单派单表'
AUTO_INCREMENT=1
DEFAULT CHARSET=utf8mb4
COLLATE='utf8mb4_general_ci'
ROW_FORMAT=DYNAMIC;
CREATE TABLE `xhpc_work_order_image`
(
`order_image_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '图片ID',

View File

@ -6,37 +6,45 @@ import com.xhpc.common.core.web.controller.BaseController;
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.common.util.LogUserUtils;
import com.xhpc.system.api.model.LoginUser;
import com.xhpc.workorder.domain.XhpcWorkOrderDomain;
import com.xhpc.workorder.service.WorkOrderService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/workorder/order")
@RequestMapping("/order")
public class WorkOrderController extends BaseController {
@Resource
WorkOrderService workOrderService;
@Resource
LogUserUtils logUserUtils;
@GetMapping("/getPage")
public TableDataInfo getOrderPage(Integer orderType,
public TableDataInfo getOrderPage(HttpServletRequest request, Integer orderType,
String userName){
startPage();
LoginUser logUser = logUserUtils.getLogUser(request);
Map<String, Object> params = new HashMap<>();
params.put("orderType", orderType);
params.put("userName", userName);
params.put("tenantId", logUser.getTenantId());
return getDataTable(workOrderService.getOrderPage(params));
}
@Log(title = "工单-新增工单", businessType = BusinessType.INSERT)
@PostMapping("/")
public R insertNewOrder(@RequestBody XhpcWorkOrderDomain domain){
public R insertNewOrder(HttpServletRequest request, @RequestBody XhpcWorkOrderDomain domain){
LoginUser logUser = logUserUtils.getLogUser(request);
domain.setTenantId(logUser.getTenantId());
return R.ok(workOrderService.insertOrder(domain));
}

View File

@ -7,37 +7,69 @@ import com.xhpc.common.core.web.controller.BaseController;
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.common.util.LogUserUtils;
import com.xhpc.system.api.model.LoginUser;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import com.xhpc.workorder.service.WorkStationService;
import com.xhpc.workorder.service.WorkUserService;
import com.xhpc.workorder.vo.XhpcStationDeviceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/workorder/station")
@RequestMapping("/station")
public class WorkStationController extends BaseController {
@Resource
WorkStationService stationService;
@Resource
WorkUserService userService;
@Resource
LogUserUtils logUserUtils;
@GetMapping("/getPage")
public TableDataInfo getPage(String stationName,
public TableDataInfo getPage(HttpServletRequest request, String stationName,
String terminalName){
startPage();
LoginUser logUser = logUserUtils.getLogUser(request);
Map<String, Object> params = new HashMap<>();
params.put("stationName", stationName);
params.put("terminalName", terminalName);
params.put("tenantId", logUser.getTenantId());
return getDataTable(stationService.getStationDevice(params));
}
@GetMapping("/getPageByParent")
public TableDataInfo getPageByParent(HttpServletRequest request,
String stationId,
String deviceType,
String parentId){
startPage();
LoginUser logUser = logUserUtils.getLogUser(request);
Map<String, Object> params = new HashMap<>();
params.put("stationId", stationId);
params.put("deviceType", deviceType);
params.put("parentId", parentId);
params.put("tenantId", logUser.getTenantId());
return getDataTable(stationService.getStationDeviceByParent(params));
}
@GetMapping("/getStationPage")
public TableDataInfo getStationList(String tenantId){
startPage();
@ -50,12 +82,18 @@ public class WorkStationController extends BaseController {
@GetMapping("/getTree")
public TableDataInfo getTree(String stationName,
String terminalName){
public TableDataInfo getTree(
HttpServletRequest request,
String deviceName,
String stationName,
String terminalName){
startPage();
LoginUser logUser = logUserUtils.getLogUser(request);
Map<String, Object> params = new HashMap<>();
params.put("stationName", stationName);
params.put("terminalName", terminalName);
params.put("deviceName", deviceName);
params.put("tenantId", logUser.getTenantId());
return getDataTable(stationService.getStationDeviceTree(params));
}
@ -84,11 +122,24 @@ public class WorkStationController extends BaseController {
@Log(title = "场站设备-新增设备", businessType = BusinessType.INSERT)
@PostMapping("/")
public R insertNewDevice(@RequestBody XhpcStationDeviceDomain domain) throws Exception{
public R insertNewDevice(HttpServletRequest request, @RequestBody XhpcStationDeviceDomain domain) throws Exception{
LoginUser logUser = logUserUtils.getLogUser(request);
domain.setCreateBy(logUser.getUserid().toString());
domain.setUpdateBy(logUser.getUserid().toString());
return R.ok(stationService.insertDevice(domain));
}
@Log(title = "场站设备-新增设备(简易)", businessType = BusinessType.INSERT)
@PostMapping("/simple")
public R insertNewSimpleDevice(HttpServletRequest request, @RequestBody XhpcStationDeviceVo vo) throws Exception{
LoginUser logUser = logUserUtils.getLogUser(request);
vo.setTenantId(logUser.getTenantId());
vo.setUserId(logUser.getUserid().toString());
return R.ok(stationService.insertSimpleDevice(vo));
}
@Log(title = "场站设备-维护设备信息", businessType = BusinessType.UPDATE)
@PutMapping("/detail")
public R updateDeviceInfo(@RequestBody XhpcStationDeviceDomain domain){
@ -102,4 +153,15 @@ public class WorkStationController extends BaseController {
public R deleteDeviceInfo(@RequestParam("deviceId") Long deviceId) throws Exception {
return R.ok(stationService.deleteDevice(deviceId));
}
@GetMapping("/user")
public R getDeptAndUser(HttpServletRequest request){
LoginUser logUser = logUserUtils.getLogUser(request);
Map<String, Object> params = new HashMap<>();
params.put("tenantId", logUser.getTenantId());
return R.ok(userService.getDeptAndUserByMap(params));
}
}

View File

@ -69,6 +69,8 @@ public class XhpcStationDeviceDomain implements Serializable {
@Excel(name = "设备编码")
private String serialNumber;
private Integer sorted;
/**
* 设备状态0-未启用1-正常2-异常3-维修中4-待检测
*/

View File

@ -47,16 +47,6 @@ public class XhpcWorkOrderDomain implements Serializable {
*/
private String serialNumber;
/**
* 指派处理部门
*/
private Long deptId;
/**
* 指派处理人
*/
private Long userId;
/**
* 故障原因
*/
@ -102,12 +92,14 @@ public class XhpcWorkOrderDomain implements Serializable {
*/
private String updateBy;
private String remark;
private String userName;
private String stationName;
private String userPhone;
private String deviceName;
private List<XhpcWorkUserDomain> userList;
private List<XhpcWorkOrderImageDomain> questionImgList;

View File

@ -0,0 +1,13 @@
package com.xhpc.workorder.domain;
import lombok.Data;
@Data
public class XhpcWorkOrderUserDomain {
private Long orderId;
private Long userId;
}

View File

@ -13,6 +13,9 @@ public interface XhpcStationDeviceMapper {
List<Map<String, Object>> selectStationGunDeviceTreeByParams(@Param("params") Map params);
List<Map<String, Object>> selectListByParent(@Param("params")Map params);
Map<String, Object> selectByDeviceId(@Param("deviceId") Long deviceId);

View File

@ -1,8 +1,18 @@
package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkDeptDomain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface XhpcWorkDeptMapper {
List<XhpcWorkDeptDomain> selectListByParams(@Param("params") Map params);
List<Map<String, Object>> selectMapListByParams(@Param("params") Map params);
int deleteByPrimaryKey(Long workDeptId);
int insert(XhpcWorkDeptDomain record);

View File

@ -1,14 +1,15 @@
package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkOrderImageDomain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface XhpcWorkOrderImageMapper {
List<XhpcWorkOrderImageDomain> selectByOrderIdAndType(Long orderId, Integer type);
List<XhpcWorkOrderImageDomain> selectByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type);
List<Long> selectImageIdByOrderIdAndType(Long orderId, Integer type);
List<Long> selectImageIdByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type);
int deleteByImageIds(List<Long> imageIds);

View File

@ -1,6 +1,7 @@
package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkOrderDomain;
import com.xhpc.workorder.domain.XhpcWorkOrderUserDomain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -11,8 +12,9 @@ public interface XhpcWorkOrderMapper {
List<Map<String, Object>> findOrderListByParams(@Param("params") Map params);
XhpcWorkOrderDomain selectByTypeAndTitle(@Param("type")Integer type,
@Param("title")String title,
@Param("userId")Long userId);
@Param("title")String title);
int insertOrderUser(@Param("domainList") List<XhpcWorkOrderUserDomain> domainList);
int deleteByPrimaryKey(Long workOrderId);
@ -25,4 +27,7 @@ public interface XhpcWorkOrderMapper {
int updateByPrimaryKeySelective(XhpcWorkOrderDomain record);
int updateByPrimaryKey(XhpcWorkOrderDomain record);
int deleteOrderUserByOrderId(Long orderId);
}

View File

@ -10,6 +10,8 @@ public interface XhpcWorkStationMapper {
List<XhpcWorkStationDomain> selectListByParams(@Param("params") Map params);
List<Map<String, Object>> selectMapListByParams(@Param("params") Map params);
XhpcWorkStationDomain selectByName(@Param("stationName") String stationName);
int deleteByPrimaryKey(Long workStationId);

View File

@ -3,10 +3,18 @@ package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkUserDomain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface XhpcWorkUserMapper {
XhpcWorkUserDomain selectByUserNameAndPhone(@Param("userName")String userName, @Param("phone") String phone);
List<Map<String, Object>> selectMapListByDeptId(@Param("deptId")String deptId);
List<XhpcWorkUserDomain> selectByOrderId(Long orderId);
int deleteByPrimaryKey(Long workUserId);
int insert(XhpcWorkUserDomain record);

View File

@ -2,6 +2,7 @@ package com.xhpc.workorder.service;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import com.xhpc.workorder.domain.XhpcWorkStationDomain;
import com.xhpc.workorder.vo.XhpcStationDeviceVo;
import java.util.List;
import java.util.Map;
@ -12,6 +13,9 @@ public interface WorkStationService {
List<Map<String, Object>> getStationDevice(Map<String, Object> params);
List<Map<String, Object>> getStationDeviceByParent(Map<String, Object> params);
List<XhpcWorkStationDomain> getStationList(Map<String, Object> params);
@ -23,6 +27,8 @@ public interface WorkStationService {
Boolean insertDevice(XhpcStationDeviceDomain domain) throws Exception;
Boolean insertSimpleDevice(XhpcStationDeviceVo vo) throws Exception;
Boolean updateDevice(XhpcStationDeviceDomain domain);
Boolean deleteDevice(Long deviceId) throws Exception;

View File

@ -2,9 +2,18 @@ package com.xhpc.workorder.service;
import com.xhpc.workorder.domain.XhpcWorkUserDomain;
import java.util.List;
import java.util.Map;
public interface WorkUserService {
Boolean insertUser(String userName, String phone);
XhpcWorkUserDomain insertUserReturnDomain(String userName, String phone);
List<Map<String, Object>> getDeptAndUserByMap(Map<String, Object> params);
XhpcWorkUserDomain findByPk(Long pk);
List<XhpcWorkUserDomain> findByOrderId(Long orderId);
}

View File

@ -1,6 +1,5 @@
package com.xhpc.workorder.service.impl;
import cn.hutool.core.util.StrUtil;
import com.xhpc.common.api.SmsService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.StringUtils;
@ -12,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -50,6 +50,7 @@ public class WorkOrderServiceImpl implements WorkOrderService {
public XhpcWorkOrderDomain selectOrderById(Long orderId){
XhpcWorkOrderDomain orderDomain = orderMapper.selectByPrimaryKey(orderId);
orderDomain.setUserList(workUserService.findByOrderId(orderId));
orderDomain.setQuestionImgList(imageMapper.selectByOrderIdAndType(orderId, 1));
orderDomain.setReplyImgList(imageMapper.selectByOrderIdAndType(orderId, 2));
@ -63,7 +64,7 @@ public class WorkOrderServiceImpl implements WorkOrderService {
List<Long> imageIds = imageMapper.selectImageIdByOrderIdAndType(domain.getWorkOrderId(), 1);
for (XhpcWorkOrderImageDomain imageDomain: domain.getQuestionImgList()){
if(StringUtils.isBlank(imageDomain.getOrderImageId().toString())){
if(StringUtils.isEmpty(imageDomain.getOrderImageId().toString())){
imageDomain.setOrderId(domain.getWorkOrderId());
imageDomain.setType(Short.valueOf("1"));
imageDomain.setDelFlag(Short.valueOf("0"));
@ -78,6 +79,19 @@ public class WorkOrderServiceImpl implements WorkOrderService {
imageMapper.deleteByImageIds(imageIds);
}
// 更新处理人
orderMapper.deleteOrderUserByOrderId(domain.getWorkOrderId());
List<XhpcWorkOrderUserDomain> orderUserDomainList = new ArrayList<>();
for(XhpcWorkUserDomain userDomain: domain.getUserList()){
XhpcWorkOrderUserDomain orderUserDomain = new XhpcWorkOrderUserDomain();
orderUserDomain.setOrderId(domain.getWorkOrderId());
orderUserDomain.setUserId(userDomain.getWorkUserId());
orderUserDomainList.add(orderUserDomain);
}
orderMapper.insertOrderUser(orderUserDomainList);
return true;
}
@ -105,19 +119,16 @@ public class WorkOrderServiceImpl implements WorkOrderService {
@Override
public Boolean insertOrder(XhpcWorkOrderDomain domain){
if (StrUtil.hasBlank(domain.getUserName()) || StrUtil.hasBlank(domain.getUserPhone())){
throw new RuntimeException("派发人姓名或手机号不能为空");
if(domain.getUserList() != null){
List<XhpcWorkUserDomain> userDomains = new ArrayList<>();
for(XhpcWorkUserDomain userDomain: domain.getUserList()){
userDomain = workUserService.findByPk(userDomain.getWorkUserId());
userDomains.add(userDomain);
}
domain.setUserList(userDomains);
}
XhpcWorkUserDomain userDomain = userMapper.selectByUserNameAndPhone(domain.getUserName(), domain.getUserPhone());
if(userDomain != null){
domain.setUserId(userDomain.getWorkUserId());
domain.setDeptId(userDomain.getDeptId());
} else {
userDomain = workUserService.insertUserReturnDomain(domain.getUserName(), domain.getUserPhone());
}
domain.setUserId(userDomain.getWorkUserId());
domain.setDeptId(userDomain.getDeptId());
if(StringUtils.isNotEmpty(domain.getSerialNumber())){
XhpcStationDeviceDomain deviceDomain = deviceMapper.selectStationGunDeviceBySerialNumber(domain.getSerialNumber());
@ -129,8 +140,8 @@ public class WorkOrderServiceImpl implements WorkOrderService {
orderMapper.insertSelective(domain);
XhpcWorkOrderDomain resDomain = orderMapper.selectByTypeAndTitle(domain.getType().intValue(),
domain.getTitle(),
domain.getUserId());
domain.getTitle());
// 上传文件
for(XhpcWorkOrderImageDomain imageDomain : domain.getQuestionImgList()){
@ -140,16 +151,30 @@ public class WorkOrderServiceImpl implements WorkOrderService {
imageMapper.insertSelective(imageDomain);
}
// 绑定人员
List<XhpcWorkOrderUserDomain> orderUserDomainList = new ArrayList<>();
String phoneList = "";
for (XhpcWorkUserDomain userDomain: domain.getUserList()){
XhpcWorkOrderUserDomain orderUserDomain = new XhpcWorkOrderUserDomain();
orderUserDomain.setOrderId(resDomain.getWorkOrderId());
orderUserDomain.setUserId(userDomain.getWorkUserId());
orderUserDomainList.add(orderUserDomain);
phoneList = userDomain.getPhone() + "," + phoneList;
}
orderMapper.insertOrderUser(orderUserDomainList);
// todo 发送多人短信
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("orderNo", resDomain.getWorkOrderId().toString());
paramMap.put("phone", domain.getUserPhone());
paramMap.put("phone", phoneList);
paramMap.put("content", "【小华充电】您好,您有新的工单(工单号:"+ resDomain.getWorkOrderId() +")待处理,请及时登陆后台查看并处理,谢谢。");
R r = smsService.sendNotice(paramMap);
XhpcWorkOrderPushMessageDomain messageDomain = new XhpcWorkOrderPushMessageDomain();
messageDomain.setContent(paramMap.get("content"));
messageDomain.setTarget(domain.getUserPhone());
messageDomain.setTarget(phoneList);
messageDomain.setType(Short.valueOf("1"));
if (r!= null && r.getCode() != 200){
messageDomain.setFailMsg("发送失败");
@ -170,6 +195,7 @@ public class WorkOrderServiceImpl implements WorkOrderService {
throw new Exception("工单不存在");
}
orderMapper.deleteByPrimaryKey(orderId);
orderMapper.deleteOrderUserByOrderId(orderId);
return true;
}

View File

@ -8,9 +8,11 @@ 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 com.xhpc.workorder.vo.XhpcStationDeviceVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -30,6 +32,11 @@ public class WorkStationServiceImpl implements WorkStationService {
}
@Override
public List<Map<String, Object>> getStationDeviceByParent(Map<String, Object> params){
return deviceMapper.selectListByParent(params);
}
@Override
public List<XhpcWorkStationDomain> getStationList(Map<String, Object> params){
return stationMapper.selectListByParams(params);
@ -38,16 +45,30 @@ public class WorkStationServiceImpl implements WorkStationService {
@Override
public List<Map<String, Object>> getStationDeviceTree(Map<String, Object> params){
Map<String, Object> stationParams = new HashMap<>();
stationParams.put("name", params.get("stationName"));
stationParams.put("tenantId", params.get("tenantId"));
stationParams.put("status", 1);
stationParams.put("delFlag", 0);
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);
List<Map<String, Object>> stationDomainList = stationMapper.selectMapListByParams(stationParams);
for (Map<String, Object> stationMap: stationDomainList){
if(StringUtils.isEmpty(params.get("stationName").toString())){
params.put("stationName", stationMap.get("name"));
}
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;
return stationDomainList;
}
@ -121,6 +142,31 @@ public class WorkStationServiceImpl implements WorkStationService {
return true;
}
@Override
public Boolean insertSimpleDevice(XhpcStationDeviceVo vo) throws Exception{
if(StringUtils.isEmpty(vo.getParentDeviceId())){
// 增加的场站
XhpcWorkStationDomain stationDomain = new XhpcWorkStationDomain();
stationDomain.setName(vo.getDeviceName());
stationDomain.setTenantId(vo.getTenantId());
stationDomain.setCreateBy(vo.getUserId());
stationDomain.setUpdateBy(vo.getUserId());
stationMapper.insertSelective(stationDomain);
} else {
XhpcStationDeviceDomain deviceDomain = new XhpcStationDeviceDomain();
deviceDomain.setDeviceName(vo.getDeviceName());
deviceDomain.setCreateBy(vo.getUserId());
deviceDomain.setUpdateBy(vo.getUserId());
deviceMapper.insertSelective(deviceDomain);
}
return true;
}
@Override
public Boolean updateDevice(XhpcStationDeviceDomain domain){
deviceMapper.updateByPrimaryKeySelective(domain);

View File

@ -1,11 +1,15 @@
package com.xhpc.workorder.service.impl;
import com.xhpc.workorder.domain.XhpcWorkDeptDomain;
import com.xhpc.workorder.domain.XhpcWorkUserDomain;
import com.xhpc.workorder.mapper.XhpcWorkDeptMapper;
import com.xhpc.workorder.mapper.XhpcWorkUserMapper;
import com.xhpc.workorder.service.WorkUserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
@ -14,6 +18,9 @@ public class WorkUserServiceImpl implements WorkUserService {
@Resource
XhpcWorkUserMapper workUserMapper;
@Resource
XhpcWorkDeptMapper deptMapper;
@Override
public Boolean insertUser(String userName, String phone){
@ -29,4 +36,27 @@ public class WorkUserServiceImpl implements WorkUserService {
return workUserMapper.selectByUserNameAndPhone(userName, phone);
}
@Override
public List<Map<String, Object>> getDeptAndUserByMap(Map<String, Object> params){
List<Map<String, Object>> deptDomains = deptMapper.selectMapListByParams(params);
for(Map<String, Object> deptMap: deptDomains){
List<Map<String, Object>> useres = workUserMapper.selectMapListByDeptId(deptMap.get("id").toString());
deptMap.put("users", useres);
}
return deptDomains;
}
@Override
public XhpcWorkUserDomain findByPk(Long pk){
return workUserMapper.selectByPrimaryKey(pk);
}
@Override
public List<XhpcWorkUserDomain> findByOrderId(Long orderId){
return workUserMapper.selectByOrderId(orderId);
}
}

View File

@ -0,0 +1,20 @@
package com.xhpc.workorder.vo;
import lombok.Data;
@Data
public class XhpcStationDeviceVo {
private String deviceName;
private String parentDeviceId;
private String deviceType;
private String stationName;
private String tenantId;
private String userId;
}

View File

@ -29,9 +29,6 @@ logging:
root: info
com.xhpc.workorder.mapper: debug
file:
path: "d:\\logs"
pattern:
console: '%d{yyyy/MM/dd-HH:mm:ss} [%thread] %-5level %logger- %msg%n'
file: '%d{yyyy/MM/dd-HH:mm:ss} [%thread] %-5level %logger- %msg%n'

View File

@ -18,7 +18,7 @@
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
</resultMap>
<sql id="Base_Column_List">
device_id, device_name, device_type, current_type, station_id, brand_model, parent_device_id, serial_number,
device_id, device_name, device_type, current_type, station_id, brand_model, parent_device_id, serial_number, sorted,
`status`, del_flag, create_time, create_by, update_time, update_by
</sql>
@ -34,27 +34,35 @@
s.`name` as 'stationName',
d1.device_id as 'pileId',
d1.device_name as 'pileName',
d1.device_type as 'pileDeviceType',
d1.serial_number as 'pileSerialNumber',
d1.brand_model as 'pileBrandModel',
d1.current_type as 'pileCurrentType',
d1.sorted as 'pileSorted',
d2.device_id as 'gunId',
d2.device_name as 'gunName',
d2.device_type as 'gunDeviceType',
d2.serial_number as 'gunSerialNumber',
d2.brand_model as 'gunBrandModel',
d2.current_type as 'gunCurrentType'
d2.current_type as 'gunCurrentType',
d2.sorted as 'gunSorted'
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 !+ ''">
<if test="params.stationName!=null and params.stationName != ''">
and s.name like concat('%', #{params.stationName}, '%')
</if>
<if test="params.stationId!=null and params.stationId != ''">
and s.work_station_id = #{params.stationId}
</if>
<if test="params.terminalName!=null and params.terminalName!=''">
and d1.device_name like concat('%', #{params.terminalName},'%')
and d2.device_name like concat('%', #{params.terminalName},'%')
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and s.tenant_id=#{params.tenantId}
</if>
order by d1.device_type, d1.sorted, d2.device_type, d2.sorted
</select>
@ -68,6 +76,7 @@
d.brand_model as 'brandModel',
d.parent_device_id as 'parengDeviceId',
d.serial_number as 'serialNumber',
d.sorted as 'sorted',
d.`status` as 'status',
d.del_flag as 'delFlag',
d.create_time as 'createTime',
@ -86,13 +95,18 @@
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
d1.device_type as 'deviceType',
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
d1.sorted as 'deviceSorted'
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 !+ ''">
<if test="params.deviceName != null and params.deviceName != ''">
and d1.device_name like concat('%', #{params.deviceName}, '%')
</if>
<if test="params.stationName!=null and params.stationName != ''">
and s.name like concat('%', #{params.stationName}, '%')
</if>
<if test="params.terminalName!=null and params.terminalName!=''">
@ -101,6 +115,45 @@
<if test="params.tenantId!=null and params.tenantId!=''">
and s.tenant_id=#{params.tenantId}
</if>
order by d1.station_id, d1.device_type, d1.sorted
</select>
<select id="selectListByParent" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
d1.device_type as 'deviceType',
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
d1.sorted as 'deviceSorted'
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.deviceName != null and params.deviceName != ''">
and d1.device_name like concat('%', #{params.deviceName}, '%')
</if>
<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>
<if test="params.stationId != null and params.stationId !=''">
and s.work_station_id = #{params.stationId}
</if>
<if test="params.deviceType != null and params.deviceType !=''">
and d1.device_type = #{params.deviceType}
</if>
<if test="params.parentId != null and params.parentId !=''">
and d1.parent_device_id = #{params.parentId}
</if>
order by d1.device_type, d1.sorted
</select>
@ -109,13 +162,16 @@
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
d1.device_type as 'deviceType',
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
d1.sorted as 'deviceSorted'
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}
order by d1.device_type, d1.sorted
</select>
@ -131,11 +187,11 @@
</update>
<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, current_type, station_id,
parent_device_id, serial_number, brand_model, `status`,
parent_device_id, serial_number, brand_model,sorted, `status`,
del_flag, create_time, create_by,
update_time, update_by)
values (#{deviceName,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR}, #{currentType,jdbcType=VARCHAR}, #{stationId,jdbcType=BIGINT},
#{parentDeviceId,jdbcType=BIGINT}, #{serialNumber,jdbcType=VARCHAR}, #{brandModel,jdbcType=VARCHAR}, #{status,jdbcType=SMALLINT},
#{parentDeviceId,jdbcType=BIGINT}, #{serialNumber,jdbcType=VARCHAR}, #{brandModel,jdbcType=VARCHAR},#{sorted, jdbcType=SMALLINT}, #{status,jdbcType=SMALLINT},
0, SYSDATE(), #{createBy,jdbcType=VARCHAR}, SYSDATE(), #{updateBy,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="device_id" keyProperty="deviceId" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain" useGeneratedKeys="true">
@ -162,6 +218,9 @@
<if test="brandModel != null">
brand_model,
</if>
<if test="sorted != null">
`sorted`,
</if>
<if test="status != null">
`status`,
</if>
@ -197,6 +256,9 @@
<if test="brandModel != null">
#{brandModel,jdbcType=VARCHAR},
</if>
<if test="sorted != null">
#{sorted,jdbcType=SMALLINT},
</if>
<if test="status != null">
#{status,jdbcType=SMALLINT},
</if>
@ -235,6 +297,9 @@
<if test="brandModel != null">
brand_model = #{brandModel,jdbcType=VARCHAR},
</if>
<if test="sorted != null">
`sorted` = #{sorted,jdbcType=SMALLINT},
</if>
<if test="status != null">
`status` = #{status,jdbcType=SMALLINT},
</if>
@ -254,6 +319,7 @@
parent_device_id = #{parentDeviceId,jdbcType=BIGINT},
serial_number = #{serialNumber,jdbcType=VARCHAR},
brand_model = #{brandModel,jdbcType=VARCHAR},
sorted = #{sorted,jdbcType=SMALLINT},
`status` = #{status,jdbcType=SMALLINT},
update_time = sysdate(),
update_by = #{updateBy,jdbcType=VARCHAR}

View File

@ -19,6 +19,28 @@
work_dept_id, dept_name, code, sort, parent_dept_id, `status`, del_flag, tenant_id,
create_time, create_by, update_time, update_by
</sql>
<select id="selectListByParams" resultType="com.xhpc.workorder.domain.XhpcWorkDeptDomain">
select
<include refid="Base_Column_List" />
from xhpc_work_dept
where del_flag = 0 and status = 1
<if test="params.tenantId !=null and params.tenantId!=''">
and tenant_id=#{params.tenantId}
</if>
</select>
<select id="selectMapListByParams" resultType="map">
select
work_dept_id as 'id',
dept_name as 'name'
from xhpc_work_dept
where del_flag = 0 and status = 1
<if test="params.tenantId !=null and params.tenantId!=''">
and tenant_id=#{params.tenantId}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />

View File

@ -34,7 +34,7 @@
select
<include refid="Base_Column_List" />
from xhpc_work_order_image
where order_id = #{orderId,jdbcType=BIGINT} and type = #{type}
where order_id = #{orderId} and type = #{type}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@ -58,6 +58,9 @@
<insert id="insertSelective" keyColumn="order_image_id" keyProperty="orderImageId" parameterType="com.xhpc.workorder.domain.XhpcWorkOrderImageDomain" useGeneratedKeys="true">
insert into xhpc_work_order_image
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">
order_id,
</if>
<if test="fileName != null">
file_name,
</if>
@ -74,6 +77,9 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">
#{orderId},
</if>
<if test="fileName != null">
#{fileName,jdbcType=VARCHAR},
</if>
@ -93,6 +99,9 @@
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.workorder.domain.XhpcWorkOrderImageDomain">
update xhpc_work_order_image
<set>
<if test="orderId !=null">
order_id=#{orderId},
</if>
<if test="fileName != null">
file_name = #{fileName,jdbcType=VARCHAR},
</if>
@ -111,7 +120,8 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.workorder.domain.XhpcWorkOrderImageDomain">
update xhpc_work_order_image
set file_name = #{fileName,jdbcType=VARCHAR},
set order_id=#{orderId},
file_name = #{fileName,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
`type` = #{type,jdbcType=SMALLINT},
where order_image_id = #{orderImageId,jdbcType=BIGINT}

View File

@ -9,8 +9,6 @@
<result column="fault_time" jdbcType="TIMESTAMP" property="faultTime" />
<result column="device_type" jdbcType="VARCHAR" property="deviceType" />
<result column="serial_number" jdbcType="VARCHAR" property="serialNumber" />
<result column="dept_id" jdbcType="BIGINT" property="deptId" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="reason" jdbcType="VARCHAR" property="reason" />
<result column="disposal_method" jdbcType="VARCHAR" property="disposalMethod" />
<result column="status" jdbcType="SMALLINT" property="status" />
@ -20,38 +18,51 @@
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
</resultMap>
<sql id="Base_Column_List">
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,
update_by
o.work_order_id, o.`type`, o.title, o.content, o.fault_time, o.device_type, o.serial_number,
o.reason, o.disposal_method, o.`status`, o.del_flag, o.tenant_id, o.create_time, o.create_by, o.update_time,
o.update_by, o.remark
</sql>
<insert id="insertOrderUser">
insert into xhpc_work_order_user (order_id, user_id)
values
<foreach collection="domainList" item="domain" separator=",">
(#{domain.orderId}, #{domain.userId})
</foreach>
</insert>
<select id="selectByTypeAndTitle" 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 user_id=#{userId}
and status=0 and del_flag=0
from xhpc_work_order o
where o.del_flag=0
and o.type =#{type}
and o.title=#{title}
and o.status=1
order by create_time desc limit 1
</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'
o.work_order_id as 'workOrderId',
o.title as 'title',
o.type as 'type',
u.dept_id as 'deptId',
d.dept_name as 'deptName',
u.work_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
LEFT JOIN xhpc_work_order_user ou on o.work_order_id=ou.order_id
LEFT JOIN xhpc_work_user u on ou.user_id=u.work_user_id
LEFT JOIN xhpc_work_dept d on d.work_dept_id=u.dept_id
where o.del_flag=0
<if test="params.orderType != null and params.orderType != ''">
and o.type=#{params.orderType}
@ -62,14 +73,18 @@
<if test="params.tenantId!=null and params.tenantId!=''">
and o.tenant_id = #{params.tenantId}
</if>
GROUP BY o.work_order_id
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<select id="selectByPrimaryKey" resultType="com.xhpc.workorder.domain.XhpcWorkOrderDomain">
select
<include refid="Base_Column_List" />
from xhpc_work_order
where work_order_id = #{workOrderId,jdbcType=BIGINT}
<include refid="Base_Column_List" />,
d.device_name, s.name
from xhpc_work_order o
LEFT JOIN xhpc_station_device d on o.serial_number=d.serial_number
LEFT JOIN xhpc_work_station s on d.station_id=s.work_station_id
where o.work_order_id = #{workOrderId,jdbcType=BIGINT}
</select>
<update id="deleteByPrimaryKey" parameterType="java.lang.Long">
update xhpc_work_order set del_flag=2
@ -77,17 +92,16 @@
</update>
<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, fault_time
device_type, serial_number, dept_id,
user_id, reason, disposal_method,
device_type, serial_number, reason, disposal_method,
`status`, del_flag, tenant_id,
create_time, create_by, update_time,
update_by)
update_by, remark)
values (#{type,jdbcType=SMALLINT}, #{title,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{faultTime, jdbcType=TIMESTAMP}
#{deviceType,jdbcType=VARCHAR}, #{serialNumber,jdbcType=VARCHAR}, #{deptId,jdbcType=BIGINT},
#{userId,jdbcType=BIGINT}, #{reason,jdbcType=VARCHAR}, #{disposalMethod,jdbcType=VARCHAR},
#{status,jdbcType=SMALLINT}, 0, #{tenantId,jdbcType=VARCHAR},
#{deviceType,jdbcType=VARCHAR}, #{serialNumber,jdbcType=VARCHAR},
#{reason,jdbcType=VARCHAR}, #{disposalMethod,jdbcType=VARCHAR},
1, 0, #{tenantId,jdbcType=VARCHAR},
sysdate(), #{createBy,jdbcType=VARCHAR},sysdate(),
#{updateBy,jdbcType=VARCHAR})
#{updateBy,jdbcType=VARCHAR}, #{remark})
</insert>
<insert id="insertSelective" keyColumn="work_order_id" keyProperty="workOrderId" parameterType="com.xhpc.workorder.domain.XhpcWorkOrderDomain" useGeneratedKeys="true">
insert into xhpc_work_order
@ -110,12 +124,6 @@
<if test="serialNumber != null">
serial_number,
</if>
<if test="deptId != null">
dept_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="reason != null">
reason,
</if>
@ -135,6 +143,9 @@
<if test="updateBy != null">
update_by,
</if>
<if test="remark != null">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null">
@ -155,19 +166,13 @@
<if test="serialNumber != null">
#{serialNumber,jdbcType=VARCHAR},
</if>
<if test="deptId != null">
#{deptId,jdbcType=BIGINT},
</if>
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="reason != null">
#{reason,jdbcType=VARCHAR},
</if>
<if test="disposalMethod != null">
#{disposalMethod,jdbcType=VARCHAR},
</if>
0,
1,
0,
<if test="tenantId != null">
#{tenantId,jdbcType=VARCHAR},
@ -180,6 +185,9 @@
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.workorder.domain.XhpcWorkOrderDomain">
@ -203,12 +211,6 @@
<if test="serialNumber != null">
serial_number = #{serialNumber,jdbcType=VARCHAR},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=BIGINT},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="reason != null">
reason = #{reason,jdbcType=VARCHAR},
</if>
@ -225,6 +227,9 @@
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark=#{remark},
</if>
</set>
where work_order_id = #{workOrderId,jdbcType=BIGINT}
</update>
@ -236,14 +241,19 @@
fault_time = #{faultTime, jdbcType=TIMESTAMP},
device_type = #{deviceType,jdbcType=VARCHAR},
serial_number = #{serialNumber,jdbcType=VARCHAR},
dept_id = #{deptId,jdbcType=BIGINT},
user_id = #{userId,jdbcType=BIGINT},
reason = #{reason,jdbcType=VARCHAR},
disposal_method = #{disposalMethod,jdbcType=VARCHAR},
`status` = #{status,jdbcType=SMALLINT},
tenant_id = #{tenantId,jdbcType=VARCHAR},
update_time = sysdate(),
update_by = #{updateBy,jdbcType=VARCHAR}
update_by = #{updateBy,jdbcType=VARCHAR},
remark=#{remark}
where work_order_id = #{workOrderId,jdbcType=BIGINT}
</update>
<delete id="deleteOrderUserByOrderId">
delete from xhpc_work_order_user where order_id=#{orderId}
</delete>
</mapper>

View File

@ -38,7 +38,7 @@
park_nums, tenant_id
</sql>
<select id="selectListByParams">
<select id="selectListByParams" resultType="com.xhpc.workorder.domain.XhpcWorkStationDomain">
select
<include refid="Base_Column_List" />
from xhpc_work_station
@ -60,6 +60,31 @@
</select>
<select id="selectMapListByParams" resultType="map">
select
work_station_id as 'workStationId',
name as 'name',
type as 'type',
address as 'address',
serial_number as 'serialNumber'
from xhpc_work_station
<where>
<if test="params.name != null and params.name !=''">
and name like concat('%', #{params.name}, '%')
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and tenant_id = #{params.tenantId}
</if>
<if test="params.status != null">
and status=#{params.status}
</if>
<if test="params.delFlag!=null">
and del_flag=#{params.delFlag}
</if>
</where>
</select>
<select id="selectByName" resultType="com.xhpc.workorder.domain.XhpcWorkStationDomain">
select
<include refid="Base_Column_List" />

View File

@ -29,6 +29,25 @@
where user_name = #{userName} and phone=#{phone}
</select>
<select id="selectMapListByDeptId" resultType="map">
select
work_user_id as 'id',
user_name as 'name',
phone,
email
from xhpc_work_user
where del_flag=0 and status=1 and dept_id = #{deptId}
</select>
<select id="selectByOrderId" resultType="com.xhpc.workorder.domain.XhpcWorkUserDomain">
select
<include refid="Base_Column_List" />
FROM xhpc_work_user u
LEFT JOIN xhpc_work_order_user ou on ou.user_id=u.work_user_id
WHERE ou.order_id=#{orderId} and u.del_flag=0 and u.status=1
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />