From b56e262cf6f5f01933b8c7eadc42a4adb112f7af Mon Sep 17 00:00:00 2001 From: panshuling321 Date: Mon, 24 Jan 2022 17:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A5=E5=8D=95=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WorkOrderController.java | 34 ++++++--- .../controller/WorkStationController.java | 32 ++++---- .../workorder/domain/XhpcWorkOrderDomain.java | 6 ++ .../domain/XhpcWorkOrderImageDomain.java | 5 ++ .../mapper/XhpcStationDeviceMapper.java | 2 + .../mapper/XhpcWorkOrderImageMapper.java | 12 +++ .../workorder/service/WorkOrderService.java | 3 + .../workorder/service/WorkStationService.java | 2 + .../service/impl/WorkOrderServiceImpl.java | 75 ++++++++++++++++--- .../service/impl/WorkStationServiceImpl.java | 7 ++ .../mapper/XhpcStationDeviceMapper.xml | 23 ++++++ .../mapper/XhpcWorkOrderImageMapper.xml | 28 ++++++- 12 files changed, 190 insertions(+), 39 deletions(-) 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 88d2ad5c..9336ef00 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 @@ -1,17 +1,19 @@ package com.xhpc.workorder.controller; +import com.xhpc.common.core.domain.R; 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.XhpcWorkOrderDomain; import com.xhpc.workorder.service.WorkOrderService; 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; @@ -36,26 +38,34 @@ public class WorkOrderController extends BaseController { @Log(title = "工单-新增工单", businessType = BusinessType.INSERT) @PostMapping("/") - public AjaxResult insertNewOrder(@RequestBody XhpcWorkOrderDomain domain){ - return AjaxResult.success(workOrderService.insertOrder(domain)); + public R insertNewOrder(@RequestBody XhpcWorkOrderDomain domain){ + return R.ok(workOrderService.insertOrder(domain)); } - @GetMapping("/{orderId}") - public AjaxResult getOrderInfo(@PathVariable("orderId")Long orderId){ - return AjaxResult.success(workOrderService.selectOrderById(orderId)); + @GetMapping("/detail") + public R getOrderInfo(@RequestParam("orderId")Long orderId){ + return R.ok(workOrderService.selectOrderById(orderId)); } @Log(title = "工单-维护工单", businessType = BusinessType.UPDATE) - @PutMapping("/{orderId}") - public AjaxResult updateOrderInfo(@RequestBody XhpcWorkOrderDomain domain){ - return AjaxResult.success(workOrderService.updateOrder(domain)); + @PutMapping("/detail") + public R updateOrderInfo(@RequestBody XhpcWorkOrderDomain domain){ + return R.ok(workOrderService.updateOrder(domain)); } + @Log(title = "工单-处理工单", businessType = BusinessType.UPDATE) + @PutMapping("/reply") + public R replyOrder(@RequestBody XhpcWorkOrderDomain domain){ + return R.ok(workOrderService.replyOrder(domain)); + } + + + @Log(title = "工单-删除工单", businessType = BusinessType.DELETE) - @DeleteMapping("/{orderId}") - public AjaxResult deleteOrder(@PathVariable("orderId")Long orderId) throws Exception { - return AjaxResult.success(workOrderService.deleteOrder(orderId)); + @DeleteMapping("/detail") + public R deleteOrder(@PathVariable("orderId")Long orderId) throws Exception { + return R.ok(workOrderService.deleteOrder(orderId)); } } 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 b2cc1132..aaf2cbe7 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 @@ -1,9 +1,9 @@ package com.xhpc.workorder.controller; +import com.xhpc.common.core.domain.R; 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; @@ -53,38 +53,42 @@ public class WorkStationController extends BaseController { @Log(title = "场站设备-导入设备", businessType = BusinessType.INSERT) @PostMapping("/importData") - public AjaxResult importDevice(MultipartFile file, boolean updateSupport) throws Exception { + public R importDevice(MultipartFile file, boolean updateSupport) throws Exception { if(file == null){ - return AjaxResult.error("没有可导入的数据文件"); + return R.fail("没有可导入的数据文件"); } ExcelUtil util = new ExcelUtil(XhpcStationDeviceDomain.class); List deviceDomainList = util.importExcel(file.getInputStream()); String message = stationService.importDevice(deviceDomainList, updateSupport); - return AjaxResult.success(message); + return R.ok(message); + } + + + @GetMapping("/detail") + public R getDeviceDetail(@RequestParam("deviceId")Long deviceId) throws Exception{ + return R.ok(stationService.getDeviceDetail(deviceId)); } @Log(title = "场站设备-新增设备", businessType = BusinessType.INSERT) @PostMapping("/") - public AjaxResult insertNewDevice(@RequestBody XhpcStationDeviceDomain domain) throws Exception{ - return AjaxResult.success(stationService.insertDevice(domain)); + public R insertNewDevice(@RequestBody XhpcStationDeviceDomain domain) throws Exception{ + return R.ok(stationService.insertDevice(domain)); } @Log(title = "场站设备-维护设备信息", businessType = BusinessType.UPDATE) - @PutMapping("/{deviceId}") - public AjaxResult updateDeviceInfo(@RequestBody XhpcStationDeviceDomain domain, - @PathVariable("deviceId")Long deviceId){ + @PutMapping("/detail") + public R updateDeviceInfo(@RequestBody XhpcStationDeviceDomain domain){ - domain.setDeviceId(deviceId); - return AjaxResult.success(stationService.updateDevice(domain)); + return R.ok(stationService.updateDevice(domain)); } @Log(title = "场站设备-删除设备信息", businessType = BusinessType.DELETE) - @DeleteMapping("/{deviceId}") - public AjaxResult deleteDeviceInfo(@PathVariable("deviceId") Long deviceId) throws Exception { - return AjaxResult.success(stationService.deleteDevice(deviceId)); + @DeleteMapping("/detail") + public R deleteDeviceInfo(@RequestParam("deviceId") Long deviceId) throws Exception { + return R.ok(stationService.deleteDevice(deviceId)); } } 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 3263d63e..bed12de6 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 @@ -2,6 +2,7 @@ package com.xhpc.workorder.domain; import java.io.Serializable; import java.util.Date; +import java.util.List; import com.xhpc.common.core.annotation.Excel; import lombok.Data; @@ -108,5 +109,10 @@ public class XhpcWorkOrderDomain implements Serializable { private String userPhone; + + private List questionImgList; + + private List replyImgList; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderImageDomain.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderImageDomain.java index 90377412..fbdb167b 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderImageDomain.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/domain/XhpcWorkOrderImageDomain.java @@ -15,6 +15,11 @@ public class XhpcWorkOrderImageDomain implements Serializable { */ private Long orderImageId; + /** + * 工单ID + */ + private Long orderId; + /** * 文件名称 */ 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 622abc4a..bdb19ca1 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,8 @@ public interface XhpcStationDeviceMapper { List> selectStationGunDeviceTreeByParams(@Param("params") Map params); + Map selectByDeviceId(@Param("deviceId") Long deviceId); + List> selectStationGunDeviceTreeByParent(@Param("parentDeviceId") String parentDeviceId); 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 7319456a..dc23c504 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 @@ -2,7 +2,19 @@ package com.xhpc.workorder.mapper; import com.xhpc.workorder.domain.XhpcWorkOrderImageDomain; +import java.util.List; + public interface XhpcWorkOrderImageMapper { + + List selectByOrderIdAndType(Long orderId, Integer type); + + + List selectImageIdByOrderIdAndType(Long orderId, Integer type); + + int deleteByImageIds(List ids); + + + int deleteByPrimaryKey(Long orderImageId); int insert(XhpcWorkOrderImageDomain record); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkOrderService.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkOrderService.java index f42946bc..01bc5471 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkOrderService.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/WorkOrderService.java @@ -2,6 +2,7 @@ package com.xhpc.workorder.service; import com.xhpc.workorder.domain.XhpcWorkOrderDomain; +import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; @@ -14,6 +15,8 @@ public interface WorkOrderService { Boolean updateOrder(XhpcWorkOrderDomain domain); + Boolean replyOrder(XhpcWorkOrderDomain domain); + Boolean insertOrder(XhpcWorkOrderDomain domain); Boolean deleteOrder(Long orderId) throws Exception; 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 66a4ec51..4cdce7aa 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 @@ -15,6 +15,8 @@ public interface WorkStationService { String importDevice(List deviceDomainList, Boolean updateSupport); + Map getDeviceDetail(Long deviceId); + Boolean insertDevice(XhpcStationDeviceDomain domain) throws Exception; Boolean updateDevice(XhpcStationDeviceDomain domain); 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 e786899f..e909dcc6 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,21 +1,17 @@ package com.xhpc.workorder.service.impl; +import cn.hutool.core.bean.BeanUtil; 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; -import com.xhpc.workorder.domain.XhpcStationDeviceDomain; -import com.xhpc.workorder.domain.XhpcWorkOrderDomain; -import com.xhpc.workorder.domain.XhpcWorkOrderPushMessageDomain; -import com.xhpc.workorder.domain.XhpcWorkUserDomain; -import com.xhpc.workorder.mapper.XhpcStationDeviceMapper; -import com.xhpc.workorder.mapper.XhpcWorkOrderMapper; -import com.xhpc.workorder.mapper.XhpcWorkOrderPushMessageMapper; -import com.xhpc.workorder.mapper.XhpcWorkUserMapper; +import com.xhpc.workorder.domain.*; +import com.xhpc.workorder.mapper.*; import com.xhpc.workorder.service.WorkOrderService; import com.xhpc.workorder.service.WorkUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.HashMap; @@ -38,6 +34,9 @@ public class WorkOrderServiceImpl implements WorkOrderService { @Resource XhpcWorkOrderPushMessageMapper messageMapper; + @Resource + XhpcWorkOrderImageMapper imageMapper; + @Resource SmsService smsService; @@ -51,12 +50,59 @@ public class WorkOrderServiceImpl implements WorkOrderService { @Override public XhpcWorkOrderDomain selectOrderById(Long orderId){ - return orderMapper.selectByPrimaryKey(orderId); + + XhpcWorkOrderDomain orderDomain = orderMapper.selectByPrimaryKey(orderId); + orderDomain.setQuestionImgList(imageMapper.selectByOrderIdAndType(orderId, 1)); + orderDomain.setReplyImgList(imageMapper.selectByOrderIdAndType(orderId, 2)); + + return orderDomain; } @Override public Boolean updateOrder(XhpcWorkOrderDomain domain){ - return orderMapper.updateByPrimaryKeySelective(domain) > 0; + orderMapper.updateByPrimaryKeySelective(domain); + + List imageIds = imageMapper.selectImageIdByOrderIdAndType(domain.getWorkOrderId(), 1); + + for (XhpcWorkOrderImageDomain imageDomain: domain.getQuestionImgList()){ + if(StringUtils.isBlank(imageDomain.getOrderImageId().toString())){ + imageDomain.setOrderId(domain.getWorkOrderId()); + imageDomain.setType(Short.valueOf("1")); + imageDomain.setDelFlag(Short.valueOf("0")); + imageMapper.insertSelective(imageDomain); + } else { + if(imageIds.contains(imageDomain.getOrderImageId())){ + imageIds.remove(imageDomain.getOrderImageId()); + } + } + } + if(imageIds.size() > 0){ + imageMapper.deleteByImageIds(imageIds); + } + + return true; + } + + + @Override + public Boolean replyOrder(XhpcWorkOrderDomain domain){ + XhpcWorkOrderDomain orderDomain = orderMapper.selectByPrimaryKey(domain.getWorkOrderId()); + if(orderDomain == null){ + throw new RuntimeException("订单不存在"); + } + + orderDomain.setReason(domain.getReason()); + orderDomain.setDisposalMethod(domain.getDisposalMethod()); + orderDomain.setStatus(Short.valueOf("2")); + orderMapper.updateByPrimaryKeySelective(orderDomain); + + for(XhpcWorkOrderImageDomain imageDomain: domain.getReplyImgList()){ + imageDomain.setOrderId(domain.getWorkOrderId()); + imageDomain.setType(Short.valueOf("2")); + imageDomain.setDelFlag(Short.valueOf("0")); + imageMapper.insertSelective(imageDomain); + } + return true; } @Override @@ -88,6 +134,15 @@ public class WorkOrderServiceImpl implements WorkOrderService { domain.getTitle(), domain.getUserId()); + // 上传文件 + for(XhpcWorkOrderImageDomain imageDomain : domain.getQuestionImgList()){ + imageDomain.setOrderId(resDomain.getWorkOrderId()); + imageDomain.setType(Short.valueOf("1")); + imageDomain.setDelFlag(Short.valueOf("0")); + imageMapper.insertSelective(imageDomain); + } + + HashMap paramMap = new HashMap<>(); paramMap.put("orderNo", resDomain.getWorkOrderId().toString()); paramMap.put("phone", domain.getUserPhone()); 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 b245bc4f..01bab7e2 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 @@ -85,6 +85,13 @@ public class WorkStationServiceImpl implements WorkStationService { return successMsg.toString(); } + + @Override + public Map getDeviceDetail(Long deviceId){ + return deviceMapper.selectByDeviceId(deviceId); + } + + @Override public Boolean insertDevice(XhpcStationDeviceDomain domain) throws Exception{ 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 6795fea8..410a0eeb 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml @@ -58,6 +58,29 @@ + + + + select + order_image_id + from xhpc_work_order_image + where order_id = #{orderId,jdbcType=BIGINT} and type = #{type} + + + + delete from xhpc_work_order_image + where order_image_id in + + #{id} + + + + +