新增工单问题类型的管理

This commit is contained in:
panshuling321 2022-03-02 16:35:04 +08:00
parent ba608fba51
commit 3ee4b263ee
7 changed files with 494 additions and 61 deletions

View File

@ -0,0 +1,103 @@
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.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.XhpcWorkTypeDictDomain;
import com.xhpc.workorder.service.WorkTypeService;
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("/type")
public class WorkTypeController extends BaseController {
@Resource
WorkTypeService typeService;
@Resource
LogUserUtils logUserUtils;
@GetMapping("/getPage")
public TableDataInfo getPage(HttpServletRequest request){
LoginUser loginUser = logUserUtils.getLogUser(request);
startPage();
Map<String, Object> params = new HashMap<>();
params.put("tenantId", loginUser.getTenantId());
return getDataTable(typeService.getPage(params));
}
@GetMapping("/getList")
public R getList(HttpServletRequest request){
LoginUser loginUser = logUserUtils.getLogUser(request);
Map<String, Object> params = new HashMap<>();
params.put("tenantId", loginUser.getTenantId());
return R.ok(typeService.getList(params));
}
@GetMapping("/getTree")
public R getTree(HttpServletRequest request){
LoginUser loginUser = logUserUtils.getLogUser(request);
Map<String, Object> params = new HashMap<>();
params.put("tenantId", loginUser.getTenantId());
return R.ok(typeService.getTree(params));
}
@GetMapping("/detail")
public R getTypeInfo(@RequestParam Integer typeId){
return R.ok(typeService.getInfoByPk(typeId));
}
@PostMapping("/")
@Log(title = "工单类型-新增工单类型", businessType = BusinessType.INSERT)
public R insertTypeInfo(HttpServletRequest request, @RequestBody XhpcWorkTypeDictDomain domain){
LoginUser loginUser = logUserUtils.getLogUser(request);
domain.setCreateBy(loginUser.getUsername());
domain.setUpdateBy(loginUser.getUsername());
domain.setTenantId(loginUser.getTenantId());
return R.ok(typeService.insertTypeInfo(domain));
}
@PutMapping("/detail")
@Log(title = "工单类型-更新工单类型信息", businessType = BusinessType.UPDATE)
public R updateTypeInfo(HttpServletRequest request, @RequestBody XhpcWorkTypeDictDomain domain){
LoginUser loginUser = logUserUtils.getLogUser(request);
domain.setTenantId(loginUser.getTenantId());
domain.setUpdateBy(loginUser.getUsername());
return R.ok(typeService.updateTypeInfo(domain));
}
@DeleteMapping("/detail")
@Log(title = "工单类型-删除工单类型", businessType = BusinessType.DELETE)
public R deleteTypeInfo(@RequestParam Integer typeId){
return R.ok(typeService.deleteTypeInfo(typeId));
}
}

View File

@ -0,0 +1,67 @@
package com.xhpc.workorder.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class XhpcWorkTypeDictDomain implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 类型ID
*/
private Integer workTypeId;
/**
* 类型名称
*/
private String name;
/**
* 父级类型ID
*/
private Integer parentTypeId;
/**
* 状态0-禁用1-启用
*/
private Integer status;
/**
* 删除标识0-正常2-已删除
*/
private Integer delFlag;
/**
* 排序
*/
private Integer sort;
/**
* 租户ID
*/
private String tenantId;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private String createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private String updateBy;
}

View File

