Commit 5f1c5a29 by huangZW

Merge branch 'developer' of http://115.159.76.241/haoban3.0/haoban-manage3.0.git into developer

parents f3c1a977 b30771b4
package com.gic.haoban.manage.service.service;
import com.gic.haoban.manage.service.entity.Test;
/**
* Created by tgs on 2020/2/9.
*/
public interface TestService {
public void save(Test test);
}
package com.gic.haoban.manage.service.service.impl;
import com.gic.haoban.manage.service.dao.mapper.TestMapper;
import com.gic.haoban.manage.service.entity.Test;
import com.gic.haoban.manage.service.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by tgs on 2020/2/9.
*/
public class TestApiServiceImpl {
@Service
public class TestApiServiceImpl implements TestService {
@Autowired
private TestMapper testMapper;
@Override
public void save(Test test) {
testMapper.insert(test);
}
}
package com.gic.haoban.manage.service.service.out.impl;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.GlobalVar;
import com.gic.commons.util.ImageUtil;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.redis.data.anno.RedisCache;
import com.gic.thirdparty.api.dto.PicUploadResDTO;
import com.gic.thirdparty.api.service.QQCloudPicService;
import com.google.common.collect.Sets;
import com.vdurmont.emoji.EmojiParser;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.GlobalVar;
import com.gic.commons.util.ImageUtil;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreGroupDTO;
import com.gic.enterprise.api.service.StoreGroupService;
......@@ -47,6 +21,9 @@ import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
......@@ -55,10 +32,26 @@ import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.redis.data.anno.RedisCache;
import com.gic.redis.data.util.RedisUtil;
import com.gic.thirdparty.api.dto.PicUploadResDTO;
import com.gic.thirdparty.api.service.QQCloudPicService;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
public class StaffApiServiceImpl implements StaffApiService {
......@@ -1398,32 +1391,31 @@ public class StaffApiServiceImpl implements StaffApiService {
@RedisCache(value = "qrcode-${clerkCode}-${storeId}", timeOut = 1, timeunit = TimeUnit.DAYS)
public ServiceResponse<String> getStaffQrcode(String clerkCode, String storeId) {
ServiceResponse<String> resp = new ServiceResponse<>();
TabHaobanDepartment department = departmentService.selectByRelatedId(storeId);
if (null == department) {
resp.setMessage("部门没关联");
resp.setCode(0);
return resp;
List<String> clerkCodes=new ArrayList<>();
clerkCodes.add(clerkCode);
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
if (CollectionUtils.isEmpty(list)) {
logger.info("成员不存在:{}",clerkCode);
return null;
}
List<TabHaobanStaffDepartmentRelated> retList = staffDepartmentRelatedService.listByDepartmentId(department.getDepartmentId());
if (CollectionUtils.isEmpty(retList)) {
resp.setMessage("成员没关联");
resp.setCode(0);
return resp;
ClerkDTO clerkDTO = list.get(0);
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getByClerkId(clerkDTO.getClerkId());
if (relationDTO==null) {
logger.info("成员没有关联:{}",clerkCode);
return null;
}
for (TabHaobanStaffDepartmentRelated tab : retList) {
if (clerkCode.equals(tab.getClerkCode())) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal());
if (null == secretSetting||secretSetting.getCheckFlag()==0) {
logger.info("没有配置secret:{}",wxEnterpriseDTO.getWxEnterpriseId());
return null;
}
UserDTO user = qywxUserApiService.getSelfWorkWxUser(wxEnterpriseDTO.getCorpid(), secretSetting.getSecretVal(), tab.getWxUserId());
if (user != null) {
resp.setResult(user.getQr_code());
return resp;
}
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(relationDTO.getWxEnterpriseId());
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal());
if (null == secretSetting||secretSetting.getCheckFlag()==0) {
logger.info("没有配置secret:{}",wxEnterpriseDTO.getWxEnterpriseId());
return null;
}
UserDTO user = qywxUserApiService.getSelfWorkWxUser(wxEnterpriseDTO.getCorpid(), secretSetting.getSecretVal(), relationDTO.getWxUserId());
if (user != null) {
resp.setResult(user.getQr_code());
return resp;
}
return resp;
}
......
......@@ -8,7 +8,10 @@
<sql id="Base_Column_List">
id, name
</sql>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.Test" >
insert into test (id,name)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR})
</insert>
<select id="queryList" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
......
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.SyncSingleDealDTO;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.haoban.manage.service.service.TestService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.QywxExternalcontactDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.redisson.api.RLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class DealSyncTest {
private static Logger logger= LoggerFactory.getLogger(DealSyncTest.class);
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private StaffService staffService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private TestService testService;
@Test
public void test() {
List<SyncSingleDealDTO> add = new ArrayList<>();
......@@ -64,11 +75,104 @@ public class DealSyncTest {
@Test
public void test2() {
dealSyncOperationApiService.cleanDiffrence("ca66a01b79474c40b3e7c7f93daf1a3b", "73387b7d355c416f93242f3d71a487a8");
int i =1;
while (true) {
i++;
if (i==5){
System.out.println("close");
RedisUtil.close();
}
if (i==10||i==25){
System.out.println("creConnect");
RedisUtil.reConnect();
}
try {
RedisUtil.setCache("1", "2");
Object cache = RedisUtil.getCache("1");
System.out.println("======={}"+i+":"+cache);
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Test
public void test3() {
staffApiService.getWxSaveNew("3e7a7c09097a40b18aef1478b04688fe", "ca66a01b79474c40b3e7c7f93daf1a3b");
}
@Test
public void test5() {
String key="test2";
RedisUtil.lock(key,100L, TimeUnit.SECONDS,0L);
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// if(RedisUtil.isLocked(key)){
// RedisUtil.unlock(key);
// }
}
@Test
public void test6() {
String key="test2";
// RedisUtil.lock(key,100L, TimeUnit.SECONDS,0L);
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
RLock lock = RedisUtil.getRedisClient().getLock(key);
try {
if (lock.tryLock(0, 10, TimeUnit.MINUTES)) {
try {
Thread.sleep(1000L);
} finally {
lock.unlock();
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}
// if(RedisUtil.isLocked(key)){
// RedisUtil.unlock(key);
// }
// RedisUtil.unlock();
// RedisUtil.setCache("test5511","111",2592030L);
}
@Test
public void test4() {
List<StaffDTO> retList = staffService.listByUserIdsAndWxEnterpriseId(null, "ca66a01b79474c40b3e7c7f93daf1a3b");
System.out.println(retList.size());
if (CollectionUtils.isEmpty(retList)) {
return;
}
List<StaffDTO> staffDTOS = retList.subList(2, retList.size()-1);
staffDTOS.forEach(staffDTO -> {
if (StringUtils.isNotBlank(staffDTO.getWxUserId())) {
logger.info(staffDTO.getWxUserId());
QywxExternalcontactDTO send = new QywxExternalcontactDTO();
send.setType(1);
send.setScene(1);
send.setRemark("tesst_" + staffDTO.getPhoneNumber());
List<String> userIds = new ArrayList<>();
userIds.add(staffDTO.getWxUserId());
send.setUser(userIds);
String configId = qywxUserApiService.getExternalcontactByUserId("ww9ede832a84b7ae5f", "65zze159pYb4ofbFsIREZ5X7d7iaZ-bWsVIQk2y5kTU", send);
if (StringUtils.isNotBlank(configId)) {
logger.info("staff:{}", configId, JSONObject.toJSONString(staffDTO));
com.gic.haoban.manage.service.entity.Test test = new com.gic.haoban.manage.service.entity.Test();
test.setId(configId);
test.setName(staffDTO.getWxUserId());
testService.save(test);
}
}
});
}
}
......@@ -114,4 +114,16 @@ public class TestController extends WebBaseController {
RedisUtil.delCache(key);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("/lock")
public HaobanResponse lock(String name,Long time,int ty) {
RedisUtil.lock(name, time, TimeUnit.SECONDS, 0L);
if (ty==0) {
if(RedisUtil.isLocked(name)){
RedisUtil.unlock(name);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
}
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