From 222c109727ed1da438f3371a2b0934d6cef85ee5 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期六, 05 八月 2023 21:26:45 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java                  |    7 +++
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java         |   40 ++++++++++++--------
 Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue                                                       |    2 
 Source/UBCS/ubcs-ops-api/ubcs-flow-api/src/main/java/com/vci/ubcs/flow/core/entity/BladeFlow.java                 |    5 ++
 Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java |   30 ++++++++++-----
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java            |   10 +++++
 Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java        |   19 +++++++++
 7 files changed, 86 insertions(+), 27 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
index d7adab9..6d4c5a1 100644
--- a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
+++ b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
@@ -876,7 +876,7 @@
     //鏁版嵁鏇存敼鍥炶皟
     updataSumbit(val){
       this.DataVisible = false;
-      val.copyfromversion = this.rowOid;
+      val.copyFromVersion = this.rowOid;
       val.oid=''
       console.log(val)
       upSaveCode(val).then(res=>{
diff --git a/Source/UBCS/ubcs-ops-api/ubcs-flow-api/src/main/java/com/vci/ubcs/flow/core/entity/BladeFlow.java b/Source/UBCS/ubcs-ops-api/ubcs-flow-api/src/main/java/com/vci/ubcs/flow/core/entity/BladeFlow.java
index a0ca9b6..dceab7c 100644
--- a/Source/UBCS/ubcs-ops-api/ubcs-flow-api/src/main/java/com/vci/ubcs/flow/core/entity/BladeFlow.java
+++ b/Source/UBCS/ubcs-ops-api/ubcs-flow-api/src/main/java/com/vci/ubcs/flow/core/entity/BladeFlow.java
@@ -185,6 +185,11 @@
 	private String historyActivityIdea;
 
 	/**
+	 * 娴佺▼寮�濮嬩簨浠�
+	 */
+	private String processDefinitionStartTime;
+
+	/**
 	 * 鑾峰彇鏄惁閫氳繃
 	 */
 	public boolean isPass() {
diff --git a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java
index 502f332..e39c37e 100644
--- a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java
+++ b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java
@@ -24,6 +24,7 @@
 import com.vci.ubcs.flow.engine.constant.FlowEngineConstant;
 import com.vci.ubcs.flow.engine.entity.FlowProcess;
 import com.vci.ubcs.flow.engine.utils.FlowCache;
+import com.vci.ubcs.starter.web.util.VciDateUtil;
 import com.vci.ubcs.system.user.cache.UserCache;
 import com.vci.ubcs.system.user.entity.User;
 import lombok.AllArgsConstructor;
@@ -81,9 +82,9 @@
 			.includeProcessVariables().active().orderByTaskCreateTime().desc();
 
 		// 鏋勫缓鍒楄〃鏁版嵁
-		buildFlowTaskList(bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM);
-		buildFlowTaskList(bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
-		buildFlowTaskList(bladeFlow, flowList, claimRoleWithoutTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
+		buildFlowTaskList(bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM, page);
+		buildFlowTaskList(bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM, page);
+		buildFlowTaskList(bladeFlow, flowList, claimRoleWithoutTenantIdQuery, FlowEngineConstant.STATUS_CLAIM, page);
 
 		// 璁$畻鎬绘暟
 		long count = claimUserQuery.count() + claimRoleWithTenantIdQuery.count() + claimRoleWithoutTenantIdQuery.count();
@@ -106,7 +107,7 @@
 			.includeProcessVariables().orderByTaskCreateTime().desc();
 
 		// 鏋勫缓鍒楄〃鏁版嵁
-		buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
+		buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO,page);
 
 		// 璁$畻鎬绘暟
 		long count = todoQuery.count();
@@ -298,8 +299,9 @@
 	 * @param flowList  娴佺▼鍒楄〃
 	 * @param taskQuery 浠诲姟鏌ヨ绫�
 	 * @param status    鐘舵��
+	 * @param page
 	 */
-	private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status) {
+	private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status, IPage<BladeFlow> page) {
 //		if (bladeFlow.getCategory() != null) {
 		if (StringUtils.isNotEmpty(bladeFlow.getCategory())) {
 			taskQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
@@ -313,7 +315,9 @@
 		if (bladeFlow.getEndDate() != null) {
 			taskQuery.taskCreatedBefore(bladeFlow.getEndDate());
 		}
-		taskQuery.list().forEach(task -> {
+		int firstResult = (int) ((page.getCurrent()-1)* page.getSize());
+		int maxResult = (int) page.getSize();
+		taskQuery.listPage(firstResult,maxResult).forEach(task -> {
 			BladeFlow flow = new BladeFlow();
 			flow.setTaskId(task.getId());
 			flow.setTaskDefinitionKey(task.getTaskDefinitionKey());
@@ -340,10 +344,11 @@
 					flow.setHistoryActivityIdea(commentList.get(0).getFullMessage());
 				}
 			}
+			List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery()
+				.processInstanceId(task.getProcessInstanceId()).orderByProcessInstanceStartTime().asc().list();
+			flow.setProcessDefinitionStartTime(VciDateUtil.date2Str(processInstanceList.get(0).getStartTime(),VciDateUtil.DateTimeFormat));
 			// 鑾峰彇娴佺▼鍙戣捣浜哄悕绉�
 			if (FlowEngineConstant.START_EVENT.equals(historicActivityInstance.getActivityType())) {
-				List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery()
-					.processInstanceId(task.getProcessInstanceId()).orderByProcessInstanceStartTime().asc().list();
 				if (processInstanceList.size() > 0) {
 					if (StringUtil.isNotBlank(processInstanceList.get(0).getStartUserId())) {
 						String taskUser = processInstanceList.get(0).getStartUserId();
@@ -357,9 +362,14 @@
 			}
 
 			if (Func.isNotEmpty(historicProcessInstance)) {
-				String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
+				String[] businessKey = new String[2];
+				if(historicProcessInstance.getBusinessKey().contains(StringPool.COLON)){
+					businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
+				}else{
+					businessKey[0] = historicProcessInstance.getBusinessKey();
+				}
 				flow.setBusinessTable(businessKey[0]);
-				flow.setBusinessId(businessKey.length>1?businessKey[1]:"1");
+				flow.setBusinessId(businessKey.length>1 && StringUtils.isNotEmpty(businessKey[1])?businessKey[1]:"1");
 			}
 
 			FlowProcess processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
diff --git a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java
index 4a1ea85..731fb62 100644
--- a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java
+++ b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java
@@ -19,14 +19,17 @@
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.vci.ubcs.flow.core.constant.ProcessConstant;
 import com.vci.ubcs.flow.core.dto.FlowTaskDTO;
+import com.vci.ubcs.flow.core.dto.ProcessStageAttrDTO;
 import com.vci.ubcs.flow.core.entity.BladeFlow;
 import com.vci.ubcs.flow.core.entity.FlowTaskUser;
+import com.vci.ubcs.flow.core.entity.ProcessStageAttr;
 import com.vci.ubcs.flow.core.utils.TaskUtil;
 import com.vci.ubcs.flow.engine.entity.*;
 import com.vci.ubcs.flow.engine.service.FlowEngineService;
 import com.vci.ubcs.flow.engine.service.FlowTaskUserService;
 import com.vci.ubcs.flow.engine.service.ProcessStageAttrService;
 import com.vci.ubcs.flow.engine.service.VICFlowService;
+import com.vci.ubcs.starter.web.util.BeanUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -232,6 +235,22 @@
 			flowTaskDTO.setVariables(variables);
 		}
 
+		//娴佺▼闃舵
+		Map<String, Object> m = new HashMap<>();
+		String templateId = variables.get("templateId").toString();
+		m.put("template_id", templateId);
+		m.put("task_id", crruentActivityId);
+		m.put("model_key", modelKey);
+		QueryWrapper q = Condition.getQueryWrapper(m, ProcessStageAttr.class)
+			.select("attr_id attrId,attr_name attrName,attr_group attrGroup");
+		List<ProcessStageAttr> stageAttrs = processStageAttrService.list(q);
+		List<ProcessStageAttrDTO> stageAttrsDto = new ArrayList<>();
+		stageAttrs.stream().forEach(e->{
+			ProcessStageAttrDTO dto = new ProcessStageAttrDTO();
+			BeanUtil.convert(e,dto);
+			stageAttrsDto.add(dto);
+		});
+		flowTaskDTO.setStageAttrs(stageAttrsDto);
 
 		//鏀惧叆娴佺▼闃舵銆佹祦绋媘odelkey
 		variables.put(TASKID,crruentActivityId);
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
index 4563b5f..9ebdb8f 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
@@ -13,6 +13,7 @@
 import com.vci.ubcs.code.service.MdmEngineService;
 import com.vci.ubcs.code.service.MdmIOService;
 import com.vci.ubcs.code.vo.pagemodel.*;
+import com.vci.ubcs.flow.core.dto.FlowStatusDTO;
 import com.vci.ubcs.starter.annotation.VciBusinessLog;
 import com.vci.ubcs.starter.revision.model.BaseModel;
 import com.vci.ubcs.starter.revision.model.TreeQueryObject;
@@ -739,4 +740,13 @@
 		return engineService.referTree(referConfigVO,queryObject);
 	}
 
+	/**
+	 * 娴佺▼涓彉鏇寸姸鎬佺殑绠�鏄撴帴鍙�
+	 * @param flowDTO 娴佺▼涓惡甯︾殑body
+	 * @return
+	 */
+	@PostMapping("/processChangeStatus")
+	public R processChangeStatus(@RequestBody FlowStatusDTO flowDTO){
+		return engineService.processChangeStatus(flowDTO);
+	}
 }
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java
index 97cdb3b..674e2fd 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java
@@ -10,6 +10,7 @@
 import com.vci.ubcs.code.vo.CodeKeyAttrRepeatVO;
 import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO;
 import com.vci.ubcs.code.vo.pagemodel.*;
+import com.vci.ubcs.flow.core.dto.FlowStatusDTO;
 import com.vci.ubcs.starter.exception.VciBaseException;
 import com.vci.ubcs.starter.revision.model.BaseModel;
 import com.vci.ubcs.starter.revision.model.TreeQueryObject;
@@ -439,4 +440,10 @@
 			||"checkouttime".equalsIgnoreCase(attrName));
 	}
 
+	/**
+	 * 娴佺▼涓彉鏇寸姸鎬佸��
+	 * @param flowDTO
+	 * @return
+	 */
+    R processChangeStatus(FlowStatusDTO flowDTO);
 }
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
index dd05221..3441b94 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -20,6 +20,7 @@
 import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO;
 import com.vci.ubcs.code.vo.pagemodel.UITablePageVO;
 import com.vci.ubcs.code.vo.pagemodel.*;
+import com.vci.ubcs.flow.core.dto.FlowStatusDTO;
 import com.vci.ubcs.flow.core.feign.IMDMIFlowAttrClient;
 import com.vci.ubcs.flow.core.vo.ProcessStageAttrVO;
 import com.vci.ubcs.omd.constant.BtmTypeLcStatusConstant;
@@ -2606,17 +2607,10 @@
                 orderDTO.getCodeClassifyOid(), "涓婚搴撳垎绫荤殑涓婚敭");
 
         //闇�瑕佸崌鐗�
-//		ClientBusinessObjectOperation cboOperation = new ClientBusinessObjectOperation();
         BaseModel cbo = null;
-//		try {
-//			//cbo = cboOperation.createBusinessObjectVersion(oldCbo,VciBaseUtil.getCurrentUserId());
         cbo = reviseBusinessObject(oldCbo);
-//		} catch (VCIError e) {
-//			throw new VciBaseException("鍒濆鍖栫浉鍏崇殑鍐呭鍑虹幇浜嗛敊璇�", new String[0], e);
-//		}
         //1. 鍒ゆ柇蹇呰緭椤�
-        //CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
-        checkRequiredAttrOnOrder(templateVO, orderDTO);
+		checkRequiredAttrOnOrder(templateVO, orderDTO);
         //2.鍏堟敞鍏ワ紝鍐嶇粍鍚堬紝鏈�鍚庢牎楠�
         switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
         //3.澶勭悊缁勫悎瑙勫垯銆傜粍鍚堣鍒欎笉鑳戒娇鐢ㄧ紪鐮佺殑灞炴�э紝鍥犱负缂栫爜鐨勭敓鎴愬彲鑳芥槸闇�瑕佸睘鎬х殑
@@ -2634,20 +2628,17 @@
         //浼佷笟鐮佸拰闆嗗洟鐮佺殑涓嶄慨鏀�
         cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
         cbo.setName(orderDTO.getName());
-//		try {
         cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
-//		cbo.setAttributeValueWithNoCheck("description", StringUtils.isBlank(orderDTO.getDescription())?"":orderDTO.getDescription());
         cbo.setName(orderDTO.getName());
-//		} catch (VCIError e) {
-//			e.printStackTrace();
-//		}
         //鏁版嵁鐨勬椂鍊欙紝缂栫爜鏄笉鍙樼殑
         cbo.setCreateTime(cbo.getCreateTime());
         cbo.setLastModifyTime(cbo.getLastModifyTime());
-//		List<ClientBusinessObject> cboList = new ArrayList<>();
-//		cboList.add(cbo);
+		cbo.setTenantId(AuthUtil.getTenantId());
+		oldCbo.setLastV("0");
+		oldCbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
+		oldCbo.setLastModifyTime(new Date());
         try {
-//			cboOperation.saveRevisionBuinessObject(cbo);
+			updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo));
             insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo));
         } catch (Exception vciError) {
             throw new VciBaseException("鏁版嵁鏇存敼淇濆瓨鍑洪敊浜�", new String[0], vciError);
@@ -3831,4 +3822,21 @@
         return toBo;
 
     }
+
+	/**
+	 * 娴佺▼涓彉鏇寸姸鎬佸��
+	 * @param flowDTO
+	 * @return
+	 */
+	@Override
+	public R processChangeStatus(FlowStatusDTO flowDTO) {
+		flowDTO.getOids().forEach(s -> {
+			BaseModelDTO baseModel = new BaseModelDTO();
+			baseModel.setOid(s);
+			baseModel.setBtmname(flowDTO.getBtmType());
+			baseModel.setLcStatus(String.valueOf(flowDTO.getVariableMap().getOrDefault("statusValue","Auditing")));
+			changeStatus(baseModel);
+		});
+		return R.success("鎴愬姛");
+	}
 }

--
Gitblit v1.9.3