|
|
@@ -5,6 +5,7 @@ import easydo.technology.enums.ChengfaEnum;
|
|
|
import easydo.technology.exception.BizException;
|
|
|
import easydo.technology.model.*;
|
|
|
import easydo.technology.model.vo.ContractVo;
|
|
|
+import easydo.technology.model.vo.GLDMessage;
|
|
|
import easydo.technology.model.vo.MDMDept;
|
|
|
import easydo.technology.model.vo.MDMSupplier;
|
|
|
import easydo.technology.model.vo.MDMUser;
|
|
|
@@ -12,6 +13,7 @@ import easydo.technology.system.domain.SysDept;
|
|
|
import easydo.technology.utils.LocalDateUtil;
|
|
|
import easydo.technology.utils.StringUtil;
|
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
@@ -28,6 +30,8 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.sql.DataSource;
|
|
|
import java.sql.Connection;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.Statement;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
@@ -330,4 +334,53 @@ public class ApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/message/push")
|
|
|
+ public Object pushMessage(@RequestBody GLDMessage gldMessage) throws Exception {
|
|
|
+ String token = gldMessage.getToken();
|
|
|
+ String type = gldMessage.getRefType();
|
|
|
+ String instanceId = gldMessage.getInstanceId();
|
|
|
+ if (!TOKEN.equals(token)) {
|
|
|
+ return new ResponseEntity<>("no auth", HttpStatus.OK);
|
|
|
+ }
|
|
|
+ if (StringUtil.isEmpty(gldMessage.getReceiveUserCode()) || StringUtil.isEmpty(instanceId)) {
|
|
|
+ return new ResponseEntity<>("参数无效", HttpStatus.OK);
|
|
|
+ }
|
|
|
+ Connection connection = null;
|
|
|
+ String businessId = "";
|
|
|
+ ResultSet resultSet = null;
|
|
|
+ try {
|
|
|
+ connection = dataSource.getConnection();
|
|
|
+ Statement statement = connection.createStatement();
|
|
|
+ Message message = new Message();
|
|
|
+ BeanUtils.copyProperties(gldMessage, message);
|
|
|
+
|
|
|
+ SysUser receiveUser = new SysUser();
|
|
|
+ receiveUser.setCode(gldMessage.getReceiveUserCode());
|
|
|
+ receiveUser = jdbcClient.getJdbcModel(receiveUser, connection);
|
|
|
+ message.setReceiveUserId(receiveUser.getUserId());
|
|
|
+ message.setReceiveUserName(receiveUser.getNickName());
|
|
|
+
|
|
|
+ if (type.equals(ChengfaEnum.BUS_APPROVE_TYPE_PURCHASE_PLAN.getValue())
|
|
|
+ || type.equals(ChengfaEnum.BUS_APPROVE_TYPE_PURCHASE.getValue())) {
|
|
|
+ String sql = "select id from " + type + " where process_instance_id = '" + instanceId + "' limit 1";
|
|
|
+ resultSet = statement.executeQuery(sql);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ String sql = "select purchase_id from " + type + " where process_instance_id = '" + instanceId
|
|
|
+ + "' limit 1";
|
|
|
+ resultSet = statement.executeQuery(sql);
|
|
|
+ }
|
|
|
+ while (resultSet.next()) {
|
|
|
+ businessId = resultSet.getString(1);
|
|
|
+ }
|
|
|
+ message.setRefId(businessId);
|
|
|
+ jdbcClient.jdbcInsert(message, connection);
|
|
|
+
|
|
|
+ return new ResponseEntity<>(message, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BizException(e.getMessage());
|
|
|
+ } finally {
|
|
|
+ jdbcClient.finallyExecute(connection);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|