@ -1,61 +0,0 @@
package com.xhpc.workorder.enums;
public enum WorkOrderTypeEnum {
PILE_OFFLINE(1, "充电桩离线"),
PILE_ERROR(2, "充电桩异常"),
TERMINAL_OFFLINE(3, "终端离线"),
TERMINAL_ERROR(4, "终端异常"),
BARRIER_OFFLINE(5, "道闸离线"),
BARRIER_ERROR(6, "道闸异常"),
GROUND_LOCK_OFFLINE(7, "地锁离线"),
GROUND_LOCK_ERROR(8, "地锁异常"),
CHARGING_ORDER_ERROR(20, "充电订单异常"),
ORDER_PUSH_EVCS_ERROR(21, "订单推送监管异常"),
ORDER_PUSH_THIRD_ERROR(22, "订单推送第三方异常"),
;
private final Integer code;
private final String name;
WorkOrderTypeEnum(Integer code, String name){
this.code = code;
this.name = name;
}
//根据code获取name
public static String getNameByCode(Integer code) {
for (WorkOrderTypeEnum typeEnum : WorkOrderTypeEnum.values()) {
if (code.equals(typeEnum.code)) {
return typeEnum.name;
}
}
return "";
}
//根据code获取name
public static Integer getCodeByName(String name) {
for (WorkOrderTypeEnum typeEnum : WorkOrderTypeEnum.values()) {
//移除交办
if (typeEnum.name.equals(name)) {
return typeEnum.code;
}
}
return null;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}

View File

@ -0,0 +1,32 @@
package com.xhpc.workorder.mapper;
import com.xhpc.workorder.domain.XhpcWorkTypeDictDomain;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface XhpcWorkTypeDictMapper {
List<XhpcWorkTypeDictDomain> selectListByParams(@Param("params") Map params);
List<Map<String, Object>> selectMapListByParams(@Param("params") Map params);
List<Map<String, Object>> selectMapListByParentParams(@Param("params") Map params);
int deleteByPrimaryKeyLogic(Integer workTypeId);
int insert(XhpcWorkTypeDictDomain record);
int insertSelective(XhpcWorkTypeDictDomain record);
XhpcWorkTypeDictDomain selectByPrimaryKey(Integer workTypeId);
XhpcWorkTypeDictDomain selectByName(String name);
int updateByPrimaryKeySelective(XhpcWorkTypeDictDomain record);
int updateByPrimaryKey(XhpcWorkTypeDictDomain record);
}

View File

@ -0,0 +1,24 @@
package com.xhpc.workorder.service;
import com.xhpc.workorder.domain.XhpcWorkTypeDictDomain;
import java.util.List;
import java.util.Map;
public interface WorkTypeService {
List<XhpcWorkTypeDictDomain> getPage(Map<String, Object> params);
List<Map<String, Object>> getList(Map<String, Object> params);
List<Map<String, Object>> getTree(Map<String, Object> params);
XhpcWorkTypeDictDomain getInfoByPk(Integer typeId);
Boolean insertTypeInfo(XhpcWorkTypeDictDomain domain);
Boolean updateTypeInfo(XhpcWorkTypeDictDomain domain);
Boolean deleteTypeInfo(Integer typeId);
}

View File

@ -0,0 +1,88 @@
package com.xhpc.workorder.service.impl;
import com.xhpc.common.core.exception.CustomException;
import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.workorder.domain.XhpcWorkTypeDictDomain;
import com.xhpc.workorder.mapper.XhpcWorkTypeDictMapper;
import com.xhpc.workorder.service.WorkTypeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
public class WorkTypeServiceImpl implements WorkTypeService {
@Resource
XhpcWorkTypeDictMapper typeDictMapper;
@Override
public List<XhpcWorkTypeDictDomain> getPage(Map<String, Object> params){
return typeDictMapper.selectListByParams(params);
}
@Override
public List<Map<String, Object>> getList(Map<String, Object> params){
return typeDictMapper.selectMapListByParams(params);
}
@Override
public List<Map<String, Object>> getTree(Map<String, Object> params){
List<Map<String, Object>> typeList = typeDictMapper.selectMapListByParentParams(params);
for (Map<String, Object> map : typeList){
params.put("parentTypeId", map.get("id"));
List<Map<String, Object>> childList = typeDictMapper.selectMapListByParentParams(params);
for (Map<String, Object> childMap: childList){
params.put("parentTypeId", childMap.get("id"));
List<Map<String, Object>> dataList = typeDictMapper.selectMapListByParentParams(params);
childMap.put("children", dataList);
}
map.put("children", childList);
}
return typeList;
}
@Override
public XhpcWorkTypeDictDomain getInfoByPk(Integer typeId){
return typeDictMapper.selectByPrimaryKey(typeId);
}
@Override
public Boolean insertTypeInfo(XhpcWorkTypeDictDomain domain){
if(StringUtils.isEmpty(domain.getName())){
throw new CustomException("名称不能为空");
}
XhpcWorkTypeDictDomain exitsDomain = typeDictMapper.selectByName(domain.getName());
if(exitsDomain != null) {
throw new CustomException("名称不能重复");
}
return typeDictMapper.insertSelective(domain) > 0;
}
@Override
public Boolean updateTypeInfo(XhpcWorkTypeDictDomain domain){
if(StringUtils.isEmpty(domain.getName())){
throw new CustomException("名称不能为空");
}
XhpcWorkTypeDictDomain exitsDomain = typeDictMapper.selectByName(domain.getName());
if(exitsDomain != null) {
throw new CustomException("名称不能重复");
}
return typeDictMapper.updateByPrimaryKeySelective(domain) > 0;
}
@Override
public Boolean deleteTypeInfo(Integer typeId){
return typeDictMapper.deleteByPrimaryKeyLogic(typeId) > 0;
}
}

View File

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.workorder.mapper.XhpcWorkTypeDictMapper">
<resultMap id="BaseResultMap" type="com.xhpc.workorder.domain.XhpcWorkTypeDictDomain">
<id column="work_type_id" jdbcType="INTEGER" property="workTypeId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="sort" jdbcType="SMALLINT" property="sort" />
<result column="parent_type_id" jdbcType="INTEGER" property="parentTypeId" />
<result column="status" jdbcType="SMALLINT" property="status" />
<result column="del_flag" jdbcType="SMALLINT" property="delFlag" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
</resultMap>
<sql id="Base_Column_List">
work_type_id, name, sort, parent_type_id, `status`, del_flag, tenant_id,
create_time, create_by, update_time, update_by
</sql>
<select id="selectListByParams" resultType="com.xhpc.workorder.domain.XhpcWorkTypeDictDomain">
select
<include refid="Base_Column_List" />
from xhpc_work_type_dict
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_type_id as 'id',
name as 'name'
from xhpc_work_type_dict
where del_flag = 0 and status = 1
<if test="params.tenantId !=null and params.tenantId!=''">
and tenant_id=#{params.tenantId}
</if>
</select>
<select id="selectMapListByParentParams" resultType="map">
select
work_type_id as 'id',
name as 'name'
from xhpc_work_type_dict
where del_flag = 0 and status = 1
<if test="params.tenantId !=null and params.tenantId!=''">
and tenant_id=#{params.tenantId}
</if>
<choose>
<when test="params.parentTypeId!=null and params.parentTypeId!='' ">
and parent_type_id=#{params.parentTypeId}
</when>
<otherwise>
and (parent_type_id is null or parent_type_id='')
</otherwise>
</choose>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xhpc_work_type_dict
where work_type_id = #{workTypeId,jdbcType=INTEGER}
</select>
<select id="selectByName" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xhpc_work_type_dict
where name = #{name}
</select>
<update id="deleteByPrimaryKeyLogic" parameterType="java.lang.Integer">
update xhpc_work_type_dict set del_flag=2
where work_type_id = #{workTypeId,jdbcType=INTEGER}
</update>
<insert id="insert" keyColumn="work_type_id" keyProperty="workTypeId" parameterType="com.xhpc.workorder.domain.XhpcWorkTypeDictDomain" useGeneratedKeys="true">
insert into xhpc_work_type_dict (name, sort,
parent_type_id, `status`, del_flag,
tenant_id, create_time, create_by,
update_time, update_by)
values (#{name,jdbcType=VARCHAR}, #{sort,jdbcType=SMALLINT},
#{parentTypeId,jdbcType=INTEGER}, #{status,jdbcType=SMALLINT}, 0,
#{tenantId,jdbcType=VARCHAR}, SYSDATE(), #{createBy,jdbcType=VARCHAR},
SYSDATE(), #{updateBy,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="work_type_id" keyProperty="workTypeId" parameterType="com.xhpc.workorder.domain.XhpcWorkTypeDictDomain" useGeneratedKeys="true">
insert into xhpc_work_type_dict
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
name,
</if>
<if test="sort != null">
sort,
</if>
<if test="parentTypeId != null">
parent_type_id,
</if>
<if test="status != null">
`status`,
</if>
del_flag,
<if test="tenantId != null">
tenant_id,
</if>
create_time,
<if test="createBy != null">
create_by,
</if>
update_time,
<if test="updateBy != null">
update_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=SMALLINT},
</if>
<if test="parentTypeId != null">
#{parentTypeId,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=SMALLINT},
</if>
0,
<if test="tenantId != null">
#{tenantId,jdbcType=VARCHAR},
</if>
SYSDATE(),
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
SYSDATE(),
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.workorder.domain.XhpcWorkTypeDictDomain">
update xhpc_work_type_dict
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=SMALLINT},
</if>
<if test="parentTypeId != null">
parent_type_id = #{parentTypeId,jdbcType=INTEGER},
</if>
<if test="status != null">
`status` = #{status,jdbcType=SMALLINT},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=VARCHAR},
</if>
update_time = SYSDATE(),
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
</set>
where work_type_id = #{workTypeId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.workorder.domain.XhpcWorkTypeDictDomain">
update xhpc_work_type_dict
set name = #{name,jdbcType=VARCHAR},
sort = #{sort,jdbcType=SMALLINT},
parent_type_id = #{parentTypeId,jdbcType=INTEGER},
`status` = #{status,jdbcType=SMALLINT},
tenant_id = #{tenantId,jdbcType=VARCHAR},
update_time = SYSDATE(),
update_by = #{updateBy,jdbcType=VARCHAR}
where work_type_id = #{workTypeId,jdbcType=INTEGER}
</update>
</mapper>