Commit 26e6178e by qwmqiuwenmin

fix

parent b9980c60
...@@ -42,4 +42,6 @@ public interface MemberUnionidRelatedApiService { ...@@ -42,4 +42,6 @@ public interface MemberUnionidRelatedApiService {
String addMemberUnionidRelatedNew(MemberUnionidRelatedDTO dto); String addMemberUnionidRelatedNew(MemberUnionidRelatedDTO dto);
void mqFreshWxFrend(String res);
} }
...@@ -277,7 +277,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -277,7 +277,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
log.info("【新增外部联系人回调】unionIdJson={}",JSON.toJSONString(unionIdJson)); log.info("【新增外部联系人回调】unionIdJson={}",JSON.toJSONString(unionIdJson));
ExternalUserPojo pojo = getExternalUserPojo(unionIdJson,userId,wxEnterpriseId); ExternalUserPojo pojo = getExternalUserPojo(unionIdJson,userId,wxEnterpriseId);
String unionId = pojo.getUnionId(); //String unionId = pojo.getUnionId();
String name = pojo.getName(); String name = pojo.getName();
String createTime = pojo.getAddCreateTime(); String createTime = pojo.getAddCreateTime();
...@@ -285,29 +285,34 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -285,29 +285,34 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
RedisUtil.lock(key,2l); RedisUtil.lock(key,2l);
dto.setWxEnterpriseId(wxEnterpriseId); dto.setWxEnterpriseId(wxEnterpriseId);
dto.setUnionid(unionId); //dto.setUnionid(unionId);
dto.setExternalName(name); dto.setExternalName(name);
dto.setAddCreateTime(createTime); dto.setAddCreateTime(createTime);
MemberUnionidRelatedDTO exsitDTO = memberUnionRelatedService.getByParams(dto.getWxUserId(), wxEnterpriseId,name,createTime); MemberUnionidRelatedDTO exsitDTO = memberUnionRelatedService.getByParams(dto.getWxUserId(), wxEnterpriseId,name,createTime);
String externalUserId = "";
String uuid = ""; String selfExternalUserId = "";
if(exsitDTO == null){ String unionId = "";
if(SELF_APP.equals(suiteid)){ if(SELF_APP.equals(suiteid)){
dto.setSelfExternalUserid(dto.getExternalUserid()); unionId = pojo.getUnionId();
selfExternalUserId = dto.getExternalUserid();
}else{ }else{
dto.setExternalUserid(dto.getExternalUserid()); externalUserId = dto.getExternalUserid();
} }
String uuid = "";
if(exsitDTO == null){
dto.setSelfExternalUserid(externalUserId);
dto.setExternalUserid(selfExternalUserId);
dto.setUnionid(unionId);
uuid = memberUnionRelatedService.addMemberUnionidRelated(dto); uuid = memberUnionRelatedService.addMemberUnionidRelated(dto);
}else{ }else{
//如果是自建更新uuid //如果是自建更新uuid
if(SELF_APP.equals(suiteid)){ exsitDTO.setSelfExternalUserid(selfExternalUserId);
dto.setSelfExternalUserid(dto.getExternalUserid());
exsitDTO.setUnionid(unionId); exsitDTO.setUnionid(unionId);
}else{
//更新对外联系人id //更新对外联系人id
exsitDTO.setExternalUserid(dto.getExternalUserid()); exsitDTO.setExternalUserid(externalUserId);
}
memberUnionRelatedService.update(exsitDTO); memberUnionRelatedService.update(exsitDTO);
uuid = exsitDTO.getMemberUnionidRelatedId(); uuid = exsitDTO.getMemberUnionidRelatedId();
} }
...@@ -607,6 +612,19 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -607,6 +612,19 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
} }
@Override @Override
public void mqFreshWxFrend(String res){
JSONObject json = JSON.parseObject(res);
String wxEnterpriseId = json.getString("wxEnterpriseId");
String wxUserId = json.getString("wxUserId");
String storeId = json.getString("storeId");
log.info("【刷下微信好友】wxEnterpriseId={}.wxUserId={},storeId={}",wxEnterpriseId,wxUserId,storeId);
if(StringUtils.isAnyBlank(wxEnterpriseId,wxUserId,storeId)){
return ;
}
freshWxFrend(wxEnterpriseId, wxUserId, storeId);
}
@Override
public void cleanByCid(String cid) { public void cleanByCid(String cid) {
if (StringUtils.isNotBlank(cid)) { if (StringUtils.isNotBlank(cid)) {
TabHaobanWxEnterprise wxEnterprise = wxEnterpriseService.getEnterpriseBycorpId(cid); TabHaobanWxEnterprise wxEnterprise = wxEnterpriseService.getEnterpriseBycorpId(cid);
......
...@@ -5,6 +5,7 @@ import com.gic.haoban.manage.api.service.DepartmentApiService; ...@@ -5,6 +5,7 @@ import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.TestApiService; import com.gic.haoban.manage.api.service.TestApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.service.MemberUnionRelatedService;
import com.gic.haoban.manage.service.util.EmojiFilterUtil; import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.DepartmentDTO; import com.gic.wechat.api.dto.qywx.DepartmentDTO;
...@@ -15,7 +16,7 @@ import com.gic.wechat.api.enums.QywxMediaTypeEnum; ...@@ -15,7 +16,7 @@ import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService; import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.binarywang.java.emoji.EmojiConverter; //import com.github.binarywang.java.emoji.EmojiConverter;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -59,280 +60,286 @@ public class ServiceTest { ...@@ -59,280 +60,286 @@ public class ServiceTest {
@Autowired @Autowired
private DepartmentApiService departmentApiService; private DepartmentApiService departmentApiService;
@Autowired
private MemberUnionRelatedService memberUnionRelatedService;
private final ExecutorService pools = Executors.newFixedThreadPool(50); private final ExecutorService pools = Executors.newFixedThreadPool(50);
@Test @Test
public void test() { public void test() {
int i=2000; List<String> staffIds = new ArrayList<>();
while (i-->0) { staffIds.add("0006ae5de6484cf9b55072d2d967c481");
departmentApiService.listAllDepartment(i+""); memberUnionRelatedService.cleanStaffRelated("ca66a01b79474c40b3e7c7f93daf1a3b", staffIds);
} // int i=2000;
// while (i-->0) {
try { // departmentApiService.listAllDepartment(i+"");
Thread.sleep(1000000L); // }
} catch (InterruptedException e) { //
e.printStackTrace(); // try {
} // Thread.sleep(1000000L);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
} }
//// @Test
//// public void test1() {
//// String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
//// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000);
//// JSONArray jsonArray = JSONArray.parseArray(res);
//// jsonArray.forEach(o -> {
//// JSONObject mid = (JSONObject) o;
//// qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f"
//// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid")
//// , mid.getString("handover_userid"), mid.getString("external_userid"));
//// });
//// System.out.println(res);
//// }
////
//// @Test
//// public void test2() {
//// UserDTO userDTO = new UserDTO();
//// userDTO.setUserid("niweizhong");
//// userDTO.setName("空闻大师");
//// userDTO.setDepartment(new Integer[]{4});
//// userDTO.setMobile("17605628855");
//// userDTO.setCorpid("ww9ede832a84b7ae5f");
//// JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27");
//// System.out.println(JSONObject.toJSONString(workWxUser));
//// }
////
//// @Test
//// public void list() {
////
//// List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f"
//// , "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1);
//// Iterator<DepartmentDTO> iterator = list.iterator();
////// while (iterator.hasNext()) {
////// DepartmentDTO next = iterator.next();
////// if(!next.getParentid().equals("1")) {
////// iterator.remove();
////// }
////// }
//// System.out.println(JSONObject.toJSONString(list));
//// }
////
// @Test // @Test
// public void test1() { // public void addDepart() {
// String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f" // DepartmentDTO dto = new DepartmentDTO();
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000); // dto.setName("测试order");
// JSONArray jsonArray = JSONArray.parseArray(res); // dto.setOrder(2147484447L);
// jsonArray.forEach(o -> { // dto.setParentid(1);
// JSONObject mid = (JSONObject) o; //
// qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f" // JSONResponse department = qywxDepartmentApiService.createSelfDepartment("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid") // , "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", dto);
// , mid.getString("handover_userid"), mid.getString("external_userid")); //// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
// }); // System.out.println(JSONObject.toJSONString(department));
// System.out.println(res);
// } // }
////
//// @Test
//// public void getUser() {
//// DepartmentDTO dto = new DepartmentDTO();
////// dto.set
//// UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
//// , "ww7d6566614055cf27", "13735457631");
////// String phonenumber = phonenumber;
////// UserDTO phonenumber = (UserDTO) useridBymobile;
//// System.out.println(JSONObject.toJSONString(phonenumber));
//// }
////
//@Test
//public void createSelfUser() {
// UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong2");
// userDTO.setName("空闻大师2");
// userDTO.setDepartment(new Integer[]{5072});
// userDTO.setMobile("17605628851");
// userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createSelfWorkWxUser(userDTO, "n",
// "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8");
// System.out.println(JSONObject.toJSONString(workWxUser));
//}
//
//
//@Test
//public void sendMessage() {
// QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
// messageDTO.setAppid("wx6054e7be35015afc");
// ArrayList<String> userIDs = new ArrayList<>();
// userIDs.add("9ae4c4f1277340a186b16a17d937c72c");
// messageDTO.setUserIds(userIDs);
// messageDTO.setTitle("我的测试test");
// messageDTO.setDescription("我的测试test11111");
// HashMap<String, String> map = new HashMap<>();
// map.put("名称", "hua");
//// messageDTO.setItems(map);
// boolean ret = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
// "ww2c34dc56739bb105", messageDTO);
// System.out.println(JSONObject.toJSONString(ret));
//}
//
// //
// @Test // @Test
// public void test2() { // public void listExternalUserid() {
// UserDTO userDTO = new UserDTO(); // UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong"); // userDTO.setUserid("niweizhong2");
// userDTO.setName("空闻大师"); // userDTO.setName("空闻大师2");
// userDTO.setDepartment(new Integer[]{4}); // userDTO.setDepartment(new Integer[]{5072});
// userDTO.setMobile("17605628855"); // userDTO.setMobile("17605628851");
// userDTO.setCorpid("ww9ede832a84b7ae5f"); // userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27"); // String s = qywxUserApiService.listExternalUserid("ww9ede832a84b7ae5f",
// System.out.println(JSONObject.toJSONString(workWxUser)); // "ww2c34dc56739bb105", "qiuwenmin");
// System.out.println(s);
// } // }
// //
// @Test // @Test
// public void list() { // public void getQrcode() {
// //
// List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f" // UserDTO workWxUser = qywxUserApiService.getSelfWorkWxUser("ww9ede832a84b7ae5f", "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", "lining");
// , "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1); // ServiceResponse<String> qrcode = staffApiService.getStaffQrcode("167442", "ff8080817181d322017182737b16021f");
// Iterator<DepartmentDTO> iterator = list.iterator(); // System.out.println(JSONObject.toJSONString(qrcode));
//// while (iterator.hasNext()) {
//// DepartmentDTO next = iterator.next();
//// if(!next.getParentid().equals("1")) {
//// iterator.remove();
//// }
//// }
// System.out.println(JSONObject.toJSONString(list));
// } // }
// //
@Test
public void addDepart() {
DepartmentDTO dto = new DepartmentDTO();
dto.setName("测试order");
dto.setOrder(2147484447L);
dto.setParentid(1);
JSONResponse department = qywxDepartmentApiService.createSelfDepartment("ww9ede832a84b7ae5f"
, "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", dto);
// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
System.out.println(JSONObject.toJSONString(department));
}
// //
// @Test // @Test
// public void getUser() { // public void extensionList() {
// DepartmentDTO dto = new DepartmentDTO();
//// dto.set
// UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
// , "ww7d6566614055cf27", "13735457631");
//// String phonenumber = phonenumber;
//// UserDTO phonenumber = (UserDTO) useridBymobile;
// System.out.println(JSONObject.toJSONString(phonenumber));
// }
// //
@Test
public void createSelfUser() {
UserDTO userDTO = new UserDTO();
userDTO.setUserid("niweizhong2");
userDTO.setName("空闻大师2");
userDTO.setDepartment(new Integer[]{5072});
userDTO.setMobile("17605628851");
userDTO.setCorpid("ww9ede832a84b7ae5f");
JSONResponse workWxUser = qywxUserApiService.createSelfWorkWxUser(userDTO, "n",
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8");
System.out.println(JSONObject.toJSONString(workWxUser));
}
@Test
public void sendMessage() {
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
messageDTO.setAppid("wx6054e7be35015afc");
ArrayList<String> userIDs = new ArrayList<>();
userIDs.add("9ae4c4f1277340a186b16a17d937c72c");
messageDTO.setUserIds(userIDs);
messageDTO.setTitle("我的测试test");
messageDTO.setDescription("我的测试test11111");
HashMap<String, String> map = new HashMap<>();
map.put("名称", "hua");
// messageDTO.setItems(map);
boolean ret = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
"ww2c34dc56739bb105", messageDTO);
System.out.println(JSONObject.toJSONString(ret));
}
@Test
public void listExternalUserid() {
UserDTO userDTO = new UserDTO();
userDTO.setUserid("niweizhong2");
userDTO.setName("空闻大师2");
userDTO.setDepartment(new Integer[]{5072});
userDTO.setMobile("17605628851");
userDTO.setCorpid("ww9ede832a84b7ae5f");
String s = qywxUserApiService.listExternalUserid("ww9ede832a84b7ae5f",
"ww2c34dc56739bb105", "qiuwenmin");
System.out.println(s);
}
@Test
public void getQrcode() {
UserDTO workWxUser = qywxUserApiService.getSelfWorkWxUser("ww9ede832a84b7ae5f", "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", "lining");
ServiceResponse<String> qrcode = staffApiService.getStaffQrcode("167442", "ff8080817181d322017182737b16021f");
System.out.println(JSONObject.toJSONString(qrcode));
}
@Test
public void extensionList() {
String s = qywxUserApiService.listSelfExternalUserid("ww9ede832a84b7ae5f", "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", "de2c33f2e8924ff884e0073ca2f2f711");
System.out.println(JSONObject.toJSONString(s));
}
@Test
public void extensionList1() {
UserDTO selfWorkWxUser = qywxUserApiService.getSelfWorkWxUser("ww9ede832a84b7ae5f", "65zze159pYb4ofbFsIREZ5X7d7iaZ-bWsVIQk2y5kTU", "de2c33f2e8924ff884e0073ca2f2f711");
// String s = qywxUserApiService.listSelfExternalUserid("ww9ede832a84b7ae5f", "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", "de2c33f2e8924ff884e0073ca2f2f711"); // String s = qywxUserApiService.listSelfExternalUserid("ww9ede832a84b7ae5f", "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", "de2c33f2e8924ff884e0073ca2f2f711");
System.out.println(JSONObject.toJSONString(selfWorkWxUser)); // System.out.println(JSONObject.toJSONString(s));
} // }
// @Test
// public void extensionList1() {
// UserDTO selfWorkWxUser = qywxUserApiService.getSelfWorkWxUser("ww9ede832a84b7ae5f", "65zze159pYb4ofbFsIREZ5X7d7iaZ-bWsVIQk2y5kTU", "de2c33f2e8924ff884e0073ca2f2f711");
@Test //// String s = qywxUserApiService.listSelfExternalUserid("ww9ede832a84b7ae5f", "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", "de2c33f2e8924ff884e0073ca2f2f711");
public void extensionList2() { // System.out.println(JSONObject.toJSONString(selfWorkWxUser));
String img="d:/test2.jpg"; // }
byte[] aByte = getFileByteArray(new File(img)); //
JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte,"测试文件", QywxMediaTypeEnum.IMAGE.getCode()); //
System.out.println(JSONObject.toJSONString(response)); //
} // @Test
// public void extensionList2() {
@Test // String img="d:/test2.jpg";
public void extensionList3() { // byte[] aByte = getFileByteArray(new File(img));
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw // JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte,"测试文件", QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
// }
//
// @Test
// public void extensionList3() {
//// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
//// String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
//// byte[] aByte = getByte(img);
//// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
//// System.out.println(JSONObject.toJSONString(response));
// QywxImageExternalMessageDTO messageDTO=new QywxImageExternalMessageDTO();
// messageDTO.setMediaId("msg59NLDQAANPwzc9aMWNCBky8EElovyg");
// messageDTO.setSenderUserId("9ae4c4f1277340a186b16a17d937c72c");
// List<String> list=new ArrayList<>();
// list.add("wm59NLDQAAL0fHb-QEbx-U9pdtRFA1bg");
// messageDTO.setExternalUserid(list);
// JSONResponse response1 = qywxSuiteApiService.sendExternalMessage("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", messageDTO);
// System.out.println(JSONObject.toJSONString(response1));
// }
//
// @Test
// public void extensionList4() {
//// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
// String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106"; // String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
// byte[] aByte = getByte(img); // byte[] aByte = getByte(img);
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode()); //// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response)); //// System.out.println(JSONObject.toJSONString(response));
QywxImageExternalMessageDTO messageDTO=new QywxImageExternalMessageDTO(); // JSONResponse response1 = qywxSuiteApiService.uploadImage("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte);
messageDTO.setMediaId("msg59NLDQAANPwzc9aMWNCBky8EElovyg"); // System.out.println(JSONObject.toJSONString(response1));
messageDTO.setSenderUserId("9ae4c4f1277340a186b16a17d937c72c"); // }
List<String> list=new ArrayList<>(); //
list.add("wm59NLDQAAL0fHb-QEbx-U9pdtRFA1bg"); //
messageDTO.setExternalUserid(list); // @Test
JSONResponse response1 = qywxSuiteApiService.sendExternalMessage("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", messageDTO); // public void redis() {
System.out.println(JSONObject.toJSONString(response1)); // long key=111;
} // RedisUtil.setCache("test-key-11",key);
// Long key2=111L;
@Test // RedisUtil.setCache("test-key-112",key2);
public void extensionList4() { //
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw // RedisUtil.setCache("test-key-113",1);
String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106"; // int ke22y=22;
byte[] aByte = getByte(img); // RedisUtil.setCache("test-key-115",ke22y);
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode()); //
// System.out.println(JSONObject.toJSONString(response)); // RedisUtil.setCache("test-key-114","1");
JSONResponse response1 = qywxSuiteApiService.uploadImage("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte); //
System.out.println(JSONObject.toJSONString(response1)); //
} // }
//
//
@Test // @Test
public void redis() { // public void staff() {
long key=111; // EmojiConverter emojiConverter = EmojiConverter.getInstance();
RedisUtil.setCache("test-key-11",key); //// List<UserDTO> userDTOList = qywxUserApiService.listSelfDepartmentUser("wwd5b0d17fd7952df8", "cFhOS1fkb8-qJNHDr5S8QI1JbpsTLCSTOsxQQUUmYz4", "1", 0);
Long key2=111L; // UserDTO wxUser = qywxUserApiService.getSelfWorkWxUser("wwd5b0d17fd7952df8", "cFhOS1fkb8-qJNHDr5S8QI1JbpsTLCSTOsxQQUUmYz4", "QingSu");
RedisUtil.setCache("test-key-112",key2); // String s = EmojiFilterUtil.removeAllEmoji(wxUser.getName());
//// String name = (String) b;
RedisUtil.setCache("test-key-113",1); //// ServiceResponse res = staffApiService.getWxSaveNew("a.XiaoPangZhi", "ca66a01b79474c40b3e7c7f93daf1a3b");
int ke22y=22; // System.out.println(JSONObject.toJSONString(wxUser));
RedisUtil.setCache("test-key-115",ke22y); //
//
RedisUtil.setCache("test-key-114","1"); // }
//
// private byte[] getByte(String strUrl){
} // ByteArrayOutputStream baos = null;
// try
// {
@Test // URL u = new URL(strUrl);
public void staff() { // BufferedImage image = ImageIO.read(u);
EmojiConverter emojiConverter = EmojiConverter.getInstance(); //
// List<UserDTO> userDTOList = qywxUserApiService.listSelfDepartmentUser("wwd5b0d17fd7952df8", "cFhOS1fkb8-qJNHDr5S8QI1JbpsTLCSTOsxQQUUmYz4", "1", 0); // //convert BufferedImage to byte array
UserDTO wxUser = qywxUserApiService.getSelfWorkWxUser("wwd5b0d17fd7952df8", "cFhOS1fkb8-qJNHDr5S8QI1JbpsTLCSTOsxQQUUmYz4", "QingSu"); // baos = new ByteArrayOutputStream();
String s = EmojiFilterUtil.removeAllEmoji(wxUser.getName()); // ImageIO.write( image, "jpg", baos);
// String name = (String) b; // baos.flush();
// ServiceResponse res = staffApiService.getWxSaveNew("a.XiaoPangZhi", "ca66a01b79474c40b3e7c7f93daf1a3b"); //
System.out.println(JSONObject.toJSONString(wxUser)); // return baos.toByteArray();
// }
// catch (Exception e)
} // {
// }
private byte[] getByte(String strUrl){ // finally
ByteArrayOutputStream baos = null; // {
try // if(baos != null)
{ // {
URL u = new URL(strUrl); // try {
BufferedImage image = ImageIO.read(u); // baos.close();
// } catch (IOException e) {
//convert BufferedImage to byte array // }
baos = new ByteArrayOutputStream(); // return baos.toByteArray();
ImageIO.write( image, "jpg", baos); // }
baos.flush(); // return null;
// }
return baos.toByteArray(); // }
} //
catch (Exception e) // public static byte[] getFileByteArray(File file) {
{ // long fileSize = file.length();
} // if (fileSize > Integer.MAX_VALUE) {
finally // System.out.println("file too big...");
{ // return null;
if(baos != null) // }
{ // byte[] buffer = null;
try { // try (FileInputStream fi = new FileInputStream(file)) {
baos.close(); // buffer = new byte[(int) fileSize];
} catch (IOException e) { // int offset = 0;
} // int numRead = 0;
return baos.toByteArray(); // while (offset < buffer.length
} // && (numRead = fi.read(buffer, offset, buffer.length - offset)) >= 0) {
return null; // offset += numRead;
} // }
} // // 确保所有数据均被读取
// if (offset != buffer.length) {
public static byte[] getFileByteArray(File file) { // throw new IOException("Could not completely read file "
long fileSize = file.length(); // + file.getName());
if (fileSize > Integer.MAX_VALUE) { // }
System.out.println("file too big..."); // } catch (Exception e) {
return null; // e.printStackTrace();
} // }
byte[] buffer = null; // return buffer;
try (FileInputStream fi = new FileInputStream(file)) { // }
buffer = new byte[(int) fileSize];
int offset = 0;
int numRead = 0;
while (offset < buffer.length
&& (numRead = fi.read(buffer, offset, buffer.length - offset)) >= 0) {
offset += numRead;
}
// 确保所有数据均被读取
if (offset != buffer.length) {
throw new IOException("Could not completely read file "
+ file.getName());
}
} catch (Exception e) {
e.printStackTrace();
}
return buffer;
}
} }
...@@ -27,6 +27,7 @@ import com.gic.clerk.api.service.ClerkNewService; ...@@ -27,6 +27,7 @@ import com.gic.clerk.api.service.ClerkNewService;
import com.gic.clerk.api.service.ClerkService; import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil; import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.StoreDTO; import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.EnterpriseService; import com.gic.enterprise.api.service.EnterpriseService;
...@@ -60,6 +61,7 @@ import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; ...@@ -60,6 +61,7 @@ import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.anno.HttpLimit; import com.gic.haoban.manage.web.anno.HttpLimit;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.interceptor.WebInterceptor; import com.gic.haoban.manage.web.interceptor.WebInterceptor;
import com.gic.haoban.manage.web.utils.RouterConstant;
import com.gic.haoban.manage.web.vo.BindClerkVO; import com.gic.haoban.manage.web.vo.BindClerkVO;
import com.gic.haoban.manage.web.vo.ClerkStoreVO; import com.gic.haoban.manage.web.vo.ClerkStoreVO;
import com.gic.haoban.manage.web.vo.ClerkVo; import com.gic.haoban.manage.web.vo.ClerkVo;
...@@ -423,6 +425,17 @@ public class ClerkController extends WebBaseController{ ...@@ -423,6 +425,17 @@ public class ClerkController extends WebBaseController{
Integer count = RedisUtil.getCache(key) == null ? 0 : (Integer)RedisUtil.getCache(key); Integer count = RedisUtil.getCache(key) == null ? 0 : (Integer)RedisUtil.getCache(key);
if(count == null || count < 4){ if(count == null || count < 4){
RedisUtil.setCache(key,count + 1,31 * 24 * 60 * 60l); RedisUtil.setCache(key,count + 1,31 * 24 * 60 * 60l);
JSONObject json = new JSONObject();
json.put("wxUserId", staff.getWxUserId());
json.put("wxEnterpriseId", wxEnterpriseId);
json.put("storeId", storeId);
logger.info("【刷下微信好友】{},{},{}",RouterConstant.FRESH_WX_FRIEND_SERVICENAME,RouterConstant.INIT_FRESH_WX_FRIEND_METHODNAME,json.toJSONString());
try {
GICMQClientUtil.getClientInstance().sendCommonMessage(RouterConstant.ROUTERTYPE, json.toJSONString(),
RouterConstant.FRESH_WX_FRIEND_SERVICENAME, RouterConstant.INIT_FRESH_WX_FRIEND_METHODNAME);
} catch (Exception e) {
logger.info(e.getMessage(),e);
}
memberUnionidRelatedApiService.freshWxFrend(wxEnterpriseId, staff.getWxUserId(),storeId); memberUnionidRelatedApiService.freshWxFrend(wxEnterpriseId, staff.getWxUserId(),storeId);
}else{ }else{
......
package com.gic.haoban.manage.web.utils;
public class RouterConstant {
public static final String FRESH_WX_FRIEND_SERVICENAME = "com.gic.haoban.manage.api.service";
public static final String INIT_FRESH_WX_FRIEND_METHODNAME = "mqFreshWxFrend";
public static final String ROUTERTYPE = "commonRouter";
}
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