Commit 32cf4f7c by fudahua

Merge remote-tracking branch 'origin/developer' into developer

parents eb593ce4 0b92514b
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
public class MaterialCategoryDTO {
public class MaterialCategoryDTO implements Serializable{
private String categoryId;
......
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
public class MaterialDTO {
public class MaterialDTO implements Serializable{
private String materialId;
......@@ -14,7 +15,7 @@ public class MaterialDTO {
private String materialContent;
private String wxLastUploadTime;
private Date wxLastUploadTime;
private String mediaId;
......@@ -78,12 +79,12 @@ public class MaterialDTO {
this.materialContent = materialContent == null ? null : materialContent.trim();
}
public String getWxLastUploadTime() {
public Date getWxLastUploadTime() {
return wxLastUploadTime;
}
public void setWxLastUploadTime(String wxLastUploadTime) {
this.wxLastUploadTime = wxLastUploadTime == null ? null : wxLastUploadTime.trim();
public void setWxLastUploadTime(Date wxLastUploadTime) {
this.wxLastUploadTime = wxLastUploadTime;
}
public String getMediaId() {
......
......@@ -29,4 +29,6 @@ public interface MaterialApiService {
Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId, Integer materialType,BasePageInfo pageInfo);
String reUpdalodMetail(String materialId);
}
......@@ -3,6 +3,9 @@ package com.gic.haoban.manage.api.service;
import java.util.Date;
import java.util.List;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.MemberStoreDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
......@@ -28,4 +31,11 @@ public interface MemberUnionidRelatedApiService {
public void cleanByCid(String cid);
Page<MemberUnionidRelatedDTO> pageMemberUnionByParams(List<String> userIdList, List<String> sendMemberIds,
String enterpriseId, BasePageInfo pageInfo);
String sendMessage(String wxEnterpriseId, String userId, List<String> extendUserList, String materialId);
JSONResponse getMessageStatus(String wxEnterpriseId, String wxMessageId);
}
......@@ -80,4 +80,6 @@ public interface StaffApiService {
public ServiceResponse<String> getStaffQrcode(String clerkCode, String storeId);
void wxFristAdd(String userJson, String wxEnterpriseId);
List<String> listBindClerkUserId(String storeId);
}
......@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.github.pagehelper.Page;
public interface MemberUnionidRelatedMapper {
int deleteByPrimaryKey(String memberUnionidRelatedId);
......@@ -35,4 +36,7 @@ public interface MemberUnionidRelatedMapper {
@Param("externalName")String name, @Param("addCreateTime")String createTime);
List<MemberUnionidRelated> listByExTernalUseridAndWxUserId(@Param("externalUserid")String externalUserid, @Param("wxUserId")String wxUserId);
Page<MemberUnionidRelated> pageMemberUnionByParams(@Param("userIdList")List<String> userIdList, @Param("sendMemberIds")List<String> sendMemberIds,
@Param("enterpriseId")String enterpriseId);
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ public class TabHaobanMaterial implements Serializable {
private String materialContent;
private String wxLastUploadTime;
private Date wxLastUploadTime;
private String mediaId;
......@@ -78,15 +78,16 @@ public class TabHaobanMaterial implements Serializable {
this.materialContent = materialContent == null ? null : materialContent.trim();
}
public String getWxLastUploadTime() {
return wxLastUploadTime;
}
public void setWxLastUploadTime(String wxLastUploadTime) {
this.wxLastUploadTime = wxLastUploadTime == null ? null : wxLastUploadTime.trim();
}
public Date getWxLastUploadTime() {
return wxLastUploadTime;
}
public void setWxLastUploadTime(Date wxLastUploadTime) {
this.wxLastUploadTime = wxLastUploadTime;
}
public String getMediaId() {
public String getMediaId() {
return mediaId;
}
......
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service;
import java.util.List;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
public interface MemberUnionRelatedService {
......@@ -19,4 +20,7 @@ public interface MemberUnionRelatedService {
void update(MemberUnionidRelatedDTO exsitDTO);
void clean(String cid);
com.github.pagehelper.Page<MemberUnionidRelated> pageMemberUnionByParams(List<String> userIdList, List<String> sendMemberIds,
String enterpriseId);
}
......@@ -13,6 +13,7 @@ import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.service.dao.mapper.MemberUnionidRelatedMapper;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.gic.haoban.manage.service.service.MemberUnionRelatedService;
import com.github.pagehelper.Page;
@Service
public class MemberUnionRelatedServiceImpl implements MemberUnionRelatedService {
......@@ -60,4 +61,10 @@ public class MemberUnionRelatedServiceImpl implements MemberUnionRelatedService
public void clean(String cid) {
mapper.cleanByCid(cid);
}
@Override
public Page<MemberUnionidRelated> pageMemberUnionByParams(List<String> userIdList, List<String> sendMemberIds,
String enterpriseId) {
return mapper.pageMemberUnionByParams(userIdList,sendMemberIds,enterpriseId);
}
}
......@@ -42,7 +42,7 @@ public class MaidianDictApiServiceImpl implements MaidianDictApiService{
}else{
//更新
tab.setUpdateTime(new Date());
tabHaobanMaidianDictModuleMapper.updateByPrimaryKey(tab);
tabHaobanMaidianDictModuleMapper.updateByPrimaryKeySelective(tab);
}
}
@Override
......@@ -53,12 +53,12 @@ public class MaidianDictApiServiceImpl implements MaidianDictApiService{
tab.setCreateTime(new Date());
tab.setUpdateTime(new Date());
tab.setStatus(1);
tab.setModuleId(UuidUtil.randomUUID());
tab.setDictId(UuidUtil.randomUUID());
tabHaobanMaidianDictMapper.insert(tab);
}else{
//更新
tab.setUpdateTime(new Date());
tabHaobanMaidianDictMapper.updateByPrimaryKey(tab);
tabHaobanMaidianDictMapper.updateByPrimaryKeySelective(tab);
}
}
......
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;
import java.util.List;
import org.apache.commons.io.IOUtils;
......@@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.GlobalInfo;
......@@ -23,6 +25,7 @@ import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanMaterial;
import com.gic.haoban.manage.service.service.MaterialCategoryService;
import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
......@@ -121,6 +124,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if(fileType != null){
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url), fileType.getCode());
if(jp.getErrorCode() == 0){
materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString());
materialService.insertMaterial(materialDTO);
}
......@@ -168,6 +172,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if(fileType != null && !url.equals(oldUrl)){
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url), fileType.getCode());
if(jp.getErrorCode() == 0){
materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString());
materialService.edit(materialDTO);
}
......@@ -176,22 +181,64 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
}
@Override
public String reUpdalodMetail(String materialId){
MaterialDTO old = materialService.selectMaterialById(materialId);
Integer type = old.getMaterialType();
if(type == null){
return "";
}
String wxEnterpriseId = old.getWxEnterpriseId();
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(wxEnterpriseId);
if(enterprise == null){
return "";
}
String url = "";
String oldUrl = "";
QywxMediaTypeEnum fileType = null;
if(type == 2){
fileType = QywxMediaTypeEnum.IMAGE;
url = old.getImgUrl();
}
if(type == 4){
fileType = QywxMediaTypeEnum.VIDEO;
url = old.getLink();
}
if(type == 5){
fileType = QywxMediaTypeEnum.FILE;
url = old.getLink();
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url), fileType.getCode());
if(jp.getErrorCode() == 0){
old.setWxLastUploadTime(new Date());
old.setMediaId(jp.getResult().toString());
materialService.edit(old);
}
return old.getMediaId();
}
@Override
public Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId,
Integer materialType,BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
return PageUtil.changePageHelperToCurrentPage(materialService.listMaterial(wxEnterpriseId,keyword,categoryId,materialType),MaterialDTO.class);
com.github.pagehelper.Page<TabHaobanMaterial> page = materialService.listMaterial(wxEnterpriseId,keyword,categoryId,materialType);
return PageUtil.changePageHelperToCurrentPage(page,MaterialDTO.class);
}
public static void main(String[] args) {
String str = "{errcode=0, errmsg=ok, media_id=3ymUzyvUwcIohAXb1lbrL-6Fa-yD3njQpgFCYrEDUHpDaja_ZThd-6XW95NEVjY1l, created_at=1589335350, type=image}";
JSON.parseObject(str);
}
private byte[] getFileByte(String url) {
private static byte[] getFileByte(String url) {
try {
InputStream in = new URL(url).openStream();
byte[] data = IOUtils.toByteArray(in);
return data;
}catch (Exception e){
logger.info("【异常】"+e.getMessage(),e);
}
return null;
}
......
......@@ -6,7 +6,12 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.wechat.api.dto.qywx.QywxIinkExternalMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxImageExternalMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxTextExternalMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -20,21 +25,28 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.MD5Utils;
import com.gic.commons.util.Md5Util;
import com.gic.commons.util.StringUtil;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.contacts.manage.api.dto.SearchDataDTO;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.MemberStoreDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
......@@ -109,6 +121,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private StoreService storeService;
@Autowired
private Config config;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private MaterialApiService materialApiService;
@Override
public List<MemberStoreDTO> listByExTernalUseridAndWxUserId(String externalUserid, String wxUserId) {
......@@ -658,4 +674,66 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
memberUnionRelatedService.clean(null);
}
}
@Override
public Page<MemberUnionidRelatedDTO> pageMemberUnionByParams(List<String> userIdList, List<String> sendMemberIds,
String enterpriseId, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
return PageUtil.changePageHelperToCurrentPage(memberUnionRelatedService.pageMemberUnionByParams(userIdList,sendMemberIds,enterpriseId),MemberUnionidRelatedDTO.class);
}
@Override
public String sendMessage(String wxEnterpriseId,String userId,List<String> extendUserList,String materialId){
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(wxEnterpriseId);
MaterialDTO material = materialApiService.selectMaterialById(materialId);
if(material == null){
return "";
}
JSONResponse jp = null;
if(material.getMaterialType() == 2 || material.getMaterialType() == 4 || material.getMaterialType() == 5){
Date wxLastTime = material.getWxLastUploadTime();
String maerialId = material.getMaterialId();
if(DateUtil.addDay(wxLastTime, 3).getTime() < System.currentTimeMillis()){
maerialId = materialApiService.reUpdalodMetail(materialId);
}
QywxImageExternalMessageDTO dto = new QywxImageExternalMessageDTO();
dto.setMediaId(maerialId);
dto.setChatType("single");
dto.setExternalUserid(extendUserList);
dto.setSenderUserId(userId);
log.info("【发送消息】dto = {}",JSON.toJSONString(dto));
jp = qywxSuiteApiService.sendExternalMessage(enterprise.getCorpid(), config.getWxSuiteid(), dto);
}else if(material.getMaterialType() == 1){
QywxTextExternalMessageDTO dto = new QywxTextExternalMessageDTO();
dto.setChatType("single");
dto.setExternalUserid(extendUserList);
dto.setSenderUserId(userId);
dto.setText(material.getMaterialContent());
log.info("【发送消息】dto = {}",JSON.toJSONString(dto));
jp = qywxSuiteApiService.sendExternalMessage(enterprise.getCorpid(), config.getWxSuiteid(), dto);
}else if(material.getMaterialType() == 3){
QywxIinkExternalMessageDTO dto = new QywxIinkExternalMessageDTO();
dto.setChatType("single");
dto.setExternalUserid(extendUserList);
dto.setSenderUserId(userId);
dto.setDesc(material.getMaterialDesc());
dto.setPicurl(material.getImgUrl());
dto.setTitle(material.getMaterialTitle());
dto.setUrl(material.getLink());
log.info("【发送消息】dto = {}",JSON.toJSONString(dto));
jp = qywxSuiteApiService.sendExternalMessage(enterprise.getCorpid(), config.getWxSuiteid(), dto);
}
log.info("【发送消息】jp = {}",JSON.toJSONString(jp));
String josnStr = jp.getReturnMap().toString();
JSONObject json = JSONObject.parseObject(josnStr);
return json.getString("msgid");
}
@Override
public JSONResponse getMessageStatus(String wxEnterpriseId, String wxMessageId) {
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(wxEnterpriseId);
if(enterprise == null){
return null;
}
JSONResponse jp = qywxSuiteApiService.resultExternalMessage(enterprise.getCorpid(), config.getWxSuiteid(), wxMessageId);
return jp;
}
}
......@@ -1226,6 +1226,18 @@ public class StaffApiServiceImpl implements StaffApiService {
List<TabHaobanStaff> list = staffMapper.listByWxUserId(wxUserId);
return EntityUtil.changeEntityListByJSON(StaffDTO.class, list);
}
@Override
public List<String> listBindClerkUserId(String storeId) {
TabHaobanDepartment department = departmentService.selectByRelatedId(storeId);
if(department == null){
return Collections.EMPTY_LIST;
}
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listByDepartmentId(department.getDepartmentId());
List<String> userIdList = list.stream().filter(s->s.getClerkCode()!=null).map(s->s.getWxUserId()).collect(Collectors.toList());
return userIdList;
}
// private String getMobile(String phoneNumber,String nationcode){
// String mobile = nationcode + phoneNumber;
......
......@@ -250,4 +250,20 @@
and external_name = #{externalName}
and add_create_time = #{addCreateTime}
</select>
<select id="pageMemberUnionByParams" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_member_unionid_related
where enterprise_id = #{enterpriseId}
and status_flag = 1
and member_id in
<foreach item="memberId" index="index" collection="sendMemberIds" open="(" separator="," close=")">
#{memberId, jdbcType=CHAR}
</foreach>
and wx_user_id in
<foreach item="wxUserId" index="index" collection="userIdList" open="(" separator="," close=")">
#{wxUserId, jdbcType=CHAR}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -7,7 +7,7 @@
<result column="material_type" property="materialType" jdbcType="INTEGER" />
<result column="category_id" property="categoryId" jdbcType="VARCHAR" />
<result column="material_content" property="materialContent" jdbcType="VARCHAR" />
<result column="wx_last_upload_time" property="wxLastUploadTime" jdbcType="VARCHAR" />
<result column="wx_last_upload_time" property="wxLastUploadTime" jdbcType="TIMESTAMP" />
<result column="media_id" property="mediaId" jdbcType="VARCHAR" />
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR" />
<result column="staff_id" property="staffId" jdbcType="VARCHAR" />
......@@ -42,7 +42,7 @@
status_flag, link, create_time,
update_time)
values (#{materialId,jdbcType=VARCHAR}, #{materialTitle,jdbcType=VARCHAR}, #{materialType,jdbcType=INTEGER},
#{categoryId,jdbcType=VARCHAR}, #{materialContent,jdbcType=VARCHAR}, #{wxLastUploadTime,jdbcType=VARCHAR},
#{categoryId,jdbcType=VARCHAR}, #{materialContent,jdbcType=VARCHAR}, #{wxLastUploadTime,jdbcType=TIMESTAMP},
#{mediaId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{staffId,jdbcType=VARCHAR},
#{staffName,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR}, #{materialDesc,jdbcType=VARCHAR},
#{statusFlag,jdbcType=INTEGER}, #{link,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
......@@ -117,7 +117,7 @@
#{materialContent,jdbcType=VARCHAR},
</if>
<if test="wxLastUploadTime != null" >
#{wxLastUploadTime,jdbcType=VARCHAR},
#{wxLastUploadTime,jdbcType=TIMESTAMP},
</if>
<if test="mediaId != null" >
#{mediaId,jdbcType=VARCHAR},
......@@ -167,7 +167,7 @@
material_content = #{materialContent,jdbcType=VARCHAR},
</if>
<if test="wxLastUploadTime != null" >
wx_last_upload_time = #{wxLastUploadTime,jdbcType=VARCHAR},
wx_last_upload_time = #{wxLastUploadTime,jdbcType=TIMESTAMP},
</if>
<if test="mediaId != null" >
media_id = #{mediaId,jdbcType=VARCHAR},
......@@ -208,7 +208,7 @@
material_type = #{materialType,jdbcType=INTEGER},
category_id = #{categoryId,jdbcType=VARCHAR},
material_content = #{materialContent,jdbcType=VARCHAR},
wx_last_upload_time = #{wxLastUploadTime,jdbcType=VARCHAR},
wx_last_upload_time = #{wxLastUploadTime,jdbcType=TIMESTAMP},
media_id = #{mediaId,jdbcType=VARCHAR},
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
staff_id = #{staffId,jdbcType=VARCHAR},
......@@ -235,6 +235,15 @@
<include refid="Base_Column_List" />
from tab_haoban_material
where status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
and wx_enterprise_id = #{wxEnterpriseId}
<if test="keyword != null and keyword != ''">
and keyword like CONCAT('%',#{keyWord},'%')
</if>
<if test="materialType != null">
and material_type = #{materialType}
</if>
<if test="categoryId != null">
and category_id = #{categoryId}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -94,7 +94,7 @@ public class MaterialController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_10016);
}
List<MaterialDTO> list = materialApiService.listMaterialByCategoryId(categoryId);
if(!list.isEmpty()){
if(list!= null && !list.isEmpty()){
return resultResponse(HaoBanErrCode.ERR_10017);
}
dto.setStatusFlag(0);
......@@ -142,7 +142,7 @@ public class MaterialController extends WebBaseController{
* 素材修改
* @return
*/
@RequestMapping("/material-eidt")
@RequestMapping("/material-edit")
public HaobanResponse materialEdit(MaterialDTO materialDTO) {
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
......
package com.gic.haoban.manage.web.controller;
import java.io.File;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.DateUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.qcloud.BucketNameEnum;
import com.gic.qcloud.FileUploadUtil;
@RestController
public class UploadController extends WebBaseController{
private static Set<String> FILE_TYPE = new HashSet<>( );
static {
for(BucketNameEnum value: BucketNameEnum.values()){
FILE_TYPE.add( value.getName() );
}
}
@RequestMapping("/upload-file")
@ResponseBody
public HaobanResponse upload(@RequestParam MultipartFile file,@RequestParam String fileType) throws Exception{
if(file == null || file.isEmpty()){
return resultResponse(HaoBanErrCode.ERR_2);
}
String name = file.getOriginalFilename();
String suffix = name.substring(name.lastIndexOf(".") + 1);
String location = System.getProperty( "user.dir" )+"/data/tmp/";
//b
long len = file.getSize();
File templateFile = new File( location+name );
FileUtils.copyInputStreamToFile( file.getInputStream(),templateFile );
// 2.上传腾讯云
String dayFilePath = LocalDateTime.now().format( DateTimeFormatter.ofPattern( DateUtil.FORMAT_DATETIME_14 ) );
String key = "haoban/"+dayFilePath+"/"+name;
fileType = FILE_TYPE.contains( fileType )?fileType:BucketNameEnum.OTHER_90000.getName();
String url = FileUploadUtil.simpleUploadFileFromLocal( templateFile,key,fileType);
if(templateFile != null){
templateFile.delete();
}
JSONObject res = new JSONObject( );
res.put( "name",name );
res.put( "ext", suffix );
res.put( "size",len );
res.put( "key",key );
res.put( "url", "https://"+url );
return resultResponse(HaoBanErrCode.ERR_1, res);
}
}
......@@ -313,5 +313,22 @@ public class WxEnterpriseController extends WebBaseController{
}
//企业信息
@RequestMapping("enterprise-is-over")
public HaobanResponse enterpriseIsOver(String enterpriseId) {
if(StringUtils.isEmpty(enterpriseId)){
return resultResponse(HaoBanErrCode.ERR_2);
}
EnterpriseDTO enterprise = enterpriseService.getEnterpriseByEid(enterpriseId);
if(enterprise == null || enterprise.getExpireTime() == null){
return resultResponse(HaoBanErrCode.ERR_1,true);
}
if(enterprise.getExpireTime().getTime() > System.currentTimeMillis()){
return resultResponse(HaoBanErrCode.ERR_1,false);
}
return resultResponse(HaoBanErrCode.ERR_1,true);
}
}
package com.gic.haoban.manage.web.init;
import com.gic.dict.api.dto.GlobalDictMap;
import com.gic.dict.api.service.ManagerDictService;
import com.gic.quartz.api.dto.QuartzTaskDTO;
import com.gic.quartz.api.service.QuartzService;
......@@ -18,12 +16,28 @@ public class MyApplicationContextAware implements ApplicationContextAware {
private Logger log = LogManager.getLogger(MyApplicationContextAware.class);
private static ApplicationContext applicationContext;
@Autowired
private QuartzService quartzService;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// TODO Auto-generated method stub
QuartzTaskDTO taskDTO = buildQuartzMessageDTO("haoban-message-status-time");
taskDTO.setTaskParam("");
taskDTO.setTaskStatus(1);
taskDTO.setTaskTimeInfo("0 30 0 * * *");
// taskDTO.setTaskTimeInfo("0 0/1 * * * *");
quartzService.addOrUpdateQuartzTask(taskDTO);
}
private QuartzTaskDTO buildQuartzMessageDTO(String id) {
QuartzTaskDTO taskDTO = new QuartzTaskDTO();
taskDTO.setReferId(id);
taskDTO.setTaskMethod("quartzUpdateMessageStatus");
taskDTO.setTaskService("com.gic.haoban.app.customer.service.api.service.messageLogApiService");
return taskDTO;
}
}
......@@ -60,5 +60,7 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.DealSyncOperationApiService"
id="dealSyncOperationApiService"/>
<dubbo:reference id="quartzService" interface="com.gic.quartz.api.service.QuartzService" timeout="10000"/>
</beans>
......@@ -5,14 +5,19 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.PageResult2;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.service.MaterialApiService;
......@@ -22,6 +27,8 @@ import com.gic.haoban.manage.web.vo.MaterialVO;
@RestController
public class MaterialController extends WebBaseController{
private static Logger logger = LoggerFactory.getLogger(MaterialController.class);
@Autowired
private MaterialApiService materialApiService;
/**
......@@ -31,7 +38,9 @@ public class MaterialController extends WebBaseController{
@RequestMapping("/material-list")
public HaobanResponse materialList(String wxEnterpriseId,String keyword,String categoryId,Integer materialType,BasePageInfo pageInfo) {
Page<MaterialDTO> page = materialApiService.listMaterial(wxEnterpriseId,keyword,categoryId,materialType,pageInfo);
return resultResponse(HaoBanErrCode.ERR_1,page);
//暂时转换
PageResult2 pageResult2 = PageUtil.getPageInfo(page);
return resultResponse(HaoBanErrCode.ERR_1, pageResult2);
}
/**
......@@ -42,6 +51,12 @@ public class MaterialController extends WebBaseController{
public HaobanResponse materialType(String wxEnterpriseId) {
List<MaterialCategoryDTO> list = materialApiService.listCategory(wxEnterpriseId);
List<MaterialVO> handerList = new ArrayList<MaterialVO>();
MaterialVO vo = new MaterialVO();
vo.setCategoryId("-1");
vo.setCategoryName("未分组");
vo.setCategoryParentId("0");
vo.setWxEnterpriseId(wxEnterpriseId);
handerList.add(vo);
for (MaterialCategoryDTO materialCategoryDTO : list) {
if("0".equals(materialCategoryDTO.getCategoryParentId())){
handerList.add(EntityUtil.changeEntityByJSON(MaterialVO.class, materialCategoryDTO));
......@@ -54,12 +69,13 @@ public class MaterialController extends WebBaseController{
private void handerSonMaterial(List<MaterialVO> handerList,Map<String,List<MaterialCategoryDTO>> map){
for (MaterialVO materialVO : handerList) {
List<MaterialCategoryDTO> sonList = map.get(materialVO.getCategoryParentId());
List<MaterialCategoryDTO> sonList = map.get(materialVO.getCategoryId());
List<MaterialVO> sonVoList = EntityUtil.changeEntityListByJSON(MaterialVO.class, sonList);
materialVO.setList(sonVoList);
while(sonList != null){
handerSonMaterial(sonVoList, map);
}
// logger.info("map={},handerList={},categoryId={},sonVoList={}",JSON.toJSONString(map),JSON.toJSONString(handerList),materialVO.getCategoryId(),JSON.toJSONString(sonVoList));
// while(sonVoList != null && sonVoList.size() > 0){
// handerSonMaterial(sonVoList, map);
// }
}
}
......
......@@ -52,5 +52,9 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.MaidianLogApiService" id="maidianLogApiService"/>
<dubbo:reference interface="com.gic.haoban.app.customer.service.api.service.StaffMemberRelationApiService" id="staffMemberRelationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.MaterialApiService" id="materialApiService"/>
</beans>
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