Commit 18785865 authored by 赵啸非's avatar 赵啸非

添加外部数据来源实现

parent 77293de4
......@@ -6,11 +6,10 @@ import com.mortals.xhx.common.code.ProcessStatusEnum;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public abstract class BaseReq implements Serializable {
/**
* 当前页
*/
......@@ -21,4 +20,35 @@ public abstract class BaseReq implements Serializable {
private Integer size;
/**
* 工号
*/
private String workNum;
/**
* 标题
*/
private String title;
/**
* 扣分时间
*/
private Date happenTime;
/**
* 规则编码
*/
private String ruleCode;
private String phone;
/**
* 类型
*/
private String performType;
}
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.xhx.busiz.dingtalk.config.TalkConfiguration;
import com.mortals.xhx.busiz.dingtalk.req.DingTalkBaseReq;
import com.mortals.xhx.common.code.YesNoEnum;
......@@ -29,6 +30,7 @@ public class TalkApiController {
private TalkConfiguration talkConfiguration;
/**
* 获取token
*
......@@ -39,8 +41,6 @@ public class TalkApiController {
log.info("收到【getToken】请求【请求体】--> {}", JSON.toJSONString(dingTalkBaseReq));
try {
// DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
// OapiGettokenRequest req = new OapiGettokenRequest();
// req.setHttpMethod("GET");
......
package com.mortals.xhx.busiz.req;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.xhx.busiz.BaseReq;
import lombok.Data;
import java.util.Date;
@Data
public class AttendSaveReq extends BaseReq {
/**
* 所属考勤组ID
*/
private Long attendanceGroupId;
/**
* 所属考勤组名称
*/
private String attendanceGroupName;
/**
* 考勤时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date attendanceDate;
/**
* 异常时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date errorTime;
/**
* 上下班时间
*/
private String goOffTimeStr;
/**
* 实际打卡时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date actualAttendTime;
/**
* 异常处理结果
*/
private String errorResult;
/**
* 扩展字段
*/
private String ext;
}
package com.mortals.xhx.busiz.req;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.xhx.busiz.BaseReq;
import lombok.Data;
import java.util.Date;
@Data
public class ComplainSaveReq extends BaseReq {
/**
* 投诉标题
*/
private String complainTitle;
/**
* 投诉内容
*/
private String complainContent;
/**
* 投诉人真实姓名
*/
private String complainRealName;
/**
* 联系电话
*/
private String contact;
/**
* 投诉时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date complainTime;
/**
* 投诉来源
*/
private String complainSource;
/**
* 投诉设备
*/
private String complainDevice;
}
package com.mortals.xhx.busiz.req;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.xhx.busiz.BaseReq;
import lombok.Data;
import java.util.Date;
@Data
public class EffectSaveReq extends BaseReq {
/**
* 违规类型(1.脱岗,2.离岗,3.玩手机,4.睡觉)
*/
private Integer irregularType;
/**
* 发生时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date happenTime;
/**
* 持续时间,秒
*/
private Integer duration;
/**
* 报警时间
*/
private Date alarmTime;
}
package com.mortals.xhx.busiz.req;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.xhx.busiz.BaseReq;
import lombok.Data;
import java.util.Date;
@Data
public class GoWorkSaveReq extends BaseReq {
/**
* 办件编码
*/
private String goworkCode;
/**
* 办件所属部门
*/
private String goworkDepts;
/**
* 事项名称
*/
private String matterlName;
/**
* 办理时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date goworkTime;
/**
* 扩展字段
*/
private String ext;
}
package com.mortals.xhx.busiz.req;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.xhx.busiz.BaseReq;
import lombok.Data;
import java.util.Date;
@Data
public class OtherSaveReq extends BaseReq {
/**
* 违规类型(1.工作纪律)
*/
private Integer irregularOtherType;
/**
* 发生时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date happenTime;
/**
* 评分标准
*/
private String ruleDesc;
/**
* 扩展字段
*/
private String ext;
}
package com.mortals.xhx.busiz.req;
import com.mortals.framework.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.xhx.busiz.BaseReq;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class PerformSaveReq extends BaseReq {
/**
* 工号
*/
private String workNum;
/**
* 标题
*/
private String title;
/**
* 扣分时间
*/
private Date happenTime;
/**
* 规则编码
*/
private String ruleCode;
private String phone;
/**
* 类型
*/
private String performType;
public class ReviewSaveReq extends BaseReq {
/**
* 评价结果(1.非常不满意,2.差评)
......@@ -47,6 +17,7 @@ public class PerformSaveReq extends BaseReq {
/**
* 评价时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date reviewTime;
/**
* 评价来源(窗口评价系统,导视系统,自助服务系统,微官网,其它)
......@@ -57,4 +28,6 @@ public class PerformSaveReq extends BaseReq {
*/
private String reviewDevice;
}
......@@ -119,6 +119,8 @@ public class PerformDetailInfo {
*/
private String filePaths;
/**
* 评价结果(1.非常不满意,2.差评)
*/
......
......@@ -2,20 +2,20 @@ package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.xhx.base.framework.annotation.ApiUserAuth;
import com.mortals.xhx.busiz.req.PerformReq;
import com.mortals.xhx.busiz.req.PerformSaveReq;
import com.mortals.xhx.busiz.req.*;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.code.PerformTypeEnum;
import com.mortals.xhx.module.perform.model.PerformAttendRecordEntity;
import com.mortals.xhx.module.perform.model.PerformReviewRecordEntity;
import com.mortals.xhx.module.perform.model.PerformRulesEntity;
import com.mortals.xhx.module.perform.model.*;
import com.mortals.xhx.module.perform.service.*;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
import javafx.scene.effect.Effect;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -30,7 +30,7 @@ import java.util.Date;
@RestController
@Slf4j
@RequestMapping("/api/v1/web/perform")
@RequestMapping("/api/v1/web/")
public class ApiWebPerformController extends AbstractBaseController<PerformReq> {
@Autowired
......@@ -52,65 +52,173 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq>
/**
* 绩效外部新增
* 考勤新增
*
* @param req
* @return
*/
@PostMapping("save")
@ApiUserAuth
public String receive(HttpServletRequest request, @RequestBody PerformSaveReq req) {
ApiResp<String> rsp = new ApiResp<>();
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
@PostMapping("attend/save")
@UnAuth
public Rest<Void> attendSave(@RequestBody AttendSaveReq req) {
String busiDesc = "外部考勤新增";
Rest rest = Rest.ok(busiDesc + "成功!");
StringBuilder message = new StringBuilder();
message.append(String.format("【外部请求】类型【%s】 内容:%s", PerformTypeEnum.getByValue(req.getPerformType()).getDesc(), JSONObject.toJSONString(req)));
try {
if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
boolean bool = attend(req);
if (!bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) {
log.error(busiDesc, e);
return Rest.fail(e.getMessage());
}
log.info("响应【{}】【响应体】--> {} ", busiDesc, JSONObject.toJSONString(rest));
return rest;
}
/**
* 评价新增
*
* @param req
* @return
*/
@PostMapping("review/save")
@UnAuth
public Rest<Void> reviewSave(@RequestBody ReviewSaveReq req) {
switch (PerformTypeEnum.getByValue(req.getPerformType())) {
case 考勤绩效:
attend(req);
break;
case 评价差评绩效:
review(req);
break;
case 评价投诉绩效:
complain(req);
break;
case 办件绩效:
gowork(req);
break;
case 效能绩效:
effect(req);
break;
case 其它绩效:
other(req);
break;
}
} catch (AppException e) {
log.error("接收数据失败", e);
rsp.setCode(e.getCode());
rsp.setMsg(e.getMessage());
return JSON.toJSONString(rsp);
String busiDesc = "外部评价新增";
Rest rest = Rest.ok(busiDesc + "成功!");
StringBuilder message = new StringBuilder();
message.append(String.format("【外部请求】类型【%s】 内容:%s", PerformTypeEnum.getByValue(req.getPerformType()).getDesc(), JSONObject.toJSONString(req)));
try {
if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
boolean bool = review(req);
if (!bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) {
log.error(busiDesc, e);
return Rest.fail(e.getMessage());
}
log.info("响应【{}】【响应体】--> {} ", busiDesc, JSONObject.toJSONString(rest));
return rest;
}
/**
* 投诉新增
*
* @param req
* @return
*/
@PostMapping("complain/save")
@UnAuth
public Rest<Void> complainSave(@RequestBody ComplainSaveReq req) {
String busiDesc = "外部投诉新增";
Rest rest = Rest.ok(busiDesc + "成功!");
StringBuilder message = new StringBuilder();
message.append(String.format("【外部请求】类型【%s】 内容:%s", PerformTypeEnum.getByValue(req.getPerformType()).getDesc(), JSONObject.toJSONString(req)));
try {
if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
boolean bool = complain(req);
if (!bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) {
log.error(busiDesc, e);
return Rest.fail(e.getMessage());
}
log.info("响应【{}】【响应体】--> {} ", busiDesc, JSONObject.toJSONString(rest));
return rest;
}
/**
* 办件新增
*
* @param req
* @return
*/
@PostMapping("gowork/save")
@UnAuth
public Rest<Void> goworkSave(@RequestBody GoWorkSaveReq req) {
String busiDesc = "外部办件新增";
Rest rest = Rest.ok(busiDesc + "成功!");
StringBuilder message = new StringBuilder();
message.append(String.format("【外部请求】类型【%s】 内容:%s", PerformTypeEnum.getByValue(req.getPerformType()).getDesc(), JSONObject.toJSONString(req)));
try {
if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
boolean bool = gowork(req);
if (!bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) {
log.error(busiDesc, e);
return Rest.fail(e.getMessage());
}
log.info("响应【{}】【响应体】--> {} ", busiDesc, JSONObject.toJSONString(rest));
return rest;
}
/**
* 效能新增
*
* @param req
* @return
*/
@PostMapping("effect/save")
@UnAuth
public Rest<Void> effectSave(@RequestBody EffectSaveReq req) {
String busiDesc = "外部效能新增";
Rest rest = Rest.ok(busiDesc + "成功!");
StringBuilder message = new StringBuilder();
message.append(String.format("【外部请求】类型【%s】 内容:%s", PerformTypeEnum.getByValue(req.getPerformType()).getDesc(), JSONObject.toJSONString(req)));
try {
if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
boolean bool = effect(req);
if (!bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) {
log.error(busiDesc, e);
return Rest.fail(e.getMessage());
}
log.info("响应【{}】【响应体】--> {} ", busiDesc, JSONObject.toJSONString(rest));
return rest;
}
/**
* 其它新增
*
* @param req
* @return
*/
@PostMapping("other/save")
@UnAuth
public Rest<Void> otherSave(@RequestBody OtherSaveReq req) {
String busiDesc = "外部其它绩效新增";
Rest rest = Rest.ok(busiDesc + "成功!");
StringBuilder message = new StringBuilder();
message.append(String.format("【外部请求】类型【%s】 内容:%s", PerformTypeEnum.getByValue(req.getPerformType()).getDesc(), JSONObject.toJSONString(req)));
try {
if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
boolean bool = other(req);
if (!bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) {
log.error("接收数据失败", e);
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
rsp.setMsg(e.getMessage());
return JSON.toJSONString(rsp);
log.error(busiDesc, e);
return Rest.fail(e.getMessage());
}
recordSysLog(request, message.toString());
log.info("响应【设备接收】【响应体】--> " + JSONObject.toJSONString(rsp));
return JSON.toJSONString(rsp);
log.info("响应【{}】【响应体】--> {} ", busiDesc, JSONObject.toJSONString(rest));
return rest;
}
private void attend(PerformSaveReq req) throws AppException {
private boolean attend(AttendSaveReq req) throws AppException {
//考勤保存
//通过手机号码查询员工属性
StaffEntity staffEntity = getStaff(req);
PerformRulesEntity rule = getRule(req);
PerformRulesEntity rule = getRule(req.getRuleCode());
StaffEntity staffEntity = getStaff(req.getPhone());
PerformAttendRecordEntity recordEntity = new PerformAttendRecordEntity();
recordEntity.initAttrValue();
......@@ -126,17 +234,19 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq>
recordEntity.setCategoryId(rule.getCategoryId());
recordEntity.setCategoryName(rule.getCategoryName());
recordEntity.setCreateUserId(1L);
recordEntity.setCreateTime(new Date());
attendRecordService.save(recordEntity);
PerformAttendRecordEntity save = attendRecordService.save(recordEntity);
return save.newEntity();
}
private void review(PerformSaveReq req) throws AppException {
private boolean review(ReviewSaveReq req) throws AppException {
//评价保存
StaffEntity staffEntity = getStaff(req);
PerformRulesEntity rule = getRule(req);
StaffEntity staffEntity = getStaff(req.getPhone());
PerformRulesEntity rule = getRule(req.getRuleCode());
PerformReviewRecordEntity recordEntity = new PerformReviewRecordEntity();
......@@ -144,8 +254,6 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq>
BeanUtils.copyProperties(req, recordEntity);
recordEntity.setStaffId(staffEntity.getId());
recordEntity.setStaffName(staffEntity.getName());
recordEntity.setSubAddType(rule.getSubAddType());
recordEntity.setScore(rule.getScore());
recordEntity.setRuleId(rule.getId());
......@@ -153,49 +261,130 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq>
recordEntity.setCategoryId(rule.getCategoryId());
recordEntity.setCategoryName(rule.getCategoryName());
recordEntity.setCreateUserId(1L);
recordEntity.setCreateTime(new Date());
reviewRecordService.save(recordEntity);
PerformReviewRecordEntity save = reviewRecordService.save(recordEntity);
return save.newEntity();
}
private void complain(PerformSaveReq req) throws AppException {
private boolean complain(ComplainSaveReq req) throws AppException {
//投诉保存
StaffEntity staffEntity = getStaff(req.getPhone());
PerformRulesEntity rule = getRule(req.getRuleCode());
PerformComplainRecordEntity recordEntity = new PerformComplainRecordEntity();
recordEntity.initAttrValue();
BeanUtils.copyProperties(req, recordEntity);
recordEntity.setStaffId(staffEntity.getId());
recordEntity.setStaffName(staffEntity.getName());
recordEntity.setSubAddType(rule.getSubAddType());
recordEntity.setScore(rule.getScore());
recordEntity.setRuleId(rule.getId());
recordEntity.setRuleName(rule.getName());
recordEntity.setCategoryId(rule.getCategoryId());
recordEntity.setCategoryName(rule.getCategoryName());
recordEntity.setCreateUserId(1L);
recordEntity.setCreateTime(new Date());
PerformComplainRecordEntity save = complainRecordService.save(recordEntity);
return save.newEntity();
}
private void gowork(PerformSaveReq req) throws AppException {
private boolean gowork(GoWorkSaveReq req) throws AppException {
//办件保存
StaffEntity staffEntity = getStaff(req.getPhone());
PerformRulesEntity rule = getRule(req.getRuleCode());
PerformGoworkRecordEntity recordEntity = new PerformGoworkRecordEntity();
recordEntity.initAttrValue();
BeanUtils.copyProperties(req, recordEntity);
recordEntity.setStaffId(staffEntity.getId());
recordEntity.setStaffName(staffEntity.getName());
recordEntity.setSubAddType(rule.getSubAddType());
recordEntity.setScore(rule.getScore());
recordEntity.setRuleId(rule.getId());
recordEntity.setRuleName(rule.getName());
recordEntity.setCategoryId(rule.getCategoryId());
recordEntity.setCategoryName(rule.getCategoryName());
recordEntity.setCreateUserId(1L);
recordEntity.setCreateTime(new Date());
PerformGoworkRecordEntity save = performGoworkRecordService.save(recordEntity);
return save.newEntity();
}
private void effect(PerformSaveReq req) throws AppException {
private boolean effect(EffectSaveReq req) throws AppException {
//效能保存
StaffEntity staffEntity = getStaff(req.getPhone());
PerformRulesEntity rule = getRule(req.getRuleCode());
PerformEffectRecordEntity recordEntity = new PerformEffectRecordEntity();
recordEntity.initAttrValue();
BeanUtils.copyProperties(req, recordEntity);
recordEntity.setStaffId(staffEntity.getId());
recordEntity.setStaffName(staffEntity.getName());
recordEntity.setSubAddType(rule.getSubAddType());
recordEntity.setScore(rule.getScore());
recordEntity.setRuleId(rule.getId());
recordEntity.setRuleName(rule.getName());
recordEntity.setCategoryId(rule.getCategoryId());
recordEntity.setCategoryName(rule.getCategoryName());
recordEntity.setCreateUserId(1L);
recordEntity.setCreateTime(new Date());
PerformEffectRecordEntity save = effectRecordService.save(recordEntity);
return save.newEntity();
}
private void other(PerformSaveReq req) throws AppException {
private boolean other(OtherSaveReq req) throws AppException {
//其它保存
}
StaffEntity staffEntity = getStaff(req.getPhone());
PerformRulesEntity rule = getRule(req.getRuleCode());
PerformOtherRecordEntity recordEntity = new PerformOtherRecordEntity();
recordEntity.initAttrValue();
BeanUtils.copyProperties(req, recordEntity);
recordEntity.setStaffId(staffEntity.getId());
recordEntity.setStaffName(staffEntity.getName());
recordEntity.setSubAddType(rule.getSubAddType());
recordEntity.setScore(rule.getScore());
recordEntity.setRuleId(rule.getId());
recordEntity.setRuleName(rule.getName());
recordEntity.setCategoryId(rule.getCategoryId());
recordEntity.setCategoryName(rule.getCategoryName());
recordEntity.setCreateUserId(1L);
recordEntity.setCreateTime(new Date());
PerformOtherRecordEntity save = otherRecordService.save(recordEntity);
return save.newEntity();
}
private PerformRulesEntity getRule(PerformSaveReq req) {
PerformRulesEntity rule = rulesService.getCache(req.getRuleCode());
private PerformRulesEntity getRule(String ruleCode) {
PerformRulesEntity rule = rulesService.getCache(ruleCode);
if (ObjectUtils.isEmpty(rule))
throw new AppException(String.format("当前手机号码未找到匹配的员工!rule:%s", req.getPhone()));
throw new AppException(String.format("当前手机号码未找到匹配的员工!rule:%s", ruleCode));
return rule;
}
private StaffEntity getStaff(PerformSaveReq req) {
StaffEntity staffEntity = staffService.selectOne(new StaffQuery().phoneNumber(req.getPhone()));
private StaffEntity getStaff(String phone) {
StaffEntity staffEntity = staffService.selectOne(new StaffQuery().phoneNumber(phone));
if (ObjectUtils.isEmpty(staffEntity))
throw new AppException(String.format("当前手机号码未找到匹配的员工!phone:%s", req.getPhone()));
throw new AppException(String.format("当前手机号码未找到匹配的员工!phone:%s", phone));
return staffEntity;
}
public static void main(String[] args) {
}
......
......@@ -34,8 +34,7 @@ public class TestController {
public String idGens() {
log.info("测试id生成");
String stringId = idgeneratorService.getLongId(IdgeneratorServiceImpl.IdGeneratorKey.EFFECT).toString();
String stringId = idgeneratorService.getLongId(IdgeneratorServiceImpl.IdGeneratorKey.EFFECT_KEY).toString();
return stringId;
}
......
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