|
|
@@ -0,0 +1,231 @@
|
|
|
+package com.lc.ibps.business.service.impl;
|
|
|
+
|
|
|
+import com.lc.ibps.base.core.constants.StringPool;
|
|
|
+import com.lc.ibps.base.core.util.AppUtil;
|
|
|
+import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
+import com.lc.ibps.base.core.util.Collections;
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
+import com.lc.ibps.business.service.ReformService;
|
|
|
+import com.lc.ibps.cloud.entity.APIResult;
|
|
|
+import com.lc.ibps.org.api.IPartyPositionService;
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyPositionTbl;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import net.sf.morph.wrap.Bean;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
+@Log4j2
|
|
|
+@Service
|
|
|
+public class ReformServiceImpl implements ReformService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ICommonDao<?> commonDao;
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据供应商类型查询供应商配置", notes = "根据供应商类型查询供应商配置")
|
|
|
+ @Override
|
|
|
+ public APIResult querySupplierConfig(
|
|
|
+ @ApiParam(name = "type", value = "供应商类型", required = true) String type) {
|
|
|
+ APIResult result = new APIResult<>();
|
|
|
+ List<Map<String,Object>> list = new ArrayList<>();
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ String sql = "SELECT id_ FROM t_mjgyskhnrpzb WHERE yong_tu_='评价' AND di_dian_='%s' ORDER BY create_time_ DESC LIMIT 1";
|
|
|
+ sql = String.format(sql, getDiDian());
|
|
|
+ Map<String, Object> map = commonDao.queryOne(sql);
|
|
|
+ if (BeanUtils.isNotEmpty(map) && BeanUtils.isNotEmpty(map.get("id_"))) {
|
|
|
+ String parentId = (String) map.get("id_");
|
|
|
+ StringBuilder conditionBuilder = new StringBuilder();
|
|
|
+ String[] types = type.split(",");
|
|
|
+ for (int i = 0; i < types.length; i++) {
|
|
|
+ if (i > 0) {
|
|
|
+ conditionBuilder.append(" OR ");
|
|
|
+ }
|
|
|
+ conditionBuilder.append("lei_xing_ LIKE '%").append(types[i].trim().replace("'", "''")).append("%'");
|
|
|
+ }
|
|
|
+ String sql2 = "SELECT * FROM t_mjgyskhnrpzzb WHERE parent_id_='%s' AND (%s) ORDER BY id_ DESC";
|
|
|
+ sql2 = String.format(sql2, parentId , conditionBuilder);
|
|
|
+ list = (List<Map<String, Object>>) commonDao.query(sql2);
|
|
|
+ data.put("data", list);
|
|
|
+ }
|
|
|
+ result.setVariables(data);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据流程定义key和业务主键id查询附件和快照", notes = "根据流程定义key和业务主键id查询附件和快照")
|
|
|
+ @Override
|
|
|
+ public APIResult getFileInfo(
|
|
|
+ @ApiParam(name = "procDefKey", value = "流程定义key", required = true) String procDefKey,
|
|
|
+ @ApiParam(name = "id", value = "业务表主键id", required = true) String id) {
|
|
|
+ APIResult result = new APIResult<>();
|
|
|
+ List<String> kuaiZhao = new ArrayList<>();
|
|
|
+ List<String> fuJian = new ArrayList<>();
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ String sql = "SELECT fu_jian_nei_rong_,shi_fou_zi_biao_,guan_lian_zi_duan from t_lcidglbdbb WHERE liu_cheng_xuan_ze='%s' limit 1";
|
|
|
+ sql = String.format(sql, procDefKey);
|
|
|
+ Map<String, Object> map = commonDao.queryOne(sql);
|
|
|
+ if (BeanUtils.isNotEmpty(map) && BeanUtils.isNotEmpty(map.get("fu_jian_nei_rong_")) && BeanUtils.isNotEmpty(map.get("shi_fou_zi_biao_"))) {
|
|
|
+ String[] fields = map.get("fu_jian_nei_rong_").toString().split("\\.");
|
|
|
+ String[] tables = map.get("shi_fou_zi_biao_").toString().split("\\.");
|
|
|
+ String[] links = new String[]{"id_"};
|
|
|
+ if (BeanUtils.isNotEmpty(map.get("guan_lian_zi_duan"))) {
|
|
|
+ links = map.get("guan_lian_zi_duan").toString().split("\\.");
|
|
|
+ }
|
|
|
+ int length = tables.length;
|
|
|
+ if (tables.length > fields.length) {
|
|
|
+ length = fields.length;
|
|
|
+ }
|
|
|
+ for (int j = 0; j < length; j++) {
|
|
|
+ String sql2 = "select " + fields[j] +" from "+ tables[j] +" where id_='"+id+"'";
|
|
|
+ if (BeanUtils.isNotEmpty(map.get("guan_lian_zi_duan"))){
|
|
|
+ sql2 = "select " + fields[j] +" from "+ tables[j] +" where "+ links[j] +"='"+id+"'";
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> fileList = (List<Map<String, Object>>) commonDao.query(sql2);
|
|
|
+ for (Map<String, Object> file : fileList) {
|
|
|
+ for (Map.Entry<String, Object> entry : file.entrySet()) {
|
|
|
+ if (BeanUtils.isEmpty(entry.getValue())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ("kuai_zhao_".equals(entry.getKey())) {
|
|
|
+ kuaiZhao.add(entry.getValue().toString());
|
|
|
+ } else {
|
|
|
+ fuJian.add(entry.getValue().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.put("kuaiZhao", kuaiZhao);
|
|
|
+ data.put("fuJian", fuJian);
|
|
|
+ result.setVariables(data);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getCatTypeIds(List<Map<String, Object>> data,String type){
|
|
|
+ List<String> typeIdList = new ArrayList<>();
|
|
|
+ for (Map<String, Object> file : data) {
|
|
|
+ if (file.get("AUTHORITY_NAME").toString().contains(type)){
|
|
|
+ typeIdList.add(file.get("id_").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return String.join(",", typeIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public APIResult getDocumentsInfo(String folderId, String fileCode, String fileName, String version, String startDate, String endDate, String order) {
|
|
|
+ APIResult result = new APIResult<>();
|
|
|
+
|
|
|
+ String conditions = "";
|
|
|
+ if (BeanUtils.isNotEmpty(fileCode)){
|
|
|
+ conditions = conditions + " and wj.wen_jian_bian_hao LIKE '%"+fileCode+"%' ";
|
|
|
+ }
|
|
|
+ if (BeanUtils.isNotEmpty(fileName)){
|
|
|
+ conditions = conditions + " and wj.wen_jian_ming_che LIKE '%"+fileName+"%' ";
|
|
|
+ }
|
|
|
+ if (BeanUtils.isNotEmpty(version)){
|
|
|
+ conditions = conditions + " and wj.ban_ben_ LIKE '%"+version+"%' ";
|
|
|
+ }
|
|
|
+ if (BeanUtils.isNotEmpty(startDate)){
|
|
|
+ conditions = conditions + " and DATE_FORMAT(wj.fa_bu_shi_jian_,'%Y-%m-%d')>='"+startDate+"'";
|
|
|
+ }
|
|
|
+ if (BeanUtils.isNotEmpty(endDate)){
|
|
|
+ conditions = conditions + " and DATE_FORMAT(wj.fa_bu_shi_jian_,'%Y-%m-%d')<='"+endDate+"'";
|
|
|
+ }
|
|
|
+
|
|
|
+ String sorts = " order by wj.wen_jian_bian_hao desc,wj.wen_jian_ming_che desc";
|
|
|
+ if (BeanUtils.isNotEmpty(order)){
|
|
|
+ sorts = " order by "+order;
|
|
|
+ }
|
|
|
+
|
|
|
+ String userId = ContextUtil.getCurrentUserId();
|
|
|
+ String cat = "SELECT id_,DEPTH_,AUTHORITY_NAME from ibps_cat_type where CATEGORY_KEY_='FILE_TYPE' and AUTHORITY_NAME like '%"+getDiDian()+"%' ";
|
|
|
+ List<Map<String, Object>> data = (List<Map<String, Object>>) commonDao.query(cat);
|
|
|
+ if (BeanUtils.isNotEmpty(folderId)){
|
|
|
+ cat = cat + "and PATH_ like '%"+folderId+"%'";
|
|
|
+ data = (List<Map<String, Object>>) commonDao.query(cat);
|
|
|
+ }
|
|
|
+
|
|
|
+ String comIds = getCatTypeIds(data,"公用查阅");
|
|
|
+ String bmIds = getCatTypeIds(data,"部门查阅");
|
|
|
+ String kzIds = getCatTypeIds(data,"受限查阅");
|
|
|
+
|
|
|
+ String sql = "select wj.id_ as id,cy.id_ as cy_id_,sc.id_ as sc_id_,wj.shu_ju_lai_yuan_ AS shu_ju_lai_yuan_,file.ext_ AS ext_," +
|
|
|
+ " file.FILE_PATH_ AS file_path_,concat(file.file_name_,'.',file.ext_,'(大小:',CASE" +
|
|
|
+ " WHEN file.total_bytes_ >= 1024 * 1024 THEN CONCAT(ROUND(file.total_bytes_ / (1024.0 * 1024), 2), ' M')" +
|
|
|
+ " WHEN file.total_bytes_ >= 1024 THEN CONCAT(ROUND(file.total_bytes_ / 1024.0, 2), ' K')" +
|
|
|
+ " ELSE CONCAT(file.total_bytes_, 'B') END ,')') as file_info_," +
|
|
|
+ " wj.wen_jian_xi_lei_,wj.wen_jian_bian_hao,wj.wen_jian_ming_che,wj.ban_ben_,wj.wen_jian_fu_jian_ AS fu_jian_," +
|
|
|
+ " wj.fa_bu_shi_jian_ as fa_fang_shi_jian_,'' AS cha_yue_jie_zhi_s from t_wjxxb wj " +
|
|
|
+ " left join (select id_,parent_id_ from t_wjcyjl group by parent_id_) cy on cy.parent_id_ = wj.id_ " +
|
|
|
+ " left join (select id_,parent_id_ from t_wjscjl group by parent_id_) sc on sc.parent_id_ = wj.id_ " +
|
|
|
+ " left join ibps_file_attachment file on file.id_ = wj.wen_jian_fu_jian_";
|
|
|
+
|
|
|
+ // 共用文件
|
|
|
+ // shi_fou_guo_shen_ ='有效' and di_dian_
|
|
|
+ String comSql = sql + " where wj.shi_fou_guo_shen_ ='有效' and wj.di_dian_='%s' and FIND_IN_SET (wj.xi_lei_id_,'%s') ";
|
|
|
+ comSql = String.format(comSql , getDiDian() , comIds );
|
|
|
+ comSql = comSql + conditions + sorts;
|
|
|
+ List<Map<String, Object>> comList = (List<Map<String, Object>>) commonDao.query(comSql);
|
|
|
+
|
|
|
+
|
|
|
+ // 部门权限文件
|
|
|
+ // shi_fou_guo_shen_ in ('有效','使用')
|
|
|
+ String buMenSql = sql + " where wj.shi_fou_guo_shen_ in ('有效','使用') and FIND_IN_SET(wj.quan_xian_xin_xi_ ,'%s') and FIND_IN_SET (wj.xi_lei_id_,'%s') ";
|
|
|
+ IPartyPositionService partyPositionService = AppUtil.getBean(IPartyPositionService.class);
|
|
|
+ APIResult<List<PartyPositionPo>> result1 = partyPositionService.findByUserId(userId);
|
|
|
+ if (result1.isFailed() || Collections.isEmpty(result1.getData())) {
|
|
|
+ throw new IllegalArgumentException("buMen not match!");
|
|
|
+ }
|
|
|
+ String currBuMen = result1.getData().stream().map(PartyPositionTbl::getId).collect(Collectors.joining(","));
|
|
|
+ buMenSql = String.format(buMenSql , currBuMen , bmIds);
|
|
|
+ buMenSql = buMenSql + conditions + sorts;
|
|
|
+ List<Map<String, Object>> buMenList = (List<Map<String, Object>>) commonDao.query(buMenSql);
|
|
|
+
|
|
|
+
|
|
|
+ // 受限文件
|
|
|
+ // 超管 和 文件管理员 查询所有 否则根据当前用户匹配查询
|
|
|
+ String role = "SELECT id_ from ibps_party_user_role WHERE ROLE_ID_ in(SELECT id_ from ibps_party_role where NAME_='wjgly') and USER_ID_='%s' limit 1";
|
|
|
+ Map<String, Object> roleMap = commonDao.queryOne(role);
|
|
|
+ String sxsql = "select wj.id_ as id,cy.id_ as cy_id_,sc.id_ as sc_id_,wj.shu_ju_lai_yuan_ AS shu_ju_lai_yuan_,file.ext_ AS ext_,file.FILE_PATH_ AS file_path_," +
|
|
|
+ " CONCAT(file.file_name_, '.', file.ext_, '(',CASE WHEN file.total_bytes_ >= 1024 * 1024 THEN CONCAT(ROUND(file.total_bytes_ / (1024.0 * 1024), 2), ' M') " +
|
|
|
+ " WHEN file.total_bytes_ >= 1024 THEN CONCAT(ROUND(file.total_bytes_ / 1024.0, 2), ' K') ELSE CONCAT(file.total_bytes_, 'B') END , ')') as file_info_," +
|
|
|
+ " wj.wen_jian_xi_lei_,wj.wen_jian_bian_hao,wj.wen_jian_ming_che,wj.ban_ben_,wj.wen_jian_fu_jian_ AS fu_jian_,wj.fa_bu_shi_jian_ as fa_fang_shi_jian_,sq.cha_yue_jie_zhi_s FROM t_wjxxb wj " +
|
|
|
+ " LEFT JOIN (SELECT * FROM t_skwjcysqsqzb WHERE parent_id_ in (SELECT id_ from t_skwjcysqsq WHERE shi_fou_guo_shen_='已完成' and bian_zhi_ren_='%s')) sq ON wj.id_ = sq.wen_jian_id_ " +
|
|
|
+ " left join (select id_,parent_id_ from t_wjcyjl group by parent_id_) cy on cy.parent_id_ = wj.id_ " +
|
|
|
+ " left join (select id_,parent_id_ from t_wjscjl group by parent_id_) sc on sc.parent_id_ = wj.id_ " +
|
|
|
+ " left join ibps_file_attachment file on file.id_ = wj.wen_jian_fu_jian_ WHERE wj.shi_fou_guo_shen_ = '有效' AND (%s OR %s " +
|
|
|
+ " OR EXISTS (SELECT 1 FROM t_wjxdzb wjxdzb JOIN t_wjxzxdjlb wjxzxdjlb ON wjxdzb.id_ = wjxzxdjlb.parent_id_ JOIN t_wjxxb wjxxb ON wjxxb.shu_ju_lai_yuan_ = wjxzxdjlb.id_ " +
|
|
|
+ " WHERE wjxxb.id_ = wj.id_ AND CONCAT_WS(',',IF( wjxdzb.bian_zhi_ren_ != '', wjxdzb.bian_zhi_ren_, NULL )," +
|
|
|
+ " IF( wjxdzb.zhu_shen_he_ren_ != '', wjxdzb.zhu_shen_he_ren_, NULL ), " +
|
|
|
+ " IF( wjxdzb.zhu_shen_pi_ren_ != '', wjxdzb.zhu_shen_pi_ren_, NULL ) " +
|
|
|
+ " ) LIKE '%%%s%%' )) and FIND_IN_SET (wj.xi_lei_id_,'%s') ";
|
|
|
+ sxsql = String.format(sxsql, userId, ContextUtil.isSuper() , BeanUtils.isNotEmpty(roleMap) , userId , kzIds);
|
|
|
+ sxsql = sxsql + conditions + sorts;
|
|
|
+ List<Map<String, Object>> limitLists = (List<Map<String, Object>>) commonDao.query(sxsql);
|
|
|
+ List<Map<String, Object>> mergedList = Stream.concat(Stream.concat(limitLists.stream(), buMenList.stream()),comList.stream()).collect(Collectors.toList());
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("data", mergedList);
|
|
|
+ result.setVariables(map);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String getDiDian() {
|
|
|
+ IPartyPositionService partyPositionService = AppUtil.getBean(IPartyPositionService.class);
|
|
|
+ APIResult<List<PartyPositionPo>> result = partyPositionService.findByUserId(ContextUtil.getCurrentUserId());
|
|
|
+ String diDian ="";
|
|
|
+ try {
|
|
|
+ diDian = result.getData().get(0).getPath().split(StringPool.BACK_SLASH + StringPool.DOT)[1];
|
|
|
+ }catch (Exception ex){
|
|
|
+ log.error("Can't get didian information",ex);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return diDian;
|
|
|
+ }
|
|
|
+}
|