Browse Source

新增需求

changchun
Jinyuanyuan 2 months ago
parent
commit
62d031c30f
  1. 7
      huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java
  2. 4
      huzhou/src/main/java/com/easy/admin/modules/huzhou/entity/HuzhouProjectinfo.java
  3. 2
      huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouProjectinfoService.java
  4. 43
      huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java
  5. 16
      huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/ImportSortOV.java
  6. 2
      huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/ShowStageOV.java

7
huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java

@ -354,5 +354,10 @@ public class HuzhouProjectController {
public Result<?> tryImport( MultipartFile file) throws Exception {
projectinfoService.updateTypeByImportFile(file);
return Result.ok("更新成功");
}//测试的时候Body选择form-data,key写file,value选择需要导入的文件
}
@GetMapping("/importSort")
public Result<?> importSort( MultipartFile file) throws Exception {
projectinfoService.updateSortByImportFile(file);
return Result.ok("更新成功");
}
}

4
huzhou/src/main/java/com/easy/admin/modules/huzhou/entity/HuzhouProjectinfo.java

@ -155,5 +155,9 @@ public class HuzhouProjectinfo extends BaseEntity {
*/
private Double urtEstimatedAmount;
/**
* 排序
*/
private Integer sort;
}

2
huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouProjectinfoService.java

@ -205,5 +205,7 @@ public interface IHuzhouProjectinfoService extends IService<HuzhouProjectinfo> {
void updateTypeByImportFile (MultipartFile file) throws Exception;
void updateSortByImportFile (MultipartFile file) throws Exception;
}

43
huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java

@ -1907,8 +1907,6 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl<HuzhouProjectinfoM
valueMap.put("3","");//建设
valueMap.put("4","");//绩效
valueMap.put("5","");//验收
//只要入库项目
projectInfo.setType("1");
projectInfo.setDutyWorkplace(projectInfo.getDutyWorkplace());
ProjectInfoAuthSelect projectInfoAuthSelect = CommonUtils.setGetProjectInfoAuth(projectInfo);
Page page = new Page(1, 10000);
@ -1963,9 +1961,12 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl<HuzhouProjectinfoM
showStage.setAcceptanceStage(valueMap.get("5"));
records.add(showStage);
}
List<ShowStageOV> sortedRecord = records.stream().filter(x -> x.getSort() != null).sorted(Comparator.comparingInt(ShowStageOV::getSort)).collect(Collectors.toList());
List<ShowStageOV> commonRecord = records.stream().filter(x -> x.getSort() == null).collect(Collectors.toList());
sortedRecord.addAll(commonRecord);
//手动分页
int fromIndex = (pageNo - 1) * pageSize;
List<ShowStageOV> currentPageData = records.subList(fromIndex, Math.min(fromIndex + pageSize, records.size()));
List<ShowStageOV> currentPageData = sortedRecord.subList(fromIndex, Math.min(fromIndex + pageSize, records.size()));
result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(projectAndChildInfoList.size());
return result;
}
@ -2034,6 +2035,40 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl<HuzhouProjectinfoM
}
}
}
public void updateSortByImportFile (MultipartFile file) throws Exception {
ImportParams importParams = new ImportParams();
HashMap<String, String> typeMap = new HashMap<>();
//表格标题行数,默认0
importParams.setTitleRows(0);
//是否需要校验上传的Excel
importParams.setNeedVerify(true);
ExcelImportResult<ImportSortOV> result = ExcelImportUtil.importExcelMore(file.getInputStream(), ImportSortOV.class, importParams);
int count=0;
if (!result.getList().isEmpty()) {
for (ImportSortOV request : result.getList()) {
int re;
HuzhouProjectinfo projectInfo = new HuzhouProjectinfo();
projectInfo.setProjectName(request.getName());
projectInfo.setSort(request.getSort());
String projectId="";
//根据项目名称获取id,
LambdaQueryWrapper<HuzhouProjectinfo> query=new LambdaQueryWrapper<>();
query.eq(HuzhouProjectinfo::getProjectName,request.getName());
List<HuzhouProjectinfo> huzhouProjectinfos = projectinfoMapper.selectList(query);
if (huzhouProjectinfos.size()>0){
projectId=huzhouProjectinfos.get(0).getId();
LambdaUpdateWrapper<HuzhouProjectinfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(HuzhouProjectinfo::getId,projectId);
updateWrapper.set(HuzhouProjectinfo::getSort, request.getSort());
projectinfoMapper.update(null,updateWrapper);
count=count+1;
}
}
System.out.println("更新成功条数"+count);
for (ImportSortOV request : result.getFailList()) {
System.out.println(request);
}
}
}
}

16
huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/ImportSortOV.java

@ -0,0 +1,16 @@
package com.easy.admin.modules.huzhou.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.v3.oas.models.security.SecurityScheme;
import lombok.Data;
@Data
public class ImportSortOV {
@Excel(name = "项目名称")
private String name;
@Excel(name = "排序")
private Integer sort;
}

2
huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/ShowStageOV.java

@ -24,6 +24,8 @@ public class ShowStageOV {
private String acceptanceStage;
private Integer sort;

Loading…
Cancel
Save