Commit 8382f00b authored by lisong's avatar lisong

添加管段相关接口

parent 73b878c8
package com.yeejoin.amos.boot.module.ugp.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "PipeDto", description = "管段信息")
public class PipeDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "管段名称")
private String pipeName;
@ApiModelProperty(value = "施工图号")
private String constructionDrawingNum;
@ApiModelProperty(value = "管段编号")
private String pipeCode;
@ApiModelProperty(value = "管段级别")
private String pipeLevel;
@ApiModelProperty(value = "管段起点(经纬度)")
private String startPosition;
@ApiModelProperty(value = "管段终点(经纬度)")
private String endPosition;
@ApiModelProperty(value = "管段长度")
private Float length;
@ApiModelProperty(value = "材质")
private String material;
@ApiModelProperty(value = "规格")
private String specification;
@ApiModelProperty(value = "设计压力")
private Float designPressure;
@ApiModelProperty(value = "设计温度")
private Float designTemperature;
@ApiModelProperty(value = "介质")
private String medium;
@ApiModelProperty(value = "关联项目id")
private Long projectId;
@ApiModelProperty(value = "起点名称")
private String startName;
@ApiModelProperty(value = "终点名称")
private String endName;
}
package com.yeejoin.amos.boot.module.ugp.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tz_ugp_pipe")
public class Pipe extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 管段名称
*/
@TableField("pipe_name")
private String pipeName;
/**
* 施工图号
*/
@TableField("construction_drawing_num")
private String constructionDrawingNum;
/**
* 管段编号
*/
@TableField("pipe_code")
private String pipeCode;
/**
* 管段级别
*/
@TableField("pipe_level")
private String pipeLevel;
/**
* 管段起点(经纬度)
*/
@TableField("start_position")
private String startPosition;
/**
* 管段终点(经纬度)
*/
@TableField("end_position")
private String endPosition;
/**
* 管段长度
*/
@TableField("length")
private Float length;
/**
* 材质
*/
@TableField("material")
private String material;
/**
* 规格
*/
@TableField("specification")
private String specification;
/**
* 设计压力
*/
@TableField("design_pressure")
private Float designPressure;
/**
* 设计温度
*/
@TableField("design_temperature")
private Float designTemperature;
/**
* 介质
*/
@TableField("medium")
private String medium;
/**
* 关联项目id
*/
@TableField("project_id")
private Long projectId;
/**
* 起点名称
*/
@TableField("start_name")
private String startName;
/**
* 终点名称
*/
@TableField("end_name")
private String endName;
}
package com.yeejoin.amos.boot.module.ugp.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ugp.api.entity.Pipe;
import org.springframework.stereotype.Repository;
@Repository
public interface PipeMapper extends BaseMapper<Pipe> {
}
package com.yeejoin.amos.boot.module.ugp.api.service;
public interface IPipeService {
void addPipeMessage(String jsonMessage, Long projectId);
}
<?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.yeejoin.amos.boot.module.ugp.api.mapper.PipeMapper">
</mapper>
\ No newline at end of file
package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.ugp.api.dto.PipeDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Pipe;
import com.yeejoin.amos.boot.module.ugp.api.service.IPipeService;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.IPipeServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@Api(tags = "管段信息Api")
@RequestMapping(value = "/pipe")
public class PipeController extends BaseController {
@Autowired
IPipeServiceImpl pipeService;
@Autowired
IPipeService pipeService1;
@Autowired
private RedisUtils redisUtils;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增管段信息", notes = "新增管段信息")
public ResponseModel<List<PipeDto>> save(@RequestBody List<PipeDto> list) {
List<PipeDto> result = new ArrayList<>();
list.forEach(item -> {
item.setProjectId(1234567890L);
PipeDto withModel = pipeService.createWithModel(item);
result.add(withModel);
});
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据管段id查询管段信息", notes = "根据管段id查询管段信息")
public ResponseModel<String> getMessage(@PathVariable Long sequenceNbr) {
LambdaQueryWrapper<Pipe> lambda = new QueryWrapper<Pipe>().lambda();
lambda.eq(Pipe::getProjectId, sequenceNbr);
List<Pipe> pipes = pipeService.lambdaQuery().getBaseMapper().selectList(lambda);
String jArr = JSON.toJSONString(pipes);
return ResponseHelper.buildResponse(jArr);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/addPipeMessage")
@ApiOperation(httpMethod = "POST", value = "新增管段信息", notes = "新增管段信息")
public ResponseModel<Object> save(@RequestParam(value = "json") String json,
@RequestParam(value = "projectId") Long projectId) {
pipeService1.addPipeMessage(json, projectId);
return ResponseHelper.buildResponse("s");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCompanyMessage")
@ApiOperation(httpMethod = "GET", value = "查询当前人所有单位-下拉选择", notes = "查询当前人所有单位")
public ResponseModel<Object> getCompanyMessage() {
List<Map<String, Object>> list = new ArrayList<>();
String exeUserId = RequestContext.getExeUserId();
FeignClientResult<AgencyUserModel> agencyUserModelFeignClientResult = Privilege.agencyUserClient.queryByUserId(exeUserId);
if (!ObjectUtils.isEmpty(agencyUserModelFeignClientResult) && !ObjectUtils.isEmpty(agencyUserModelFeignClientResult.getResult()) && !ObjectUtils.isEmpty(agencyUserModelFeignClientResult.getResult().getCompanys())) {
List<CompanyModel> companies = agencyUserModelFeignClientResult.getResult().getCompanys();
companies.forEach(item -> {
HashMap<String, Object> result = new HashMap<>();
result.put("name", item.getCompanyName());
result.put("value", item.getSequenceNbr());
list.add(result);
});
return ResponseHelper.buildResponse(list);
} else {
return ResponseHelper.buildResponse(null);
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getRoles")
@ApiOperation(httpMethod = "GET", value = "查询当前人某单位下角色-下拉选择", notes = "查询当前人某单位下角色")
public ResponseModel<Object> getRoles(@RequestParam Long companyId) {
String exeUserId = RequestContext.getExeUserId();
FeignClientResult<AgencyUserModel> agencyUserModelFeignClientResult = Privilege.agencyUserClient.queryByUserId(exeUserId);
if (!ObjectUtils.isEmpty(agencyUserModelFeignClientResult) && !ObjectUtils.isEmpty(agencyUserModelFeignClientResult.getResult()) && !ObjectUtils.isEmpty(agencyUserModelFeignClientResult.getResult().getOrgRoles())) {
Map<Long, List<RoleModel>> orgRoles = agencyUserModelFeignClientResult.getResult().getOrgRoles();
if (!ObjectUtils.isEmpty(orgRoles)) {
List<RoleModel> roleModels = orgRoles.get(companyId);
return ResponseHelper.buildResponse(roleModels);
}
}
return ResponseHelper.buildResponse(null);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/changeUserMessage")
@ApiOperation(httpMethod = "POST", value = "跳转选择公司、角色后修改用户登录缓存西信息", notes = "跳转选择公司、角色后修改用户登录缓存西信息")
public ResponseModel<Object> changeUserMessage(@RequestParam(value = "companyId") String companyId,
@RequestParam(value = "roleId") String roleId) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (!ObjectUtils.isEmpty(reginParams) && !ObjectUtils.isEmpty(reginParams.getCompany())) {
CompanyBo company = reginParams.getCompany();
company.setSequenceNbr(Long.valueOf(companyId));
reginParams.setCompany(company);
String result = JSON.toJSONString(reginParams);
redisUtils.set(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()), result);
return ResponseHelper.buildResponse(company);
} else {
return ResponseHelper.buildResponse(null);
}
}
}
package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.ugp.api.dto.PipeDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Pipe;
import com.yeejoin.amos.boot.module.ugp.api.mapper.PipeMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IPipeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
@Service
public class IPipeServiceImpl extends BaseService<PipeDto, Pipe, PipeMapper> implements IPipeService {
@Autowired
PipeMapper pipeMapper;
@Override
@Transactional
public void addPipeMessage(String jsonMessage, Long projectId) {
List<PipeDto> userList2 = JSON.parseArray(jsonMessage, PipeDto.class);
if (!ObjectUtils.isEmpty(userList2)) {
LambdaQueryWrapper<Pipe> lambda = new QueryWrapper<Pipe>().lambda();
lambda.eq(Pipe::getProjectId, projectId);
pipeMapper.delete(lambda);
userList2.forEach(item -> {
item.setProjectId(projectId);
this.createWithModel(item);
});
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment