Commit df47ee7a by tiger

Merge branch 'v1.0.1' of http://192.168.3.233:8090/platform/platform-process-server into v1.0.1

2 parents 559d76a9 dad2a8c2
......@@ -11,12 +11,6 @@ import javax.persistence.Transient;
@Table(name = "sop_inst_node")
public class SopInstNode {
public static final byte NODE_SKIP_FALSE = 0;
public static final byte NODE_SKIP_TRUE = 1;
public static final int NODE_STATUS_DELETED = 0;
public static final int NODE_STATUS_NORMAL = 1;
/**
* 实例节点id
*/
......
......@@ -7,9 +7,6 @@ import javax.persistence.Table;
@Table(name = "sop_tpl_node")
public class SopTplNode {
public static final byte NODE_SKIPABLE_NO = 0;
public static final byte NODE_SKIPABLE_YES = 1;
/**
* 节点id
*/
......
package cn.com.glsx.process.modules.model.enums;
public enum SopInstNodeSkipEnum {
FALSE("不跳过节点", (byte)0), TRUE("跳过节点", (byte)1);
private String name;
private byte value;
SopInstNodeSkipEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopInstNodeStatusEnum {
DELETED("停用", 0), NORMAL("启用", 1);
private String name;
private int value;
SopInstNodeStatusEnum(String name, int value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopTplNodeSkipableEnum {
NO("不可跳过节点", (byte)0), YES("可跳过节点", (byte)1);
private String name;
private byte value;
SopTplNodeSkipableEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
package cn.com.glsx;
import static java.time.ZoneId.of;
import static java.util.TimeZone.getTimeZone;
import java.util.TimeZone;
import javax.annotation.PostConstruct;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import com.glsx.plat.context.EnableRestAdmin;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
......@@ -16,9 +12,11 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.glsx.plat.context.EnableRestAdmin;
import javax.annotation.PostConstruct;
import java.util.TimeZone;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import static java.time.ZoneId.of;
import static java.util.TimeZone.getTimeZone;
/**
* @author payu
......@@ -26,7 +24,7 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
@EnableDubbo
@EnableRestAdmin
@EnableDiscoveryClient
@EnableFeignClients(basePackages = { "cn.com.glsx.*.api", "cn.com.glsx.process.modules.client" })
@EnableFeignClients(basePackages = { "cn.com.glsx.*.api"})
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableTransactionManagement
......
package cn.com.glsx.process.common.sysenum;
import com.glsx.plat.exception.SystemMessage;
/**
* 试驾服务错误码
*
* @author zhouhaibao
*/
public enum ResultEnum {
PARAM_ERROR(1001, "参数错误"),
FEIGN_REQUEST_ERROR(1002, "feign请求异常"),
DATA_HANDLE_ERROR(1003, "数据处理异常");
private final Integer code;
private final String message;
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
ResultEnum(SystemMessage systemMessage) {
this.code = systemMessage.getCode();
this.message = systemMessage.getMsg();
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
}
package cn.com.glsx.process.exception;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import com.glsx.plat.exception.SystemMessage;
import lombok.Getter;
import lombok.Setter;
/**
* @author payu
*/
@Setter
@Getter
public class AdminException extends RuntimeException {
private int errorCode;
private String message;
public AdminException() {
}
public AdminException(String message) {
super(message);
this.errorCode = SystemMessage.FAILURE.getCode();
this.message = message;
}
public AdminException(int errorCode, String message) {
super(message);
this.errorCode = errorCode;
this.message = message;
}
public AdminException(ResultEnum resultEnum) {
this.errorCode = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public AdminException(Throwable cause) {
super(cause);
}
public AdminException(String message, Throwable cause) {
super(message, cause);
}
}
package cn.com.glsx.process.exception;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.glsx.plat.core.web.R;
import com.glsx.plat.exception.ExceptionLevel;
import com.glsx.plat.exception.GlobalRExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.BindingException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 全局异常处理
*
* @author payu
*/
@Slf4j
@RestControllerAdvice
public class AdminExceptionHandler extends GlobalRExceptionHandler {
@ExceptionHandler(AdminException.class)
public R handleAdminException(AdminException e) {
return R.error(e.getErrorCode(),e.getMessage());
}
/**
* Mybatis BindingException
*
* @param e
* @return
*/
@ExceptionHandler(BindingException.class)
public R handleBindingException(BindingException e) {
return R.error(e.getMessage());
}
@ExceptionHandler(ExcelDataConvertException.class)
public R handleExcelDataConvertException(ExcelDataConvertException e) {
return R.error(e.getMessage());
}
@Override
protected void saveException(Exception e, ExceptionLevel level) {
super.saveException(e, level);
}
}
package cn.com.glsx.process.modules.controller;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import com.glsx.plat.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -29,8 +32,7 @@ public class TestXXLJobController {
@GetMapping("/jobtest")
@Operation(summary = "动态任务添加", description = "动态任务添加")
public void addtest(@RequestParam("cron") String cron, @RequestParam("jobName") String jobName, @RequestParam("param") String param,
@RequestParam("executorHandler") String executorHandler, @RequestParam("busKey") String busKey) {
public void addtest(@RequestParam("cron") String cron, @RequestParam("jobName") String jobName, @RequestParam("param") String param, @RequestParam("executorHandler") String executorHandler, @RequestParam("busKey") String busKey) {
// cron表达式
XxlJobInfo jobInfo = new XxlJobInfo();
jobInfo.setExecutorParam(param);
......@@ -44,11 +46,7 @@ public class TestXXLJobController {
@PostMapping("/jobtestupdate")
@Operation(summary = "动态任务更新", description = "动态任务更新")
public void updatetest(@RequestParam(value = "cron", required = false) String cron,
@RequestParam("id") String id,
@RequestParam(value = "executorParam", required = false) String executorParam,
@RequestParam(value = "jobDesc", required = false) String jobDesc,
@RequestParam(value = "triggerStatus", required = false) Integer triggerStatus) {
public void updatetest(@RequestParam(value = "cron", required = false) String cron, @RequestParam("id") String id, @RequestParam(value = "executorParam", required = false) String executorParam, @RequestParam(value = "jobDesc", required = false) String jobDesc, @RequestParam(value = "triggerStatus", required = false) Integer triggerStatus) {
XxlJobInfo jobInfo = new XxlJobInfo();
jobInfo.setBusKey(id);
jobInfo.setScheduleConf(cron);
......@@ -91,6 +89,9 @@ public class TestXXLJobController {
@PostMapping("/testJava")
@Operation(summary = "测试java", description = "动态任务触发")
public R testJava(@RequestParam("busKey") String busKey) throws Exception {
if (true) {
throw new AdminException(ResultEnum.PARAM_ERROR);
}
return R.ok().data(userDemoService.testJava(busKey));
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import java.util.Date;
import java.util.Objects;
/**
*
......@@ -75,6 +76,10 @@ public class SopCustomerExcelDTO {
}
public int getSopJourneyDays() {
if (Objects.isNull(sopJourneyEnterTime)) {
return 0;
}
Date now = new Date();
long nowTime = now.getTime();
long enterTime = sopJourneyEnterTime.getTime();
......@@ -103,7 +108,10 @@ public class SopCustomerExcelDTO {
}
public int getSopJourneyStageDays() {
// TODO 注意空指针
if (Objects.isNull(sopJourneyStageEnterTime)) {
return 0;
}
Date now = new Date();
long nowTime = now.getTime();
long enterTime = sopJourneyStageEnterTime.getTime();
......
......@@ -10,10 +10,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
public static final String DATA_REPORT_QUEUE_NAME = "dataReport_queue";
public static final String DATA_REPORT_EXCHANGE_NAME = "dataReport_exchange";
public static final String DATA_REPORT_TOPIC = "dataReport.#";
//声明topic交换机
@Bean
public TopicExchange topicExchange() {
......@@ -23,18 +19,18 @@ public class RabbitConfig {
@Bean(name = "dataReportQueue")
public Queue dataReportQueue() {
return new Queue(DATA_REPORT_QUEUE_NAME, true);
return new Queue(RabbitMQConstants.DATA_REPORT_QUEUE_NAME, true);
}
@Bean(name = "dataReportTopicExchange")
public TopicExchange dataReportTopicExchange() {
return new TopicExchange(DATA_REPORT_EXCHANGE_NAME);
return new TopicExchange(RabbitMQConstants.DATA_REPORT_EXCHANGE_NAME);
}
@Bean
public Binding bindingDataReport(@Qualifier("dataReportQueue") Queue dataReportQueue,
@Qualifier("dataReportTopicExchange") TopicExchange dataReportTopicExchange) {
return BindingBuilder.bind(dataReportQueue).to(dataReportTopicExchange).with(DATA_REPORT_TOPIC);
return BindingBuilder.bind(dataReportQueue).to(dataReportTopicExchange).with(RabbitMQConstants.DATA_REPORT_TOPIC);
}
......
......@@ -4,4 +4,10 @@ public interface RabbitMQConstants {
String TOPIC_EXCHANGE_PLATFORM_PROCESS = "sop.platform-process";
String ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE = "sop_inst.inst_param.custom_data.update";
//上报给cdp的相关信息常量(cdp那边固定)
String DATA_REPORT_QUEUE_NAME = "dataReport_queue";
String DATA_REPORT_EXCHANGE_NAME = "dataReport_exchange";
String DATA_REPORT_TOPIC = "dataReport.#";
String DATA_REPORT_ROUTING_KEY = "dataReport.customer.event";
}
......@@ -5,6 +5,8 @@ import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import cn.com.glsx.process.modules.converter.SopInstConverter;
import cn.com.glsx.process.modules.converter.SopTplConverter;
import cn.com.glsx.process.modules.converter.SopTplLinKConverter;
......@@ -12,19 +14,20 @@ import cn.com.glsx.process.modules.converter.SopTplNodeConverter;
import cn.com.glsx.process.modules.entity.*;
import cn.com.glsx.process.modules.mapper.*;
import cn.com.glsx.process.modules.model.*;
import cn.com.glsx.process.modules.model.enums.SopInstNodeSkipEnum;
import cn.com.glsx.process.modules.model.enums.SopInstNodeStatusEnum;
import cn.com.glsx.process.modules.model.enums.SopInstStatusEnum;
import cn.com.glsx.process.modules.model.enums.SopTplNodeSkipableEnum;
import cn.com.glsx.process.modules.rabbitmq.MsgProducer;
import cn.com.glsx.process.modules.rabbitmq.RabbitConfig;
import cn.com.glsx.process.modules.rabbitmq.RabbitMQConstants;
import cn.com.glsx.process.util.FileUploadServerData;
import cn.com.glsx.process.util.FileUploadUtil;
import cn.com.glsx.process.util.SopTplParamHandler;
import cn.hutool.core.date.DatePattern;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.enums.SysConstants;
import com.glsx.plat.core.web.Result;
import com.glsx.plat.exception.ResultException;
import com.glsx.plat.exception.SystemMessage;
import com.glsx.plat.office.excel.EasyExcelUtils;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -272,13 +275,13 @@ public class SopInstService {
List<SopTplGrant> sopTplGrants = sopInstDTO.getSopTplGrants();
if (CollectionUtils.isEmpty(sopTplGrants)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "请选择门店");
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "请选择门店");
}
List<String> groupIds = sopTplGrants.stream().map(sopTplGrant -> sopTplGrant.getGroupId()).collect(Collectors.toList());
List<SopTplGrant> grants = sopTplGrantMapper.selectInUseGrants(tplId, groupIds);
if (!CollectionUtils.isEmpty(grants)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), String.format("%s已存在该旅程,请确认后重新操作", grants.get(0).getGroupName()));
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), String.format("%s已存在该旅程,请确认后重新操作", grants.get(0).getGroupName()));
}
//新增派发门店记录
......@@ -327,7 +330,7 @@ public class SopInstService {
for (SopTplNode sopTplNode : nodes) {
SopInstNode sopInstNode = sopTplNodeConverter.tpl2inst(sopTplNode);
sopInstNode.setInstId(instId);
sopInstNode.setNodeStatus(SopInstNode.NODE_STATUS_NORMAL);
sopInstNode.setNodeStatus(SopInstNodeStatusEnum.NORMAL.getValue());
// 处理模板节点定义的初始化参数
sopInstNode.setNodeParam(SopTplParamHandler.extract(sopTplNode.getNodeParamDef()));
......@@ -335,12 +338,12 @@ public class SopInstService {
//页面选择是否跳过处理
SopInstNode sopInstNodeTemp = customNodesMap.get(sopInstNode.getNodeId());
if (!Objects.isNull(sopInstNodeTemp)
&& sopInstNodeTemp.getNodeSkip().equals(SopInstNode.NODE_SKIP_TRUE)
&& sopTplNode.getNodeSkipable().equals(SopTplNode.NODE_SKIPABLE_NO)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), String.format("节点 %s 不可跳过", sopInstNode.getNodeName()));
&& sopInstNodeTemp.getNodeSkip().equals(SopInstNodeSkipEnum.TRUE.getValue())
&& sopTplNode.getNodeSkipable().equals(SopTplNodeSkipableEnum.NO.getValue())) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), String.format("节点 %s 不可跳过", sopInstNode.getNodeName()));
}
sopInstNode.setNodeSkip(!Objects.isNull(sopInstNodeTemp) ? sopInstNodeTemp.getNodeSkip() : SopInstNode.NODE_SKIP_FALSE);
sopInstNode.setNodeSkip(!Objects.isNull(sopInstNodeTemp) ? sopInstNodeTemp.getNodeSkip() : SopInstNodeSkipEnum.FALSE.getValue());
sopInstNodes.add(sopInstNode);
}
sopInstNodeMapper.insertList(sopInstNodes);
......@@ -357,7 +360,7 @@ public class SopInstService {
String sopJourneyId = search.getSopJourneyId();
SopInst sopInst = sopInstMapper.selectByPrimaryKey(sopJourneyId);
if (Objects.isNull(sopInst)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "该模板实例不存在!");
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "该模板实例不存在!");
}
SopTplGrant sopTplGrant = sopTplGrantMapper.selectByPrimaryKey(sopInst.getGrantId());
......@@ -409,12 +412,12 @@ public class SopInstService {
String oneId = body.getOneId();
Result<CustomerSopJourneyDetailDTO> detail = customerSopJourneyFeignClient.detail(orgId, sopJourneyId, oneId);
if (!SysConstants.ResultStatus.success.getCode().equals(detail.getCode())) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "查询客户信息异常");
throw new AdminException(ResultEnum.FEIGN_REQUEST_ERROR.getCode(), "查询客户信息异常");
}
CustomerSopJourneyDetailDTO customerDetail = detail.getData();
if (Objects.isNull(customerDetail)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "客户信息不存在");
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "客户信息不存在");
}
ModifySopJourneyStageRequest request = new ModifySopJourneyStageRequest();
......@@ -426,7 +429,7 @@ public class SopInstService {
Result<Boolean> booleanResult = customerSopJourneyFeignClient.modifyStage(request);
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);
HashMap<String, Object> mqMap = new HashMap<>();
mqMap.put("org_id", orgId);
......@@ -437,7 +440,7 @@ public class SopInstService {
mqMap.put("platform", "WebPage");
mqMap.put("extra", body);
msgProducer.topicSend(RabbitConfig.DATA_REPORT_EXCHANGE_NAME, "dataReport.customer.event", Lists.newArrayList(mqMap));
msgProducer.topicSend(RabbitMQConstants.DATA_REPORT_EXCHANGE_NAME, RabbitMQConstants.DATA_REPORT_ROUTING_KEY, Lists.newArrayList(mqMap));
return booleanResult;
}
......@@ -445,7 +448,7 @@ public class SopInstService {
search.setPageSize(5000);
SopInst sopInst = sopInstMapper.selectByPrimaryKey(search.getSopJourneyId());
if (Objects.isNull(sopInst)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), "模板实例不存在");
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "模板实例不存在");
}
List<SopCustomerExcelDTO> data = new ArrayList<>();
......@@ -477,14 +480,14 @@ public class SopInstService {
FileUploadServerData fileUploadServerData = FileUploadUtil.uploadToFileSystem(String.format("客户数据_%d", now.getTime()), bytes, "xlsx");
return fileUploadServerData;
} catch (Exception e) {
throw ResultException.create(SystemMessage.DATA_HANDLE_ERROR.getCode(), "客户数据导出处理异常");
throw new AdminException(ResultEnum.DATA_HANDLE_ERROR.getCode(), "客户数据导出处理异常");
}
}
private void getCustomersForExcel(SopCustomerSearch search, List<CustomerSopJourneyDTO> customerSopJourneyDTOList) {
Result<PageInfo<CustomerSopJourneyDTO>> customersResult = customers(search);
if (!SysConstants.ResultStatus.success.getCode().equals(customersResult.getCode())) {
throw ResultException.create(SystemMessage.MICROSERVICE_CALL_FAIL.getCode(), "查询客户数据接口异常");
throw new AdminException(ResultEnum.FEIGN_REQUEST_ERROR.getCode(), "查询客户数据接口异常");
}
PageInfo<CustomerSopJourneyDTO> pageInfo = customersResult.getData();
......
package cn.com.glsx.process.util;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.glsx.plat.exception.ResultException;
import com.glsx.plat.exception.SystemMessage;
import lombok.experimental.UtilityClass;
import org.springframework.util.StringUtils;
......@@ -24,7 +24,7 @@ public class SopTplParamHandler {
JsonNode rootNode = objectMapper.readTree(tplParam);
return processNode(rootNode);
} catch (Exception e) {
throw ResultException.create(SystemMessage.DATA_HANDLE_ERROR.getCode(), "参数转json对象异常");
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "参数转json对象异常");
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!