diff --git a/sql/v2.1.sql b/sql/v2.1.sql index 11d87929..aa420405 100644 --- a/sql/v2.1.sql +++ b/sql/v2.1.sql @@ -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', diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkOrderController.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkOrderController.java index 0bbc8026..e5db871e 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkOrderController.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkOrderController.java @@ -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 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)); } diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkStationController.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkStationController.java index 3c5fc375..b03116ff 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkStationController.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/controller/WorkStationController.java @@ -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 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 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 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 params = new HashMap<>(); + params.put("tenantId", logUser.getTenantId()); + return R.ok(userService.getDeptAndUserByMap(params)); + } } diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcStationDeviceDomain.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcStationDeviceDomain.java index db64282b..a3e71a91 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcStationDeviceDomain.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcStationDeviceDomain.java @@ -69,6 +69,8 @@ public class XhpcStationDeviceDomain implements Serializable { @Excel(name = "设备编码") private String serialNumber; + private Integer sorted; + /** * 设备状态(0-未启用,1-正常,2-异常,3-维修中,4-待检测) */ diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderDomain.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderDomain.java index 3a596853..af53bf09 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderDomain.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderDomain.java @@ -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 userList; private List questionImgList; diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderUserDomain.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderUserDomain.java new file mode 100644 index 00000000..dfcb6817 --- /dev/null +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderUserDomain.java @@ -0,0 +1,13 @@ +package com.xhpc.workorder.domain; + + +import lombok.Data; + +@Data +public class XhpcWorkOrderUserDomain { + + private Long orderId; + + private Long userId; + +} diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcStationDeviceMapper.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcStationDeviceMapper.java index bdb19ca1..2a93ad24 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcStationDeviceMapper.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcStationDeviceMapper.java @@ -13,6 +13,9 @@ public interface XhpcStationDeviceMapper { List> selectStationGunDeviceTreeByParams(@Param("params") Map params); + + List> selectListByParent(@Param("params")Map params); + Map selectByDeviceId(@Param("deviceId") Long deviceId); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkDeptMapper.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkDeptMapper.java index 25e15bd7..b62833ec 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkDeptMapper.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkDeptMapper.java @@ -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 selectListByParams(@Param("params") Map params); + + List> selectMapListByParams(@Param("params") Map params); + + int deleteByPrimaryKey(Long workDeptId); int insert(XhpcWorkDeptDomain record); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderImageMapper.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderImageMapper.java index 9dc14d31..44b38acb 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderImageMapper.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderImageMapper.java @@ -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 selectByOrderIdAndType(Long orderId, Integer type); + List selectByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type); - List selectImageIdByOrderIdAndType(Long orderId, Integer type); + List selectImageIdByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type); int deleteByImageIds(List imageIds); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java index 69e7670c..12216b9f 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java @@ -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> 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 domainList); int deleteByPrimaryKey(Long workOrderId); @@ -25,4 +27,7 @@ public interface XhpcWorkOrderMapper { int updateByPrimaryKeySelective(XhpcWorkOrderDomain record); int updateByPrimaryKey(XhpcWorkOrderDomain record); + + + int deleteOrderUserByOrderId(Long orderId); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkStationMapper.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkStationMapper.java index 5550e166..1d27466c 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkStationMapper.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkStationMapper.java @@ -10,6 +10,8 @@ public interface XhpcWorkStationMapper { List selectListByParams(@Param("params") Map params); + List> selectMapListByParams(@Param("params") Map params); + XhpcWorkStationDomain selectByName(@Param("stationName") String stationName); int deleteByPrimaryKey(Long workStationId); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkUserMapper.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkUserMapper.java index b93b136b..d8ae76d7 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkUserMapper.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkUserMapper.java @@ -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> selectMapListByDeptId(@Param("deptId")String deptId); + + + List selectByOrderId(Long orderId); + int deleteByPrimaryKey(Long workUserId); int insert(XhpcWorkUserDomain record); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkStationService.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkStationService.java index cbd67304..c949114e 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkStationService.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkStationService.java @@ -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> getStationDevice(Map params); + List> getStationDeviceByParent(Map params); + + List getStationList(Map 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; diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkUserService.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkUserService.java index 18e5f4db..7d31c735 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkUserService.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkUserService.java @@ -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> getDeptAndUserByMap(Map params); + + XhpcWorkUserDomain findByPk(Long pk); + + List findByOrderId(Long orderId); } diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java index 04f83af1..0358d0ae 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java @@ -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 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 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 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 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 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; } diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java index f475aec0..c1496c47 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java @@ -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> getStationDeviceByParent(Map params){ + return deviceMapper.selectListByParent(params); + } + @Override public List getStationList(Map params){ return stationMapper.selectListByParams(params); @@ -38,16 +45,30 @@ public class WorkStationServiceImpl implements WorkStationService { @Override public List> getStationDeviceTree(Map params){ + Map stationParams = new HashMap<>(); + stationParams.put("name", params.get("stationName")); + stationParams.put("tenantId", params.get("tenantId")); + stationParams.put("status", 1); + stationParams.put("delFlag", 0); - List> resultData = deviceMapper.selectStationGunDeviceTreeByParams(params); - for (Map resultMap: resultData){ - List> childData = deviceMapper.selectStationGunDeviceTreeByParent(resultMap.get("deviceId").toString()); - if(childData != null){ - resultMap.put("children", childData); + List> stationDomainList = stationMapper.selectMapListByParams(stationParams); + for (Map stationMap: stationDomainList){ + if(StringUtils.isEmpty(params.get("stationName").toString())){ + params.put("stationName", stationMap.get("name")); + } + List> resultData = deviceMapper.selectStationGunDeviceTreeByParams(params); + for (Map resultMap: resultData){ + List> 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); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkUserServiceImpl.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkUserServiceImpl.java index 92411ff9..cb1a0b88 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkUserServiceImpl.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkUserServiceImpl.java @@ -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> getDeptAndUserByMap(Map params){ + List> deptDomains = deptMapper.selectMapListByParams(params); + for(Map deptMap: deptDomains){ + List> 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 findByOrderId(Long orderId){ + return workUserMapper.selectByOrderId(orderId); + } } diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/vo/XhpcStationDeviceVo.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/vo/XhpcStationDeviceVo.java new file mode 100644 index 00000000..8beaac64 --- /dev/null +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/vo/XhpcStationDeviceVo.java @@ -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; +} diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-workorder/src/main/resources/bootstrap.yml index f706f09d..3e08df7c 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/bootstrap.yml @@ -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' diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml index 410a0eeb..c31531d2 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml @@ -18,7 +18,7 @@ - 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 @@ -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' - + and s.name like concat('%', #{params.stationName}, '%') + + and s.work_station_id = #{params.stationId} + - and d1.device_name like concat('%', #{params.terminalName},'%') + and d2.device_name like concat('%', #{params.terminalName},'%') and s.tenant_id=#{params.tenantId} + order by d1.device_type, d1.sorted, d2.device_type, d2.sorted @@ -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 - + + and d1.device_name like concat('%', #{params.deviceName}, '%') + + and s.name like concat('%', #{params.stationName}, '%') @@ -101,6 +115,45 @@ and s.tenant_id=#{params.tenantId} + order by d1.station_id, d1.device_type, d1.sorted + + + + @@ -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 @@ -131,11 +187,11 @@ 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}) @@ -162,6 +218,9 @@ brand_model, + + `sorted`, + `status`, @@ -197,6 +256,9 @@ #{brandModel,jdbcType=VARCHAR}, + + #{sorted,jdbcType=SMALLINT}, + #{status,jdbcType=SMALLINT}, @@ -235,6 +297,9 @@ brand_model = #{brandModel,jdbcType=VARCHAR}, + + `sorted` = #{sorted,jdbcType=SMALLINT}, + `status` = #{status,jdbcType=SMALLINT}, @@ -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} diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkDeptMapper.xml b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkDeptMapper.xml index 6c86eaa1..1bd86675 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkDeptMapper.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkDeptMapper.xml @@ -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 + + + + + select - 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 - - from xhpc_work_order - where work_order_id = #{workOrderId,jdbcType=BIGINT} + , + 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} update xhpc_work_order set del_flag=2 @@ -77,17 +92,16 @@ 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 into xhpc_work_order @@ -110,12 +124,6 @@ serial_number, - - dept_id, - - - user_id, - reason, @@ -135,6 +143,9 @@ update_by, + + remark, + @@ -155,19 +166,13 @@ #{serialNumber,jdbcType=VARCHAR}, - - #{deptId,jdbcType=BIGINT}, - - - #{userId,jdbcType=BIGINT}, - #{reason,jdbcType=VARCHAR}, #{disposalMethod,jdbcType=VARCHAR}, - 0, + 1, 0, #{tenantId,jdbcType=VARCHAR}, @@ -180,6 +185,9 @@ #{updateBy,jdbcType=VARCHAR}, + + #{remark}, + @@ -203,12 +211,6 @@ serial_number = #{serialNumber,jdbcType=VARCHAR}, - - dept_id = #{deptId,jdbcType=BIGINT}, - - - user_id = #{userId,jdbcType=BIGINT}, - reason = #{reason,jdbcType=VARCHAR}, @@ -225,6 +227,9 @@ update_by = #{updateBy,jdbcType=VARCHAR}, + + remark=#{remark}, + where work_order_id = #{workOrderId,jdbcType=BIGINT} @@ -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} + + + + + delete from xhpc_work_order_user where order_id=#{orderId} + \ No newline at end of file diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkStationMapper.xml b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkStationMapper.xml index f6602e82..eba91709 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkStationMapper.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkStationMapper.xml @@ -38,7 +38,7 @@ park_nums, tenant_id - select from xhpc_work_station @@ -60,6 +60,31 @@ + + + + + + + +