|
@@ -30,8 +30,11 @@ import org.springblade.business.service.IImageClassificationFileService;
|
|
|
import org.springblade.business.vo.TreeVo;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.manager.entity.WbsParam;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.feign.WbsTreeContractClient;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
@@ -39,7 +42,7 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
*
|
|
|
* @author BladeX
|
|
|
* @since 2022-05-24
|
|
@@ -47,91 +50,138 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageClassificationFileMapper, ImageClassificationFile> implements IImageClassificationFileService {
|
|
|
- private final WbsTreeContractClient wbsTreeContractClient;
|
|
|
- @Override
|
|
|
- public List<Integer> queryCurrentContractImageFileType(String contractId) {
|
|
|
- return this.baseMapper.queryCurrentContractImageFileType(contractId);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Integer queryCurrentClassifyAllFileCount(String projectId, String contractId, Long classifyId) {
|
|
|
- return this.baseMapper.queryCurrentClassifyAllFileCount(projectId, contractId, classifyId);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<TreeVo> getYearDateTree(String classifyId, String projectId, String contractId) {
|
|
|
- //获取时间
|
|
|
- List<Date> shootingTimes = this.baseMapper.selectShootingTimeByClassifyAndProjectId(classifyId, projectId, contractId);
|
|
|
- //转换时间
|
|
|
- List<String> yearMonthDayList = new ArrayList<>();
|
|
|
- shootingTimes.forEach(date -> yearMonthDayList.add(DateFormatUtils.format(date, "yyyy-MM-dd")));
|
|
|
- //转成结构树
|
|
|
- return YearTreeUtils.yearMonthDayTree(yearMonthDayList, "DESC");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public IPage<ImageClassificationFileVO> selectImageClassificationFilePage(IPage<ImageClassificationFileVO> page, ImageClassificationFileVO imageClassificationFile) {
|
|
|
- long current = (page.getCurrent() - 1L) * page.getSize();
|
|
|
- if(StringUtils.isNotEmpty(imageClassificationFile.getWbsIdsStr())){
|
|
|
- //查询下级节点信息
|
|
|
+
|
|
|
+ private final WbsTreeContractClient wbsTreeContractClient;
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Integer> queryCurrentContractImageFileType(String contractId) {
|
|
|
+ return this.baseMapper.queryCurrentContractImageFileType(contractId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer queryCurrentClassifyAllFileCount(String projectId, String contractId, Long classifyId) {
|
|
|
+ return this.baseMapper.queryCurrentClassifyAllFileCount(projectId, contractId, classifyId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TreeVo> getYearDateTree(String classifyId, String projectId, String contractId) {
|
|
|
+ //获取时间
|
|
|
+ List<Date> shootingTimes = this.baseMapper.selectShootingTimeByClassifyAndProjectId(classifyId, projectId, contractId);
|
|
|
+ //转换时间
|
|
|
+ List<String> yearMonthDayList = new ArrayList<>();
|
|
|
+ shootingTimes.forEach(date -> yearMonthDayList.add(DateFormatUtils.format(date, "yyyy-MM-dd")));
|
|
|
+ //转成结构树
|
|
|
+ return YearTreeUtils.yearMonthDayTree(yearMonthDayList, "DESC");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<ImageClassificationFileVO> selectImageClassificationFilePage(IPage<ImageClassificationFileVO> page, ImageClassificationFileVO imageClassificationFile) {
|
|
|
+ long current = (page.getCurrent() - 1L) * page.getSize();
|
|
|
+ if (StringUtils.isNotEmpty(imageClassificationFile.getWbsIdsStr())) {
|
|
|
+ //查询下级节点信息
|
|
|
// imageClassificationFile.setWbsIds(JSONArray.parseArray(JSONObject.toJSONString(imageClassificationFile.getWbsIdsStr().split(",")), String.class));
|
|
|
- WbsTreeContract node = wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.valueOf(imageClassificationFile.getWbsIdsStr()));
|
|
|
- List<WbsTreeContract> wbsTreeContracts = new ArrayList<>();
|
|
|
- if (node.getParentId()==0){
|
|
|
- wbsTreeContracts = wbsTreeContractClient.queryAllChild(imageClassificationFile.getContractId());
|
|
|
- }else {
|
|
|
- wbsTreeContracts = wbsTreeContractClient.queryCurrentNodeAllChild(imageClassificationFile.getContractId(), node.getId());
|
|
|
- }
|
|
|
- wbsTreeContracts.add(node);
|
|
|
- imageClassificationFile.setWbsIds(wbsTreeContracts.stream().map(wtc->wtc.getPKeyId()+"").collect(Collectors.toList()));
|
|
|
- }
|
|
|
- //获取数据
|
|
|
- List<ImageClassificationFile> fileVOS = this.baseMapper.selectImageClassificationFilePage(current, page.getSize(), imageClassificationFile);
|
|
|
- if(fileVOS != null && fileVOS.size() > 0){
|
|
|
- //分组
|
|
|
- List<List<ImageClassificationFile>> group = CommonUtil.getBatchSize(fileVOS, new Integer(String.valueOf(page.getSize())));
|
|
|
-
|
|
|
- //获取数据并设置分页信息
|
|
|
- List<ImageClassificationFile> result = group.get(new Integer(String.valueOf(page.getCurrent())) - 1);
|
|
|
- //转换类型
|
|
|
- List<ImageClassificationFileVO> resultVo = JSONArray.parseArray(JSONObject.toJSONString(result), ImageClassificationFileVO.class);
|
|
|
-
|
|
|
- //处理文件大小单位
|
|
|
- resultVo.forEach(vo -> {
|
|
|
- //获取文件大小
|
|
|
- String fileSize = vo.getFileSize();
|
|
|
- if(StringUtils.isNotEmpty(fileSize) && CommonUtil.checkIsBigDecimal(fileSize)){
|
|
|
- long size = new Long(fileSize);
|
|
|
- if(size < 1024L){
|
|
|
- vo.setFileSize(vo.getFileSize() + "B");
|
|
|
- } else {
|
|
|
- vo.setFileSize((size / 1024) + "K");
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- page.setTotal(fileVOS.size());
|
|
|
- page.setRecords(resultVo);
|
|
|
- }
|
|
|
-
|
|
|
- return page;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 恢复删除
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Boolean recoveryByIds(List<String> ids) {
|
|
|
- return baseMapper.recoveryByIds(ids);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 根据ids查找已经删除的数据
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<ImageClassificationFile> getDeleteDataByIds(List<String> ids) {
|
|
|
- return baseMapper.getDeleteDataByIds(ids);
|
|
|
- }
|
|
|
+ WbsTreeContract node = wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.valueOf(imageClassificationFile.getWbsIdsStr()));
|
|
|
+ List<WbsTreeContract> wbsTreeContracts = new ArrayList<>();
|
|
|
+ if (node.getParentId() == 0) {
|
|
|
+ wbsTreeContracts = wbsTreeContractClient.queryAllChild(imageClassificationFile.getContractId());
|
|
|
+ } else {
|
|
|
+ wbsTreeContracts = wbsTreeContractClient.queryCurrentNodeAllChild(imageClassificationFile.getContractId(), node.getId());
|
|
|
+ }
|
|
|
+ wbsTreeContracts.add(node);
|
|
|
+ imageClassificationFile.setWbsIds(wbsTreeContracts.stream().map(wtc -> wtc.getPKeyId() + "").collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ //获取数据
|
|
|
+ List<ImageClassificationFile> fileVOS = this.baseMapper.selectImageClassificationFilePage(current, page.getSize(), imageClassificationFile);
|
|
|
+ if (fileVOS != null && fileVOS.size() > 0) {
|
|
|
+ //分组
|
|
|
+ List<List<ImageClassificationFile>> group = CommonUtil.getBatchSize(fileVOS, new Integer(String.valueOf(page.getSize())));
|
|
|
+
|
|
|
+ //获取数据并设置分页信息
|
|
|
+ List<ImageClassificationFile> result = group.get(new Integer(String.valueOf(page.getCurrent())) - 1);
|
|
|
+ //转换类型
|
|
|
+ List<ImageClassificationFileVO> resultVo = JSONArray.parseArray(JSONObject.toJSONString(result), ImageClassificationFileVO.class);
|
|
|
+
|
|
|
+ //处理文件大小单位
|
|
|
+ resultVo.forEach(vo -> {
|
|
|
+ //获取文件大小
|
|
|
+ String fileSize = vo.getFileSize();
|
|
|
+ if (StringUtils.isNotEmpty(fileSize) && CommonUtil.checkIsBigDecimal(fileSize)) {
|
|
|
+ long size = new Long(fileSize);
|
|
|
+ if (size < 1024L) {
|
|
|
+ vo.setFileSize(vo.getFileSize() + "B");
|
|
|
+ } else {
|
|
|
+ vo.setFileSize((size / 1024) + "K");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ page.setTotal(fileVOS.size());
|
|
|
+ page.setRecords(resultVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 恢复删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean recoveryByIds(List<String> ids) {
|
|
|
+ return baseMapper.recoveryByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ids查找已经删除的数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ImageClassificationFile> getDeleteDataByIds(List<String> ids) {
|
|
|
+ return baseMapper.getDeleteDataByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getFileTitleName(String pKeyId) {
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.query("select id,ancestors,contract_id,project_id,wbs_id from m_wbs_tree_contract where is_deleted = 0 and status = 1 and p_key_id = " + pKeyId, new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
|
+ if (wbsTreeContract != null) {
|
|
|
+ WbsParam wbsParam = jdbcTemplate.query("select v from m_wbs_param where is_deleted = 0 and status = 1 and v is not null and k = 'FILE_TITLE' and name = '文件题名' and node_id = " + wbsTreeContract.getId(), new BeanPropertyRowMapper<>(WbsParam.class)).stream().findAny().orElse(null);
|
|
|
+ if (wbsParam != null) {
|
|
|
+ String[] titles = wbsParam.getV().split("-");
|
|
|
+ List<String> nodeNumber = new ArrayList<>();
|
|
|
+ for (String title : titles) {
|
|
|
+ if (title.contains("c") || title.contains("C")) {
|
|
|
+ String lastStr = title.substring(title.length() - 1);
|
|
|
+ nodeNumber.add(lastStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> ancestors = Arrays.asList(wbsTreeContract.getAncestors().split(","));
|
|
|
+ /*ancestors = new ArrayList<>(ancestors); // 将固定大小的列表复制到新的可变列表中
|
|
|
+ ancestors.removeIf(("0")::equals); //删除根节点*/
|
|
|
+
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
+ for (String index : nodeNumber) {
|
|
|
+ if ("0".equals(index)) {
|
|
|
+ index = "1";
|
|
|
+ }
|
|
|
+ if (Integer.parseInt(index) <= ancestors.size()) {
|
|
|
+ String id = ancestors.get(Integer.parseInt(index));
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ ids.add(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WbsTreeContract> wbsTreeContractList = jdbcTemplate.query("select node_name from m_wbs_tree_contract where is_deleted = 0 and status = 1 and project_id = " + wbsTreeContract.getProjectId() + " and contract_id = " + wbsTreeContract.getContractId() + " and wbs_id = " + wbsTreeContract.getWbsId() + " and id in(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ List<String> nameList = wbsTreeContractList.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
|
|
|
+ if (nameList.size() > 0) {
|
|
|
+ return StringUtils.join(nameList, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
}
|