Commit 725fad7c authored by 韩桐桐's avatar 韩桐桐

feat(jg):安装告知添加列别字段的排序功能支持

parent 09912c76
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.api.mapper; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice; import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -24,7 +25,11 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat ...@@ -24,7 +25,11 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat
* @param type 类型:enterprise-企业端、supervision-监管端 * @param type 类型:enterprise-企业端、supervision-监管端
* @return 安装告知列表 * @return 安装告知列表
*/ */
Page<Map<String, Object>> queryForPage(Page<JgInstallationNotice> page, @Param("param") JgInstallationNoticeDto model, @Param("type") String type, @Param("orgCode") String orgCode); Page<Map<String, Object>> queryForPage(Page<JgInstallationNotice> page,
@Param("param") JgInstallationNoticeDto model,
@Param("type") String type,
@Param("sort") SortVo sort,
@Param("orgCode") String orgCode);
/** /**
* 根据安装告知编号查询设备、设计、制造等信息 * 根据安装告知编号查询设备、设计、制造等信息
......
...@@ -44,7 +44,7 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot ...@@ -44,7 +44,7 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
* @param type 类型:enterprise-企业端、supervision-监管端 * @param type 类型:enterprise-企业端、supervision-监管端
* @return 安装告知列表 * @return 安装告知列表
*/ */
Page<Map<String, Object>> queryForJgInstallationNoticePage(Page<JgInstallationNotice> page, JgInstallationNoticeDto model, String type, ReginParams reginParams); Page<Map<String, Object>> queryForJgInstallationNoticePage(Page<JgInstallationNotice> page, JgInstallationNoticeDto model, String type,String sort, ReginParams reginParams);
/** /**
* 批量删除 * 批量删除
......
package com.yeejoin.amos.boot.module.jg.api.vo;
import lombok.Builder;
import lombok.Data;
/**
* @description: 排序对象
**/
@Data
@Builder
public class SortVo {
String field;
String sortType;
}
...@@ -106,6 +106,9 @@ ...@@ -106,6 +106,9 @@
</if> </if>
</where> </where>
ORDER BY ORDER BY
<if test="sort != null">
isn.${sort.field} ${sort.sortType},
</if>
isn.create_date DESC isn.create_date DESC
</select> </select>
......
...@@ -138,16 +138,20 @@ public class JgInstallationNoticeController extends BaseController { ...@@ -138,16 +138,20 @@ public class JgInstallationNoticeController extends BaseController {
@PostMapping(value = "/page") @PostMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "安装告知分页查询", notes = "安装告知分页查询") @ApiOperation(httpMethod = "GET", value = "安装告知分页查询", notes = "安装告知分页查询")
public ResponseModel<Page<Map<String, Object>>> queryForPage( public ResponseModel<Page<Map<String, Object>>> queryForPage(
@ApiParam(value = "当前页码", required = true) @RequestParam(value = "current", defaultValue = "1") int current, @ApiParam(value = "当前页码", required = true)
@ApiParam(value = "每页大小", required = true) @RequestParam(value = "size", defaultValue = "20") int size, @RequestParam(value = "current", defaultValue = "1") int current,
@ApiParam(value = "每页大小", required = true)
@RequestParam(value = "size", defaultValue = "20") int size,
@ApiParam(value = "类型:enterprise-企业端、supervision-监管端", required = true) @ApiParam(value = "类型:enterprise-企业端、supervision-监管端", required = true)
@RequestParam(value = "type", defaultValue = "enterprise") String type, @RequestParam(value = "type", defaultValue = "enterprise") String type,
@ApiParam(value = "排序字段",required = false)
@RequestParam(value = "sort",required = false) String sort,
@RequestBody(required = false) JgInstallationNoticeDto model @RequestBody(required = false) JgInstallationNoticeDto model
) { ) {
Page<JgInstallationNotice> page = new Page<>(current, size); Page<JgInstallationNotice> page = new Page<>(current, size);
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
type = (String) iJgInstallationNoticeService.getCompanyType().get("companyLevel"); type = (String) iJgInstallationNoticeService.getCompanyType().get("companyLevel");
return ResponseHelper.buildResponse(iJgInstallationNoticeService.queryForJgInstallationNoticePage(page, model, type, reginParams)); return ResponseHelper.buildResponse(iJgInstallationNoticeService.queryForJgInstallationNoticePage(page, model, type, sort, reginParams));
} }
/** /**
......
...@@ -34,6 +34,7 @@ import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransfer ...@@ -34,6 +34,7 @@ import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransfer
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgMaintainNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgMaintainNoticeService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgTransferNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgTransferNoticeService;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
...@@ -1688,6 +1689,47 @@ public class CommonServiceImpl implements ICommonService { ...@@ -1688,6 +1689,47 @@ public class CommonServiceImpl implements ICommonService {
} }
return result; return result;
} }
/**
* 驼峰转下划线
*
* @param str
* @return
*/
public static String convertToUnderline(String str) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (Character.isUpperCase(c)) {
sb.append("_").append(Character.toLowerCase(c));
} else {
sb.append(c);
}
}
return sb.toString();
}
/**
* 排序 :页面列表排序功能支持,将 "字段,ascend" 或 "字段,descend" 转化为对应JSONObject
* @param sort "字段,ascend" 或 "字段,descend"
* @return JSONObject
*/
public SortVo sortFieldConversion(String sort) {
Optional<String> optionalSort = Optional.ofNullable(sort);
Optional<SortVo> optionalSortMap = optionalSort.filter(s -> !s.isEmpty())
.map(s -> {
String[] sortParts = s.split(",");
if (sortParts.length == 2) {
String field = sortParts[0];
String sortSituation = sortParts[1].contains("asc") ? "ASC" : "DESC";
return SortVo.builder()
.field(convertToUnderline(field))
.sortType(sortSituation)
.build();
}
return null;
});
return optionalSortMap.orElse(null);
}
@Override @Override
public void fightUseFlagGenerate(UseFlagParamDto useFlagParamDto, HttpServletResponse response) { public void fightUseFlagGenerate(UseFlagParamDto useFlagParamDto, HttpServletResponse response) {
......
...@@ -24,6 +24,7 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper; ...@@ -24,6 +24,7 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgConstructionInfoService; import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgConstructionInfoService;
...@@ -381,12 +382,16 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -381,12 +382,16 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
* @return 安装告知列表 * @return 安装告知列表
*/ */
@Override @Override
public Page<Map<String, Object>> queryForJgInstallationNoticePage(Page<JgInstallationNotice> page, JgInstallationNoticeDto model, String type , ReginParams reginParams) { public Page<Map<String, Object>> queryForJgInstallationNoticePage(Page<JgInstallationNotice> page,
JgInstallationNoticeDto model,
String orgCode; String type ,
orgCode = reginParams.getCompany().getCompanyCode(); String sort,
ReginParams reginParams) {
String orgCode = reginParams.getCompany().getCompanyCode();
SortVo sortMap = commonService.sortFieldConversion(sort);
model.setTransferToUserIds(reginParams.getUserModel().getUserId()); model.setTransferToUserIds(reginParams.getUserModel().getUserId());
Page<Map<String, Object>> noticePage = jgInstallationNoticeMapper.queryForPage(page, model, type, orgCode); Page<Map<String, Object>> noticePage = jgInstallationNoticeMapper.queryForPage(page, model, type,sortMap, orgCode);
List<Map<String, Object>> mappedRecords = noticePage.getRecords().stream().peek(notice -> { List<Map<String, Object>> mappedRecords = noticePage.getRecords().stream().peek(notice -> {
Optional<Long> noticeStatusOpt = Optional.ofNullable((String) notice.get("noticeStatus")).map(Long::valueOf); Optional<Long> noticeStatusOpt = Optional.ofNullable((String) notice.get("noticeStatus")).map(Long::valueOf);
noticeStatusOpt.ifPresent(status -> { noticeStatusOpt.ifPresent(status -> {
......
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