Selaa lähdekoodia

Merge remote-tracking branch 'origin/matser' into matser

Li Yuan 2 vuotta sitten
vanhempi
sitoutus
10d7590a35

+ 8 - 0
ibps-common-root/modules/org-biz/src/main/java/com/lc/ibps/org/party/repository/PartyEntityRepository.java

@@ -72,6 +72,14 @@ public interface PartyEntityRepository extends IRepository<String, PartyEntityPo
 	 * @return
 	 */
 	public List<PartyEntityTreePo> findTreeByTypePid(String type, String pid, boolean needRoot, boolean needParent, boolean needSub);
+
+	/**
+	 * 查询所有岗位信息
+	 * @param type
+	 * @param pid
+	 * @return
+	 */
+	public List<PartyEntityTreePo> findAllPosition(String type, String pid,String path);
 	
 	/**
 	 * 

+ 8 - 1
ibps-common-root/modules/org-biz/src/main/java/com/lc/ibps/org/party/repository/impl/PartyEntityRepositoryImpl.java

@@ -275,7 +275,14 @@ public class PartyEntityRepositoryImpl extends AbstractRepository<String, PartyE
 		
 		return groupTreeList;
 	}
-	
+
+	@Override
+	public List<PartyEntityTreePo> findAllPosition(String type, String pid,String path) {
+		List<PartyEntityPo> poList = findByKey("findAllPosition", "findAllPosition",
+				b().a("partyType", type).a("pid", pid).a("path",path).p());
+		return new ArrayList<>(PartyEntityTreeBuilder.build(poList));
+	}
+
 	@Override
 	public List<PartyEntityTreePo> getTreeByTypeAndPid(String type, String pid, boolean needRoot) {
 		List<PartyEntityTreePo> groupTreeList = new ArrayList<PartyEntityTreePo>();

+ 13 - 0
ibps-model-root/modules/org-model/src/main/resources/com/lc/ibps/org/party/persistence/mapping/PartyEntity.map.xml

@@ -230,6 +230,19 @@
 		order by e.SN_ ASC,e.CREATE_TIME_ asc
 	</select>
 
+	<select id="findAllPosition" parameterType="java.util.Map" resultMap="PartyEntity">
+		select e.*,o.NAME_ from IBPS_PARTY_ENTITY e
+		INNER JOIN IBPS_PARTY_POSITION o on e.ID_=o.ID_
+		and e.PARTY_TYPE_=#{partyType}
+		<if test="@o.Ognl@isNotEmpty(pid)">
+			and e.PARENT_ID_ = #{pid}
+		</if>
+		<if test="@o.Ognl@isNotEmpty(path)">
+			and e.PATH_ like #{path}
+		</if>
+		order by e.PATH_
+	</select>
+
 	<select id="findRootPosIdsByTypeAndPid" parameterType="java.util.Map" resultMap="PartyEntity">
 		select e.ID_,e.SN_,e.CREATE_TIME_ from IBPS_PARTY_ENTITY e 
 		INNER JOIN IBPS_PARTY_POSITION o on e.ID_=o.ID_

+ 8 - 0
ibps-provider-base-root/modules/provider-platform-api/src/main/java/com/lc/ibps/org/api/IPartyPositionService.java

@@ -346,4 +346,12 @@ public interface IPartyPositionService {
 	@RequestMapping(value = "/findTreeData", method = { RequestMethod.POST })
 	public APIResult<List<PartyEntityTreePo>> findTreeData(
 			@RequestBody(required = true) APIRequest request);
+
+	/**
+	 * 获取所有岗位
+	 * @return
+	 */
+	@RequestMapping(value = "/findAllPosition", method = { RequestMethod.POST })
+	public APIResult<List<PartyEntityTreePo>> findAllPosition(
+			@RequestBody(required = true) APIRequest request);
 }

+ 59 - 6
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/org/provider/PartyPositionProvider.java

@@ -1,11 +1,8 @@
 package com.lc.ibps.org.provider;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
@@ -818,7 +815,63 @@ public class PartyPositionProvider extends GenericProvider implements IPartyPosi
 		
 		return result;
 	}
