木垒添加吊装作业
This commit is contained in:
parent
17da925e66
commit
995bd33dab
@ -246,6 +246,9 @@ public class FlowOrgRepositoryServiceImpl implements OrgRepositoryService {
|
||||
Set<Long> userIds = baseRoleUserMapper.selectList(new LambdaQueryWrapper<BaseRoleUser>()
|
||||
.in(BaseRoleUser::getRoleId, roles)).stream()
|
||||
.map(u -> u.getUserId()).collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
userIds.add(0L);
|
||||
}
|
||||
return systemUserMapper.selectList(Wrappers.<SystemUser>lambdaQuery().in(SystemUser::getUserId, userIds).eq(SystemUser::getSn, projectSn))
|
||||
.stream().map(u -> u.getUserId().toString()).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@ -0,0 +1,199 @@
|
||||
package com.zhgd.xmgl.modules.mulei.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.mulei.entity.MlHoist;
|
||||
import com.zhgd.xmgl.modules.mulei.service.IMlHoistService;
|
||||
import com.zhgd.xmgl.modules.video.entity.VideoItem;
|
||||
import com.zhgd.xmgl.modules.video.service.IVideoItemService;
|
||||
import com.zhgd.xmgl.util.FlowUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.simpleframework.xml.core.Validate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
/**
|
||||
* @Title: Controller
|
||||
* @Description: 吊装作业
|
||||
* @author: pds
|
||||
* @date: 2024-09-14
|
||||
* @version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/mlHoist")
|
||||
@Slf4j
|
||||
@Api(tags = "吊装作业相关Api")
|
||||
public class MlHoistController {
|
||||
@Autowired
|
||||
private IMlHoistService mlHoistService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IVideoItemService videoItemService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "吊装作业管理", operType = "分页查询", operDesc = "分页列表查询吊装作业信息")
|
||||
@ApiOperation(value = "分页列表查询吊装作业信息", notes = "分页列表查询吊装作业信息", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
|
||||
})
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<MlHoist>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
return Result.success(mlHoistService.queryPageList(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "吊装作业管理", operType = "列表查询", operDesc = "列表查询吊装作业信息")
|
||||
@ApiOperation(value = "列表查询吊装作业信息", notes = "列表查询吊装作业信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<MlHoist>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
return Result.success(mlHoistService.queryList(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param mlHoist
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "吊装作业管理", operType = "添加", operDesc = "添加吊装作业信息")
|
||||
@ApiOperation(value = "添加吊装作业信息", notes = "添加吊装作业信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<MlHoist> add(@RequestBody @Validate MlHoist mlHoist) {
|
||||
mlHoistService.add(mlHoist);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@OperLog(operModul = "吊装作业管理", operType = "添加", operDesc = "工作流添加吊装作业信息")
|
||||
@ApiOperation(value = "工作流添加吊装作业信息", notes = "工作流添加吊装作业信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/flow/add")
|
||||
public Result<MlHoist> addFromFlow(@RequestBody @Validate Map<String, Object> map) {
|
||||
log.info("工作流添加吊装作业信息:{}", JSON.toJSONString(map));
|
||||
Long videoItemId = FlowUtil.getPullDownLong(map, "videoItemId");
|
||||
String num = FlowUtil.getString(map, "num");
|
||||
String projectSn = FlowUtil.getString(map, "projectSn");
|
||||
MlHoist hoist = new MlHoist();
|
||||
hoist.setVideoItemId(videoItemId);
|
||||
hoist.setNum(num);
|
||||
hoist.setProjectSn(projectSn);
|
||||
mlHoistService.add(hoist);
|
||||
VideoItem item = new VideoItem();
|
||||
item.setItemId(videoItemId);
|
||||
item.setIsFlowPass(1);
|
||||
videoItemService.updateById(item);
|
||||
item = videoItemService.getById(item.getItemId());
|
||||
VideoItem finalItem = item;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
//木垒转发
|
||||
map.put("projectSn", "58FD625B512E4592B7E63C3797442D2C");
|
||||
map.put("serialNumber", finalItem.getSerialNumber());
|
||||
String result2 = HttpRequest.post("http://222.80.185.228:6090/xmgl/mlHoist/flow/add/transpond")
|
||||
.form(map)
|
||||
.timeout(2000)//超时,毫秒
|
||||
.execute().body();
|
||||
log.info("工作流添加吊装作业信息转发结果:{}", result2);
|
||||
});
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "工作流添加吊装作业信息转发", notes = "工作流添加吊装作业信息转发", httpMethod = "POST")
|
||||
@PostMapping(value = "/flow/add/transpond")
|
||||
public Result<MlHoist> addFromFlowTranspond(@RequestBody @Validate Map<String, Object> map) {
|
||||
log.info("工作流添加吊装作业信息转发:{}", JSON.toJSONString(map));
|
||||
Long serialNumber = FlowUtil.getPullDownLong(map, "serialNumber");
|
||||
String num = FlowUtil.getString(map, "num");
|
||||
String projectSn = FlowUtil.getString(map, "projectSn");
|
||||
MlHoist hoist = new MlHoist();
|
||||
VideoItem item = videoItemService.getOne(new LambdaQueryWrapper<VideoItem>()
|
||||
.eq(VideoItem::getSerialNumber, serialNumber));
|
||||
hoist.setVideoItemId(item.getItemId());
|
||||
hoist.setNum(num);
|
||||
hoist.setProjectSn(projectSn);
|
||||
mlHoistService.add(hoist);
|
||||
item.setIsFlowPass(1);
|
||||
videoItemService.updateById(item);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param mlHoist
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "吊装作业管理", operType = "编辑", operDesc = "编辑吊装作业信息")
|
||||
@ApiOperation(value = "编辑吊装作业信息", notes = "编辑吊装作业信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<MlHoist> edit(@RequestBody MlHoist mlHoist) {
|
||||
mlHoistService.edit(mlHoist);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "吊装作业管理", operType = "删除", operDesc = "删除吊装作业信息")
|
||||
@ApiOperation(value = "删除吊装作业信息", notes = "删除吊装作业信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "吊装作业ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<MlHoist> delete(@ApiIgnore @RequestBody HashMap<String, Object> map) {
|
||||
mlHoistService.delete(MapUtils.getString(map, "id"));
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "吊装作业管理", operType = "通过id查询", operDesc = "通过id查询吊装作业信息")
|
||||
@ApiOperation(value = "通过id查询吊装作业信息", notes = "通过id查询吊装作业信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "吊装作业ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MlHoist> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
return Result.success(mlHoistService.queryById(id));
|
||||
}
|
||||
|
||||
@OperLog(operModul = "吊装作业管理", operType = "", operDesc = "统计吊装作业信息")
|
||||
@ApiOperation(value = "统计吊装作业信息", notes = "统计吊装作业信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "String")
|
||||
@GetMapping(value = "/stats")
|
||||
public Result<Map<String, Object>> statsMlHoist(@RequestParam(name = "id", required = true) String id) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
String projectSn = MapUtils.getString(map, "projectSn");
|
||||
map.put("total", mlHoistService.count(new LambdaQueryWrapper<MlHoist>()
|
||||
.eq(StrUtil.isNotBlank(projectSn), MlHoist::getProjectSn, projectSn)));
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.zhgd.xmgl.modules.mulei.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @Description: 吊装作业
|
||||
* @author: pds
|
||||
* @date: 2024-09-14
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("ml_hoist")
|
||||
@ApiModel(value = "MlHoist实体类", description = "MlHoist")
|
||||
public class MlHoist implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.Long id;
|
||||
|
||||
@ApiModelProperty(value = "视频设备列表id")
|
||||
private java.lang.Long videoItemId;
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@Excel(name = "编号", width = 15)
|
||||
@ApiModelProperty(value = "编号")
|
||||
private java.lang.String num;
|
||||
/**
|
||||
* 所属项目SN
|
||||
*/
|
||||
@Excel(name = "所属项目SN", width = 15)
|
||||
@ApiModelProperty(value = "所属项目SN")
|
||||
private java.lang.String projectSn;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private java.util.Date createDate;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateDate;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.zhgd.xmgl.modules.mulei.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhgd.xmgl.modules.mulei.entity.MlHoist;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 吊装作业
|
||||
* @author: pds
|
||||
* @date: 2024-09-14
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface MlHoistMapper extends BaseMapper<MlHoist> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
<?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.zhgd.xmgl.modules.mulei.mapper.MlHoistMapper">
|
||||
</mapper>
|
||||
@ -0,0 +1,65 @@
|
||||
package com.zhgd.xmgl.modules.mulei.service;
|
||||
|
||||
import com.zhgd.xmgl.modules.mulei.entity.MlHoist;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 吊装作业
|
||||
* @author: pds
|
||||
* @date: 2024-09-14
|
||||
* @version: V1.0
|
||||
*/
|
||||
public interface IMlHoistService extends IService<MlHoist> {
|
||||
/**
|
||||
* 分页列表查询吊装作业信息
|
||||
*
|
||||
* @param param 参数map
|
||||
* @return
|
||||
*/
|
||||
IPage<MlHoist> queryPageList(HashMap<String, Object> param);
|
||||
|
||||
/**
|
||||
* 列表查询吊装作业信息
|
||||
*
|
||||
* @param param 参数map
|
||||
* @return
|
||||
*/
|
||||
List<MlHoist> queryList(HashMap<String, Object> param);
|
||||
|
||||
/**
|
||||
* 添加吊装作业信息
|
||||
*
|
||||
* @param mlHoist 吊装作业
|
||||
* @return
|
||||
*/
|
||||
void add(MlHoist mlHoist);
|
||||
|
||||
/**
|
||||
* 编辑吊装作业信息
|
||||
*
|
||||
* @param mlHoist 吊装作业
|
||||
* @return
|
||||
*/
|
||||
void edit(MlHoist mlHoist);
|
||||
|
||||
/**
|
||||
* 根据id删除吊装作业信息
|
||||
*
|
||||
* @param id 吊装作业的id
|
||||
* @return
|
||||
*/
|
||||
void delete(String id);
|
||||
|
||||
/**
|
||||
* 根据id查询吊装作业信息
|
||||
*
|
||||
* @param id 吊装作业的id
|
||||
* @return
|
||||
*/
|
||||
MlHoist queryById(String id);
|
||||
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package com.zhgd.xmgl.modules.mulei.service.impl;
|
||||
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.mulei.entity.MlHoist;
|
||||
import com.zhgd.xmgl.modules.mulei.mapper.MlHoistMapper;
|
||||
import com.zhgd.xmgl.modules.mulei.service.IMlHoistService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Description: 吊装作业
|
||||
* @author: pds
|
||||
* @date: 2024-09-14
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class MlHoistServiceImpl extends ServiceImpl<MlHoistMapper, MlHoist> implements IMlHoistService {
|
||||
@Autowired
|
||||
private MlHoistMapper mlHoistMapper;
|
||||
|
||||
@Override
|
||||
public IPage<MlHoist> queryPageList(HashMap<String, Object> param) {
|
||||
QueryWrapper<MlHoist> queryWrapper = this.getQueryWrapper(param);
|
||||
Page<MlHoist> page = PageUtil.getPage(param);
|
||||
IPage<MlHoist> pageList = this.page(page, queryWrapper);
|
||||
pageList.setRecords(this.dealList(pageList.getRecords()));
|
||||
return pageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MlHoist> queryList(HashMap<String, Object> param) {
|
||||
QueryWrapper<MlHoist> queryWrapper = getQueryWrapper(param);
|
||||
return dealList(this.list(queryWrapper));
|
||||
}
|
||||
|
||||
private QueryWrapper<MlHoist> getQueryWrapper(HashMap<String, Object> param) {
|
||||
QueryWrapper<MlHoist> queryWrapper = QueryGenerator.initPageQueryWrapper(MlHoist.class, param, true);
|
||||
queryWrapper.orderByDesc(RefUtil.fieldNameUlc(MlHoist::getId));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private List<MlHoist> dealList(List<MlHoist> list) {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(MlHoist mlHoist) {
|
||||
mlHoist.setId(null);
|
||||
baseMapper.insert(mlHoist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(MlHoist mlHoist) {
|
||||
MlHoist oldMlHoist = baseMapper.selectById(mlHoist.getId());
|
||||
if (oldMlHoist == null) {
|
||||
throw new OpenAlertException("未找到对应实体");
|
||||
}
|
||||
baseMapper.updateById(mlHoist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
MlHoist mlHoist = baseMapper.selectById(id);
|
||||
if (mlHoist == null) {
|
||||
throw new OpenAlertException("未找到对应实体");
|
||||
}
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MlHoist queryById(String id) {
|
||||
MlHoist entity = getById(id);
|
||||
if (entity == null) {
|
||||
throw new OpenAlertException("未找到对应实体");
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
@ -139,6 +139,8 @@ public class VideoItem implements Serializable {
|
||||
private String longitude;
|
||||
@ApiModelProperty(value = "父级的对象")
|
||||
private String parentObj;
|
||||
@ApiModelProperty(value = "工作流是否通过(1是0否)工作流吊装通过显示图标")
|
||||
private Integer isFlowPass;
|
||||
/**
|
||||
* 项目sn
|
||||
*/
|
||||
|
||||
@ -80,6 +80,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
http.authorizeRequests()
|
||||
//请求路径允许访问
|
||||
.antMatchers("/xmgl/mlHoist/flow/add/transpond").permitAll()
|
||||
.antMatchers("/xmgl/mlHoist/flow/add").permitAll()
|
||||
.antMatchers("/xmgl/videoItem/camera/search").permitAll()
|
||||
.antMatchers("/xmgl/videoItem/getVideoItemInfo").permitAll()
|
||||
.antMatchers("/xmgl/contractorProjectMonthlyWeeklyReport/flow/add").permitAll()
|
||||
|
||||
101
src/main/java/com/zhgd/xmgl/util/FlowUtil.java
Normal file
101
src/main/java/com/zhgd/xmgl/util/FlowUtil.java
Normal file
@ -0,0 +1,101 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class FlowUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件url
|
||||
*
|
||||
* @param map
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getFileUrl(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : ((Map) ((List) o).get(0)).get("url").toString()).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件url完整链接
|
||||
*
|
||||
* @param map
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getFileUrlWithHost(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : PathUtil.getServerUrl() + "/image/" + ((Map) ((List) o).get(0)).get("url").toString()).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件原来的名称
|
||||
*
|
||||
* @param map
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getFileOriginFileName(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : ((Map) ((List) o).get(0)).get("name").toString()).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下拉Long
|
||||
*
|
||||
* @param map
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static Long getPullDownLong(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : Convert.toLong(((List) o).get(0))).orElse(null);
|
||||
}
|
||||
|
||||
public static Date getDate(Map<String, Object> map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : DateUtil.parse(o.toString())).orElse(null);
|
||||
}
|
||||
|
||||
public static Date getStartDate(Map<String, Object> map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : DateUtil.parse(Convert.toStr(((List) o).get(0)))).orElse(null);
|
||||
}
|
||||
|
||||
public static Date getEndDate(Map<String, Object> map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : DateUtil.parse(Convert.toStr(((List) o).get(1)))).orElse(null);
|
||||
}
|
||||
|
||||
public static String getJSONString(Map<String, Object> map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(JSON::toJSONString).orElse(null);
|
||||
}
|
||||
|
||||
public static List getList(Map<String, Object> map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : ((List) o)).orElse(null);
|
||||
}
|
||||
|
||||
public static String getStrings(Map<String, Object> map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : StringUtils.join(((List) o), ",")).orElse(null);
|
||||
}
|
||||
|
||||
public static String getString(Map<String, Object> map, String key) {
|
||||
return MapUtils.getString(map, key);
|
||||
}
|
||||
|
||||
public static Integer getPullDownInteger(Map<String, Object> map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : Convert.toInt(((List) o).get(0))).orElse(null);
|
||||
}
|
||||
|
||||
public static String getLongitude(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : JSON.parseObject(o.toString()).getString("lng")).orElse(null);
|
||||
}
|
||||
|
||||
public static String getLatitude(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : JSON.parseObject(o.toString()).getString("lat")).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
|
||||
public class PathUtil {
|
||||
|
||||
private static String basePath;
|
||||
private static String serverUrl;
|
||||
|
||||
/**
|
||||
* 删除多余的斜杠
|
||||
@ -18,6 +19,17 @@ public class PathUtil {
|
||||
return path.replaceAll("([^:])(//+)", "$1/");
|
||||
}
|
||||
|
||||
|
||||
public static String getServerUrl() {
|
||||
return StrUtil.removeSuffix(serverUrl, "/");
|
||||
}
|
||||
|
||||
@Value("${serverUrl}")
|
||||
public void setServerUrl(String serverUrl) {
|
||||
PathUtil.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(reviseSlash("/home//foo/"));
|
||||
System.out.println(reviseSlash("/home/foo/"));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user