|
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
@@ -41,7 +42,9 @@ import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
+import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -54,6 +57,9 @@ import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigInteger;
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
+import java.sql.SQLException;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.regex.Matcher;
|
|
@@ -812,6 +818,46 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean syncContractTabSort(String projectId) {
|
|
|
+ if (ObjectUtil.isNotEmpty(projectId)) {
|
|
|
+ List<WbsTreePrivate> tabs = jdbcTemplate.query("select id,sort from m_wbs_tree_private where is_deleted = 0 and sort is not null and wbs_type = 1 and project_id = " + projectId, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ List<ContractInfo> contractInfos = jdbcTemplate.query("select id from m_contract_info where is_deleted = 0 and contract_type = 1 and p_id = " + projectId, new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
+ for (ContractInfo contractInfo : contractInfos) {
|
|
|
+ for (List<WbsTreePrivate> wbsTreePrivates : Lists.partition(tabs, 1000)) {
|
|
|
+ try {
|
|
|
+ this.batchUpdateData(wbsTreePrivates, contractInfo.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ServiceException("保存数据异常,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量修改合同段表单sort
|
|
|
+ *
|
|
|
+ * @param wbsTreePrivates 表分组(1000一组)
|
|
|
+ * @param contractId 合同段id
|
|
|
+ */
|
|
|
+ private void batchUpdateData(List<WbsTreePrivate> wbsTreePrivates, Long contractId) {
|
|
|
+ StringBuilder updateSqlBuilder = new StringBuilder("UPDATE m_wbs_tree_contract SET sort = CASE id ");
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
|
|
|
+ updateSqlBuilder.append("WHEN ").append(wbsTreePrivate.getId()).append(" THEN ").append(wbsTreePrivate.getSort()).append(" ");
|
|
|
+ }
|
|
|
+ updateSqlBuilder.append("END WHERE id IN (");
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
|
|
|
+ updateSqlBuilder.append(wbsTreePrivate.getId()).append(",");
|
|
|
+ }
|
|
|
+ updateSqlBuilder.deleteCharAt(updateSqlBuilder.length() - 1); //删除最后一个逗号
|
|
|
+ updateSqlBuilder.append(") AND contract_id = ").append(contractId);
|
|
|
+ jdbcTemplate.update(updateSqlBuilder.toString());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 反向递归获取父级(父级Id=子级parentId)
|
|
|
*
|