-	
+
+	@ApiOperation(value = "获取岗位树", notes = "获取岗位树,\n"
+			+ "当type的value为0且posId没有值的时候,则返回系统内所有部门的信息\n"
+			+ "当type的value为0且posId有值的时候,则返回posId本级及其下属所有的部门信息\n"
+			+ "超级管理员可查看所有组织,普通用户默认查询本组织部门信息"
+			+ "参数QA^key,Object,对应参与者属性"
+	)
+	@Override
+	public APIResult<List<PartyEntityTreePo>> findAllPosition(
+			@ApiParam(name = "request", value = "传入查询请求json字符串", required = true)
+			@RequestBody(required = true) APIRequest request) {
+		APIResult<List<PartyEntityTreePo>> result = new APIResult<>();
+		List<PartyEntityTreePo> groupTreeList = new ArrayList<>();
+		try{
+			String postId = RequestUtil.getString(request, "posId");
+			if(ContextUtil.isSuper()){
+				groupTreeList = partyEntityRepository.findAllPosition(PartyType.POSITION.getValue(),postId,"");
+			}else {
+				// 查询本岗位数据
+				String userId = ContextUtil.getCurrentUserId();
+				PartyEmployeePo partyEmployee = partyEmployeeRepository.get(userId);
+				if (BeanUtils.isNotEmpty(partyEmployee) && StringUtil.isNotBlank(partyEmployee.getPositions())) {
+					String position = partyEmployee.getPositions().split(",")[0];
+					PartyEntityPo entityPo = partyEntityRepository.get(position);
+					String path3 = entityPo.getPath().split(StringPool.BACK_SLASH+StringPool.DOT)[2];
+					groupTreeList = partyEntityRepository.findAllPosition(PartyType.POSITION.getValue(),"","%"+path3+"%");
+					if (BeanUtils.isNotEmpty(groupTreeList)){
+						List<PartyEntityTreePo> entityTreeList = new ArrayList<>();
+						for (int i = 0; i < groupTreeList.size(); i++) {
+							PartyEntityTreePo bean = groupTreeList.get(i);
+							if (bean.getDepth() ==3){
+								this.getPosition(bean.getParentId(),entityTreeList);
+							}
+						}
+						groupTreeList.addAll(entityTreeList);
+					}
+				}
+			}
+			List<PartyEntityTreePo> filteredList = groupTreeList.stream()
+					.filter(Objects::nonNull) // 使用Objects.nonNull方法过滤掉null
+					.collect(Collectors.toList()); // 收集过滤后的元素到新的List中
+			result.setData(PartyUtil.unique(filteredList));
+		}catch (Exception e){
+			setExceptionResult(result, StateEnum.ERROR_POSITION.getCode(), I18nUtil.getMessage(StateEnum.ERROR_POSITION.getCode()+""), e);
+		}
+		return result;
+	}
+
+	public void getPosition(String parentId,List<PartyEntityTreePo> groupTreeList ){
+		PartyEntityPo entity = partyEntityRepository.get(parentId);
+		if (!"0".equals(parentId)){
+			getPosition(entity.getParentId(),groupTreeList);
+		}
+		groupTreeList.add(PartyEntityTreeBuilder.build(entity));
+	}
+
+
 	private List<String> findByAttrKeyValue(Map<String, Object> map, String partyType) {
 		PartyParamsValidator.paramValidateObject(map, "参数为空");
 		List<String> entitys = PartyUtil.getIds(partyEntityRepository.findByPartyType(partyType));

+ 44 - 24
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/mq/consumer/rabbit/RabbitSnapshotMessageQueueConsumer.java

@@ -26,6 +26,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 @RabbitListener(bindings = {
@@ -87,53 +88,72 @@ public class RabbitSnapshotMessageQueueConsumer   {
         Map<String, Object> hisMap = commonDao.queryOne("SELECT PROC_DEF_KEY_,BIZ_KEY_,PROC_DEF_NAME_ FROM ibps_bpm_inst_his WHERE id_ = '" + instId + "' ");
 
         if (BeanUtils.isNotEmpty(hisMap)){
-
+            String procDefKey = hisMap.get("PROC_DEF_KEY_").toString();
+            String bizKey = hisMap.get("BIZ_KEY_").toString();
+            String procDefName = hisMap.get("PROC_DEF_NAME_").toString();
             Map<String, Object> kzMap = commonDao.queryOne(" SELECT ti_jiao_kuai_zhao,bao_biao_lu_jing_,tablekey_ FROM t_lcidglbdbb " +
-                "where liu_cheng_xuan_ze = '" + hisMap.get("PROC_DEF_KEY_") + "' AND gui_dang_lei_xing = 'process' limit 1");
-            APIResult<AttachmentPo> result = new APIResult<>();
+                "where liu_cheng_xuan_ze = '"+procDefKey+"' AND gui_dang_lei_xing = 'process' limit 1");
 
             if (BeanUtils.isNotEmpty(kzMap) && kzMap.containsKey("ti_jiao_kuai_zhao") &&
                     BeanUtils.isNotEmpty(kzMap.get("ti_jiao_kuai_zhao")) && "是".equals(kzMap.get("ti_jiao_kuai_zhao")) ) {
                 LOGGER.warn("processing snapshot with instId= " + instId);
                 PartyEmployeePo employeePo = partyEmployeeRepository.get(userId);
-                String position = employeePo.getPositions().split(",")[0];
+                String position = employeePo.getPositions().split(StringPool.COMMA)[0];
                 PartyEntityPo entityPo = partyEntityRepository.get(position);
-                String org = entityPo.getPath().split("\\.")[0];
+                String org = entityPo.getPath().split(StringPool.BACK_SLASH+StringPool.DOT)[0];
                 String reportPath = "金通医学实验室管理系统/" + kzMap.get("bao_biao_lu_jing_");
-
-                String baseUrl = runqianServer + runqianBasePath + "/reportServlet?action=6&file=";
                 reportPath = URLEncoder.encode(reportPath, "UTF-8");
-                String url = baseUrl + reportPath + "&print=1&srcType=file&paramString=id_%3D" + hisMap.get("BIZ_KEY_") + "&org_=" + org;
-                String formattedTime = new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
-                String name = hisMap.get("PROC_DEF_NAME_") + formattedTime ;
-
+                String baseUrl = runqianServer + runqianBasePath + "/reportServlet?action=6&file=";
                 DefaultPartyUserPo user = new DefaultPartyUserPo();
                 user.setUserId(userId);
                 user.setFullname(employeePo.getName());
                 user.setAccount(employeePo.getAccount());
                 ContextUtil.setCurrentUser(user);
 
-                result = uploadFile.runQianUpload(url , name , StringPool.FileType.Office.PDF );
-
-            }
-
-            Map<String, Object> defMap = commonDao.queryOne("select BO_CODE_ from ibps_bpm_def where DEF_KEY_ = '" + hisMap.get("PROC_DEF_KEY_") + "' ");
-            if (BeanUtils.isNotEmpty(defMap)) {
-                if (result.getState() == 200 && BeanUtils.isNotEmpty(result.getData())) {
-                    String sql = "update t_" + defMap.get("BO_CODE_") + " set kuai_zhao_ = '" + result.getData().getId() + "'  where id_ = '" + hisMap.get("BIZ_KEY_") + "' ";
-                    commonDao.execute(sql);
-                    LOGGER.warn("Generated Snapshot ID=" + result.getData().getId());
+                // 文件批量新增修订记录表  需要根据子表(t_wjxzxdjlb)生成各自的快照  流程绑定的是主表(t_wjxdzb)
+                // 生成的快照文件名 取文件修订子表  xiu_ding_wen_jian 字段值 ,若该字段值为空则取 wen_jian_ming_che 字段
+                if ("Process_1ek5omy_2".equals(procDefKey)){
+                    String fileSql = "select id_,parent_id_,xiu_ding_wen_jian,wen_jian_ming_che from t_wjxzxdjlb where parent_id_ = '"+bizKey+"'";
+                    List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(fileSql);
+                    if (BeanUtils.isNotEmpty(list)){
+                        for (Map<String,Object> map : list){
+                            procDefName = (String) (BeanUtils.isNotEmpty(map.get("xiu_ding_wen_jian"))?map.get("xiu_ding_wen_jian"):map.get("wen_jian_ming_che"));
+                            bizKey = (String) map.get("id_");
+                            updateKuaiZhao(procDefKey,procDefName,bizKey,baseUrl,reportPath,org);
+                        }
+                    }
+                }else {
+                    updateKuaiZhao(procDefKey,procDefName,bizKey,baseUrl,reportPath,org);
                 }
             }
-
         } else{
             LOGGER.warn("can't find any record. it will be tried it again. instId=" +instId);
             throw new Exception("can't find any record. it will be tried it again.");
         }
+    }
 
+    /**
+     * 把生成的快照附件id 回填到对应的业务表快照字段
+     */
+    private void updateKuaiZhao(String procDefKey,String procDefName,String bizKey,String baseUrl,String reportPath,String org){
+        String url = baseUrl + reportPath + "&print=1&srcType=file&paramString=id_%3D"+bizKey+"&org_="+org;
+        String name = procDefName + new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
+        APIResult<AttachmentPo> result = uploadFile.runQianUpload(url , name , StringPool.FileType.Office.PDF );
+        Map<String, Object> defMap = commonDao.queryOne("select BO_CODE_ from ibps_bpm_def where DEF_KEY_ = '"+procDefKey+"' ");
+        if (BeanUtils.isNotEmpty(defMap)) {
+            if (result.getState() == 200 && BeanUtils.isNotEmpty(result.getData())) {
+                String sql = "";
+                if ("Process_1ek5omy_2".equals(procDefKey)){
+                    sql = "update t_wjxzxdjlb set kuai_zhao_='"+result.getData().getId()+"' where id_='"+bizKey+"'";
+                }else {
+                    sql = "update t_" + defMap.get("BO_CODE_") + " set kuai_zhao_ = '" + result.getData().getId() + "'  where id_ = '"+bizKey+"'";
+                }
+                commonDao.execute(sql);
+                LOGGER.warn("Generated Snapshot ID=" + result.getData().getId());
+            }
+        }
+    }
 
 
 
-    }
-
 }