提交修改

This commit is contained in:
quyixiao 2021-01-06 18:04:08 +08:00
parent 0cd5e13657
commit 22a2b16cb7
3 changed files with 211 additions and 78 deletions

View File

@ -52,6 +52,7 @@ public class ShiroConfig {
Map<String, String> filterMap = new LinkedHashMap<>(); Map<String, String> filterMap = new LinkedHashMap<>();
filterMap.put("/webjars/**", "anon"); filterMap.put("/webjars/**", "anon");
filterMap.put("/oneCode/**", "anon"); filterMap.put("/oneCode/**", "anon");
filterMap.put("/dingding/**", "anon");
filterMap.put("/file/**", "anon"); filterMap.put("/file/**", "anon");
filterMap.put("/test/**", "anon"); filterMap.put("/test/**", "anon");
filterMap.put("/druid/**", "anon"); filterMap.put("/druid/**", "anon");

View File

@ -0,0 +1,125 @@
package com.lz.modules.app.controller;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
import com.lz.common.utils.DingTalkUtil;
import com.lz.common.utils.R;
import com.lz.common.utils.StringUtil;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.third.entity.ThirdAppConfig;
import com.lz.modules.third.service.ThirdAppConfigService;
import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.net.URLEncoder;
@RestController
@Slf4j
@RequestMapping("/dingding")
public class DingDingController {
@Autowired
private ThirdAppConfigService thirdAppConfigService;
@Autowired
private DingTalkUtil dingTalkUtil;
@Autowired
private StaffService staffService;
static String homeUrl = "https://lzmanagement.ldxinyong.com/digitization";
//http://localhost:8080/lz_management/dingding/msg?username=18458195149&title=%E8%AF%B7%E6%B3%A8%E6%84%8F&content=%E9%A1%B9%E7%9B%AE%E8%A6%81%E8%BF%87%E6%9C%9F%E4%BA%86
@RequestMapping("/msg")
public R dingdingxiaoxi(String username, String title, String content) {
String appid = "856016278";
StaffEntity staffEntity = staffService.selectByPhone(username);
ThirdAppConfig thirdAppConfig = thirdAppConfigService.getByAppId(appid);
String token = dingTalkUtil.getAccessTokenWitchEntity(thirdAppConfig);
String url = homeUrl;
if (url.contains("?")) {
url += "&halokit=" + System.currentTimeMillis();
} else {
url += "?halokit=" + System.currentTimeMillis();
}
url += "&detail=1&id=1&detailId=" + 1;
url = URLEncoder.encode(url);
url = "dingtalk://dingtalkclient/action/openapp?corpid=" + thirdAppConfig.getCorpId() +
"&container_type=work_platform&app_id=0_" +
appid + "&redirect_type=jump&redirect_url=" + url;
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
OapiMessageCorpconversationAsyncsendV2Request req = new OapiMessageCorpconversationAsyncsendV2Request();
req.setAgentId(Long.parseLong(appid));
req.setUseridList(staffEntity.getEmployeeId());//员工 id
OapiMessageCorpconversationAsyncsendV2Request.Msg obj1 = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
obj1.setMsgtype("action_card");
OapiMessageCorpconversationAsyncsendV2Request.ActionCard obj2 = new OapiMessageCorpconversationAsyncsendV2Request.ActionCard();
obj2.setSingleTitle(title);
obj2.setSingleUrl(url);
obj2.setMarkdown(
getMarkDown(content)
);
obj2.setTitle(title);
obj1.setActionCard(obj2);
req.setMsg(obj1);
OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(req, token);
log.info("钉钉请求返回{}", rsp.getBody());
//插入数据库
} catch (ApiException e) {
e.printStackTrace();
return R.error("抛出异常");
}
return R.ok();
}
public static String getMarkDown(String content) {
StringBuilder sb = new StringBuilder();
char[] cs = content.toCharArray();
int i = 0;
int j = 0;
for (char c : cs) {
if (i == 0) {
if (c == '/') {
sb.append("#");
} else {
sb.append("# ").append(c);
}
} else {
if (c == '/') {
if (j == 0) {
sb.append("\n");
}
j++;
sb.append("#");
continue;
} else {
j = 0;
String xx = sb.toString();
if(StringUtil.isNotBlank(xx)){
char [] yy = xx.toCharArray();
if(yy[yy.length -1 ] == '#'){
sb.append(" ");
}
}
sb.append(c);
}
}
i++;
}
log.info(" getmarkdown :" + sb.toString());
return sb.toString();
}
}

