Commit 3f4fb2b2 by guojuxing

udesk

parents
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gic-pom-base</artifactId>
<groupId>com.gic</groupId>
<version>4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-platform-udesk-api</artifactId>
<version>${libraryVersion}</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<libraryVersion>4.0-SNAPSHOT</libraryVersion>
</properties>
<dependencies>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-base-api</artifactId>
<version>${gic-base-api}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-base-api</artifactId>
<version>${gic-enterprise-base-api}</version>
</dependency>
<!--参数验证-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.16.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b09</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<flattenMode>defaults</flattenMode>
</configuration>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.gic.udesk.constant;
/**
* udesk共享常量类
* @ClassName: UdeskSharedConstant

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:43 PM

*/
public class UdeskSharedConstant {
/**
* udesk消息来源
*/
public static final String UDESK_SOURCE = "udesk";
/**
* tapd消息来源
*/
public static final String TAPD_SOURCE = "tapd";
/**
* tapd消息主题
*/
public static final String TAPD_MESSAGE_TOPIC = "bug";
/**
* tapd缺陷更新事件
*/
public static final String TAPD_BUG_UPDATE_EVENT = "bug::update";
/**
* tapd缺陷删除事件
*/
public static final String TAPD_BUG_DELETE_EVENT = "bug::delete";
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 附件
* @ClassName: AttachmentDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:05 PM

*/
public class AttachmentDTO implements Serializable{
private static final long serialVersionUID = 6369929530568254062L;
/**
* 坑,文档示例返回是name,调用是file_name
*/
private String file_name;
/**
*
*/
private String url;
public String getFile_name() {
return file_name;
}
public void setFile_name(String file_name) {
this.file_name = file_name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 关注者
* @ClassName: FollowerDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:06 PM

*/
public class FollowerDTO implements Serializable{
private static final long serialVersionUID = -6806790410409455090L;
/**
*
*/
private Integer id;
/**
*
*/
private String nick_name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNick_name() {
return nick_name;
}
public void setNick_name(String nick_name) {
this.nick_name = nick_name;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
import java.util.Map;
/**
* udesk公司信息
* @ClassName: OrganizationDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:07 PM

*/
public class OrganizationDTO implements Serializable{
private static final long serialVersionUID = -3042952127522207394L;
/**
*
*/
private Integer id;
/**
*
*/
private String name;
/**
*
*/
private String domains;
/**
*
*/
private String description;
/**
*
*/
private String token;
/**
*
*/
private Map<String, String> custom_fields;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDomains() {
return domains;
}
public void setDomains(String domains) {
this.domains = domains;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Map<String, String> getCustom_fields() {
return custom_fields;
}
public void setCustom_fields(Map<String, String> custom_fields) {
this.custom_fields = custom_fields;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 缺陷基类
* @ClassName: TapdBugBaseDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:08 PM

*/
public class TapdBugBaseDTO implements Serializable{
private static final long serialVersionUID = 996019256030454386L;
/**
* BUG id
*/
private String id;
/**
* 标题
*/
private String title;
/**
* 详细描述
*/
private String description;
/**
* 优先级
*/
private String priority;
/**
* 严重程度
*/
private String severity;
/**
* 状态
*/
private String status;
/**
* 创建人
*/
private String reporter;
/**
* 缺陷类型
*/
private String bugtype;
/**
* 当前处理人
*/
private String current_owner;
/**
* 发现阶段
*/
private String originphase;
/**
* 测试类型
*/
private String testtype;
/**
* 重现规律
*/
private String frequency;
/**
* 自定义字段
*/
private String custom_field_one;
private String custom_field_two;
private String custom_field_three;
private String custom_field_four;
private String custom_field_five;
private String custom_field_6;
private String custom_field_7;
private String custom_field_8;
private String custom_field_9;
private String custom_field_10;
/**
* 项目id
*/
private String workspace_id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getSeverity() {
return severity;
}
public void setSeverity(String severity) {
this.severity = severity;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getReporter() {
return reporter;
}
public void setReporter(String reporter) {
this.reporter = reporter;
}
public String getBugtype() {
return bugtype;
}
public void setBugtype(String bugtype) {
this.bugtype = bugtype;
}
public String getCurrent_owner() {
return current_owner;
}
public void setCurrent_owner(String current_owner) {
this.current_owner = current_owner;
}
public String getOriginphase() {
return originphase;
}
public void setOriginphase(String originphase) {
this.originphase = originphase;
}
public String getTesttype() {
return testtype;
}
public void setTesttype(String testtype) {
this.testtype = testtype;
}
public String getFrequency() {
return frequency;
}
public void setFrequency(String frequency) {
this.frequency = frequency;
}
public String getCustom_field_one() {
return custom_field_one;
}
public void setCustom_field_one(String custom_field_one) {
this.custom_field_one = custom_field_one;
}
public String getCustom_field_two() {
return custom_field_two;
}
public void setCustom_field_two(String custom_field_two) {
this.custom_field_two = custom_field_two;
}
public String getCustom_field_three() {
return custom_field_three;
}
public void setCustom_field_three(String custom_field_three) {
this.custom_field_three = custom_field_three;
}
public String getCustom_field_four() {
return custom_field_four;
}
public void setCustom_field_four(String custom_field_four) {
this.custom_field_four = custom_field_four;
}
public String getCustom_field_five() {
return custom_field_five;
}
public void setCustom_field_five(String custom_field_five) {
this.custom_field_five = custom_field_five;
}
public String getCustom_field_6() {
return custom_field_6;
}
public void setCustom_field_6(String custom_field_6) {
this.custom_field_6 = custom_field_6;
}
public String getCustom_field_7() {
return custom_field_7;
}
public void setCustom_field_7(String custom_field_7) {
this.custom_field_7 = custom_field_7;
}
public String getCustom_field_8() {
return custom_field_8;
}
public void setCustom_field_8(String custom_field_8) {
this.custom_field_8 = custom_field_8;
}
public String getCustom_field_9() {
return custom_field_9;
}
public void setCustom_field_9(String custom_field_9) {
this.custom_field_9 = custom_field_9;
}
public String getCustom_field_10() {
return custom_field_10;
}
public void setCustom_field_10(String custom_field_10) {
this.custom_field_10 = custom_field_10;
}
public String getWorkspace_id() {
return workspace_id;
}
public void setWorkspace_id(String workspace_id) {
this.workspace_id = workspace_id;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 缺陷类,用于tapd,(获取缺陷接口,添加缺陷接口,更新缺陷接口)
* @ClassName: TapdBugDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:09 PM

*/
public class TapdBugDTO extends TapdBugBaseDTO implements Serializable{
private static final long serialVersionUID = 1194893729619773267L;
/**
* 模块
*/
private String module;
/**
* 解决期限
*/
private String deadline;
/**
* 创建时间
*/
private String created;
/**
* 解决时间
*/
private String resolved;
/**
* 关闭时间
*/
private String closed;
/**
* 最后修改时间
*/
private String modified;
/**
* 最后修改人
*/
private String lastmodify;
/**
* 审核人
*/
private String auditer;
/**
* 开发人员
*/
private String de;
/**
* 验证版本
*/
private String version_test;
/**
* 发现版本
*/
private String version_report;
/**
* 关闭版本
*/
private String version_close;
/**
* 合入版本
*/
private String version_fix;
/**
* 发现基线
*/
private String baseline_find;
/**
* 合入基线
*/
private String baseline_join;
/**
* 关闭基线
*/
private String baseline_close;
/**
* 验证基线
*/
private String baseline_test;
/**
* 引入阶段
*/
private String sourcephase;
/**
* 测试人员
*/
private String te;
/**
* 迭代
*/
private String iteration_id;
/**
* 解决方法
*/
private String resolution;
/**
* 缺陷根源
*/
private String source;
/**
* 验证人
*/
private String confirmer;
/**
* TAPD产品文档中没写.(里程碑?)
*/
private String milestone;
/**
* 参与人
*/
private String participator;
/**
* 关闭人
*/
private String closer;
/**
* 软件平台
*/
private String platform;
/**
* 操作系统
*/
private String os;
/**
* 测试阶段
*/
private String testphase;
/**
* 抄送人
*/
private String cc;
/**
* TAPD产品文档中没写
*/
private String regression_number;
/**
* TAPD产品文档中没写
*/
private String flows;
/**
* TAPD产品文档中没写
*/
private String feature;
/**
* 测试方式
*/
private String testmode;
/**
* TAPD产品文档中没写
*/
private String estimate;
/**
* TAPD产品文档中没写
*/
private String issue_id;
/**
* TAPD产品文档中没写
*/
private String created_from;
/**
* 接受处理时间
*/
private String in_progress_time;
/**
* 验证时间
*/
private String verify_time;
/**
* 拒绝时间
*/
private String reject_time;
/**
* TAPD产品文档中没写
*/
private String reopen_time;
/**
* TAPD产品文档中没写
*/
private String audit_time;
/**
* TAPD产品文档中没写
*/
private String suspend_time;
/**
* 预计结束
*/
private String due;
/**
* 预计开始
*/
private String begin;
/**
* 自定义字段
*/
private String custom_field_11;
private String custom_field_12;
private String custom_field_13;
private String custom_field_14;
private String custom_field_15;
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
}
public String getDeadline() {
return deadline;
}
public void setDeadline(String deadline) {
this.deadline = deadline;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getResolved() {
return resolved;
}
public void setResolved(String resolved) {
this.resolved = resolved;
}
public String getClosed() {
return closed;
}
public void setClosed(String closed) {
this.closed = closed;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
public String getLastmodify() {
return lastmodify;
}
public void setLastmodify(String lastmodify) {
this.lastmodify = lastmodify;
}
public String getAuditer() {
return auditer;
}
public void setAuditer(String auditer) {
this.auditer = auditer;
}
public String getDe() {
return de;
}
public void setDe(String de) {
this.de = de;
}
public String getVersion_test() {
return version_test;
}
public void setVersion_test(String version_test) {
this.version_test = version_test;
}
public String getVersion_report() {
return version_report;
}
public void setVersion_report(String version_report) {
this.version_report = version_report;
}
public String getVersion_close() {
return version_close;
}
public void setVersion_close(String version_close) {
this.version_close = version_close;
}
public String getVersion_fix() {
return version_fix;
}
public void setVersion_fix(String version_fix) {
this.version_fix = version_fix;
}
public String getBaseline_find() {
return baseline_find;
}
public void setBaseline_find(String baseline_find) {
this.baseline_find = baseline_find;
}
public String getBaseline_join() {
return baseline_join;
}
public void setBaseline_join(String baseline_join) {
this.baseline_join = baseline_join;
}
public String getBaseline_close() {
return baseline_close;
}
public void setBaseline_close(String baseline_close) {
this.baseline_close = baseline_close;
}
public String getBaseline_test() {
return baseline_test;
}
public void setBaseline_test(String baseline_test) {
this.baseline_test = baseline_test;
}
public String getSourcephase() {
return sourcephase;
}
public void setSourcephase(String sourcephase) {
this.sourcephase = sourcephase;
}
public String getTe() {
return te;
}
public void setTe(String te) {
this.te = te;
}
public String getIteration_id() {
return iteration_id;
}
public void setIteration_id(String iteration_id) {
this.iteration_id = iteration_id;
}
public String getResolution() {
return resolution;
}
public void setResolution(String resolution) {
this.resolution = resolution;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getConfirmer() {
return confirmer;
}
public void setConfirmer(String confirmer) {
this.confirmer = confirmer;
}
public String getMilestone() {
return milestone;
}
public void setMilestone(String milestone) {
this.milestone = milestone;
}
public String getParticipator() {
return participator;
}
public void setParticipator(String participator) {
this.participator = participator;
}
public String getCloser() {
return closer;
}
public void setCloser(String closer) {
this.closer = closer;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getOs() {
return os;
}
public void setOs(String os) {
this.os = os;
}
public String getTestphase() {
return testphase;
}
public void setTestphase(String testphase) {
this.testphase = testphase;
}
public String getCc() {
return cc;
}
public void setCc(String cc) {
this.cc = cc;
}
public String getRegression_number() {
return regression_number;
}
public void setRegression_number(String regression_number) {
this.regression_number = regression_number;
}
public String getFlows() {
return flows;
}
public void setFlows(String flows) {
this.flows = flows;
}
public String getFeature() {
return feature;
}
public void setFeature(String feature) {
this.feature = feature;
}
public String getTestmode() {
return testmode;
}
public void setTestmode(String testmode) {
this.testmode = testmode;
}
public String getEstimate() {
return estimate;
}
public void setEstimate(String estimate) {
this.estimate = estimate;
}
public String getIssue_id() {
return issue_id;
}
public void setIssue_id(String issue_id) {
this.issue_id = issue_id;
}
public String getCreated_from() {
return created_from;
}
public void setCreated_from(String created_from) {
this.created_from = created_from;
}
public String getIn_progress_time() {
return in_progress_time;
}
public void setIn_progress_time(String in_progress_time) {
this.in_progress_time = in_progress_time;
}
public String getVerify_time() {
return verify_time;
}
public void setVerify_time(String verify_time) {
this.verify_time = verify_time;
}
public String getReject_time() {
return reject_time;
}
public void setReject_time(String reject_time) {
this.reject_time = reject_time;
}
public String getReopen_time() {
return reopen_time;
}
public void setReopen_time(String reopen_time) {
this.reopen_time = reopen_time;
}
public String getAudit_time() {
return audit_time;
}
public void setAudit_time(String audit_time) {
this.audit_time = audit_time;
}
public String getSuspend_time() {
return suspend_time;
}
public void setSuspend_time(String suspend_time) {
this.suspend_time = suspend_time;
}
public String getDue() {
return due;
}
public void setDue(String due) {
this.due = due;
}
public String getBegin() {
return begin;
}
public void setBegin(String begin) {
this.begin = begin;
}
public String getCustom_field_11() {
return custom_field_11;
}
public void setCustom_field_11(String custom_field_11) {
this.custom_field_11 = custom_field_11;
}
public String getCustom_field_12() {
return custom_field_12;
}
public void setCustom_field_12(String custom_field_12) {
this.custom_field_12 = custom_field_12;
}
public String getCustom_field_13() {
return custom_field_13;
}
public void setCustom_field_13(String custom_field_13) {
this.custom_field_13 = custom_field_13;
}
public String getCustom_field_14() {
return custom_field_14;
}
public void setCustom_field_14(String custom_field_14) {
this.custom_field_14 = custom_field_14;
}
public String getCustom_field_15() {
return custom_field_15;
}
public void setCustom_field_15(String custom_field_15) {
this.custom_field_15 = custom_field_15;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* @ClassName: TapdBugUpdateDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:11 PM

*/
public class TapdBugUpdateDTO extends TapdBugBaseDTO implements Serializable{
private static final long serialVersionUID = 2954842604288372658L;
/**
* 项目ID
*/
private Integer project_id;
/**
* 更新人(操作人)
*/
private String current_user;
public Integer getProject_id() {
return project_id;
}
public void setProject_id(Integer project_id) {
this.project_id = project_id;
}
public String getCurrent_user() {
return current_user;
}
public void setCurrent_user(String current_user) {
this.current_user = current_user;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* tapd自定义字段
* @ClassName: TapdCustomFieldConfig

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:12 PM

*/
public class TapdCustomFieldConfig implements Serializable{
private static final long serialVersionUID = -6242431131348000720L;
/**
* 自定义字段配置的ID
*/
private Integer id;
/**
* 所属项目ID
*/
private String workspace_id;
/**
* 所属实体对象
*/
private String entry_type;
/**
* 自定义字段标识(英文名)
*/
private String custom_field;
/**
* 输入类型
*/
private String type;
/**
* 自定义字段显示名称
*/
private String name;
/**
* 自定义字段可选值
*/
private String options;
/**
* 是否启用
*/
private String enabled;
/**
* 显示时排序系数
*/
private String sort;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getWorkspace_id() {
return workspace_id;
}
public void setWorkspace_id(String workspace_id) {
this.workspace_id = workspace_id;
}
public String getEntry_type() {
return entry_type;
}
public void setEntry_type(String entry_type) {
this.entry_type = entry_type;
}
public String getCustom_field() {
return custom_field;
}
public void setCustom_field(String custom_field) {
this.custom_field = custom_field;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOptions() {
return options;
}
public void setOptions(String options) {
this.options = options;
}
public String getEnabled() {
return enabled;
}
public void setEnabled(String enabled) {
this.enabled = enabled;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* tapd监听发送的消息参数
* @ClassName: TapdMessageDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:13 PM

*/
public class TapdMessageDTO implements Serializable{
private static final long serialVersionUID = 1782405175563991216L;
/**
* udesk工单的id
*/
private String udeskId;
/**
* 新对象ID。需求、缺陷、任务、发布评审的都是19位长度的长ID
*/
private String id;
/**
* 事件名
*/
private String event;
/**
* 事件触发时的时间。格式:Y-m-d H:i:s,如 2019-03-29 10:55:02
*/
private String created;
/**
* 事件触发地方.有web、api
*/
private String event_from;
/**
* 事件id
*/
private String event_id;
/**
* 操作人
*/
private String current_user;
/**
* 项目ID
*/
private String workspace_id;
/**
* 发生变更的字段,以 , 分隔
*/
private String change_fields;
/**
* 标题
*/
private String old_title;
public String getUdeskId() {
return udeskId;
}
public void setUdeskId(String udeskId) {
this.udeskId = udeskId;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getEvent_from() {
return event_from;
}
public void setEvent_from(String event_from) {
this.event_from = event_from;
}
public String getEvent_id() {
return event_id;
}
public void setEvent_id(String event_id) {
this.event_id = event_id;
}
public String getCurrent_user() {
return current_user;
}
public void setCurrent_user(String current_user) {
this.current_user = current_user;
}
public String getWorkspace_id() {
return workspace_id;
}
public void setWorkspace_id(String workspace_id) {
this.workspace_id = workspace_id;
}
public String getChange_fields() {
return change_fields;
}
public void setChange_fields(String change_fields) {
this.change_fields = change_fields;
}
public String getOld_title() {
return old_title;
}
public void setOld_title(String old_title) {
this.old_title = old_title;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 接收新增TAPD的bug返回
* @ClassName: TapdRespBugDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:29 PM

*/
public class TapdRespBugDTO implements Serializable{
private static final long serialVersionUID = 7729863361142012314L;
private Integer status;
private String info;
private TapdRespBugDataDTO data;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public TapdRespBugDataDTO getData() {
return data;
}
public void setData(TapdRespBugDataDTO data) {
this.data = data;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 接收新增TAPD的bug返回data
* @ClassName: TapdRespBugDataDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:28 PM

*/
public class TapdRespBugDataDTO implements Serializable{
private static final long serialVersionUID = 9113924195626824396L;
private TapdBugDTO Bug;
public TapdBugDTO getBug() {
return Bug;
}
public void setBug(TapdBugDTO bug) {
Bug = bug;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
import java.util.List;
/**
* 接收新增TAPD自定义字
* @ClassName: TapdRespCustomFieldDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:31 PM

*/
public class TapdRespCustomFieldDTO implements Serializable{
private static final long serialVersionUID = 6841199187523354905L;
private Integer status;
private String info;
private List<TapdRespCustomFieldDataDTO> data;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public List<TapdRespCustomFieldDataDTO> getData() {
return data;
}
public void setData(List<TapdRespCustomFieldDataDTO> data) {
this.data = data;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* TAPD自定义字段返回data
* @ClassName: TapdRespCustomFieldDataDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:29 PM

*/
public class TapdRespCustomFieldDataDTO implements Serializable{
private static final long serialVersionUID = 6070115012514102123L;
private TapdCustomFieldConfig CustomFieldConfig;
public TapdCustomFieldConfig getCustomFieldConfig() {
return CustomFieldConfig;
}
public void setCustomFieldConfig(TapdCustomFieldConfig customFieldConfig) {
CustomFieldConfig = customFieldConfig;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 工单信息
* @ClassName: TicketDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:32 PM

*/
public class TicketDTO implements Serializable{
private static final long serialVersionUID = 1316075989331518774L;
/**
* 唯一标识,系统自动生成
*/
private Integer id;
/**
* 唯一标识,系统自动生成
*/
private String field_num;
/**
* 标题
*/
private String subject;
/**
* 内容
*/
private String content;
/**
* 内容类型
*/
private String content_type;
/**
* 客户id
*/
private Integer user_id;
/**
* 客户姓名
*/
private String user_name;
/**
* 客户邮箱
*/
private String user_email;
/**
* 客户电话
*/
private String user_cellphone;
/**
* 客户所属公司id
*/
private Integer organization_id;
/**
* 受理客服id
*/
private Integer assignee_id;
/**
* 受理客服姓名
*/
private String assignee_name;
/**
* 受理客服头像
*/
private String assignee_avatar;
/**
* 受理客服组id
*/
private Integer user_group_id;
/**
* 受理客服组名称
*/
private String user_group_name;
/**
* 模板id
*/
private Integer template_id;
/**
* 优先级中文名称
*/
private String priority;
/**
* 状态中文名称
*/
private String status;
/**
* 状态英文名称
*/
private String status_en;
/**
* 渠道中文名称
*/
private String platform;
/**
* 满意度调查结果
*/
private String satisfaction;
/**
* 自定义字段
*/
private Map<String, String> custom_fields;
/**
* 标签
*/
private String tags;
/**
* 关注者
*/
private List<FollowerDTO> followers;
/**
* 创建人
*/
private Integer creator_id;
/**
* 创建时间,系统自动生成
*/
private String created_at;
/**
* 更新时间,系统自动生成
*/
private String updated_at;
/**
* 开始解决时间
*/
private String solving_at;
/**
* 解决时间
*/
private String resolved_at;
/**
* 关闭时间
*/
private String closed_at;
/**
* 到期时间
*/
private String solved_deadline;
/**
* 最后回复时间
*/
private String replied_at;
/**
* 客服最后回复时间
*/
private String agent_replied_at;
/**
* 客户最后回复时间
*/
private String customer_replied_at;
/**
* 最后回复人
*/
private String replied_by;
/**
* 工单关联的附件
*/
private List<AttachmentDTO> attachments;
/**
* 工单的sub_session_id
*/
private Integer im_sub_session_id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getField_num() {
return field_num;
}
public void setField_num(String field_num) {
this.field_num = field_num;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getContent_type() {
return content_type;
}
public void setContent_type(String content_type) {
this.content_type = content_type;
}
public Integer getUser_id() {
return user_id;
}
public void setUser_id(Integer user_id) {
this.user_id = user_id;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getUser_email() {
return user_email;
}
public void setUser_email(String user_email) {
this.user_email = user_email;
}
public String getUser_cellphone() {
return user_cellphone;
}
public void setUser_cellphone(String user_cellphone) {
this.user_cellphone = user_cellphone;
}
public Integer getOrganization_id() {
return organization_id;
}
public void setOrganization_id(Integer organization_id) {
this.organization_id = organization_id;
}
public Integer getAssignee_id() {
return assignee_id;
}
public void setAssignee_id(Integer assignee_id) {
this.assignee_id = assignee_id;
}
public String getAssignee_name() {
return assignee_name;
}
public void setAssignee_name(String assignee_name) {
this.assignee_name = assignee_name;
}
public String getAssignee_avatar() {
return assignee_avatar;
}
public void setAssignee_avatar(String assignee_avatar) {
this.assignee_avatar = assignee_avatar;
}
public Integer getUser_group_id() {
return user_group_id;
}
public void setUser_group_id(Integer user_group_id) {
this.user_group_id = user_group_id;
}
public String getUser_group_name() {
return user_group_name;
}
public void setUser_group_name(String user_group_name) {
this.user_group_name = user_group_name;
}
public Integer getTemplate_id() {
return template_id;
}
public void setTemplate_id(Integer template_id) {
this.template_id = template_id;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus_en() {
return status_en;
}
public void setStatus_en(String status_en) {
this.status_en = status_en;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getSatisfaction() {
return satisfaction;
}
public void setSatisfaction(String satisfaction) {
this.satisfaction = satisfaction;
}
public Map<String, String> getCustom_fields() {
return custom_fields;
}
public void setCustom_fields(Map<String, String> custom_fields) {
this.custom_fields = custom_fields;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
public List<FollowerDTO> getFollowers() {
return followers;
}
public void setFollowers(List<FollowerDTO> followers) {
this.followers = followers;
}
public Integer getCreator_id() {
return creator_id;
}
public void setCreator_id(Integer creator_id) {
this.creator_id = creator_id;
}
public String getCreated_at() {
return created_at;
}
public void setCreated_at(String created_at) {
this.created_at = created_at;
}
public String getUpdated_at() {
return updated_at;
}
public void setUpdated_at(String updated_at) {
this.updated_at = updated_at;
}
public String getSolving_at() {
return solving_at;
}
public void setSolving_at(String solving_at) {
this.solving_at = solving_at;
}
public String getResolved_at() {
return resolved_at;
}
public void setResolved_at(String resolved_at) {
this.resolved_at = resolved_at;
}
public String getClosed_at() {
return closed_at;
}
public void setClosed_at(String closed_at) {
this.closed_at = closed_at;
}
public String getSolved_deadline() {
return solved_deadline;
}
public void setSolved_deadline(String solved_deadline) {
this.solved_deadline = solved_deadline;
}
public String getReplied_at() {
return replied_at;
}
public void setReplied_at(String replied_at) {
this.replied_at = replied_at;
}
public String getAgent_replied_at() {
return agent_replied_at;
}
public void setAgent_replied_at(String agent_replied_at) {
this.agent_replied_at = agent_replied_at;
}
public String getCustomer_replied_at() {
return customer_replied_at;
}
public void setCustomer_replied_at(String customer_replied_at) {
this.customer_replied_at = customer_replied_at;
}
public String getReplied_by() {
return replied_by;
}
public void setReplied_by(String replied_by) {
this.replied_by = replied_by;
}
public List<AttachmentDTO> getAttachments() {
return attachments;
}
public void setAttachments(List<AttachmentDTO> attachments) {
this.attachments = attachments;
}
public Integer getIm_sub_session_id() {
return im_sub_session_id;
}
public void setIm_sub_session_id(Integer im_sub_session_id) {
this.im_sub_session_id = im_sub_session_id;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* udesk客户回复
* @ClassName: UdeskAgentReplyDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:34 PM

*/
public class UdeskAgentReplyDTO implements Serializable{
private static final long serialVersionUID = -4964133303321416857L;
/**
* 工单id
*/
private Integer id;
/**
* 工单编号
*/
private String num;
/**
* 客服id
*/
private Integer agent_id;
/**
* 回复类型,"internal"内部备注/"external"外部评论
*/
private String function_type;
/**
* 回复内容
*/
private String new_reply;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public Integer getAgent_id() {
return agent_id;
}
public void setAgent_id(Integer agent_id) {
this.agent_id = agent_id;
}
public String getFunction_type() {
return function_type;
}
public void setFunction_type(String function_type) {
this.function_type = function_type;
}
public String getNew_reply() {
return new_reply;
}
public void setNew_reply(String new_reply) {
this.new_reply = new_reply;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* udesk公司信息
* @ClassName: UdeskCompanyDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:35 PM

*/
public class UdeskCompanyDTO implements Serializable{
private static final long serialVersionUID = -7766353148345022802L;
/**
* 执行结果码,1000代表成功
*/
private Integer code;
/**
* 客户公司信息
*/
private OrganizationDTO organization;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public OrganizationDTO getOrganization() {
return organization;
}
public void setOrganization(OrganizationDTO organization) {
this.organization = organization;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 消息,udesk/tapd监听
* @ClassName: UdeskMessageDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:00 PM

*/
public class UdeskMessageDTO implements Serializable{
private static final long serialVersionUID = -4024232985956325129L;
/**
* 消息来源,udesk或tapd
*/
private String source;
/**
* 消息主题
*/
private String topic;
/**
* 消息事件
*/
private String event;
/**
* 消息体
*/
private String msgBody;
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getMsgBody() {
return msgBody;
}
public void setMsgBody(String msgBody) {
this.msgBody = msgBody;
}
@Override
public String toString() {
return "UdeskMessageDTO [source=" + source + ", topic=" + topic + ", event=" + event + ", msgBody=" + msgBody
+ "]";
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* UDESK客服回复返回消息
* @ClassName: UdeskRespReplyDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:35 PM

*/
public class UdeskRespReplyDTO implements Serializable{
private static final long serialVersionUID = -7910815396193380366L;
/**
* 1000
*/
private Integer code;
/**
* 返回数据
*/
private Object data;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
package com.gic.udesk.dto;
import java.io.Serializable;
/**
* 查询工单详情返回数据
* @ClassName: UdeskTicketDetailDTO

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:36 PM

*/
public class UdeskTicketDetailDTO implements Serializable{
private static final long serialVersionUID = 8168560910532170329L;
/**
* 执行结果码,1000代表成功
*/
private Integer code;
/**
* 执行结果说明
*/
private String message;
/**
* 工单信息
*/
private TicketDTO ticket;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public TicketDTO getTicket() {
return ticket;
}
public void setTicket(TicketDTO ticket) {
this.ticket = ticket;
}
}
package com.gic.udesk.service;
import com.gic.api.base.commons.ServiceResponse;
/**
* tapd和udesk关联(tapd的项目ID和udesk的自定义字段)
* @ClassName: TapdConfigApiService

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:42 PM

*/
public interface TapdConfigApiService {
/**
* tapd和udesk关联(tapd的项目ID和udesk的自定义字段)
* @Title: setTapdCustomFieldRelUdesk

* @Description:

 * @author guojuxing
* @param workspaceId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>


 */
ServiceResponse<String> setTapdCustomFieldRelUdesk(String workspaceId);
}
package com.gic.udesk.service;
import com.gic.api.base.commons.ServiceResponse;
public interface TapdMessageApiService {
/**
* tapd监听消息处理
* @Title: handleTapdMessage

* @Description:

 * @author guojuxing
* @param tapdMessageStr

* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>


 */
ServiceResponse<String> handleTapdMessage(String tapdMessageStr);
}
package com.gic.udesk.service;
import com.gic.api.base.commons.ServiceResponse;
public interface UdeskBaseApiService {
/**
* 保存udesk类型的异常信息
* @Title: saveUdeskException

* @Description:

 * @author guojuxing
* @param exceptionRecord

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


 */
ServiceResponse<Void> saveUdeskException(String exceptionRecord);
/**
* 保存tapd类型的异常信息
* @Title: saveTapdException

* @Description:

 * @author guojuxing
* @param exceptionRecord

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


 */
ServiceResponse<Void> saveTapdException(String exceptionRecord);
}
package com.gic.udesk.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.udesk.dto.UdeskMessageDTO;
public interface UdeskMessageApiService {
/**
* 监听处理udesk消息
* @Title: saveUdeskMessage

* @Description:

 * @author guojuxing
* @param messageDTO

* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>


 */
ServiceResponse<String> saveUdeskMessage(UdeskMessageDTO messageDTO);
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-platform-udesk-service</artifactId>
<version>${libraryVersion}</version>
<name>${project.artifactId}</name>
<url>http://www.demogic.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<libraryVersion>4.0-SNAPSHOT</libraryVersion>
<gic-sharding-sdk>3.1-SNAPSHOT</gic-sharding-sdk>
<!-- api依赖,正式版会在 gic-pom-base 里生成 -->
<gic-store-api>4.0-SNAPSHOT</gic-store-api>
<gic-redis-data>4.0-SNAPSHOT</gic-redis-data>
<gic-bizdict-api>4.0.0-SNAPSHOT</gic-bizdict-api>
<gic-platform-auth-api>4.0-SNAPSHOT</gic-platform-auth-api>
<gic-wechat-business-api>4.0-SNAPSHOT</gic-wechat-business-api>
<gic-member-api>4.0-SNAPSHOT</gic-member-api>
<gic-open-platform-api>4.0-SNAPSHOT</gic-open-platform-api>
</properties>
<dependencies>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-commons</artifactId>
<version>${gic-commons}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<artifactId>dubbo</artifactId>
<groupId>com.alibaba</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-config</artifactId>
<version>${gic-platform-config}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-udesk-api</artifactId>
<version>${gic-platform-enterprise-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-sharding-sdk</artifactId>
<version>${gic-sharding-sdk}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.1.7.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.gic </groupId>
<artifactId>gic-redis-data </artifactId>
<version>${gic-redis-data} </version>
</dependency>
<dependency>
<groupId>com.gic.bizdict</groupId>
<artifactId>gic-bizdict-api</artifactId>
<version>${gic-bizdict-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-base-api</artifactId>
<version>${gic-enterprise-base-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-enterprise-api</artifactId>
<version>${gic-platform-enterprise-api}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>target/classes/</classesDirectory>
<archive>
<manifest>
<mainClass>com.gic.commons.DubboMain</mainClass>
<!-- 打包时 MANIFEST.MF文件不记录的时间戳版本 -->
<useUniqueVersions>false</useUniqueVersions>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.gic.udesk.dao.mapper;
import com.gic.udesk.entity.TabUdeskEnterprise;
public interface TabUdeskEnterpriseMapper {
/**
* 根据主键删除
*
* @param id 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer id);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabUdeskEnterprise record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabUdeskEnterprise record);
/**
* 根据主键查询
*
* @param id 主键
* @return 实体对象
*/
TabUdeskEnterprise selectByPrimaryKey(Integer id);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabUdeskEnterprise record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabUdeskEnterprise record);
}
\ No newline at end of file
package com.gic.udesk.dao.mapper;
import com.gic.udesk.entity.TabUdeskException;
public interface TabUdeskExceptionMapper {
/**
* 根据主键删除
*
* @param id 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer id);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabUdeskException record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabUdeskException record);
/**
* 根据主键查询
*
* @param id 主键
* @return 实体对象
*/
TabUdeskException selectByPrimaryKey(Integer id);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabUdeskException record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabUdeskException record);
}
\ No newline at end of file
package com.gic.udesk.dao.mapper;
import com.gic.udesk.entity.TabUdeskMessage;
public interface TabUdeskMessageMapper {
/**
* 根据主键删除
*
* @param id 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer id);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabUdeskMessage record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabUdeskMessage record);
/**
* 根据主键查询
*
* @param id 主键
* @return 实体对象
*/
TabUdeskMessage selectByPrimaryKey(Integer id);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabUdeskMessage record);
/**
* 根据主键更新记录,包括二进制大对象
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeyWithBLOBs(TabUdeskMessage record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabUdeskMessage record);
}
\ No newline at end of file
package com.gic.udesk.dao.mapper;
import com.gic.udesk.entity.TabUdeskTapdRel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabUdeskTapdRelMapper {
/**
* 根据主键删除
*
* @param id 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer id);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabUdeskTapdRel record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabUdeskTapdRel record);
/**
* 根据主键查询
*
* @param id 主键
* @return 实体对象
*/
TabUdeskTapdRel selectByPrimaryKey(Integer id);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabUdeskTapdRel record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabUdeskTapdRel record);
/**
* 查询列
* @Title: list

* @Description:

 * @author guojuxing
* @param record

* @return java.util.List<com.gic.udesk.entity.TabUdeskTapdRel>


 */
List<TabUdeskTapdRel> list(TabUdeskTapdRel record);
int deleteByWorkspaceId(@Param("relType") int relType, @Param("workspace_id") String workspace_id);
}
\ No newline at end of file
package com.gic.udesk.dao.mapper;
import com.gic.udesk.entity.TabUdeskTicket;
import java.util.List;
public interface TabUdeskTicketMapper {
/**
* 根据主键删除
*
* @param id 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer id);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabUdeskTicket record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabUdeskTicket record);
/**
* 根据主键查询
*
* @param id 主键
* @return 实体对象
*/
TabUdeskTicket selectByPrimaryKey(Integer id);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabUdeskTicket record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabUdeskTicket record);
List<TabUdeskTicket> list(TabUdeskTicket params);
}
\ No newline at end of file
package com.gic.udesk.entity;
import java.util.Date;
/**
* tab_udesk_enterprise
*/
public class TabUdeskEnterprise {
/**
* id
*/
private Integer id;
/**
* 业务模块ID
*/
private String businessModule;
/**
* 业务模块名称
*/
private String businessModuleName;
/**
* 业务模块类型 1:基础模块 2:应用模块
*/
private Integer businessType;
/**
* 工单ID
*/
private Integer ticketId;
/**
* 工单编号
*/
private String ticketNum;
/**
* 工单标题
*/
private String ticketTitle;
/**
* 工单状态
*/
private String ticketStatus;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getBusinessModule() {
return businessModule;
}
public void setBusinessModule(String businessModule) {
this.businessModule = businessModule;
}
public String getBusinessModuleName() {
return businessModuleName;
}
public void setBusinessModuleName(String businessModuleName) {
this.businessModuleName = businessModuleName;
}
public Integer getBusinessType() {
return businessType;
}
public void setBusinessType(Integer businessType) {
this.businessType = businessType;
}
public Integer getTicketId() {
return ticketId;
}
public void setTicketId(Integer ticketId) {
this.ticketId = ticketId;
}
public String getTicketNum() {
return ticketNum;
}
public void setTicketNum(String ticketNum) {
this.ticketNum = ticketNum;
}
public String getTicketTitle() {
return ticketTitle;
}
public void setTicketTitle(String ticketTitle) {
this.ticketTitle = ticketTitle;
}
public String getTicketStatus() {
return ticketStatus;
}
public void setTicketStatus(String ticketStatus) {
this.ticketStatus = ticketStatus;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.udesk.entity;
import java.util.Date;
/**
* tab_udesk_exception
*/
public class TabUdeskException {
/**
* 主键id
*/
private Integer id;
/**
* 异常来源类型,如udesk,tapd
*/
private String expType;
/**
* 异常记录
*/
private String exceptionRecord;
/**
*
*/
private Date createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getExpType() {
return expType;
}
public void setExpType(String expType) {
this.expType = expType;
}
public String getExceptionRecord() {
return exceptionRecord;
}
public void setExceptionRecord(String exceptionRecord) {
this.exceptionRecord = exceptionRecord;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
package com.gic.udesk.entity;
import java.util.Date;
/**
* tab_udesk_message
*/
public class TabUdeskMessage {
/**
* 消息id
*/
private Integer id;
/**
* 消息来源
*/
private String source;
/**
* 消息主题
*/
private String topic;
/**
* 事件类型
*/
private String event;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* 状态(0:删除;1:未删除)
*/
private Integer status;
/**
* TPAD的bug_id
*/
private String bugId;
/**
* 工单id
*/
private String ticketId;
/**
* 消息体
*/
private String msgBody;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getBugId() {
return bugId;
}
public void setBugId(String bugId) {
this.bugId = bugId;
}
public String getTicketId() {
return ticketId;
}
public void setTicketId(String ticketId) {
this.ticketId = ticketId;
}
public String getMsgBody() {
return msgBody;
}
public void setMsgBody(String msgBody) {
this.msgBody = msgBody;
}
}
\ No newline at end of file
package com.gic.udesk.entity;
import com.gic.udesk.utils.UdeskConstant;
import java.util.Date;
/**
* tab_udesk_tapd_rel
*/
public class TabUdeskTapdRel {
/**
* 关联id
*/
private Integer id;
/**
* 关联类型,1:模块关联,2:处理人关联,3:录入客服关联,4:严重程度关联
*/
private Integer relType;
/**
* tapd项目id
*/
private String workspaceId;
/**
* udesk字段id的key
*/
private String udeskIdKey;
/**
* udesk字段id的value
*/
private String udeskIdValue;
/**
* udesk字段名称
*/
private String udeskName;
/**
* tapd字段id
*/
private String tapdId;
/**
* tapd字段名称
*/
private String tapdName;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* 状态(0:删除;1:正常)
*/
private Integer status;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getRelType() {
return relType;
}
public void setRelType(Integer relType) {
this.relType = relType;
}
public String getWorkspaceId() {
return workspaceId;
}
public void setWorkspaceId(String workspaceId) {
this.workspaceId = workspaceId;
}
public String getUdeskIdKey() {
return udeskIdKey;
}
public void setUdeskIdKey(String udeskIdKey) {
this.udeskIdKey = udeskIdKey;
}
public String getUdeskIdValue() {
return udeskIdValue;
}
public void setUdeskIdValue(String udeskIdValue) {
this.udeskIdValue = udeskIdValue;
}
public String getUdeskName() {
return udeskName;
}
public void setUdeskName(String udeskName) {
this.udeskName = udeskName;
}
public String getTapdId() {
return tapdId;
}
public void setTapdId(String tapdId) {
this.tapdId = tapdId;
}
public String getTapdName() {
return tapdName;
}
public void setTapdName(String tapdName) {
this.tapdName = tapdName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public TabUdeskTapdRel() {
}
public TabUdeskTapdRel(Integer relType, String udeskIdKey, String udeskIdValue, String udeskName, String tapdId,
String tapdName) {
this.relType = relType;
this.udeskIdKey = udeskIdKey;
this.udeskIdValue = udeskIdValue;
this.udeskName = udeskName;
this.tapdId = tapdId;
this.tapdName = tapdName;
this.status = UdeskConstant.UNDELETED;
}
public TabUdeskTapdRel(String workspaceId,Integer relType, String udeskIdKey, String udeskName, String tapdId,
String tapdName) {
this.workspaceId = workspaceId;
this.relType = relType;
this.udeskIdKey = udeskIdKey;
this.udeskName = udeskName;
this.tapdId = tapdId;
this.tapdName = tapdName;
this.status = UdeskConstant.UNDELETED;
}
}
\ No newline at end of file
package com.gic.udesk.entity;
import java.util.Date;
/**
* tab_udesk_ticket
*/
public class TabUdeskTicket {
/**
* 工单id
*/
private Integer id;
/**
* 工单编号
*/
private String fieldNum;
/**
* 标题
*/
private String subject;
/**
* 客户id
*/
private Integer userId;
/**
* 客户姓名
*/
private String userName;
/**
* 客户所属公司id
*/
private Integer organizationId;
/**
* 客户所属公司名称
*/
private String organizationName;
/**
* 创建人id
*/
private Integer creatorId;
/**
* 受理客服id
*/
private Integer assigneeId;
/**
* 受理客服姓名
*/
private String assigneeName;
/**
* 优先级中文名称
*/
private String priority;
/**
* 状态英文名称
*/
private String statusEn;
/**
*
*/
private String statusTapd;
/**
* 提报人
*/
private String reporter;
/**
* TPAD的bug_id
*/
private String bugId;
/**
* TPAD项目id
*/
private String workspaceId;
/**
* TPAD当前处理人
*/
private String currentOwner;
/**
* udesk客服名称--tapd创建人
*/
private String serviceStaff;
/**
* 严重程度
*/
private String severity;
/**
* 开始解决时间
*/
private String solvingAt;
/**
* 最后回复时间
*/
private String repliedAt;
/**
* 解决时间
*/
private String resolvedAt;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* 状态(0:删除;1:未删除)
*/
private Integer status;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFieldNum() {
return fieldNum;
}
public void setFieldNum(String fieldNum) {
this.fieldNum = fieldNum;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Integer organizationId) {
this.organizationId = organizationId;
}
public String getOrganizationName() {
return organizationName;
}
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
public Integer getCreatorId() {
return creatorId;
}
public void setCreatorId(Integer creatorId) {
this.creatorId = creatorId;
}
public Integer getAssigneeId() {
return assigneeId;
}
public void setAssigneeId(Integer assigneeId) {
this.assigneeId = assigneeId;
}
public String getAssigneeName() {
return assigneeName;
}
public void setAssigneeName(String assigneeName) {
this.assigneeName = assigneeName;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getStatusEn() {
return statusEn;
}
public void setStatusEn(String statusEn) {
this.statusEn = statusEn;
}
public String getStatusTapd() {
return statusTapd;
}
public void setStatusTapd(String statusTapd) {
this.statusTapd = statusTapd;
}
public String getReporter() {
return reporter;
}
public void setReporter(String reporter) {
this.reporter = reporter;
}
public String getBugId() {
return bugId;
}
public void setBugId(String bugId) {
this.bugId = bugId;
}
public String getWorkspaceId() {
return workspaceId;
}
public void setWorkspaceId(String workspaceId) {
this.workspaceId = workspaceId;
}
public String getCurrentOwner() {
return currentOwner;
}
public void setCurrentOwner(String currentOwner) {
this.currentOwner = currentOwner;
}
public String getServiceStaff() {
return serviceStaff;
}
public void setServiceStaff(String serviceStaff) {
this.serviceStaff = serviceStaff;
}
public String getSeverity() {
return severity;
}
public void setSeverity(String severity) {
this.severity = severity;
}
public String getSolvingAt() {
return solvingAt;
}
public void setSolvingAt(String solvingAt) {
this.solvingAt = solvingAt;
}
public String getRepliedAt() {
return repliedAt;
}
public void setRepliedAt(String repliedAt) {
this.repliedAt = repliedAt;
}
public String getResolvedAt() {
return resolvedAt;
}
public void setResolvedAt(String resolvedAt) {
this.resolvedAt = resolvedAt;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
\ No newline at end of file
package com.gic.udesk.service;
import com.gic.udesk.entity.TabUdeskException;
public interface UdeskExceptionService {
/**
* 记录接口异常信息
* @Title: save

* @Description:

 * @author guojuxing
* @param record

* @return int


 */
int save(TabUdeskException record);
}
package com.gic.udesk.service;
import com.gic.udesk.entity.TabUdeskMessage;
public interface UdeskMessageService {
/**
* 新增消息
* @Title: save

* @Description:

 * @author guojuxing
* @param record

* @return int
 主键ID

 */
int save(TabUdeskMessage record);
int update(TabUdeskMessage record);
}
package com.gic.udesk.service;
import com.gic.udesk.entity.TabUdeskTapdRel;
import java.util.List;
public interface UdeskTapdRelService {
/**
* 查询所有有效的数据
* @Title: list

* @Description:

 * @author guojuxing 

* @return java.util.List<com.gic.udesk.entity.TabUdeskTapdRel>


 */
List<TabUdeskTapdRel> list(TabUdeskTapdRel record);
/**
* 保存
* @Title: save

* @Description:

 * @author guojuxing
* @param record

* @return int


 */
int save(TabUdeskTapdRel record);
/**
* 删除
* @Title: deleteByWorkspaceId

* @Description:

 * @author guojuxing
* @param relType 关联类型
* @param workspace_id
 tapd项目id
* @return int


 */
int deleteByWorkspaceId(int relType, String workspace_id);
}
package com.gic.udesk.service;
import com.gic.udesk.entity.TabUdeskTicket;
import java.util.List;
public interface UdeskTicketService {
int save(TabUdeskTicket record);
int update(TabUdeskTicket record);
/**
* 主键ID查询记录
* @Title: getById

* @Description:

 * @author guojuxing
* @param id

* @return com.gic.udesk.entity.TabUdeskTicket


 */
TabUdeskTicket getById(Integer id);
List<TabUdeskTicket> list(TabUdeskTicket params);
}
package com.gic.udesk.service.impl;
import com.gic.udesk.dao.mapper.TabUdeskExceptionMapper;
import com.gic.udesk.entity.TabUdeskException;
import com.gic.udesk.service.UdeskExceptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("udeskExceptionService")
public class UdeskExceptionServiceImpl implements UdeskExceptionService{
@Autowired
private TabUdeskExceptionMapper tabUdeskExceptionMapper;
@Override
public int save(TabUdeskException record) {
record.setCreateTime(new Date());
return tabUdeskExceptionMapper.insert(record);
}
}
package com.gic.udesk.service.impl;
import com.gic.udesk.dao.mapper.TabUdeskMessageMapper;
import com.gic.udesk.entity.TabUdeskMessage;
import com.gic.udesk.service.UdeskMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("udeskMessageService")
public class UdeskMessageServiceImpl implements UdeskMessageService{
@Autowired
private TabUdeskMessageMapper tabUdeskMessageMapper;
@Override
public int save(TabUdeskMessage record) {
record.setCreateTime(new Date());
record.setUpdateTime(new Date());
record.setStatus(1);
tabUdeskMessageMapper.insertSelective(record);
return record.getId();
}
@Override
public int update(TabUdeskMessage record) {
record.setUpdateTime(new Date());
return tabUdeskMessageMapper.updateByPrimaryKeySelective(record);
}
}
package com.gic.udesk.service.impl;
import com.gic.udesk.dao.mapper.TabUdeskTapdRelMapper;
import com.gic.udesk.entity.TabUdeskTapdRel;
import com.gic.udesk.service.UdeskTapdRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service("udeskTapdRelService")
public class UdeskTapdRelServiceImpl implements UdeskTapdRelService{
@Autowired
private TabUdeskTapdRelMapper tabUdeskTapdRelMapper;
@Override
public List<TabUdeskTapdRel> list(TabUdeskTapdRel record) {
return tabUdeskTapdRelMapper.list(record);
}
@Override
public int save(TabUdeskTapdRel record) {
record.setCreateTime(new Date());
record.setUpdateTime(new Date());
record.setStatus(1);
return tabUdeskTapdRelMapper.insertSelective(record);
}
@Override
public int deleteByWorkspaceId(int relType, String workspace_id) {
return tabUdeskTapdRelMapper.deleteByWorkspaceId(relType, workspace_id);
}
}
package com.gic.udesk.service.impl;
import com.gic.udesk.dao.mapper.TabUdeskTicketMapper;
import com.gic.udesk.entity.TabUdeskTicket;
import com.gic.udesk.service.UdeskTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service("udeskTicketService")
public class UdeskTicketServiceImpl implements UdeskTicketService{
@Autowired
private TabUdeskTicketMapper tabUdeskTicketMapper;
@Override
public int save(TabUdeskTicket record) {
record.setCreateTime(new Date());
record.setUpdateTime(new Date());
record.setStatus(1);
return tabUdeskTicketMapper.insertSelective(record);
}
@Override
public int update(TabUdeskTicket record) {
record.setUpdateTime(new Date());
return tabUdeskTicketMapper.updateByPrimaryKeySelective(record);
}
@Override
public TabUdeskTicket getById(Integer id) {
return tabUdeskTicketMapper.selectByPrimaryKey(id);
}
@Override
public List<TabUdeskTicket> list(TabUdeskTicket params) {
return tabUdeskTicketMapper.list(params);
}
}
package com.gic.udesk.service.outer.impl;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.error.ErrorCode;
import com.gic.udesk.dto.TapdCustomFieldConfig;
import com.gic.udesk.dto.TapdRespCustomFieldDTO;
import com.gic.udesk.dto.TapdRespCustomFieldDataDTO;
import com.gic.udesk.entity.TabUdeskTapdRel;
import com.gic.udesk.service.TapdConfigApiService;
import com.gic.udesk.service.UdeskBaseApiService;
import com.gic.udesk.service.UdeskTapdRelService;
import com.gic.udesk.utils.UdeskConstant;
import com.gic.udesk.utils.UdeskHttpClientUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("tapdConfigApiService")
public class TapdConfigApiServiceImpl implements TapdConfigApiService {
private static Logger logger = LogManager.getLogger(TapdConfigApiServiceImpl.class);
@Autowired
private UdeskBaseApiService udeskBaseApiService;
@Autowired
private UdeskTapdRelService udeskTapdRelService;
/**
* tapd获取缺陷自定义字段配置
* 接口路径
*/
private static final String CUSTOM_FIELDS_SETTINGS = "/bugs/custom_fields_settings";
@Override
public ServiceResponse<String> setTapdCustomFieldRelUdesk(String workspaceId) {
Map<String, Object> param = new HashMap<>(4);
param.put("workspace_id", workspaceId);
logger.info("获取TAPD缺陷自定义字段入参为{}", workspaceId);
String customFieldsStr = UdeskHttpClientUtil.getTapdJsonFromParam(CUSTOM_FIELDS_SETTINGS, param);
logger.info("获取TAPD缺陷自定义字段返回为{}", customFieldsStr);
//转为对象
TapdRespCustomFieldDTO tapdCustomField = JSON.parseObject(customFieldsStr, TapdRespCustomFieldDTO.class);
if (tapdCustomField.getStatus() == UdeskConstant.TAPD_RESP_SUCCESS_STATUS) {
//9 : tapd的项目ID和udesk的自定义字段的关联
udeskTapdRelService.deleteByWorkspaceId(9, workspaceId);
List<TapdRespCustomFieldDataDTO> customFieldData = tapdCustomField.getData();
for (TapdRespCustomFieldDataDTO customField : customFieldData) {
TapdCustomFieldConfig customFieldConfig = customField.getCustomFieldConfig();
String name = customFieldConfig.getName();
String custom_field = customFieldConfig.getCustom_field();
TabUdeskTapdRel tabUdeskTapdRel = null;
//tapd返回的自定义字段数据,没有不变化的ID,所以用名称来匹配
//tapd不同项目建立如录入客服这个自定义字段的时候,对应的key是不确定的,所以用名称来匹配,且用反射来获取值
switch (name) {
case "提报人":
tabUdeskTapdRel = new TabUdeskTapdRel(workspaceId, 9, "getUserName", "客户姓名",
"set" + captureName(custom_field), "提报人");
break;
case "录入客服":
tabUdeskTapdRel = new TabUdeskTapdRel(workspaceId, 9, "getServiceStaff", "录入客服",
"set" + captureName(custom_field), "录入客服");
break;
case "UDESK工单编号":
tabUdeskTapdRel = new TabUdeskTapdRel(workspaceId, 9, "getFieldNum", "UDESK工单编号",
"set" + captureName(custom_field), "UDESK工单编号");
break;
case "公司信息":
tabUdeskTapdRel = new TabUdeskTapdRel(workspaceId, 9, "getOrganizationName", "公司",
"set" + captureName(custom_field), "公司信息");
break;
default:
break;
}
if (tabUdeskTapdRel != null) {
udeskTapdRelService.save(tabUdeskTapdRel);
}
}
} else {
String exceptionRecord = "tapd项目id为" + workspaceId + "查询自定义字段失败,返回为" + customFieldsStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveTapdException(exceptionRecord);
return ServiceResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), "查询tapd自定义字段失败");
}
return ServiceResponse.success();
}
/**
* 首字母大写
*/
private String captureName(String name) {
char[] cs = name.toCharArray();
cs[0] -= 32;
return String.valueOf(cs);
}
}
package com.gic.udesk.service.outer.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.udesk.constant.UdeskSharedConstant;
import com.gic.udesk.dto.*;
import com.gic.udesk.entity.TabUdeskMessage;
import com.gic.udesk.entity.TabUdeskTapdRel;
import com.gic.udesk.entity.TabUdeskTicket;
import com.gic.udesk.service.*;
import com.gic.udesk.utils.UdeskConstant;
import com.gic.udesk.utils.UdeskHttpClientUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("tapdMessageApiService")
public class TapdMessageApiServiceImpl implements TapdMessageApiService {
private static Logger logger = LogManager.getLogger(TapdMessageApiServiceImpl.class);
@Resource(name = "udeskTapdRelMap")
private Map<String, String> udeskTapdRelMap;
@Autowired
private UdeskTicketService udeskTicketService;
@Autowired
private UdeskMessageService udeskMessageService;
@Autowired
private UdeskBaseApiService udeskBaseApiService;
@Autowired
private UdeskTapdRelService udeskTapdRelService;
/**
* tapd缺陷接口
*/
private static final String BUGS = "/bugs";
/**
* udesk工单接口
*/
private static final String UDESK_UPDATE_TICKET = "/tickets/";
/**
* 客服回复
*/
private static final String AGENT_REPLY = "/tickets/agent_reply";
private static final String NOT_HANDLE = "NotHandle";
private static final String TAPD_FIELD_NAME_PRIORITY = "priority";
private static final String TAPD_FIELD_NAME_SEVERITY = "severity";
@Override
public ServiceResponse<String> handleTapdMessage(String tapdMessageStr) {
//接收tapd消息数据
TapdMessageDTO tapdMessageDTO = JSON.parseObject(tapdMessageStr, TapdMessageDTO.class);
String event = tapdMessageDTO.getEvent();
String handleResult = null;
if (UdeskSharedConstant.TAPD_BUG_UPDATE_EVENT.equals(event)) {
//tapd更新消息
logger.info("TAPD发送了缺陷更新事件,缺陷id:{},变更字段:{}", tapdMessageDTO.getId(), tapdMessageDTO.getChange_fields());
handleResult = handleTapdBugUpdate(tapdMessageDTO);
} else if (UdeskSharedConstant.TAPD_BUG_DELETE_EVENT.equals(event)) {
logger.info("TAPD发送了缺陷删除事件,缺陷id:{} ", tapdMessageDTO.getId());
handleResult = handleTapdBugDelete(tapdMessageDTO);
}
return ServiceResponse.success(handleResult);
}
private String handleTapdBugUpdate(TapdMessageDTO tapdMessage) {
// 查询TapdBug在中间件中记录
List<TabUdeskTicket> dataBaseTicketList = this.getDataBaseTicket(tapdMessage);
if (CollectionUtils.isEmpty(dataBaseTicketList)) {
//没有建立关联 结束
return NOT_HANDLE;
}
TabUdeskTicket dataBaseTicket = dataBaseTicketList.get(0);
// 根据变更字段,来检查是否需要更新
boolean needUpdate = this.checkChangeFields(tapdMessage.getChange_fields());
if (!needUpdate) {
return NOT_HANDLE;
}
//工单ID
tapdMessage.setUdeskId(dataBaseTicket.getId().toString());
TabUdeskMessage tabTapdMessage = this.getTapdMessageTemplate(tapdMessage,
UdeskSharedConstant.TAPD_BUG_UPDATE_EVENT);
Integer msgId = udeskMessageService.save(tabTapdMessage);
logger.info("消息{}保存成功", tabTapdMessage);
// 获取缺陷最新的内容
TapdBugDTO latestBugFromTAPD = this.getLatestBugFromTAPD(tapdMessage);
if (latestBugFromTAPD == null) {
return msgId.toString();
}
// 数据转换一下. priorityEN,取值: "",high-高 ..
String priorityEN = this.ensureFieldValueIsEn(latestBugFromTAPD.getPriority(), TAPD_FIELD_NAME_PRIORITY,
tapdMessage);
if (priorityEN == null) {
return msgId.toString();
}
String priorityCN = udeskTapdRelMap.get(priorityEN + UdeskConstant.MAP_UDESK_NAME_SUFFIX);
// severityEN,取值: "",advice-建议
String severityEN = this.ensureFieldValueIsEn(latestBugFromTAPD.getSeverity(), TAPD_FIELD_NAME_SEVERITY,
tapdMessage);
if (severityEN == null) {
return msgId.toString();
}
String severityCN = udeskTapdRelMap.get(severityEN + UdeskConstant.MAP_UDESK_NAME_SUFFIX);
// 是否要更新中间件的数据库. 根据数据库表设计,数据库中ticket的status不会为null,priority、severity可能为null.
if ((dataBaseTicket.getStatusTapd().equals(latestBugFromTAPD.getStatus()))
&& ((dataBaseTicket.getPriority() == null ? "" : dataBaseTicket.getPriority())
.equals(priorityCN == null ? "" : priorityCN))
&& ((dataBaseTicket.getSeverity() == null ? "" : dataBaseTicket.getSeverity())
.equals((severityCN == null ? "" : severityCN)))) {
// 如果tapd最新的数据和数据库中的数据相同就不操作了,再完成消息处理
tabTapdMessage.setStatus(UdeskConstant.DELETED);
udeskMessageService.update(tabTapdMessage);
return NOT_HANDLE;
}
// 同步Udesk的工单 1.拼装数据
JSONObject updateTicketRequestBody = new JSONObject();
JSONObject udeskTicketUpdate = new JSONObject();
JSONObject customFields = new JSONObject();
udeskTicketUpdate.put("status_id",
udeskTapdRelMap.get(latestBugFromTAPD.getStatus() + UdeskConstant.MAP_UDESK_ID_VALUE_SUFFIX));
udeskTicketUpdate.put("priority_id", udeskTapdRelMap.get(priorityEN + UdeskConstant.MAP_UDESK_ID_VALUE_SUFFIX));
// key:value,value为null的话,不会被序列化. 为了防止误操作,如果TAPD的缺陷的严重程度为空,并不会去更新udesk中的严重程度.
customFields.put(UdeskConstant.UDESK_FIELD_SEVERITY,
udeskTapdRelMap.get(severityEN + UdeskConstant.MAP_UDESK_ID_VALUE_SUFFIX));
udeskTicketUpdate.put("custom_fields", customFields);
updateTicketRequestBody.put("ticket", udeskTicketUpdate);
// 更新udesk的工单
boolean updateUdeskTicketSuccess = this.updateUdeskTicket(tapdMessage, updateTicketRequestBody);
if (!updateUdeskTicketSuccess) {
return msgId.toString();
}
// 更新数据库中的数据 注: 放在udesk操作完成之后
dataBaseTicket
.setStatusEn(udeskTapdRelMap.get(latestBugFromTAPD.getStatus() + UdeskConstant.MAP_UDESK_NAME_SUFFIX));
dataBaseTicket.setPriority(priorityCN);
dataBaseTicket.setSeverity(severityCN);
dataBaseTicket.setStatusTapd(latestBugFromTAPD.getStatus());
udeskTicketService.update(dataBaseTicket);
//消息处理完成
tabTapdMessage.setStatus(UdeskConstant.DELETED);
udeskMessageService.update(tabTapdMessage);
return msgId.toString();
}
private String handleTapdBugDelete(TapdMessageDTO tapdMessage) {
// 查询TapdBug在中间件中记录
List<TabUdeskTicket> dataBaseTicketList = this.getDataBaseTicket(tapdMessage);
if (CollectionUtils.isEmpty(dataBaseTicketList)) {
//没有建立关联 结束
return NOT_HANDLE;
}
TabUdeskTicket dataBaseTicket = dataBaseTicketList.get(0);
// 保存消息
tapdMessage.setUdeskId(dataBaseTicket.getId().toString());
TabUdeskMessage tabTapdMessage = this.getTapdMessageTemplate(tapdMessage,
UdeskSharedConstant.TAPD_BUG_DELETE_EVENT);
Integer msgId = udeskMessageService.save(tabTapdMessage);
logger.info("消息{}保存成功", tabTapdMessage);
//在Udesk工单下添加缺陷删除消息
UdeskAgentReplyDTO reply = new UdeskAgentReplyDTO();
reply.setAgent_id(Integer.valueOf(udeskTapdRelMap.get(UdeskConstant.UDESK_DEFAULT_AGENT)));
reply.setFunction_type(UdeskConstant.INTERNAL);
reply.setId(Integer.valueOf(tapdMessage.getUdeskId()));
reply.setNew_reply("缺陷Id:" + dataBaseTicket.getBugId() + " ,在TAPD已删除");
//在udesk工单下面添加客服回复
boolean addReplySuccess = this.addAgentInternalReplyInUdesk(tapdMessage, reply);
if (!addReplySuccess) {
return msgId.toString();
}
//更新数据库中ticket状态 注: 放在udesk操作完成之后
dataBaseTicket.setStatus(UdeskConstant.DELETED);
udeskTicketService.update(dataBaseTicket);
//消息处理完成
tabTapdMessage.setStatus(UdeskConstant.DELETED);
udeskMessageService.update(tabTapdMessage);
return msgId.toString();
}
/**
* 根据tapdMessage在数据库中查找对应的工单
*
* @param tapdMessage tapd传来的message,当然是经过删减的
* @return 查询结果
*/
private List<TabUdeskTicket> getDataBaseTicket(TapdMessageDTO tapdMessage) {
TabUdeskTicket params = new TabUdeskTicket();
params.setBugId(tapdMessage.getId());
List<TabUdeskTicket> list = udeskTicketService.list(params);
return list;
}
/**
* 检查变更字段,判断是否需要同步.
* 当TAPD的 status-状态,priority-优先级,severity-严重程度 发生改变时,需要更新
* @param changeFields 变更了的字段 e.g: status,severity
* @return 是否需要同步
*/
private boolean checkChangeFields(String changeFields) {
if (StringUtils.isBlank(changeFields)) {
return false;
}
String[] changeFieldsArray = changeFields.split(",");
for (String fieldName : changeFieldsArray) {
// 当TAPD的 status-状态,priority-优先级,severity-严重程度 发生改变时,需要更新
if ("status".equals(fieldName) || TAPD_FIELD_NAME_PRIORITY.equals(fieldName)
|| TAPD_FIELD_NAME_SEVERITY.equals(fieldName)) {
return true;
}
}
return false;
}
/**
* 根据tapd传来的message来转换为保存在数据库中的message模板
*
* @param tapdMessage tapd传来的message,当然是经过删减的
* @param bugEvent 缺陷事件,e.g: bug::update,bug::delete
* @return 存储在数据库中的消息
*/
private TabUdeskMessage getTapdMessageTemplate(TapdMessageDTO tapdMessage, String bugEvent) {
TabUdeskMessage tabTapdMessage = new TabUdeskMessage();
tabTapdMessage.setBugId(tapdMessage.getId());
tabTapdMessage.setTicketId(tapdMessage.getUdeskId());
//消息来源 udesk/tapd
tabTapdMessage.setSource(UdeskSharedConstant.TAPD_SOURCE);
//消息主题 bug
tabTapdMessage.setTopic(UdeskSharedConstant.TAPD_MESSAGE_TOPIC);
//事件类型 update / delete
tabTapdMessage.setEvent(bugEvent);
//消息数据
tabTapdMessage.setMsgBody(JSON.toJSONString(tapdMessage));
tabTapdMessage.setStatus(UdeskConstant.UNDELETED);
return tabTapdMessage;
}
/**
* 从TAPD中获取缺陷最新的详情
*
* @param tapdMessage tapd的消息
* @return TapdBugDTO
*/
private TapdBugDTO getLatestBugFromTAPD(TapdMessageDTO tapdMessage) {
Map<String, Object> queryBugParamsMap = new HashMap<>(4);
queryBugParamsMap.put("id", tapdMessage.getId());
queryBugParamsMap.put("workspace_id", tapdMessage.getWorkspace_id());
logger.info("获取缺陷详情,请求内容:{}", queryBugParamsMap);
String tapdApiResponseStr = UdeskHttpClientUtil.getTapdJsonFromParam(BUGS, queryBugParamsMap);
logger.info("获取缺陷详情,请求返回:{}", tapdApiResponseStr);
TapdRespBugDTO tapdRespBug = JSON.parseObject(tapdApiResponseStr, TapdRespBugDTO.class);
if (tapdRespBug == null || UdeskConstant.TAPD_RESP_SUCCESS_STATUS != tapdRespBug.getStatus()) {
String exceptionRecord = "查询TAPD缺陷失败;workSpaceId:" + tapdMessage.getWorkspace_id() + ";bugId:"
+ tapdMessage.getId() + ";ticketId:" + tapdMessage.getUdeskId() + ";请求返回:" + tapdApiResponseStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveTapdException(exceptionRecord);
return null;
}
return tapdRespBug.getData().getBug();
}
/**
* 获取tapd缺陷详情时,优先级(priority)和严重程度(serverityt)的值有时是中文、有时是英文。如果是传来的是中文,便将中文值转换为对应的英文值。
*
* @param fieldValue 字段值
* @param fieldName 字段名
* @return 对应的英文值或者是""; null的话就是有问题了.
*/
private String ensureFieldValueIsEn(String fieldValue, String fieldName, TapdMessageDTO tapdMessage) {
// fieldValue是""是由正常流程;是null,就是异常了走下面的return null;
if ("".equals(fieldValue)) {
return fieldValue;
}
// 如果在map里找得到映射就说明它是英文的,不用再查数据库找转换为中文了。
if (StringUtils.isNotBlank(udeskTapdRelMap.get(fieldValue + UdeskConstant.MAP_UDESK_NAME_SUFFIX))) {
return fieldValue;
}
TabUdeskTapdRel udeskTapdRel = null;
if (TAPD_FIELD_NAME_PRIORITY.equals(fieldName)) {
// 7对应优先级
TabUdeskTapdRel params = new TabUdeskTapdRel();
params.setRelType(7);
params.setTapdName(fieldValue);
udeskTapdRel = udeskTapdRelService.list(params).get(0);
} else if (TAPD_FIELD_NAME_SEVERITY.equals(fieldName)) {
// 4 对应严重程度
TabUdeskTapdRel params = new TabUdeskTapdRel();
params.setRelType(4);
params.setUdeskName(fieldValue);
udeskTapdRel = udeskTapdRelService.list(params).get(0);
}
if (udeskTapdRel == null) {
String exceptionRecord = "转化字段值时,在缓存和数据库中都找不到对应的转换值;" + fieldName + ":" + fieldValue + ";workSpaceId:"
+ tapdMessage.getWorkspace_id() + ";bugId:" + tapdMessage.getId() + ";ticketId:"
+ tapdMessage.getUdeskId();
logger.info(exceptionRecord);
udeskBaseApiService.saveTapdException(exceptionRecord);
return null;
}
return udeskTapdRel.getTapdId();
}
/**
* 更新udesk的工单
*
* @param tapdMessage tapd消息,包含ticketId、workSpaceId、bugId
* @param updateTicketRequestBody udesk ticket的更新内容
* @return 是否成功
*/
private boolean updateUdeskTicket(TapdMessageDTO tapdMessage, JSONObject updateTicketRequestBody) {
String updateTicketStr = updateTicketRequestBody.toJSONString();
logger.info("更新udesk工单,工单Id:{},更新内容为:{}", tapdMessage.getUdeskId(), updateTicketStr);
String updateTicketRespStr = UdeskHttpClientUtil
.putUdeskJsonFromJson(UDESK_UPDATE_TICKET + tapdMessage.getUdeskId(), updateTicketStr);
logger.info("更新udesk工单,工单返回为:{}", updateTicketRespStr);
UdeskTicketDetailDTO updateDetail = JSON.parseObject(updateTicketRespStr, UdeskTicketDetailDTO.class);
if (updateDetail == null || updateDetail.getCode() != UdeskConstant.UDESK_SUCCESS_CODE) {
String exceptionRecord = "更新工单失败;workSpaceId:" + tapdMessage.getWorkspace_id() + ";bugId:"
+ tapdMessage.getId() + ";ticketId:" + tapdMessage.getUdeskId() + ";请求返回:" + updateTicketRespStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveUdeskException(exceptionRecord);
return false;
}
return true;
}
/**
* 在Udesk工单下添加客服回复
*
* @param tapdMessage 来自tapd的消息
* @param reply 添加回复的内容
* @return 是否成功
*/
private boolean addAgentInternalReplyInUdesk(TapdMessageDTO tapdMessage, UdeskAgentReplyDTO reply) {
String replyStr = JSON.toJSONString(reply);
logger.info("回复udesk工单bug链接入参为{}", replyStr);
String replyRespStr = UdeskHttpClientUtil.postUdeskJsonFromJson(AGENT_REPLY, replyStr);
logger.info("回复udesk工单bug链接返回为{}", replyRespStr);
UdeskRespReplyDTO replyDetail = JSON.parseObject(replyRespStr, UdeskRespReplyDTO.class);
if (replyDetail == null || UdeskConstant.UDESK_SUCCESS_CODE != replyDetail.getCode()) {
String exceptionRecord = "在udesk工单下添加缺陷删除消息失败;workSpaceId:" + tapdMessage.getWorkspace_id() + ";bugId:"
+ tapdMessage.getId() + ";ticketId:" + tapdMessage.getUdeskId() + ";请求返回:" + replyRespStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveUdeskException(exceptionRecord);
return false;
}
return true;
}
}
package com.gic.udesk.service.outer.impl;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.udesk.entity.TabUdeskException;
import com.gic.udesk.entity.TabUdeskTapdRel;
import com.gic.udesk.service.UdeskBaseApiService;
import com.gic.udesk.service.UdeskExceptionService;
import com.gic.udesk.service.UdeskTapdRelService;
import com.gic.udesk.utils.UdeskConstant;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("udeskBaseApiService")
public class UdeskBaseApiServiceImpl implements UdeskBaseApiService {
private static Logger logger = LogManager.getLogger(UdeskBaseApiServiceImpl.class);
@Autowired
private UdeskExceptionService udeskExceptionService;
@Autowired
private UdeskTapdRelService udeskTapdRelService;
@Resource(name = "udeskTapdRelMap")
private Map<String, String> udeskTapdRelMap;
@PostConstruct
public void init() {
logger.info("初始化udeskTapdRelMap启动。。。。。。。。。。。。。。。");
List<TabUdeskTapdRel> list = udeskTapdRelService.list(null);
if (CollectionUtils.isNotEmpty(list)) {
logger.info("共有" + list.size() + "条数据要处理");
for (TabUdeskTapdRel tabUdeskTapdRel : list) {
Integer relType = tabUdeskTapdRel.getRelType();
if (relType == 1) {
// 1 udesk的业务模块与tapd项目的对应
udeskTapdRelMap.put(tabUdeskTapdRel.getUdeskIdKey() + ":" + tabUdeskTapdRel.getUdeskIdValue(),
tabUdeskTapdRel.getTapdId());
continue;
} else if (relType == 8) {
// 8 udesk状态 -> tapd状态
udeskTapdRelMap.put(tabUdeskTapdRel.getUdeskName(), tabUdeskTapdRel.getTapdId());
continue;
} else if (relType == 5 || relType == 4 || relType == 7) {
// 4 tapd严重程度->udsek 5 tapd状态 -> udesk状态 7 优先级
udeskTapdRelMap.put(tabUdeskTapdRel.getTapdId() + UdeskConstant.MAP_UDESK_ID_VALUE_SUFFIX,
tabUdeskTapdRel.getUdeskIdValue());
udeskTapdRelMap.put(tabUdeskTapdRel.getTapdId() + UdeskConstant.MAP_UDESK_NAME_SUFFIX,
tabUdeskTapdRel.getUdeskName());
if (relType == 4) {
// udesk严重程度字段名:idvalue -> udsek严重程度CN
udeskTapdRelMap.put(tabUdeskTapdRel.getUdeskIdKey() + ":" + tabUdeskTapdRel.getUdeskIdValue(),
tabUdeskTapdRel.getUdeskName());
}
continue;
} else if (relType == 6) {
// 6 客服
udeskTapdRelMap.put(UdeskConstant.UDESK_DEFAULT_AGENT, tabUdeskTapdRel.getUdeskIdValue());
continue;
}
udeskTapdRelMap.put(tabUdeskTapdRel.getUdeskIdKey() + ":" + tabUdeskTapdRel.getUdeskIdValue(),
tabUdeskTapdRel.getUdeskName());
}
logger.info("初始化udeskTapdRelMap完成:" + JSON.toJSONString(udeskTapdRelMap));
}
}
@Override
public ServiceResponse<Void> saveUdeskException(String exceptionRecord) {
TabUdeskException exception = new TabUdeskException();
exception.setExpType(UdeskConstant.UDESK_EXP_TYPE);
exception.setExceptionRecord(exceptionRecord);
udeskExceptionService.save(exception);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> saveTapdException(String exceptionRecord) {
TabUdeskException exception = new TabUdeskException();
exception.setExpType(UdeskConstant.TAPD_EXP_TYPE);
exception.setExceptionRecord(exceptionRecord);
udeskExceptionService.save(exception);
return ServiceResponse.success();
}
}
package com.gic.udesk.service.outer.impl;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.validation.ConstraintViolationException;
import com.gic.udesk.entity.TabUdeskTapdRel;
import com.gic.udesk.service.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.udesk.dto.*;
import com.gic.udesk.entity.TabUdeskMessage;
import com.gic.udesk.entity.TabUdeskTicket;
import com.gic.udesk.utils.UdeskConstant;
import com.gic.udesk.utils.UdeskHttpClientUtil;
@Service("udeskMessageApiService")
public class UdeskMessageApiServiceImpl implements UdeskMessageApiService {
private static Logger logger = LogManager.getLogger(UdeskMessageApiServiceImpl.class);
@Autowired
private UdeskMessageService udeskMessageService;
@Autowired
private UdeskBaseApiService udeskBaseApiService;
@Autowired
private UdeskTicketService udeskTicketService;
@Autowired
private UdeskTapdRelService udeskTapdRelService;
@Resource(name = "udeskTapdRelMap")
private Map<String, String> udeskTapdRelMap;
/**
* udesk工单详情接口路径
*/
private static final String TICKET_DETAIL = "/tickets/detail";
/**
* udesk客户公司详情接口路径
*/
private static final String ORG_DETAIL = "/organizations/show_org";
/**
* tapd 缺陷
*/
private static final String TAPD_BUGS = "/bugs";
private static final String TAPD_BUGS_URL_PART = "/bugtrace/bugs/view?bug_id=";
/**
* udesk客服回复接口路径
*/
private static final String AGENT_REPLY = "/tickets/agent_reply";
@Override
public ServiceResponse<String> saveUdeskMessage(UdeskMessageDTO messageDTO) {
TabUdeskMessage tabUdeskMessage = new TabUdeskMessage();
tabUdeskMessage.setEvent(messageDTO.getEvent());
tabUdeskMessage.setMsgBody(messageDTO.getMsgBody());
tabUdeskMessage.setSource(messageDTO.getSource());
tabUdeskMessage.setStatus(UdeskConstant.UNDELETED);
tabUdeskMessage.setTopic(messageDTO.getTopic());
udeskMessageService.save(tabUdeskMessage);
logger.info("消息为{}已经保存成功", messageDTO);
//创建工单消息
if (UdeskConstant.TICKET_CREATE.equals(messageDTO.getEvent())) {
//udesk工单ID
String id = messageDTO.getMsgBody();
//udesk工单详情接口
String detailStr = this.getUdeskTicketDetail(id);
UdeskTicketDetailDTO detail = JSON.parseObject(detailStr, UdeskTicketDetailDTO.class);
if (detail.getCode() == UdeskConstant.UDESK_SUCCESS_CODE) {
//usesk工单信息
TicketDTO ticket = detail.getTicket();
//udesk自定义字段信息
Map<String, String> customFields = ticket.getCustom_fields();
//udesk工单表实体
TabUdeskTicket tabUdeskTicket = new TabUdeskTicket();
TapdBugDTO tapdBug = new TapdBugDTO();
if (customFields != null) {
//udesk客服名称--tapd创建人
String staffValue = customFields.get(UdeskConstant.UDESK_FIELD_STAFF);
tabUdeskTicket
.setServiceStaff(udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_STAFF + ":" + staffValue));
//tapd项目ID
String workspaceValue = customFields.get(UdeskConstant.UDESK_FIELD_WORKSPACE);
tabUdeskTicket.setWorkspaceId(
udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_WORKSPACE + ":" + workspaceValue));
//TPAD当前处理人
String transactorValue = customFields.get(UdeskConstant.UDESK_FIELD_TRANSACTOR);
if (StringUtils.isNotBlank(transactorValue)) {
String[] transactors = transactorValue.split(",");
StringBuilder builder = new StringBuilder();
for (String transactor : transactors) {
builder.append(udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_TRANSACTOR + ":" + transactor))
.append(";");
}
tabUdeskTicket.setCurrentOwner(builder.toString());
}
//填充部分自定义字段值
this.setUdeskCostomFields(tabUdeskTicket, tapdBug, customFields);
}
//受理客服id
tabUdeskTicket.setAssigneeId(ticket.getAssignee_id());
//受理客服姓名
tabUdeskTicket.setAssigneeName(ticket.getAssignee_name());
//创建人id
tabUdeskTicket.setCreatorId(ticket.getCreator_id());
//工单编号
tabUdeskTicket.setFieldNum(ticket.getField_num());
//工单id
tabUdeskTicket.setId(ticket.getId());
//客户所属公司id
Integer organizationId = ticket.getOrganization_id();
if (organizationId != null) {
this.setOrganizationIdAndName(tabUdeskTicket, organizationId);
}
//填充工单优先级中文名称
this.setPriority(ticket, tabUdeskTicket, tapdBug);
tabUdeskTicket.setStatus(UdeskConstant.UNDELETED);
//状态英文名称
tabUdeskTicket.setStatusEn(ticket.getStatus_en());
//tapd状态值
tabUdeskTicket.setStatusTapd(udeskTapdRelMap.get(ticket.getStatus_en()));
//标题
tabUdeskTicket.setSubject(ticket.getSubject());
//客户id
tabUdeskTicket.setUserId(ticket.getUser_id());
//客户姓名
tabUdeskTicket.setUserName(ticket.getUser_name());
try {
udeskTicketService.save(tabUdeskTicket);
logger.info("工单id为{}已经保存成功", ticket.getId());
} catch (DataIntegrityViolationException | ConstraintViolationException e) {
logger.info("工单id为{}已经保存失败,重复插入", ticket.getId(), e);
return null;
}
tapdBug.setTitle(ticket.getSubject());
tapdBug.setCurrent_owner(tabUdeskTicket.getCurrentOwner());
tapdBug.setReporter(UdeskConstant.TPAD_REPORTER);
String workspaceId = tabUdeskTicket.getWorkspaceId();
tapdBug.setWorkspace_id(workspaceId);
this.setTapdCustomField(workspaceId, tapdBug, tabUdeskTicket);
tapdBug.setStatus(tabUdeskTicket.getStatusTapd());
this.setDescription(ticket, tapdBug);
String bugStr = JSON.toJSONString(tapdBug);
logger.info("添加TAPDbug入参为{}", bugStr);
String bugReturnStr = UdeskHttpClientUtil.postTapdJsonFromJson(TAPD_BUGS, bugStr);
logger.info("添加TAPDbug返回为{}", bugReturnStr);
TapdRespBugDTO tapdRespBug = JSON.parseObject(bugReturnStr, TapdRespBugDTO.class);
if (tapdRespBug.getStatus() == UdeskConstant.TAPD_RESP_SUCCESS_STATUS) {
//tapd缺陷ID
String bugId = tapdRespBug.getData().getBug().getId();
tabUdeskTicket.setBugId(bugId);
udeskTicketService.update(tabUdeskTicket);
String bugUrl = UdeskConstant.TAPD_HOST + workspaceId + TAPD_BUGS_URL_PART + bugId;
//客服回复对象
UdeskAgentReplyDTO reply = new UdeskAgentReplyDTO();
//客服id
reply.setAgent_id(Integer.valueOf(udeskTapdRelMap.get(UdeskConstant.UDESK_DEFAULT_AGENT)));
//回复类型,"internal"内部备注/"external"外部评论
reply.setFunction_type(UdeskConstant.INTERNAL);
//工单ID
reply.setId(ticket.getId());
//回复内容
reply.setNew_reply("TAPD的bug链接为:<a href=\""+ bugUrl +"\" target=\"_blank\">" + bugUrl + "</a>");
//客服回复对象转为接口入参数
String replyStr = JSON.toJSONString(reply);
logger.info("回复udesk工单bug链接入参为{}", replyStr);
String replyRespStr = UdeskHttpClientUtil.postUdeskJsonFromJson(AGENT_REPLY, replyStr);
logger.info("回复udesk工单bug链接返回为{}", replyRespStr);
UdeskRespReplyDTO replyDetail = JSON.parseObject(replyRespStr, UdeskRespReplyDTO.class);
if (replyDetail.getCode() != UdeskConstant.UDESK_SUCCESS_CODE) {
String exceptionRecord = "工单id为" + id + "回复udesk工单bug链接失败,返回为" + replyRespStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveUdeskException(exceptionRecord);
} else {
//消息删除status = 0
this.updateTabUdeskMessage(tabUdeskMessage, id, bugId);
}
if(!"new".equals(tapdBug.getStatus())){
this.reSetTapdStatus(id, ticket, tapdBug, workspaceId, bugId);
}
return ServiceResponse.success(bugId);
} else {
String exceptionRecord = "工单id为" + id + "创建TAPDbug失败,返回为" + bugReturnStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveTapdException(exceptionRecord);
}
} else {
String exceptionRecord = "工单id为" + id + "请求udesk工单详情异常,返回为" + detailStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveUdeskException(exceptionRecord);
}
} else if (UdeskConstant.TICKET_UPDATE.equals(messageDTO.getEvent())) {
//更新消息
String id = messageDTO.getMsgBody();
String detailStr = this.getUdeskTicketDetail(id);
UdeskTicketDetailDTO detail = JSON.parseObject(detailStr, UdeskTicketDetailDTO.class);
if (detail.getCode() == UdeskConstant.UDESK_SUCCESS_CODE) {
//udesk接口查询的工单信息
TicketDTO ticket = detail.getTicket();
//数据库查询的工单记录信息
TabUdeskTicket tabUdeskTicket = udeskTicketService.getById(Integer.parseInt(id));
if (tabUdeskTicket == null) {
UdeskMessageDTO createMessage = new UdeskMessageDTO();
//事件类型 创建/更新
createMessage.setEvent(UdeskConstant.TICKET_CREATE);
//工单ID
createMessage.setMsgBody(id);
createMessage.setSource(UdeskConstant.UDESK_UPDATE_CREATE);
//消息主题
createMessage.setTopic(UdeskConstant.UDESK_TICKET_TOPIC);
ServiceResponse<String> saveResult = this.saveUdeskMessage(createMessage);
String bugId = saveResult.getResult();
//删除消息status = 0
this.updateTabUdeskMessage(tabUdeskMessage, id, bugId);
return ServiceResponse.success(bugId);
}
TapdBugUpdateDTO tapdBug = new TapdBugUpdateDTO();
//防止创建工单误触发更新
String bugId = tabUdeskTicket.getBugId();
if (StringUtils.isBlank(bugId)) {
return null;
}
tapdBug.setId(bugId);
tapdBug.setTitle(ticket.getSubject());
tapdBug.setCurrent_user(UdeskConstant.TPAD_REPORTER);
this.setDescription(ticket, tapdBug);
//tapd项目ID
String workspaceId = tabUdeskTicket.getWorkspaceId();
tapdBug.setProject_id(Integer.valueOf(workspaceId));
tapdBug.setWorkspace_id(workspaceId);
tapdBug.setReporter(UdeskConstant.TPAD_REPORTER);
//工单状态英文名称
String statusEn = ticket.getStatus_en();
//如果udesk工单状态不等于本地数据库对应的工单状态
if (StringUtils.isNotBlank(statusEn) && !statusEn.equals(tabUdeskTicket.getStatusEn())) {
if (UdeskConstant.CLOSED.equals(tabUdeskTicket.getStatusEn())) {
//本地工单状态如果是关闭状态,设置tapd缺陷 更新人(操作人)
tapdBug.setCurrent_owner(tabUdeskTicket.getCurrentOwner());
}
//获取字典的状态值
String tapdStatus = udeskTapdRelMap.get(statusEn);
tabUdeskTicket.setStatusEn(statusEn);
tabUdeskTicket.setStatusTapd(tapdStatus);
//同步tapd缺陷状态
tapdBug.setStatus(tapdStatus);
}
tabUdeskTicket.setSubject(ticket.getSubject());
this.setPriority(ticket, tabUdeskTicket, tapdBug);
Integer organizationId = ticket.getOrganization_id();
if(organizationId != null && !organizationId.equals(tabUdeskTicket.getOrganizationId())){
this.setOrganizationIdAndName(tabUdeskTicket, organizationId);
}
Map<String, String> customFields = ticket.getCustom_fields();
if(customFields != null){
this.setUdeskCostomFields(tabUdeskTicket, tapdBug, customFields);
}
tabUdeskTicket.setUserName(ticket.getUser_name());
this.setTapdCustomField(workspaceId, tapdBug, tabUdeskTicket);
udeskTicketService.update(tabUdeskTicket);
String bugStr = JSON.toJSONString(tapdBug);
logger.info("更新TAPDbug入参为{}", bugStr);
String bugReturnStr = UdeskHttpClientUtil.postTapdJsonFromJson(TAPD_BUGS, bugStr);
logger.info("更新TAPDbug返回为{}", bugReturnStr);
TapdRespBugDTO tapdRespBug = JSON.parseObject(bugReturnStr, TapdRespBugDTO.class);
if (tapdRespBug.getStatus() == UdeskConstant.TAPD_RESP_SUCCESS_STATUS) {
this.updateTabUdeskMessage(tabUdeskMessage, id, bugId);
return ServiceResponse.success(bugId);
} else {
String exceptionRecord = "工单id为" + id + "更新TAPDbug失败,返回为" + bugReturnStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveTapdException(exceptionRecord);
}
} else {
String exceptionRecord = "工单id为" + id + "更新工单请求udesk工单详情异常,返回为" + detailStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveUdeskException(exceptionRecord);
}
}
return null;
}
/**
* udesk工单详情接口
* @param id
* @return
*/
private String getUdeskTicketDetail(String id) {
Map<String, Object> param = new HashMap<>(8);
param.put("id", id);
logger.info("请求udesk工单详情入参id为{}", id);
String detailStr = UdeskHttpClientUtil.getUdeskJsonFromParam(TICKET_DETAIL, param);
logger.info("请求udesk工单详情返回为{}", detailStr);
return detailStr;
}
/**
* 设置部分自定义字段的值到udesk工单
* @param tabUdeskTicket
* @param tapdBug
* @param customFields
*/
private void setUdeskCostomFields(TabUdeskTicket tabUdeskTicket, TapdBugBaseDTO tapdBug,
Map<String, String> customFields) {
//严重程度
String severityValue = customFields.get(UdeskConstant.UDESK_FIELD_SEVERITY);
tabUdeskTicket.setSeverity(udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_SEVERITY + ":" + severityValue));
tapdBug.setSeverity(tabUdeskTicket.getSeverity());
//发现阶段
String originphaseValue = customFields.get(UdeskConstant.UDESK_FIELD_ORIGINPHASE);
tapdBug.setOriginphase(udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_ORIGINPHASE + ":" + originphaseValue));
//测试类型
String testtypeValue = customFields.get(UdeskConstant.UDESK_FIELD_TESTTYPE);
tapdBug.setTesttype(udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_TESTTYPE + ":" + testtypeValue));
//缺陷类型
String bugtypeValue = customFields.get(UdeskConstant.UDESK_FIELD_BUGTYPE);
tapdBug.setBugtype(udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_BUGTYPE + ":" + bugtypeValue));
//重现规律
String frequencyValue = customFields.get(UdeskConstant.UDESK_FIELD_FREQUENCY);
tapdBug.setFrequency(udeskTapdRelMap.get(UdeskConstant.UDESK_FIELD_FREQUENCY + ":" + frequencyValue));
}
/**
* 工单表填充客户所属公司名称
* @param tabUdeskTicket
* @param organizationId 客户所属公司ID
*/
private void setOrganizationIdAndName(TabUdeskTicket tabUdeskTicket, Integer organizationId) {
tabUdeskTicket.setOrganizationId(organizationId);
Map<String, Object> orgParam = new HashMap<>(8);
orgParam.put("type", "id");
orgParam.put("content", organizationId);
logger.info("请求udesk企业详情入参id为{}", organizationId);
String orgDetailStr = UdeskHttpClientUtil.getUdeskJsonFromParam(ORG_DETAIL, orgParam);
logger.info("请求udesk企业详情返回为{}", orgDetailStr);
UdeskCompanyDTO orgDetail = JSON.parseObject(orgDetailStr, UdeskCompanyDTO.class);
if (orgDetail.getCode() == UdeskConstant.UDESK_SUCCESS_CODE) {
OrganizationDTO organization = orgDetail.getOrganization();
if (organization != null) {
tabUdeskTicket.setOrganizationName(organization.getName());
}
} else {
String exceptionRecord = "企业id为" + organizationId + "请求udesk企业详情异常,返回为" + orgDetailStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveUdeskException(exceptionRecord);
}
}
/**
* 填充工单优先级中文名称
* @param ticket
* @param tabUdeskTicket
* @param tapdBug
*/
private void setPriority(TicketDTO ticket, TabUdeskTicket tabUdeskTicket, TapdBugBaseDTO tapdBug) {
String priority = ticket.getPriority();
if (UdeskConstant.UDESK_PRIORITY_NORMAL.equals(priority)) {
priority = UdeskConstant.TAPD_PRIORITY_NORMAL;
}
tabUdeskTicket.setPriority(priority);
tapdBug.setPriority(tabUdeskTicket.getPriority());
}
/**
* 填充tapd缺陷的自定义字段值
* @param workspaceId
* @param tapdBug
* @param tabUdeskTicket
*/
private void setTapdCustomField(String workspaceId, TapdBugDTO tapdBug, TabUdeskTicket tabUdeskTicket) {
TabUdeskTapdRel params = new TabUdeskTapdRel();
params.setRelType(9);
params.setWorkspaceId(workspaceId);
List<TabUdeskTapdRel> udeskTapdRelList = udeskTapdRelService.list(params);
for (TabUdeskTapdRel tabUdeskTapdRel : udeskTapdRelList) {
try {
Method udeskMethod = TabUdeskTapdRel.class.getMethod(tabUdeskTapdRel.getUdeskIdKey());
String value = (String) udeskMethod.invoke(tabUdeskTicket);
Method tapdMethod = TapdBugDTO.class.getMethod(tabUdeskTapdRel.getTapdId(), String.class);
tapdMethod.invoke(tapdBug, value);
} catch (Exception e) {
String exceptionRecord = "创建tapd缺陷设置tapd自定义字段异常" + e.getMessage();
logger.info(exceptionRecord, e);
udeskBaseApiService.saveUdeskException(exceptionRecord);
}
}
}
/**
* 填充tapd缺陷的自定义字段值
* @param workspaceId
* @param tapdBug
* @param tabUdeskTicket
*/
private void setTapdCustomField(String workspaceId, TapdBugUpdateDTO tapdBug, TabUdeskTicket tabUdeskTicket) {
TabUdeskTapdRel params = new TabUdeskTapdRel();
params.setWorkspaceId(workspaceId);
params.setRelType(9);
List<TabUdeskTapdRel> udeskTapdRelList = udeskTapdRelService.list(params);
for (TabUdeskTapdRel tabUdeskTapdRel : udeskTapdRelList) {
String udeskIdKey = tabUdeskTapdRel.getUdeskIdKey();
if ("getFieldNum".equals(udeskIdKey) || "getServiceStaff".equals(udeskIdKey)) {
continue;
}
try {
Method udeskMethod = TabUdeskTicket.class.getMethod(udeskIdKey);
String value = (String) udeskMethod.invoke(tabUdeskTicket);
Method tapdMethod = TapdBugUpdateDTO.class.getMethod(tabUdeskTapdRel.getTapdId(), String.class);
tapdMethod.invoke(tapdBug, value);
} catch (Exception e) {
String exceptionRecord = "更新tapd缺陷设置tapd自定义字段异常" + e.getMessage();
logger.info(exceptionRecord, e);
udeskBaseApiService.saveUdeskException(exceptionRecord);
}
}
}
private void setDescription(TicketDTO ticket, TapdBugBaseDTO tapdBug) {
String content = "<p>" + ticket.getContent() + "</p>";
List<AttachmentDTO> attachments = ticket.getAttachments();
if (attachments != null && attachments.size() > 0) {
StringBuilder builder = new StringBuilder(content).append("<p>附件:<ul id=udesk_attachments'>");
for (AttachmentDTO attachment : attachments) {
builder.append("<li>").append("<a href='" + attachment.getUrl() + "' download='")
.append(attachment.getFile_name()).append("'>").append(attachment.getFile_name())
.append("</a></li>");
}
tapdBug.setDescription(builder.append("</ul></p>").toString());
} else {
tapdBug.setDescription(content);
}
}
/**
* 删除消息数据
* @param tabUdeskMessage
* @param id
* @param bugId
*/
private void updateTabUdeskMessage(TabUdeskMessage tabUdeskMessage, String id, String bugId) {
tabUdeskMessage.setBugId(bugId);
tabUdeskMessage.setTicketId(id);
tabUdeskMessage.setStatus(UdeskConstant.DELETED);
udeskMessageService.update(tabUdeskMessage);
}
/**
* 同步tapd缺陷状态值
* @param id
* @param ticket
* @param tapdBug
* @param workspaceId
* @param bugId
*/
private void reSetTapdStatus(String id, TicketDTO ticket, TapdBugDTO tapdBug, String workspaceId, String bugId) {
TapdBugUpdateDTO tapdBugUpdate = new TapdBugUpdateDTO();
//tapd缺陷主键ID
tapdBugUpdate.setId(bugId);
//标题
tapdBugUpdate.setTitle(ticket.getSubject());
tapdBugUpdate.setCurrent_user(UdeskConstant.TPAD_REPORTER);
//项目ID
tapdBugUpdate.setProject_id(Integer.valueOf(workspaceId));
tapdBugUpdate.setWorkspace_id(workspaceId);
tapdBugUpdate.setReporter(UdeskConstant.TPAD_REPORTER);
tapdBugUpdate.setStatus(tapdBug.getStatus());
String updateStr = JSON.toJSONString(tapdBugUpdate);
logger.info("创建工单单独更新TAPDbug状态入参为{}", updateStr);
String bugUpdateReturnStr = UdeskHttpClientUtil.postTapdJsonFromJson(TAPD_BUGS, updateStr);
logger.info("创建工单单独更新TAPDbug状态返回为{}", bugUpdateReturnStr);
TapdRespBugDTO tapdRespBugUpdate = JSON.parseObject(bugUpdateReturnStr, TapdRespBugDTO.class);
if (tapdRespBugUpdate.getStatus() != UdeskConstant.TAPD_RESP_SUCCESS_STATUS) {
String exceptionRecord = "工单id为" + id + "单独更新TAPDbug状态失败,返回为" + updateStr;
logger.info(exceptionRecord);
udeskBaseApiService.saveTapdException(exceptionRecord);
}
}
}
package com.gic.udesk.utils;
import org.apache.commons.codec.binary.Base64;
/**
* udesk常量类
* @ClassName: UdeskConstant

* @Description: 

* @author guojuxing

* @date 2019/12/23 3:57 PM

*/
public class UdeskConstant {
/**
* udesk邮箱账号
*/
public static final String EMAIL = "jingjiawei@demogic.com";
/**
* udesk密码
*/
public static final String SECRET = "*ys15658036172";
/**
* udesk API TOKEN
*/
public static final String API_TOKEN = "2a83c020-2309-4064-b4eb-af1367425c99";
/**
* udesk API 请求地址
*/
public static final String UDESK_URI = "http://demogic.udesk.cn/open_api_v1";
/**
* TAPD API 请求地址
*/
public static final String TAPD_URI = "https://api.tapd.cn";
/**
* TAPD 请求地址
*/
public static final String TAPD_HOST = "https://www.tapd.cn/";
/**
* TAPD API ACCOUNT
*/
public static final String TAPD_ACCOUNT = "e6PWqG!l";
/**
* TAPD company_id
*/
public static final int TAPD_COMPANY_ID = 20078731;
/**
* TAPD API SECRET
*/
public static final String TAPD_SECRET = "313EFA55-7D83-D8A6-ECE4-E832CC6844B1";
/**
* TAPD Authorization
*/
public static final String TAPD_AUTH = "Basic " + new Base64().encodeToString((TAPD_ACCOUNT + ":" + TAPD_SECRET).getBytes());
/**
* 已删除
*/
public static final int DELETED = 0;
/**
* 未删除
*/
public static final int UNDELETED = 1;
/**
* 新建工单消息
*/
public static final String TICKET_CREATE = "ticketCreate";
/**
* 更新工单消息
*/
public static final String TICKET_UPDATE = "ticketUpdate";
/**
* udesk请求返回正确码
*/
public static final int UDESK_SUCCESS_CODE = 1000;
/**
* udesk字段指定的tapd处理人
*/
public static final String UDESK_FIELD_OWNER = "SelectField_19948";
/**
* udesk字段客服
*/
public static final String UDESK_FIELD_STAFF = "SelectField_19952";
/**
* udesk字段严重程度
*/
public static final String UDESK_FIELD_SEVERITY = "SelectField_19958";
/**
* udesk字段对应项目
*/
public static final String UDESK_FIELD_WORKSPACE = "SelectField_19946";
/**
* udesk字段发现阶段
*/
public static final String UDESK_FIELD_ORIGINPHASE = "SelectField_23551";
/**
* udesk字段测试类型
*/
public static final String UDESK_FIELD_TESTTYPE = "SelectField_23561";
/**
* udesk字段缺陷类型
*/
public static final String UDESK_FIELD_BUGTYPE = "SelectField_23571";
/**
* udesk字段重现规律
*/
public static final String UDESK_FIELD_FREQUENCY = "SelectField_23581";
/**
* udesk字段多选处理人
*/
public static final String UDESK_FIELD_TRANSACTOR = "SelectField_23591";
/**
* udesk来源的类型异常
*/
public static final String UDESK_EXP_TYPE = "udesk";
/**
* tapd来源的类型异常
*/
public static final String TAPD_EXP_TYPE = "tapd";
/**
* udesk优先级为标准
*/
public static final String UDESK_PRIORITY_NORMAL = "标准";
/**
* tapd优先级为中
*/
public static final String TAPD_PRIORITY_NORMAL = "中";
/**
* tapd默认提报人
*/
public static final String TPAD_REPORTER = "udesk";
/**
* tapd请求返回正确码
*/
public static final int TAPD_RESP_SUCCESS_STATUS = 1;
/**
* UDESK内部备注
*/
public static final String INTERNAL = "internal";
/**
* 加在MAP缓存 udeskId_value Key的后面
*/
public static final String MAP_UDESK_ID_VALUE_SUFFIX = "-value";
/**
* 加在MAP缓存 udesk_name Key的后面
*/
public static final String MAP_UDESK_NAME_SUFFIX = "-name";
/**
* 更新触发创建工单
*/
public static final String UDESK_UPDATE_CREATE = "udesk-update-create";
/**
* UDESK工单主题
*/
public static final String UDESK_TICKET_TOPIC = "ticket";
/**
* UDESK默认回复客服对应map的key
*/
public static final String UDESK_DEFAULT_AGENT = "agent";
/**
* 异常返回null
*/
public static final String NULL = "null";
/**
* 关闭状态
*/
public static final String CLOSED = "closed";
}
package com.gic.udesk.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class UdeskHttpClientUtil {
private static final Logger logger = LogManager.getLogger(UdeskHttpClientUtil.class);
private static PoolingHttpClientConnectionManager connectionManager = null;
private static CloseableHttpClient httpClient = null;
static {
LayeredConnectionSocketFactory sslsf = null;
try {
sslsf = new SSLConnectionSocketFactory(SSLContext.getDefault());
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", sslsf).register("http", new PlainConnectionSocketFactory()).build();
connectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
connectionManager.setMaxTotal(500);
connectionManager.setDefaultMaxPerRoute(100);
httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();
} catch (NoSuchAlgorithmException e) {
logger.info("加载UdeskHttpClientUtil失败", e);
}
}
/**
* udesk的get请求拼接url参数
*/
public static String getUdeskJsonFromParam(String url, Map<String, Object> param) {
if (param == null) {
param = new HashMap<String, Object>();
}
long timeStamp = System.currentTimeMillis() / 1000;
param.put("email", UdeskConstant.EMAIL);
param.put("timestamp", timeStamp);
param.put("sign", UdeskUtils.getSign(timeStamp));
url = UdeskConstant.UDESK_URI + getURL(url, param);
logger.info(url);
CloseableHttpResponse response = null;
try {
HttpGet httpGet = new HttpGet(url);
response = httpClient.execute(httpGet);
return EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
logger.info("GET请求{}失败", url, e);
} finally {
closeResponse(response);
}
return null;
}
/**
* udesk的post请求,Request Body
*/
public static String postUdeskJsonFromJson(String url, String json) {
long timeStamp = System.currentTimeMillis() / 1000;
url = UdeskConstant.UDESK_URI + url + "?email=" + UdeskConstant.EMAIL + "&timestamp=" + timeStamp + "&sign=" + UdeskUtils.getSign(timeStamp);
logger.info(url);
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(url);
response = getResponse(json, httpPost);
return EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
logger.info("POST请求{}失败,参数为{}", url, json, e);
} finally {
closeResponse(response);
}
return null;
}
/**
* udesk的put请求,Request Body
*/
public static String putUdeskJsonFromJson(String url, String json) {
long timeStamp = System.currentTimeMillis() / 1000;
url = UdeskConstant.UDESK_URI + url + "?email=" + UdeskConstant.EMAIL + "&timestamp=" + timeStamp + "&sign=" + UdeskUtils.getSign(timeStamp);
logger.info(url);
CloseableHttpResponse response = null;
try {
HttpPut httpPut = new HttpPut(url);
if (json != null && (!"".equals(json.trim()))) {
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPut.setEntity(entity);
}
response = httpClient.execute(httpPut);
return EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
logger.info("PUT请求{}失败,参数为{}", url, json, e);
} finally {
closeResponse(response);
}
return null;
}
/**
* udesk的delete请求拼接url参数
*/
public static String deleteUdeskJsonFromParam(String url, Map<String, Object> param) {
if (param == null) {
param = new HashMap<String, Object>();
}
long timeStamp = System.currentTimeMillis() / 1000;
param.put("email", UdeskConstant.EMAIL);
param.put("timestamp", timeStamp);
param.put("sign", UdeskUtils.getSign(timeStamp));
url = UdeskConstant.UDESK_URI + getURL(url, param);
logger.info(url);
CloseableHttpResponse response = null;
try {
HttpDelete httpDelete = new HttpDelete(url);
response = httpClient.execute(httpDelete);
return EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
logger.info("DELETE请求{}失败", url, e);
} finally {
closeResponse(response);
}
return null;
}
/**
* TAPD的get请求拼接url参数
*/
public static String getTapdJsonFromParam(String url, Map<String, Object> param) {
CloseableHttpResponse response = null;
try {
url = UdeskConstant.TAPD_URI +getURIBuilder(url, param);
logger.info(url);
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("Authorization", UdeskConstant.TAPD_AUTH);
response = httpClient.execute(httpGet);
return EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
logger.info("GET请求{}失败", url, e);
} finally {
closeResponse(response);
}
return null;
}
/**
* TAPD的post请求拼接url参数
*/
public static String postTapdJsonFromJson(String url, String json) {
url = UdeskConstant.TAPD_URI + url;
logger.info(url);
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Authorization", UdeskConstant.TAPD_AUTH);
response = getResponse(json, httpPost);
return EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
logger.info("POST请求{}失败,参数为{}", url, json, e);
} finally {
closeResponse(response);
}
return null;
}
/**
* 铁臂-使用httpclient自带的URIBuilder建立URI
* @param uri
* @param requestParams
* @return String
* @throws URISyntaxException
*/
private static String getURIBuilder(String uri, Map<String, Object> requestParams) throws URISyntaxException {
URIBuilder uriBuilder = new URIBuilder( uri);
if (requestParams != null && requestParams.size() > 0) {
for (Map.Entry<String, Object> entry : requestParams.entrySet()) {
String key = entry.getKey();
if (StringUtils.isNotBlank(key)) {
uriBuilder.setParameter(key, String.valueOf(entry.getValue()));
}
}
}
return uriBuilder.build().toString();
}
/**
* 拼接URL
*/
private static String getURL(String url, Map<String, Object> param) {
if (param != null && param.size() > 0) {
StringBuilder urlSB = new StringBuilder(url);
Set<Map.Entry<String, Object>> paramSet = param.entrySet();
boolean isFirst = true;
for (Map.Entry<String, Object> entry : paramSet) {
if (isFirst) {
urlSB.append("?");
isFirst = false;
} else {
urlSB.append("&");
}
urlSB.append(entry.getKey()).append("=").append(entry.getValue());
}
return urlSB.toString();
}
return url;
}
/**
* 关闭Response
*/
private static void closeResponse(CloseableHttpResponse response) {
if (response != null) {
try {
response.close();
} catch (Exception e) {
logger.info("关闭response失败", e);
}
}
}
/**
* 获取Response
*/
private static CloseableHttpResponse getResponse(String json, HttpPost httpPost)
throws IOException, ClientProtocolException {
CloseableHttpResponse response;
if (json != null && (!"".equals(json.trim()))) {
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
}
response = httpClient.execute(httpPost);
return response;
}
}
package com.gic.udesk.utils;
import org.apache.commons.codec.digest.DigestUtils;
public class UdeskUtils {
public static String getSign(long timeStamp){
return DigestUtils.sha1Hex(UdeskConstant.EMAIL + "&" + UdeskConstant.API_TOKEN + "&" +timeStamp);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:applicationContext-init.xml"/>
<import resource="classpath:dubbo-gic-platform-udesk-service.xml"/>
<import resource="classpath*:dubbo-setting.xml"/>
<import resource="classpath:jdbc-gic-platform-udesk-service.xml"/>
<import resource="classpath*:redis-init.xml" />
<util:map id="udeskTapdRelMap" map-class="java.util.HashMap"></util:map>
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<context:component-scan base-package="com.gic.udesk.*"/>
<!-- 应用名称 -->
<dubbo:application name="gic-platform-udesk-service"/>
<dubbo:protocol name="dubbo" port="20320"/>
<dubbo:service interface="com.gic.udesk.service.UdeskMessageApiService" ref="udeskMessageApiService" retries="0"/>
<dubbo:service interface="com.gic.udesk.service.TapdConfigApiService" ref="tapdConfigApiService" retries="0"/>
<dubbo:service interface="com.gic.udesk.service.TapdMessageApiService" ref="tapdMessageApiService" retries="0"/>
</beans>
dubbo.registry.file=gic-platform-udesk-service
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:apollo="http://www.ctrip.com/schema/apollo"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.ctrip.com/schema/apollo
http://www.ctrip.com/schema/apollo.xsd">
<context:annotation-config/>
<!--<apollo:config namespaces="COMMON.sharding,COMMON.4.0-jdbc"/>-->
<!--<bean id="dataSource" class="com.gic.sharding.sdk.ShardingDatasource" init-method="init">-->
<!--<property name="shardingId" value="${sharding.shardingId}"/>-->
<!--<property name="maxSize" value="${jdbc.maxsize}"/>-->
<!--<property name="urlType" value="${sharding.urlType:inner}"/>-->
<!--</bean>-->
<import resource="classpath:applicationContext-db-only.xml"/>
<bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" value="com.gic.udesk.**.entity"/>
<property name="mapperLocations" value="classpath*:mapper/*.xml"/>
<property name="plugins">
<array>
<!-- 自动生成id -->
<bean class="com.gic.commons.plugin.mybatis.AutoIdInterceptor"/>
<!-- 分页插件 -->
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>
helperDialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.gic.udesk.**.dao.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 事务管理器 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="error" packages="com.gic.commons.log">
<appenders>
<!--这个输出控制台的配置-->
<Console name="Console" target="SYSTEM_OUT">
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
<ThresholdFilter level="trace" onMatch="ACCEPT" onMismatch="DENY" />
<!--这个都知道是输出日志的格式-->
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c:%L] [%traceId] %m%n" />
</Console>
</appenders>
<loggers>
<!--建立一个默认的root的logger-->
<Logger name="com.gic" level="DEBUG"/>
<Logger name="org.springframework" level="INFO"/>
<logger name="Sharding-JDBC-SQL" level="INFO"/>
<logger name="org.hibernate.SQL" level="DEBUG"/>
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="DEBUG"/>
<Root level="WARN">
<!--<Root level="DEBUG">-->
<AppenderRef ref="Console" />
</Root>
</loggers>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.udesk.dao.mapper.TabUdeskEnterpriseMapper">
<resultMap id="BaseResultMap" type="com.gic.udesk.entity.TabUdeskEnterprise">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="business_module" jdbcType="VARCHAR" property="businessModule" />
<result column="business_module_name" jdbcType="VARCHAR" property="businessModuleName" />
<result column="business_type" jdbcType="INTEGER" property="businessType" />
<result column="ticket_id" jdbcType="INTEGER" property="ticketId" />
<result column="ticket_num" jdbcType="CHAR" property="ticketNum" />
<result column="ticket_title" jdbcType="CHAR" property="ticketTitle" />
<result column="ticket_status" jdbcType="VARCHAR" property="ticketStatus" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, business_module, business_module_name, business_type, ticket_id, ticket_num,
ticket_title, ticket_status, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_udesk_enterprise
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_udesk_enterprise
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.udesk.entity.TabUdeskEnterprise">
insert into tab_udesk_enterprise (id, business_module, business_module_name,
business_type, ticket_id, ticket_num,
ticket_title, ticket_status, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{businessModule,jdbcType=VARCHAR}, #{businessModuleName,jdbcType=VARCHAR},
#{businessType,jdbcType=INTEGER}, #{ticketId,jdbcType=INTEGER}, #{ticketNum,jdbcType=CHAR},
#{ticketTitle,jdbcType=CHAR}, #{ticketStatus,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.udesk.entity.TabUdeskEnterprise">
insert into tab_udesk_enterprise
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="businessModule != null">
business_module,
</if>
<if test="businessModuleName != null">
business_module_name,
</if>
<if test="businessType != null">
business_type,
</if>
<if test="ticketId != null">
ticket_id,
</if>
<if test="ticketNum != null">
ticket_num,
</if>
<if test="ticketTitle != null">
ticket_title,
</if>
<if test="ticketStatus != null">
ticket_status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="businessModule != null">
#{businessModule,jdbcType=VARCHAR},
</if>
<if test="businessModuleName != null">
#{businessModuleName,jdbcType=VARCHAR},
</if>
<if test="businessType != null">
#{businessType,jdbcType=INTEGER},
</if>
<if test="ticketId != null">
#{ticketId,jdbcType=INTEGER},
</if>
<if test="ticketNum != null">
#{ticketNum,jdbcType=CHAR},
</if>
<if test="ticketTitle != null">
#{ticketTitle,jdbcType=CHAR},
</if>
<if test="ticketStatus != null">
#{ticketStatus,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.udesk.entity.TabUdeskEnterprise">
update tab_udesk_enterprise
<set>
<if test="businessModule != null">
business_module = #{businessModule,jdbcType=VARCHAR},
</if>
<if test="businessModuleName != null">
business_module_name = #{businessModuleName,jdbcType=VARCHAR},
</if>
<if test="businessType != null">
business_type = #{businessType,jdbcType=INTEGER},
</if>
<if test="ticketId != null">
ticket_id = #{ticketId,jdbcType=INTEGER},
</if>
<if test="ticketNum != null">
ticket_num = #{ticketNum,jdbcType=CHAR},
</if>
<if test="ticketTitle != null">
ticket_title = #{ticketTitle,jdbcType=CHAR},
</if>
<if test="ticketStatus != null">
ticket_status = #{ticketStatus,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.udesk.entity.TabUdeskEnterprise">
update tab_udesk_enterprise
set business_module = #{businessModule,jdbcType=VARCHAR},
business_module_name = #{businessModuleName,jdbcType=VARCHAR},
business_type = #{businessType,jdbcType=INTEGER},
ticket_id = #{ticketId,jdbcType=INTEGER},
ticket_num = #{ticketNum,jdbcType=CHAR},
ticket_title = #{ticketTitle,jdbcType=CHAR},
ticket_status = #{ticketStatus,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.udesk.dao.mapper.TabUdeskExceptionMapper">
<resultMap id="BaseResultMap" type="com.gic.udesk.entity.TabUdeskException">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="exp_type" jdbcType="VARCHAR" property="expType" />
<result column="exception_record" jdbcType="VARCHAR" property="exceptionRecord" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, exp_type, exception_record, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_udesk_exception
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_udesk_exception
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.udesk.entity.TabUdeskException">
insert into tab_udesk_exception (id, exp_type, exception_record,
create_time)
values (#{id,jdbcType=INTEGER}, #{expType,jdbcType=VARCHAR}, #{exceptionRecord,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.udesk.entity.TabUdeskException">
insert into tab_udesk_exception
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="expType != null">
exp_type,
</if>
<if test="exceptionRecord != null">
exception_record,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="expType != null">
#{expType,jdbcType=VARCHAR},
</if>
<if test="exceptionRecord != null">
#{exceptionRecord,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.udesk.entity.TabUdeskException">
update tab_udesk_exception
<set>
<if test="expType != null">
exp_type = #{expType,jdbcType=VARCHAR},
</if>
<if test="exceptionRecord != null">
exception_record = #{exceptionRecord,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.udesk.entity.TabUdeskException">
update tab_udesk_exception
set exp_type = #{expType,jdbcType=VARCHAR},
exception_record = #{exceptionRecord,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.udesk.dao.mapper.TabUdeskMessageMapper">
<resultMap id="BaseResultMap" type="com.gic.udesk.entity.TabUdeskMessage">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="source" jdbcType="VARCHAR" property="source" />
<result column="topic" jdbcType="VARCHAR" property="topic" />
<result column="event" jdbcType="VARCHAR" property="event" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="bug_id" jdbcType="VARCHAR" property="bugId" />
<result column="ticket_id" jdbcType="VARCHAR" property="ticketId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.gic.udesk.entity.TabUdeskMessage">
<result column="msg_body" jdbcType="LONGVARCHAR" property="msgBody" />
</resultMap>
<sql id="Base_Column_List">
id, source, topic, event, create_time, update_time, status, bug_id, ticket_id
</sql>
<sql id="Blob_Column_List">
msg_body
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from tab_udesk_message
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_udesk_message
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.udesk.entity.TabUdeskMessage">
insert into tab_udesk_message (id, source, topic,
event, create_time, update_time,
status, bug_id, ticket_id,
msg_body)
values (#{id,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR}, #{topic,jdbcType=VARCHAR},
#{event,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{status,jdbcType=INTEGER}, #{bugId,jdbcType=VARCHAR}, #{ticketId,jdbcType=VARCHAR},
#{msgBody,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.gic.udesk.entity.TabUdeskMessage" useGeneratedKeys="true" keyProperty="id">
insert into tab_udesk_message
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="source != null">
source,
</if>
<if test="topic != null">
topic,
</if>
<if test="event != null">
event,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="status != null">
status,
</if>
<if test="bugId != null">
bug_id,
</if>
<if test="ticketId != null">
ticket_id,
</if>
<if test="msgBody != null">
msg_body,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="source != null">
#{source,jdbcType=VARCHAR},
</if>
<if test="topic != null">
#{topic,jdbcType=VARCHAR},
</if>
<if test="event != null">
#{event,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="bugId != null">
#{bugId,jdbcType=VARCHAR},
</if>
<if test="ticketId != null">
#{ticketId,jdbcType=VARCHAR},
</if>
<if test="msgBody != null">
#{msgBody,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.udesk.entity.TabUdeskMessage">
update tab_udesk_message
<set>
<if test="source != null">
source = #{source,jdbcType=VARCHAR},
</if>
<if test="topic != null">
topic = #{topic,jdbcType=VARCHAR},
</if>
<if test="event != null">
event = #{event,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="bugId != null">
bug_id = #{bugId,jdbcType=VARCHAR},
</if>
<if test="ticketId != null">
ticket_id = #{ticketId,jdbcType=VARCHAR},
</if>
<if test="msgBody != null">
msg_body = #{msgBody,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.gic.udesk.entity.TabUdeskMessage">
update tab_udesk_message
set source = #{source,jdbcType=VARCHAR},
topic = #{topic,jdbcType=VARCHAR},
event = #{event,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
bug_id = #{bugId,jdbcType=VARCHAR},
ticket_id = #{ticketId,jdbcType=VARCHAR},
msg_body = #{msgBody,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.udesk.entity.TabUdeskMessage">
update tab_udesk_message
set source = #{source,jdbcType=VARCHAR},
topic = #{topic,jdbcType=VARCHAR},
event = #{event,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
bug_id = #{bugId,jdbcType=VARCHAR},
ticket_id = #{ticketId,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.udesk.dao.mapper.TabUdeskTapdRelMapper">
<resultMap id="BaseResultMap" type="com.gic.udesk.entity.TabUdeskTapdRel">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="rel_type" jdbcType="INTEGER" property="relType" />
<result column="workspace_id" jdbcType="CHAR" property="workspaceId" />
<result column="udesk_id_key" jdbcType="CHAR" property="udeskIdKey" />
<result column="udesk_id_value" jdbcType="CHAR" property="udeskIdValue" />
<result column="udesk_name" jdbcType="CHAR" property="udeskName" />
<result column="tapd_id" jdbcType="CHAR" property="tapdId" />
<result column="tapd_name" jdbcType="CHAR" property="tapdName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<sql id="Base_Column_List">
id, rel_type, workspace_id, udesk_id_key, udesk_id_value, udesk_name, tapd_id, tapd_name,
create_time, update_time, status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_udesk_tapd_rel
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_udesk_tapd_rel
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.udesk.entity.TabUdeskTapdRel">
insert into tab_udesk_tapd_rel (id, rel_type, workspace_id,
udesk_id_key, udesk_id_value, udesk_name,
tapd_id, tapd_name, create_time,
update_time, status)
values (#{id,jdbcType=INTEGER}, #{relType,jdbcType=INTEGER}, #{workspaceId,jdbcType=CHAR},
#{udeskIdKey,jdbcType=CHAR}, #{udeskIdValue,jdbcType=CHAR}, #{udeskName,jdbcType=CHAR},
#{tapdId,jdbcType=CHAR}, #{tapdName,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.gic.udesk.entity.TabUdeskTapdRel">
insert into tab_udesk_tapd_rel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="relType != null">
rel_type,
</if>
<if test="workspaceId != null">
workspace_id,
</if>
<if test="udeskIdKey != null">
udesk_id_key,
</if>
<if test="udeskIdValue != null">
udesk_id_value,
</if>
<if test="udeskName != null">
udesk_name,
</if>
<if test="tapdId != null">
tapd_id,
</if>
<if test="tapdName != null">
tapd_name,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="status != null">
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="relType != null">
#{relType,jdbcType=INTEGER},
</if>
<if test="workspaceId != null">
#{workspaceId,jdbcType=CHAR},
</if>
<if test="udeskIdKey != null">
#{udeskIdKey,jdbcType=CHAR},
</if>
<if test="udeskIdValue != null">
#{udeskIdValue,jdbcType=CHAR},
</if>
<if test="udeskName != null">
#{udeskName,jdbcType=CHAR},
</if>
<if test="tapdId != null">
#{tapdId,jdbcType=CHAR},
</if>
<if test="tapdName != null">
#{tapdName,jdbcType=CHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.udesk.entity.TabUdeskTapdRel">
update tab_udesk_tapd_rel
<set>
<if test="relType != null">
rel_type = #{relType,jdbcType=INTEGER},
</if>
<if test="workspaceId != null">
workspace_id = #{workspaceId,jdbcType=CHAR},
</if>
<if test="udeskIdKey != null">
udesk_id_key = #{udeskIdKey,jdbcType=CHAR},
</if>
<if test="udeskIdValue != null">
udesk_id_value = #{udeskIdValue,jdbcType=CHAR},
</if>
<if test="udeskName != null">
udesk_name = #{udeskName,jdbcType=CHAR},
</if>
<if test="tapdId != null">
tapd_id = #{tapdId,jdbcType=CHAR},
</if>
<if test="tapdName != null">
tapd_name = #{tapdName,jdbcType=CHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.udesk.entity.TabUdeskTapdRel">
update tab_udesk_tapd_rel
set rel_type = #{relType,jdbcType=INTEGER},
workspace_id = #{workspaceId,jdbcType=CHAR},
udesk_id_key = #{udeskIdKey,jdbcType=CHAR},
udesk_id_value = #{udeskIdValue,jdbcType=CHAR},
udesk_name = #{udeskName,jdbcType=CHAR},
tapd_id = #{tapdId,jdbcType=CHAR},
tapd_name = #{tapdName,jdbcType=CHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="list" resultMap="BaseResultMap" parameterType="com.gic.udesk.entity.TabUdeskTapdRel">
select <include refid="Base_Column_List"></include>
from tab_udesk_tapd_rel
where status = 1
<if test="relType != null">
and rel_type = #{relType,jdbcType=INTEGER},
</if>
<if test="workspaceId != null">
and workspace_id = #{workspaceId,jdbcType=CHAR},
</if>
<if test="tapdName != null">
and tapd_name = #{tapdName,jdbcType=CHAR},
</if>
<if test="udeskName != null">
and udesk_name = #{udeskName,jdbcType=CHAR},
</if>
</select>
<update id="deleteByWorkspaceId">
update tab_udesk_tapd_rel set status = 0
where status = 1
and rel_type = #{relType};
and workspace_id = #{workspace_id}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.udesk.dao.mapper.TabUdeskTicketMapper">
<resultMap id="BaseResultMap" type="com.gic.udesk.entity.TabUdeskTicket">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="field_num" jdbcType="VARCHAR" property="fieldNum" />
<result column="subject" jdbcType="VARCHAR" property="subject" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="organization_id" jdbcType="INTEGER" property="organizationId" />
<result column="organization_name" jdbcType="VARCHAR" property="organizationName" />
<result column="creator_id" jdbcType="INTEGER" property="creatorId" />
<result column="assignee_id" jdbcType="INTEGER" property="assigneeId" />
<result column="assignee_name" jdbcType="VARCHAR" property="assigneeName" />
<result column="priority" jdbcType="VARCHAR" property="priority" />
<result column="status_en" jdbcType="VARCHAR" property="statusEn" />
<result column="status_tapd" jdbcType="VARCHAR" property="statusTapd" />
<result column="reporter" jdbcType="VARCHAR" property="reporter" />
<result column="bug_id" jdbcType="VARCHAR" property="bugId" />
<result column="workspace_id" jdbcType="VARCHAR" property="workspaceId" />
<result column="current_owner" jdbcType="VARCHAR" property="currentOwner" />
<result column="service_staff" jdbcType="VARCHAR" property="serviceStaff" />
<result column="severity" jdbcType="VARCHAR" property="severity" />
<result column="solving_at" jdbcType="VARCHAR" property="solvingAt" />
<result column="replied_at" jdbcType="VARCHAR" property="repliedAt" />
<result column="resolved_at" jdbcType="VARCHAR" property="resolvedAt" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<sql id="Base_Column_List">
id, field_num, subject, user_id, user_name, organization_id, organization_name, creator_id,
assignee_id, assignee_name, priority, status_en, status_tapd, reporter, bug_id, workspace_id,
current_owner, service_staff, severity, solving_at, replied_at, resolved_at, create_time,
update_time, status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_udesk_ticket
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_udesk_ticket
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.udesk.entity.TabUdeskTicket">
insert into tab_udesk_ticket (id, field_num, subject,
user_id, user_name, organization_id,
organization_name, creator_id, assignee_id,
assignee_name, priority, status_en,
status_tapd, reporter, bug_id,
workspace_id, current_owner, service_staff,
severity, solving_at, replied_at,
resolved_at, create_time, update_time,
status)
values (#{id,jdbcType=INTEGER}, #{fieldNum,jdbcType=VARCHAR}, #{subject,jdbcType=VARCHAR},
#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{organizationId,jdbcType=INTEGER},
#{organizationName,jdbcType=VARCHAR}, #{creatorId,jdbcType=INTEGER}, #{assigneeId,jdbcType=INTEGER},
#{assigneeName,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{statusEn,jdbcType=VARCHAR},
#{statusTapd,jdbcType=VARCHAR}, #{reporter,jdbcType=VARCHAR}, #{bugId,jdbcType=VARCHAR},
#{workspaceId,jdbcType=VARCHAR}, #{currentOwner,jdbcType=VARCHAR}, #{serviceStaff,jdbcType=VARCHAR},
#{severity,jdbcType=VARCHAR}, #{solvingAt,jdbcType=VARCHAR}, #{repliedAt,jdbcType=VARCHAR},
#{resolvedAt,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{status,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.gic.udesk.entity.TabUdeskTicket">
insert into tab_udesk_ticket
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="fieldNum != null">
field_num,
</if>
<if test="subject != null">
subject,
</if>
<if test="userId != null">
user_id,
</if>
<if test="userName != null">
user_name,
</if>
<if test="organizationId != null">
organization_id,
</if>
<if test="organizationName != null">
organization_name,
</if>
<if test="creatorId != null">
creator_id,
</if>
<if test="assigneeId != null">
assignee_id,
</if>
<if test="assigneeName != null">
assignee_name,
</if>
<if test="priority != null">
priority,
</if>
<if test="statusEn != null">
status_en,
</if>
<if test="statusTapd != null">
status_tapd,
</if>
<if test="reporter != null">
reporter,
</if>
<if test="bugId != null">
bug_id,
</if>
<if test="workspaceId != null">
workspace_id,
</if>
<if test="currentOwner != null">
current_owner,
</if>
<if test="serviceStaff != null">
service_staff,
</if>
<if test="severity != null">
severity,
</if>
<if test="solvingAt != null">
solving_at,
</if>
<if test="repliedAt != null">
replied_at,
</if>
<if test="resolvedAt != null">
resolved_at,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="status != null">
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="fieldNum != null">
#{fieldNum,jdbcType=VARCHAR},
</if>
<if test="subject != null">
#{subject,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="organizationId != null">
#{organizationId,jdbcType=INTEGER},
</if>
<if test="organizationName != null">
#{organizationName,jdbcType=VARCHAR},
</if>
<if test="creatorId != null">
#{creatorId,jdbcType=INTEGER},
</if>
<if test="assigneeId != null">
#{assigneeId,jdbcType=INTEGER},
</if>
<if test="assigneeName != null">
#{assigneeName,jdbcType=VARCHAR},
</if>
<if test="priority != null">
#{priority,jdbcType=VARCHAR},
</if>
<if test="statusEn != null">
#{statusEn,jdbcType=VARCHAR},
</if>
<if test="statusTapd != null">
#{statusTapd,jdbcType=VARCHAR},
</if>
<if test="reporter != null">
#{reporter,jdbcType=VARCHAR},
</if>
<if test="bugId != null">
#{bugId,jdbcType=VARCHAR},
</if>
<if test="workspaceId != null">
#{workspaceId,jdbcType=VARCHAR},
</if>
<if test="currentOwner != null">
#{currentOwner,jdbcType=VARCHAR},
</if>
<if test="serviceStaff != null">
#{serviceStaff,jdbcType=VARCHAR},
</if>
<if test="severity != null">
#{severity,jdbcType=VARCHAR},
</if>
<if test="solvingAt != null">
#{solvingAt,jdbcType=VARCHAR},
</if>
<if test="repliedAt != null">
#{repliedAt,jdbcType=VARCHAR},
</if>
<if test="resolvedAt != null">
#{resolvedAt,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.udesk.entity.TabUdeskTicket">
update tab_udesk_ticket
<set>
<if test="fieldNum != null">
field_num = #{fieldNum,jdbcType=VARCHAR},
</if>
<if test="subject != null">
subject = #{subject,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="organizationId != null">
organization_id = #{organizationId,jdbcType=INTEGER},
</if>
<if test="organizationName != null">
organization_name = #{organizationName,jdbcType=VARCHAR},
</if>
<if test="creatorId != null">
creator_id = #{creatorId,jdbcType=INTEGER},
</if>
<if test="assigneeId != null">
assignee_id = #{assigneeId,jdbcType=INTEGER},
</if>
<if test="assigneeName != null">
assignee_name = #{assigneeName,jdbcType=VARCHAR},
</if>
<if test="priority != null">
priority = #{priority,jdbcType=VARCHAR},
</if>
<if test="statusEn != null">
status_en = #{statusEn,jdbcType=VARCHAR},
</if>
<if test="statusTapd != null">
status_tapd = #{statusTapd,jdbcType=VARCHAR},
</if>
<if test="reporter != null">
reporter = #{reporter,jdbcType=VARCHAR},
</if>
<if test="bugId != null">
bug_id = #{bugId,jdbcType=VARCHAR},
</if>
<if test="workspaceId != null">
workspace_id = #{workspaceId,jdbcType=VARCHAR},
</if>
<if test="currentOwner != null">
current_owner = #{currentOwner,jdbcType=VARCHAR},
</if>
<if test="serviceStaff != null">
service_staff = #{serviceStaff,jdbcType=VARCHAR},
</if>
<if test="severity != null">
severity = #{severity,jdbcType=VARCHAR},
</if>
<if test="solvingAt != null">
solving_at = #{solvingAt,jdbcType=VARCHAR},
</if>
<if test="repliedAt != null">
replied_at = #{repliedAt,jdbcType=VARCHAR},
</if>
<if test="resolvedAt != null">
resolved_at = #{resolvedAt,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.udesk.entity.TabUdeskTicket">
update tab_udesk_ticket
set field_num = #{fieldNum,jdbcType=VARCHAR},
subject = #{subject,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=INTEGER},
user_name = #{userName,jdbcType=VARCHAR},
organization_id = #{organizationId,jdbcType=INTEGER},
organization_name = #{organizationName,jdbcType=VARCHAR},
creator_id = #{creatorId,jdbcType=INTEGER},
assignee_id = #{assigneeId,jdbcType=INTEGER},
assignee_name = #{assigneeName,jdbcType=VARCHAR},
priority = #{priority,jdbcType=VARCHAR},
status_en = #{statusEn,jdbcType=VARCHAR},
status_tapd = #{statusTapd,jdbcType=VARCHAR},
reporter = #{reporter,jdbcType=VARCHAR},
bug_id = #{bugId,jdbcType=VARCHAR},
workspace_id = #{workspaceId,jdbcType=VARCHAR},
current_owner = #{currentOwner,jdbcType=VARCHAR},
service_staff = #{serviceStaff,jdbcType=VARCHAR},
severity = #{severity,jdbcType=VARCHAR},
solving_at = #{solvingAt,jdbcType=VARCHAR},
replied_at = #{repliedAt,jdbcType=VARCHAR},
resolved_at = #{resolvedAt,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="list" resultMap="BaseResultMap" parameterType="com.gic.udesk.entity.TabUdeskTicket">
select <include refid="Base_Column_List"></include>
from tab_udesk_ticket
where status = 1
<if test="bugId != null">
and bug_id = #{bugId,jdbcType=VARCHAR},
</if>
<if test="workspaceId != null">
and workspace_id = #{workspaceId,jdbcType=VARCHAR},
</if>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gic-platform-udesk-web</artifactId>
<version>${libraryVersion}</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<url>http://www.demogic.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<libraryVersion>4.0-SNAPSHOT</libraryVersion>
<!-- api依赖,正式版会在 gic-pom-base 里生成 -->
<gic-store-api>4.0-SNAPSHOT</gic-store-api>
<gic-redis-data>4.0-SNAPSHOT</gic-redis-data>
<gic-marketing-api>4.0-SNAPSHOT</gic-marketing-api>
<gic-open-platform-api>4.0-SNAPSHOT</gic-open-platform-api>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-commons</artifactId>
<version>${gic-commons}</version>
<exclusions>
<exclusion>
<artifactId>dubbo</artifactId>
<groupId>com.alibaba</groupId>
</exclusion>
<exclusion>
<artifactId>logback-core</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<artifactId>spring-data-redis</artifactId>
<groupId>org.springframework.data</groupId>
</exclusion>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.23.2-GA</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-config</artifactId>
<version>${gic-platform-config}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-udesk-api</artifactId>
<version>${gic-platform-enterprise-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-base-api</artifactId>
<version>${gic-enterprise-base-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-common</artifactId>
<version>${gic-enterprise-common}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.5.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.23</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>com.gic </groupId>
<artifactId>gic-redis-data </artifactId>
<version>${gic-redis-data} </version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-enterprise-api</artifactId>
<version>${gic-platform-enterprise-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-enterprise-download</artifactId>
<version>${gic-enterprise-download}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.5.RELEASE</version>
<configuration>
<mainClass>com.gic.auth.web.Main</mainClass>
<excludeGroupIds>ch.qos.logback</excludeGroupIds>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.gic.udesk.web;
import com.gic.dubbo.util.DubboContextUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ImportResource;
/**
* Spring Boot Web 启动类
*
* @author zhurz
*/
@SpringBootApplication(
scanBasePackages = "com.gic",
exclude = {
RedisAutoConfiguration.class,
RedisRepositoriesAutoConfiguration.class,
QuartzAutoConfiguration.class
}
)
@ImportResource(value = {
"classpath*:applicationContext-init.xml",
"classpath*:dubbo-setting.xml",
"classpath*:dubbo-gic-platform-udesk-web.xml",
"classpath*:spring-interceptor.xml",
"classpath*:redis-init.xml",
"classpath:web-common-spring.xml"
})
public class Main {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(Main.class, args);
DubboContextUtil.setApplicationContext(context);
}
}
\ No newline at end of file
package com.gic.udesk.web.controller;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.udesk.constant.UdeskSharedConstant;
import com.gic.udesk.dto.UdeskMessageDTO;
import com.gic.udesk.service.TapdMessageApiService;
import com.gic.udesk.service.UdeskMessageApiService;
@RestController
public class MessageController {
private static final Logger logger = LogManager.getLogger(MessageController.class);
@Autowired
private UdeskMessageApiService udeskMessageApiService;
@Autowired
private TapdMessageApiService tapdMessageApiService;
@IgnoreLogin
@RequestMapping("udesk-message")
public RestResponse udeskMessage(@RequestBody UdeskMessageDTO udeskMessage) {
logger.info("接收UDESK的消息是:{}", udeskMessage);
udeskMessage.setSource(UdeskSharedConstant.UDESK_SOURCE);
return ResultControllerUtils.commonResult(udeskMessageApiService.saveUdeskMessage(udeskMessage));
}
@RequestMapping(value = "tapd-message", method = RequestMethod.POST)
@IgnoreLogin
public RestResponse tapdMessage(@RequestBody String tapdMessageStr) {
logger.info("接收TAPD的消息:{}",tapdMessageStr);
return ResultControllerUtils.commonResult(tapdMessageApiService.handleTapdMessage(tapdMessageStr));
}
}
package com.gic.udesk.web.controller;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.udesk.service.TapdConfigApiService;
@RestController
public class TapdConfigController {
private static final Logger logger = LogManager.getLogger(TapdConfigController.class);
@Autowired
private TapdConfigApiService tapdConfigApiService;
@RequestMapping(value = "/set-custom-field-rel")
@IgnoreLogin
public RestResponse setTapdCustomFieldRelUdesk(String workspaceId) {
return ResultControllerUtils.commonResult(tapdConfigApiService.setTapdCustomFieldRelUdesk(workspaceId));
}
}
server:
port: 8360
servlet:
context-path: /gic-udesk-web
tomcat:
uri-encoding: UTF-8
spring:
jackson:
serialization:
# 以时间戳返回日期
write-dates-as-timestamps: true
http:
encoding:
charset: UTF-8
enabled: true
force: true
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<context:component-scan base-package="com.gic.udesk"/>
<!-- 应用名称 -->
<dubbo:application name="gic-platform-udesk-web"/>
<dubbo:reference interface="com.gic.udesk.service.UdeskMessageApiService" id="udeskMessageApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.udesk.service.TapdMessageApiService" id="tapdMessageApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.udesk.service.TapdConfigApiService" id="tapdConfigApiService" timeout="6000"/>
</beans>
\ No newline at end of file
dubbo.registry.file=gic-platform-udesk-web
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:interceptors>
<bean class="com.gic.commons.interceptor.HeaderTagInterceptor"/>
</mvc:interceptors>
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gic</groupId>
<artifactId>gic-platform-udesk</artifactId>
<packaging>pom</packaging>
<version>4.0-SNAPSHOT</version>
<modules>
<module>gic-platform-udesk-api</module>
<module>gic-platform-udesk-service</module>
<module>gic-platform-udesk-web</module>
</modules>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment