增加工单处理

This commit is contained in:
panshuling321 2022-01-24 17:23:53 +08:00
parent c819bc13ba
commit b56e262cf6
12 changed files with 190 additions and 39 deletions

View File

@ -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));
}
}

View File

@ -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<XhpcStationDeviceDomain> util = new ExcelUtil<XhpcStationDeviceDomain>(XhpcStationDeviceDomain.class);
List<XhpcStationDeviceDomain> 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));
}
}

View File

@ -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<XhpcWorkOrderImageDomain> questionImgList;
private List<XhpcWorkOrderImageDomain> replyImgList;
private static final long serialVersionUID = 1L;
}

View File

@ -15,6 +15,11 @@ public class XhpcWorkOrderImageDomain implements Serializable {
*/
private Long orderImageId;
/**
* 工单ID
*/
private Long orderId;
/**
* 文件名称
*/

View File

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

View File

@ -2,7 +2,19 @@ package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkOrderImageDomain;
import java.util.List;
public interface XhpcWorkOrderImageMapper {
List<XhpcWorkOrderImageDomain> selectByOrderIdAndType(Long orderId, Integer type);
List<Long> selectImageIdByOrderIdAndType(Long orderId, Integer type);
int deleteByImageIds(List<Long> ids);
int deleteByPrimaryKey(Long orderImageId);
int insert(XhpcWorkOrderImageDomain record);

View File

@ -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;

View File

@ -15,6 +15,8 @@ public interface WorkStationService {
String importDevice(List<XhpcStationDeviceDomain> deviceDomainList, Boolean updateSupport);
Map<String, Object> getDeviceDetail(Long deviceId);
Boolean insertDevice(XhpcStationDeviceDomain domain) throws Exception;
Boolean updateDevice(XhpcStationDeviceDomain domain);

View File

@ -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<Long> 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<String, String> paramMap = new HashMap<>();
paramMap.put("orderNo", resDomain.getWorkOrderId().toString());
paramMap.put("phone", domain.getUserPhone());

View File

@ -85,6 +85,13 @@ public class WorkStationServiceImpl implements WorkStationService {
return successMsg.toString();
}
@Override
public Map<String, Object> getDeviceDetail(Long deviceId){
return deviceMapper.selectByDeviceId(deviceId);
}
@Override
public Boolean insertDevice(XhpcStationDeviceDomain domain) throws Exception{

View File

@ -58,6 +58,29 @@
</select>
<select id="selectByDeviceId" resultType="java.util.Map">
select
d.device_id as 'deviceId',
d.device_name as 'deviceName',
d.device_type as 'deviceType',
d.current_type as 'currentType',
d.station_id as 'stationId',
d.brand_model as 'brandModel',
d.parent_device_id as 'parengDeviceId',
d.serial_number as 'serialNumber',
d.`status` as 'status',
d.del_flag as 'delFlag',
d.create_time as 'createTime',
d.create_by as 'createBy',
d.update_time as 'updateTime',
d.update_by as 'updateBy',
s.name as 'stationName'
from xhpc_station_device d
left join xhpc_work_station s on d.station_id=s.work_station_id
where device_id = #{deviceId,jdbcType=INTEGER}
</select>
<select id="selectStationGunDeviceTreeByParams" resultType="map">
SELECT
s.`name` as 'stationName',

View File

@ -3,6 +3,7 @@
<mapper namespace="com.xhpc.workorder.mapper.XhpcWorkOrderImageMapper">
<resultMap id="BaseResultMap" type="com.xhpc.workorder.domain.XhpcWorkOrderImageDomain">
<id column="order_image_id" jdbcType="BIGINT" property="orderImageId" />
<result column="order_id" jdbcType="BIGINT" property="orderId"/>
<result column="file_name" jdbcType="VARCHAR" property="fileName" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="type" jdbcType="SMALLINT" property="type" />
@ -11,8 +12,31 @@
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
</resultMap>
<sql id="Base_Column_List">
order_image_id, file_name, url, `type`, del_flag, create_time, create_by
order_image_id, order_id, file_name, url, `type`, del_flag, create_time, create_by
</sql>
<select id="selectImageIdByOrderIdAndType" resultType="java.lang.Long">
select
order_image_id
from xhpc_work_order_image
where order_id = #{orderId,jdbcType=BIGINT} and type = #{type}
</select>
<delete id="deleteByImageIds">
delete from xhpc_work_order_image
where order_image_id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<select id="selectByOrderIdAndType" resultType="com.xhpc.workorder.domain.XhpcWorkOrderImageDomain">
select
<include refid="Base_Column_List" />
from xhpc_work_order_image
where order_id = #{orderId,jdbcType=BIGINT} and type = #{type}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
@ -90,8 +114,6 @@
set file_name = #{fileName,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
`type` = #{type,jdbcType=SMALLINT},
create_time = SYSDATE(),
create_by = #{createBy,jdbcType=VARCHAR}
where order_image_id = #{orderImageId,jdbcType=BIGINT}
</update>
</mapper>