View File

@ -3,6 +3,11 @@ package com.lz.modules.app.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
import com.lz.common.utils.DingTalkUtil;
import com.lz.common.utils.NumberUtil; import com.lz.common.utils.NumberUtil;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.app.dto.ApprovalDto; import com.lz.modules.app.dto.ApprovalDto;
@ -29,6 +34,9 @@ import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.SysUserService; import com.lz.modules.sys.service.SysUserService;
import com.lz.modules.sys.service.app.ResultDetailService; import com.lz.modules.sys.service.app.ResultDetailService;
import com.lz.modules.sys.service.app.ResultRecordService; import com.lz.modules.sys.service.app.ResultRecordService;
import com.lz.modules.third.entity.ThirdAppConfig;
import com.lz.modules.third.service.ThirdAppConfigService;
import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -36,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -73,7 +82,7 @@ public class TestController {
private IEquipmentInfoService equipmentInfoService; private IEquipmentInfoService equipmentInfoService;
@RequestMapping("/test/xx") @RequestMapping("/test/xx")
public void test(){ public void test() {
ResultRecord resultRecord = new ResultRecord(); ResultRecord resultRecord = new ResultRecord();
resultRecord.setAllScore(new BigDecimal(10)); resultRecord.setAllScore(new BigDecimal(10));
resultRecord.setLastScore(new BigDecimal(8)); resultRecord.setLastScore(new BigDecimal(8));
@ -83,21 +92,21 @@ public class TestController {
@RequestMapping("/test/department") @RequestMapping("/test/department")
public void department(){ public void department() {
List<DepartmentsEntity> departmentsEntityList = departmentsService.selectEntityByParentDepartmentId("0"); List<DepartmentsEntity> departmentsEntityList = departmentsService.selectEntityByParentDepartmentId("0");
for(DepartmentsEntity child1:departmentsEntityList){ for (DepartmentsEntity child1 : departmentsEntityList) {
child1.setLevel(1); child1.setLevel(1);
departmentsService.updateById(child1); departmentsService.updateById(child1);
List<DepartmentsEntity> departmentsEntityList2 = departmentsService.selectEntityByParentDepartmentId(child1.getDepartmentId()); List<DepartmentsEntity> departmentsEntityList2 = departmentsService.selectEntityByParentDepartmentId(child1.getDepartmentId());
for(DepartmentsEntity child2: departmentsEntityList2){ for (DepartmentsEntity child2 : departmentsEntityList2) {
child2.setLevel(2); child2.setLevel(2);
departmentsService.updateById(child2); departmentsService.updateById(child2);
List<DepartmentsEntity> departmentsEntityList3 = departmentsService.selectEntityByParentDepartmentId(child2.getDepartmentId()); List<DepartmentsEntity> departmentsEntityList3 = departmentsService.selectEntityByParentDepartmentId(child2.getDepartmentId());
for(DepartmentsEntity child3: departmentsEntityList3){ for (DepartmentsEntity child3 : departmentsEntityList3) {
child3.setLevel(3); child3.setLevel(3);
departmentsService.updateById(child3); departmentsService.updateById(child3);
List<DepartmentsEntity> departmentsEntityList4 = departmentsService.selectEntityByParentDepartmentId(child3.getDepartmentId()); List<DepartmentsEntity> departmentsEntityList4 = departmentsService.selectEntityByParentDepartmentId(child3.getDepartmentId());
for(DepartmentsEntity child4: departmentsEntityList4){ for (DepartmentsEntity child4 : departmentsEntityList4) {
child4.setLevel(4); child4.setLevel(4);
departmentsService.updateById(child4); departmentsService.updateById(child4);
} }
@ -107,9 +116,9 @@ public class TestController {
} }
@RequestMapping("/test/relate") @RequestMapping("/test/relate")
public void relate(){ public void relate() {
List<DepartmentsStaffRelateEntity> list = departmentsStaffRelateService.selectAll(); List<DepartmentsStaffRelateEntity> list = departmentsStaffRelateService.selectAll();
for(DepartmentsStaffRelateEntity l:list){ for (DepartmentsStaffRelateEntity l : list) {
DepartmentsEntity departmentsEntity = departmentsService.selectByDepartmentId(l.getDepartmentId()); DepartmentsEntity departmentsEntity = departmentsService.selectByDepartmentId(l.getDepartmentId());
l.setLevel(departmentsEntity.getLevel()); l.setLevel(departmentsEntity.getLevel());
departmentsStaffRelateService.updateById(l); departmentsStaffRelateService.updateById(l);
@ -118,36 +127,36 @@ public class TestController {
/** /**
* { * {
* "type": "node", * "type": "node",
* "left": 818, * "left": 818,
* "top": 510, * "top": 510,
* "uuid": "id3", * "uuid": "id3",
* "prev": [ * "prev": [
* "id1", * "id1",
* "id2" * "id2"
* ], * ],
* "next": [ * "next": [
* "id4", * "id4",
* "id5" * "id5"
* ], * ],
* "formData": { * "formData": {
* "stepName": "名称1", * "stepName": "名称1",
* "ruleGroupList": [{ * "ruleGroupList": [{
* "name": "名称2", * "name": "名称2",
* "nextStep": "id5" * "nextStep": "id5"
* }, * },
* { * {
* "name": "名称6", * "name": "名称6",
* "nextStep": "id7" * "nextStep": "id7"
* } * }
* ] * ]
* }, * },
* "nextIfId": "id12", * "nextIfId": "id12",
* "nextElseId": "id11" * "nextElseId": "id11"
* } * }
*/ */
@RequestMapping("/test/step") @RequestMapping("/test/step")
public void step(){ public void step() {
Long staffId = 294l; Long staffId = 294l;
ResultRecord resultRecord = new ResultRecord(); ResultRecord resultRecord = new ResultRecord();
resultRecord.setType(2); resultRecord.setType(2);
@ -156,13 +165,13 @@ public class TestController {
resultRecord.setDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); resultRecord.setDepartmentId(departmentsStaffRelateEntity.getDepartmentId());
List<Step> test = resultDetailService.getStepList(resultRecord); List<Step> test = resultDetailService.getStepList(resultRecord);
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if(CollectionUtils.isNotEmpty(test)){ if (CollectionUtils.isNotEmpty(test)) {
Step step = test.get(0); Step step = test.get(0);
StaffEntity staffEntity = staffService.selectStaffById(staffId); StaffEntity staffEntity = staffService.selectStaffById(staffId);
if(staffEntity !=null && !staffEntity.getName().equals(step.getName())){ if (staffEntity != null && !staffEntity.getName().equals(step.getName())) {
list.add(staffEntity.getName()); list.add(staffEntity.getName());
} }
for(Step s:test){ for (Step s : test) {
list.add(s.getName()); list.add(s.getName());
} }
} }
@ -170,33 +179,32 @@ public class TestController {
List<FlowModel> flowModels = new ArrayList<>(); List<FlowModel> flowModels = new ArrayList<>();
FlowModel flowModel = new FlowModel(); FlowModel flowModel = new FlowModel();
for(String s:list){ for (String s : list) {
} }
} }
@RequestMapping("/test/userinfo") @RequestMapping("/test/userinfo")
public void userinfo(){ public void userinfo() {
} }
@RequestMapping("/test/init") @RequestMapping("/test/init")
public void testinit(){ public void testinit() {
List<String> allDeparmentIds = staffService.selectAllDeparmentIdsByDepartmentParentId("1"); List<String> allDeparmentIds = staffService.selectAllDeparmentIdsByDepartmentParentId("1");
//获取部门下所有人员 //获取部门下所有人员
List<String> staffIds = staffService.staffsByAllDeparmentIds(allDeparmentIds); List<String> staffIds = staffService.staffsByAllDeparmentIds(allDeparmentIds);
List<Object> collect=resultRecordService.listObjs(new QueryWrapper<ResultRecord>() List<Object> collect = resultRecordService.listObjs(new QueryWrapper<ResultRecord>()
.eq("is_delete", 0) .eq("is_delete", 0)
.eq("type", 2) .eq("type", 2)
.like("month_time","2020-09") .like("month_time", "2020-09")
.in("department_id",allDeparmentIds) .in("department_id", allDeparmentIds)
.in("staff_id",staffIds) .in("staff_id", staffIds)
.select(" DISTINCT staff_id")); .select(" DISTINCT staff_id"));
List<String> collect1 = new ArrayList<>(); List<String> collect1 = new ArrayList<>();
if(CollectionUtils.isNotEmpty(collect)){ if (CollectionUtils.isNotEmpty(collect)) {
collect1 = collect.stream().map(o -> o.toString()).collect(Collectors.toList()); collect1 = collect.stream().map(o -> o.toString()).collect(Collectors.toList());
System.out.println(); System.out.println();
} }
@ -204,12 +212,11 @@ public class TestController {
} }
// http://localhost:8080/lz_management/test/restore // http://localhost:8080/lz_management/test/restore
@RequestMapping("/test/restore") @RequestMapping("/test/restore")
public void restore() throws Exception{ public void restore() throws Exception {
List<StaffEntity> staffEntities = staffService.selectAll(); List<StaffEntity> staffEntities = staffService.selectAll();
for(StaffEntity staffEntity:staffEntities){ for (StaffEntity staffEntity : staffEntities) {
//doRestore(staffEntity.getId()); //doRestore(staffEntity.getId());
} }
} }
@ -221,36 +228,36 @@ public class TestController {
StaffEntity staff = staffService.selectStaffById(staffId); StaffEntity staff = staffService.selectStaffById(staffId);
List<ResultRecord> resultRecords = resultRecordService.selectResultRecordAllByStaffId(staffId); List<ResultRecord> resultRecords = resultRecordService.selectResultRecordAllByStaffId(staffId);
Date node = sdf.parse("2020-09-29 19:08:07"); Date node = sdf.parse("2020-09-29 19:08:07");
if(resultRecords== null || resultRecords.size() == 0){ if (resultRecords == null || resultRecords.size() == 0) {
log.info("staffid = " + staffId + " ,没有数据"); log.info("staffid = " + staffId + " ,没有数据");
return; return;
} }
boolean flag = true; boolean flag = true;
for(ResultRecord resultRecord:resultRecords){ for (ResultRecord resultRecord : resultRecords) {
if(resultRecord.getGmtCreate().getTime() > node.getTime()){ if (resultRecord.getGmtCreate().getTime() > node.getTime()) {
List<ResultDetail> resultDetails = resultDetailService.selectByRecordIdAndType(resultRecord.getId(),1); List<ResultDetail> resultDetails = resultDetailService.selectByRecordIdAndType(resultRecord.getId(), 1);
if(resultDetails !=null && resultDetails.size() > 0){ if (resultDetails != null && resultDetails.size() > 0) {
flag = false; flag = false;
log.info("staff_id " + staff.getId() + ",name = " + staff.getName() + " ,己经正常"); log.info("staff_id " + staff.getId() + ",name = " + staff.getName() + " ,己经正常");
return ; return;
} }
} }
} }
if(flag){ if (flag) {
for(ResultRecord resultRecord:resultRecords){ for (ResultRecord resultRecord : resultRecords) {
if(resultRecord.getGmtCreate().getTime() > node.getTime()){ if (resultRecord.getGmtCreate().getTime() > node.getTime()) {
resultRecord.setIsDelete(1); resultRecord.setIsDelete(1);
log.info("staff_id " + staff.getId() + ",name = " + staff.getName() + " ,删除不要数据"); log.info("staff_id " + staff.getId() + ",name = " + staff.getName() + " ,删除不要数据");
resultRecordService.updateResultRecordById(resultRecord); resultRecordService.updateResultRecordById(resultRecord);
} }
} }
for(int i = resultRecords.size() - 1 ;i >= 0 ; i --){ for (int i = resultRecords.size() - 1; i >= 0; i--) {
ResultRecord resultRecord = resultRecords.get(i); ResultRecord resultRecord = resultRecords.get(i);
if(resultRecord.getGmtCreate().getTime() < node.getTime()){ if (resultRecord.getGmtCreate().getTime() < node.getTime()) {
List<ResultDetail> resultDetails = resultDetailService.selectByRecordIdAndType(resultRecord.getId(),1); List<ResultDetail> resultDetails = resultDetailService.selectByRecordIdAndType(resultRecord.getId(), 1);
if(resultDetails !=null && resultDetails.size() > 0){ if (resultDetails != null && resultDetails.size() > 0) {
resultRecord.setIsDelete(0); resultRecord.setIsDelete(0);
log.info("staff_id " + staff.getId() + ",name = " + staff.getName() + " ,数据恢复"); log.info("staff_id " + staff.getId() + ",name = " + staff.getName() + " ,数据恢复");
resultRecordService.updateResultRecordById(resultRecord); resultRecordService.updateResultRecordById(resultRecord);
break; break;
} }
@ -261,15 +268,15 @@ public class TestController {
// http://localhost:8080/lz_management/test/resultrecord?resultRecordId=475 // http://localhost:8080/lz_management/test/resultrecord?resultRecordId=475
@RequestMapping("/test/resultrecord") @RequestMapping("/test/resultrecord")
public void resultRecorcd(Long resultRecordId) throws Exception{ public void resultRecorcd(Long resultRecordId) throws Exception {
R r = resultRecordService.initFlowRecord(resultRecordId); R r = resultRecordService.initFlowRecord(resultRecordId);
} }
// http://localhost:8080/lz_management/test/getAuth?userId=298 // http://localhost:8080/lz_management/test/getAuth?userId=298
@RequestMapping("/test/getAuth") @RequestMapping("/test/getAuth")
public R getAuth(Long userId) throws Exception{ public R getAuth(Long userId) throws Exception {
Map<String,Integer> map = staffRoleService.getRoleByUserId(userId); Map<String, Integer> map = staffRoleService.getRoleByUserId(userId);
return R.ok().put("data",map); return R.ok().put("data", map);
} }
@Autowired @Autowired
@ -277,7 +284,7 @@ public class TestController {
// http://localhost:8080/lz_management/test/testmaster // http://localhost:8080/lz_management/test/testmaster
@RequestMapping("/test/testmaster") @RequestMapping("/test/testmaster")
public R testmaster(Long userId) throws Exception{ public R testmaster(Long userId) throws Exception {
List<StaffRole> masterPMs = staffRoleMapper.selectStaffRolesByDepartmentLevelList(Arrays.asList(new String[]{RoleEnums.MASTER_PM.getName()})); List<StaffRole> masterPMs = staffRoleMapper.selectStaffRolesByDepartmentLevelList(Arrays.asList(new String[]{RoleEnums.MASTER_PM.getName()}));
@ -287,11 +294,11 @@ public class TestController {
public static void main(String[] args) { public static void main(String[] args) {
String a = "{\"313\":[17,20,13]}"; String a = "{\"313\":[17,20,13]}";
Map<String,Object> map = JSONObject.parseObject(a,Map.class); Map<String, Object> map = JSONObject.parseObject(a, Map.class);
List<Long> roleIds = null; List<Long> roleIds = null;
for (Map.Entry<String, Object> entry : map.entrySet()) { for (Map.Entry<String, Object> entry : map.entrySet()) {
if(entry.getValue() !=null ){ if (entry.getValue() != null) {
roleIds = JSON.parseArray(entry.getValue().toString(),Long.class); roleIds = JSON.parseArray(entry.getValue().toString(), Long.class);
} }
} }
System.out.println(roleIds); System.out.println(roleIds);
@ -334,10 +341,10 @@ public class TestController {
public R equpinfo() { public R equpinfo() {
List<EquipmentInfo> equipmentInfos = equipmentInfoService.selectAll(); List<EquipmentInfo> equipmentInfos = equipmentInfoService.selectAll();
for(EquipmentInfo equipmentInfo : equipmentInfos){ for (EquipmentInfo equipmentInfo : equipmentInfos) {
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectByStaffId(equipmentInfo.getUserId()); DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectByStaffId(equipmentInfo.getUserId());
if(departmentsStaffRelateEntity !=null){ if (departmentsStaffRelateEntity != null) {
equipmentInfo.setDepartId(NumberUtil.objToLongDefault(departmentsStaffRelateEntity.getDepartmentId(),-1)); equipmentInfo.setDepartId(NumberUtil.objToLongDefault(departmentsStaffRelateEntity.getDepartmentId(), -1));
} }
equipmentInfoService.updateCoverEquipmentInfoById(equipmentInfo); equipmentInfoService.updateCoverEquipmentInfoById(equipmentInfo);
} }