|
@@ -0,0 +1,120 @@
|
|
|
+package com.ruoyi.execution.produce.dispersed.service.impl.runbpm;
|
|
|
+
|
|
|
+import com.ruoyi.common.config.bpm.BpmProperties;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.utils.http.sending;
|
|
|
+import com.ruoyi.execution.produce.dispersed.enetity.runbpm.IRunBPMEntity;
|
|
|
+import com.ruoyi.execution.produce.dispersed.service.IRunBPMService;
|
|
|
+import com.ruoyi.system.entity.CommonEntity;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 测试排产任务节点
|
|
|
+ */
|
|
|
+public class Test1Bpm implements IRunBPMService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BpmProperties bpmProperties;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private sending sending;
|
|
|
+
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult preValidation(IRunBPMEntity iRunBPMEntity) {
|
|
|
+ Map<String, Object> map = iRunBPMEntity.getExecutionMap();
|
|
|
+ //判断表名是否存在
|
|
|
+ if (!map.containsKey("basicMap")) return AjaxResult.error("表名不存在");
|
|
|
+ //判断字段是否存在
|
|
|
+ if (!map.containsKey("commMap")) return AjaxResult.error("插入字段不存在");
|
|
|
+ //判断修改条件是否存在
|
|
|
+ if (!map.containsKey("conditionMap")) return AjaxResult.error("修改条件不存在");
|
|
|
+ //判断查询条件是否存在
|
|
|
+ if (!map.containsKey("queryConditions")) return AjaxResult.error("查询条件不存在");
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult executeNode(IRunBPMEntity iRunBPMEntity) throws Exception {
|
|
|
+ //接收参数
|
|
|
+ Map<String, Object> map = iRunBPMEntity.getExecutionMap();
|
|
|
+ //查询
|
|
|
+ CommonEntity queryMap = new CommonEntity();
|
|
|
+ queryMap.setBasicMap((Map<String, Object>) map.get("basicMap"));
|
|
|
+ queryMap.setConditionMap((Map<String, Object>) map.get("queryConditions"));
|
|
|
+ ResponseEntity<AjaxResult> response = null;
|
|
|
+// try {
|
|
|
+// response = restTemplate.exchange(
|
|
|
+// bpmProperties.formCommonGetInfoIp, HttpMethod.GET, new HttpEntity<>(queryMap), AjaxResult.class);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// if (response.getStatusCodeValue() != 200) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+ try {
|
|
|
+ response = sending.sendCommonGetInfo(queryMap);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new Exception("网络错误");
|
|
|
+ }
|
|
|
+ if (response.getStatusCodeValue() != 200) {
|
|
|
+ return AjaxResult.error();
|
|
|
+ }
|
|
|
+ AjaxResult body = response.getBody();
|
|
|
+ //得到详情数据
|
|
|
+ Map<String, Object> data = (Map<String, Object>) body.get("data");
|
|
|
+ //库里planWeight
|
|
|
+ Long planWeight = Long.valueOf(data.get("planWeight").toString());
|
|
|
+ Map<String, Object> basicMap = (Map<String, Object>) map.get("basicMap");
|
|
|
+ //累加的planWeight
|
|
|
+ Long planWeight1 = Long.valueOf(basicMap.get("planWeight").toString());
|
|
|
+ //计算planWeight
|
|
|
+ Long weight = planWeight + planWeight1;
|
|
|
+ String planState = basicMap.get("planState").toString();
|
|
|
+
|
|
|
+ //修改map
|
|
|
+ CommonEntity editMap = new CommonEntity();
|
|
|
+ queryMap.setBasicMap((Map<String, Object>) map.get("basicMap"));
|
|
|
+ Map<String, Object> commMap = new HashMap<>();
|
|
|
+ commMap.put("plan_weight", weight);
|
|
|
+ commMap.put("plan_state", planState);
|
|
|
+ queryMap.setCommMap(commMap);
|
|
|
+ queryMap.setConditionMap((Map<String, Object>) map.get("conditionMap"));
|
|
|
+
|
|
|
+// AjaxResult ajaxResult = restTemplate.postForObject(bpmProperties.formCommonUpdateIp, editMap, AjaxResult.class);
|
|
|
+// if (Long.valueOf(ajaxResult.get("code").toString()) != 200L) return false;
|
|
|
+ try {
|
|
|
+ response = sending.sendCommonUpdate(editMap);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new Exception("网络错误");
|
|
|
+ }
|
|
|
+ if (response.getStatusCodeValue() != 200) {
|
|
|
+ return AjaxResult.error();
|
|
|
+ }else {
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult afterValidation(IRunBPMEntity iRunBPMEntity) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isVerificationMethod() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean preDestroy() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|