Commit 1085862d by 徐高华

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

parents 4445ff19 fd2a6a9b
......@@ -32,7 +32,7 @@ public interface HmQrcodeApiService {
* @author mozhu
* @date 2022-07-05 10:59:06
*/
int update(HmQrcodeQDTO hmQrcodeQDTO);
ServiceResponse update(HmQrcodeQDTO hmQrcodeQDTO);
/**
* 查询详情
......
package com.gic.haoban.manage.service.pojo.bo.welcome;
import java.io.Serializable;
/**
* @Author MUSI
* @Date 2022/7/14 3:26 PM
* @Description
* @Version
**/
public class WelcomeReferBO implements Serializable {
private static final long serialVersionUID = 6490051043315353967L;
/**
* @see com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType
*/
private Integer type;
private String referId;
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getReferId() {
return referId;
}
public void setReferId(String referId) {
this.referId = referId;
}
}
......@@ -135,7 +135,7 @@ public interface WelcomeService {
* @param referId 活码 / 链接id
* @return
*/
WelcomeDetailBO getMatchWelcomeWithReferId(String staffId, String wxEnterpriseId, String referId);
WelcomeDetailBO getMatchWelcomeWithReferId(String staffId, String wxEnterpriseId, WelcomeReferBO welcomeReferBo);
/**
* 删除欢迎语
......
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service.hm;
import com.gic.api.base.commons.Page;
import com.gic.haoban.manage.service.pojo.bo.hm.HmWelcomeRelationBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeReferBO;
import com.gic.haoban.manage.service.pojo.qo.WelcomeRelationQO;
import java.util.List;
......@@ -16,12 +17,10 @@ import java.util.List;
public interface WelcomeRelationService {
/**
* 查询欢迎语关联关系
* @param referId
* @param status
* 查询关联的欢迎语
* @return
*/
HmWelcomeRelationBO queryWelcomeRelation(String referId, Integer status);
String queryWelcomeRelation(WelcomeReferBO welcomeReferBo);
/**
* 条件查询 欢迎语引用列表
......
......@@ -3,13 +3,13 @@ package com.gic.haoban.manage.service.service.hm.impl;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.enums.WelcomeRelationStatusEnum;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanWelcomeTemplateRelationMapper;
import com.gic.haoban.manage.service.entity.hm.TabHaobanWelcomeTemplateRelation;
import com.gic.haoban.manage.service.pojo.bo.hm.HmWelcomeRelationBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeReferBO;
import com.gic.haoban.manage.service.pojo.qo.WelcomeRelationQO;
import com.gic.haoban.manage.service.service.WelcomeService;
import com.gic.haoban.manage.service.service.hm.WelcomeRelationService;
......@@ -27,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
......@@ -46,7 +45,6 @@ public class WelcomeRelationServiceImpl implements WelcomeRelationService {
@Autowired
private WelcomeService welcomeService;
private static final String WELCOME_RELATION_KEY = "HM:welcome:relation:";
private static final Long WELCOME_RELATION_CACHE_TIME = 5 * 60L;
......@@ -54,24 +52,12 @@ public class WelcomeRelationServiceImpl implements WelcomeRelationService {
/**
* 查询欢迎语关联关系
*
* @param referId
* @param status
* @return
* @retur
*/
@Override
public HmWelcomeRelationBO queryWelcomeRelation(String referId, Integer status) {
String welcomeRelationCacheKey = WELCOME_RELATION_KEY + referId;
HmWelcomeRelationBO cache = RedisUtil.getCache(welcomeRelationCacheKey, HmWelcomeRelationBO.class);
if (cache != null) {
return cache;
}
List<TabHaobanWelcomeTemplateRelation> welcomeTemplateRelations = welcomeTemplateRelationMapper.queryWelTemplateRelation(null, referId, status);
if (CollectionUtils.isEmpty(welcomeTemplateRelations)) {
return null;
}
HmWelcomeRelationBO welcomeRelationBO = EntityUtil.changeEntityByOrika(HmWelcomeRelationBO.class, welcomeTemplateRelations.get(0));
RedisUtil.setCache(welcomeRelationCacheKey, welcomeRelationBO, WELCOME_RELATION_CACHE_TIME, TimeUnit.SECONDS);
return welcomeRelationBO;
public String queryWelcomeRelation(WelcomeReferBO welcomeReferBo) {
return null;
}
/**
......
package com.gic.haoban.manage.service.service.impl;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.service.LinkService;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.welcome.dto.WelcomeRemoveCheckDTO;
import com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeQDTO;
......@@ -23,6 +25,8 @@ import com.gic.haoban.manage.service.entity.TabHaobanWelcomeMedia;
import com.gic.haoban.manage.service.entity.TabHaobanWelcomeSuitRang;
import com.gic.haoban.manage.service.entity.TabMiniprogramSetting;
import com.gic.haoban.manage.service.entity.TabWelcome;
import com.gic.haoban.manage.service.pojo.bo.hm.HmLinkBO;
import com.gic.haoban.manage.service.pojo.bo.hm.HmQrcodeBO;
import com.gic.haoban.manage.service.pojo.bo.hm.HmWelcomeRelationBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.FriendSettingDetailBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.SaveFriendSettingBO;
......@@ -31,6 +35,7 @@ import com.gic.haoban.manage.service.pojo.bo.welcome.SaveWelcomeMediaBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeListBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeMediaBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeReferBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeSuitDepartmentBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeSuitStaffBO;
import com.gic.haoban.manage.service.pojo.qo.WelcomeInfoQO;
......@@ -38,6 +43,8 @@ import com.gic.haoban.manage.service.pojo.qo.WelcomeRelationQO;
import com.gic.haoban.manage.service.service.KeyDataService;
import com.gic.haoban.manage.service.service.WelcomeService;
import com.gic.haoban.manage.service.service.WelcomeSuitRangService;
import com.gic.haoban.manage.service.service.hm.HmLinkService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeService;
import com.gic.haoban.manage.service.service.hm.WelcomeRelationService;
import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils;
......@@ -85,7 +92,10 @@ public class WelcomeServiceImpl implements WelcomeService {
private WelcomeRelationService welcomeRelationService;
@Autowired
private KeyDataService keyDataService;
@Autowired
private HmLinkService linkService;
@Autowired
private HmQrcodeService qrcodeService;
private static final int WELCOME_LIMIT = 50;
private static final int DEPARTMENT_NUM_LIMIT = 10000;
private static final int STAFF_NUM_LIMIT = 2000;
......@@ -661,19 +671,36 @@ public class WelcomeServiceImpl implements WelcomeService {
}
@Override
public WelcomeDetailBO getMatchWelcomeWithReferId(String staffId, String wxEnterpriseId, String referId) {
logger.info("[getMatchWelcomeWithReferId] staffId:{}, wxEnterpriseId:{}, referId:{}",
staffId, wxEnterpriseId, referId);
public WelcomeDetailBO getMatchWelcomeWithReferId(String staffId, String wxEnterpriseId, WelcomeReferBO welcomeReferBo) {
logger.info("[getMatchWelcomeWithReferId] staffId:{}, wxEnterpriseId:{}, welcomeReferBo:{}",
staffId, wxEnterpriseId, JSON.toJSONString(welcomeReferBo));
if (StringUtils.isBlank(referId)){
if (welcomeReferBo == null || welcomeReferBo.getType() == null || StringUtils.isBlank(welcomeReferBo.getReferId())) {
return null;
}
HmWelcomeRelationBO welcomeRelationBO = welcomeRelationService.queryWelcomeRelation(referId, WelcomeRelationStatusEnum.ENABLE.getCode());
if (welcomeRelationBO == null){
// 不存在
String welcomeId = "";
try {
if (HmWelcomeReferType.LINK.getCode().equals(welcomeReferBo.getType())) {
HmLinkBO linkBo = linkService.getByLinkIdFormCache(null, null, Long.parseLong(welcomeReferBo.getReferId()));
if (linkBo == null || StringUtils.isBlank(linkBo.getWelcomeId())){
return null;
}
welcomeId = linkBo.getWelcomeId();
} else if (HmWelcomeReferType.HM.getCode().equals(welcomeReferBo.getType())) {
HmQrcodeBO qrcodeBo = qrcodeService.queryById(Long.parseLong(welcomeReferBo.getReferId()));
if (qrcodeBo == null || StringUtils.isBlank(qrcodeBo.getWelcomeId())){
return null;
}
welcomeId = qrcodeBo.getWelcomeId();
}
} catch (Exception ex) {
logger.error("[getMatchWelcomeWithReferId] err", ex);
}
logger.info("[getMatchWelcomeWithReferId] 获取欢迎语Id:{}, params:{}", welcomeId, JSON.toJSONString(welcomeReferBo));
if (StringUtils.isBlank(welcomeId)){
return null;
}
TabWelcome tabWelcome = welcomeMapper.selectByPrimaryKey(welcomeRelationBO.getWelcomeId());
TabWelcome tabWelcome = welcomeMapper.selectByPrimaryKey(welcomeId);
return convertWelcomeToBo(tabWelcome);
}
......
......@@ -35,6 +35,7 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.dto.qdto.hm.WxUserAddLogQDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.enums.WelcomeMediaTypeEnum;
import com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType;
import com.gic.haoban.manage.api.service.CheckQywxSettingApiService;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.api.service.MaterialApiService;
......@@ -52,6 +53,7 @@ import com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo;
import com.gic.haoban.manage.service.pojo.bo.hm.KeyDataLinkBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeMediaBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeReferBO;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.hm.WxUserAddLogService;
import com.gic.haoban.manage.service.util.CommonUtil;
......@@ -577,8 +579,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
if (StringUtils.isNotBlank(state)) {
//"HM+id" "DT+key"
log.info("特殊欢迎语 state:{}", state);
String refId = getRefId(state);
welcomeDetailBO = welcomeService.getMatchWelcomeWithReferId(staffId, wxEnterpriseId, refId);
WelcomeReferBO welcomeReferBo = getWelcomeReferBo(state);
welcomeDetailBO = welcomeService.getMatchWelcomeWithReferId(staffId, wxEnterpriseId, welcomeReferBo);
} else {
welcomeDetailBO = welcomeService.getMatchWelcome(staffId, wxEnterpriseId);
}
......@@ -630,6 +632,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
qywxWelcomeMsgDTO.setAttachments(attachments);
}
qywxWelcomeMsgDTO.setWelcomeCode(welcomeCode);
log.info("[sendWelcome] 发送欢迎语 params:{}", JSON.toJSONString(qywxWelcomeMsgDTO));
if (dto.getSuiteid().equals(SELF_APP)) {
//好办助手和代开发
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(dto.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal());
......@@ -644,18 +647,20 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
* @param state
* @return
*/
private String getRefId(String state) {
private WelcomeReferBO getWelcomeReferBo(String state){
WelcomeReferBO welcomeReferBo = new WelcomeReferBO();
String id = state.substring(2);
String refId = "";
if (state.contains("HM")) {
refId = id;
welcomeReferBo.setType(HmWelcomeReferType.HM.getCode());
welcomeReferBo.setReferId(id);
} else if (state.contains("DT")) {
KeyDataLinkBO dataForHmLink = keyDataService.getDataForHmLink(id);
if (dataForHmLink != null) {
refId = Convert.toStr(dataForHmLink.getLinkId());
welcomeReferBo.setType(HmWelcomeReferType.LINK.getCode());
welcomeReferBo.setReferId(Convert.toStr(dataForHmLink.getLinkId()));
}
}
return refId;
return welcomeReferBo;
}
private void attachmentAddImage(List<QywxExternalMessageBaseDTO> attachments, WelcomeMediaBO media, WxEnterpriseDTO wxEnterpriseDTO) {
......
......@@ -121,7 +121,10 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
} else {
hmQrcodeQDTO.setHmCode("HM02" + hmId);
}
Long hmGroupId = hmQrcodeQDTO.getHmGroupId();
if (hmGroupId == null) {
hmQrcodeQDTO.setHmGroupId(0L);
}
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType);
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"该导购已经生成过活码或未关联过好办");
......@@ -172,19 +175,6 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
GicLogRecordEvaluationContext.putAttribute("userName", userName);
}
private void saveWelcomeRelation(HmQrcodeQDTO hmQrcodeQDTO) {
if (StringUtils.isNotBlank(hmQrcodeQDTO.getWelcomeId())) {
HmWelcomeRelationBO welcomeRelationBo = new HmWelcomeRelationBO();
welcomeRelationBo.setEnterpriseId(hmQrcodeQDTO.getEnterpriseId());
welcomeRelationBo.setWxEnterpriseId(hmQrcodeQDTO.getWxEnterpriseId());
welcomeRelationBo.setWelcomeId(hmQrcodeQDTO.getWelcomeId());
welcomeRelationBo.setReferId(hmQrcodeQDTO.getHmId() + "");
welcomeRelationBo.setReferCode(hmQrcodeQDTO.getHmCode());
welcomeRelationBo.setReferName(hmQrcodeQDTO.getName());
welcomeRelationBo.setType(HmWelcomeReferType.HM.getCode());
welcomeRelationService.saveHmWelcomeRelation(welcomeRelationBo);
}
}
@GicLogRecord(value = "修改员工活码-${#hmName}-${#logContent}",
category = GicLogRecordCategoryEnum.HUOMA,
......@@ -193,18 +183,20 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
afterFunc = LogRecordAfterServiceImpl.class)
@Override
@Transactional(rollbackFor = Exception.class)
public int update(HmQrcodeQDTO hmQrcodeQDTO) {
public ServiceResponse update(HmQrcodeQDTO hmQrcodeQDTO) {
String wxEnterpriseId = hmQrcodeQDTO.getWxEnterpriseId();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
logger.error("未查询到微信企业");
return 0;
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"微信企业不存在");
}
Long hmId = hmQrcodeQDTO.getHmId();
Integer hmType = hmQrcodeQDTO.getHmType();
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType);
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"该导购已经生成过活码或未关联过好办");
}
//更新活码
QywxExternalcontactDTO qywxExternalcontactDTO = new QywxExternalcontactDTO();
qywxExternalcontactDTO.setType(hmQrcodeQDTO.getHmType());
......@@ -213,11 +205,14 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
qywxExternalcontactDTO.setSkipVerify(hmQrcodeQDTO.getPassFlag() == 1);
qywxExternalcontactDTO.setState("HM" + hmId);
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId);
if (CollectionUtils.isEmpty(userIds)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"导购未关联好办");
}
qywxExternalcontactDTO.setUser(userIds);
boolean flag = qywxUserApiService.updateContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO);
if (!flag) {
logger.error("更新企微活码失败");
return 0;
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()),"更新企微活码失败");
}
int updateResult = hmQrcodeService.update(hmQrcodeQDTO);
......@@ -229,7 +224,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getModifierId(), hmQrcodeQDTO.getModifierName());
updateSystemLog(hmQrcodeQDTO, hmId);
return updateResult;
return ServiceResponse.success();
}
/**
......@@ -329,12 +324,6 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
*/
private List<String> setStoreClerk(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId, Integer hmType) {
List<String> clerkIdList = hmQrcodeQDTO.getClerkIdList();
String storeId = hmQrcodeQDTO.getStoreId();
StoreDTO storeDTO = storeService.getStore(storeId);
if (storeDTO != null) {
storeDTO.setStoreCode(storeDTO.getStoreCode());
storeDTO.setStoreName(storeDTO.getStoreName());
}
if (hmType == 2) {
//多人活码
......@@ -352,6 +341,13 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
if (clerkDTO != null) {
hmQrcodeQDTO.setClerkName(clerkDTO.getClerkName());
hmQrcodeQDTO.setClerkCode(clerkDTO.getClerkCode());
String storeId = clerkDTO.getStoreId();
hmQrcodeQDTO.setStoreId(storeId);
StoreDTO storeDTO = storeService.getStore(storeId);
if (storeDTO != null) {
hmQrcodeQDTO.setStoreCode(storeDTO.getStoreCode());
hmQrcodeQDTO.setStoreName(storeDTO.getStoreName());
}
}
StaffClerkRelationDTO staffClerkRelationDTO = staffClerkRelationService.getByClerkId(clerkId);
if (staffClerkRelationDTO != null) {
......@@ -384,12 +380,16 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmClerkRelationQDTO.setWxUserId(clerkRelationDTO.getWxUserId());
hmClerkRelationQDTO.setWxEnterpriseId(wxEnterpriseId);
hmClerkRelationQDTO.setEnterpriseId(hmQrcodeQDTO.getEnterpriseId());
hmClerkRelationQDTO.setStoreId(hmQrcodeQDTO.getStoreId());
hmClerkRelationQDTO.setStoreName(hmQrcodeQDTO.getStoreName());
hmClerkRelationQDTO.setStoreCode(hmQrcodeQDTO.getStoreCode());
hmClerkRelationQDTO.setClerkId(clerkId);
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
if (clerkDTO != null) {
String storeId = clerkDTO.getStoreId();
hmClerkRelationQDTO.setStoreId(storeId);
StoreDTO storeDTO = storeService.getStore(storeId);
if (storeDTO != null) {
hmClerkRelationQDTO.setStoreCode(storeDTO.getStoreCode());
hmClerkRelationQDTO.setStoreName(storeDTO.getStoreName());
}
hmClerkRelationQDTO.setClerkName(clerkDTO.getClerkName());
hmClerkRelationQDTO.setClerkCode(clerkDTO.getClerkCode());
}
......
......@@ -198,6 +198,12 @@
<artifactId>gic-webapp-common</artifactId>
<version>${gic-webapp-common}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-ds-mongo-api</artifactId>
<version>${gic-ds-mongo-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -88,7 +88,10 @@ public class HmQrcodeController {
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
this.hmQrcodeApiService.update(hmQrcodeQDTO);
ServiceResponse serviceResponse = this.hmQrcodeApiService.update(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_0.getCode()),serviceResponse.getMessage());
}
return RestResponse.successResult();
}
......
package com.gic.haoban.manage.web.controller.logrecord;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.dsmongo.api.dto.DocumentResultDTO;
import com.gic.dsmongo.api.dto.QueryDocDTO;
import com.gic.dsmongo.api.service.MongoOperationService;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.web.qo.logrecord.LogRecordQo;
import com.gic.haoban.manage.web.vo.logrecord.LogRecordTypeVO;
import com.gic.log.record.bean.GicLogRecordBean;
import com.gic.log.record.util.GicLogRecordCategoryEnum;
import com.gic.log.record.util.GicLogRecordOptTypeEnum;
import com.gic.log.record.util.LogCommenUtil;
import com.gic.web.common.controller.DefaultController;
import com.gic.web.common.utils.Response;
import com.mongodb.BasicDBObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bson.conversions.Bson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
@Controller
@RequestMapping("/log-record")
public class LogRecordController extends DefaultController {
private static final Logger LOGGER = LogManager.getLogger(LogRecordController.class);
@Autowired
MongoOperationService mongoOperationService;
/**
* 系统类型 0gic 1好办
*/
private static Integer systemType = 1;
@RequestMapping("/list")
@ResponseBody
public Response pageLog(LogRecordQo qo, @RequestParam(defaultValue="1")int pageNum , @RequestParam(defaultValue="20")int pageSize){
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String eid = qo.getEnterpriseId() ;
if(null != loginUser && StringUtils.isEmpty(eid)) {
eid = loginUser.getEnterpriseId() ;
}
QueryDocDTO doc = new QueryDocDTO();
doc.setSkip((pageNum-1)*pageSize);
doc.setLimit(pageSize);
String mongoName = LogCommenUtil.getMongoName();
doc.setDatabaseName(mongoName);
doc.setCountFlag(true);
BasicDBObject filter = new BasicDBObject().append("enterpriseId", eid);
filter.append("statusFlag",1);
//
filter.append("systemType", systemType);
filter.append("wxEnterpriseId", loginUser.getWxEnterpriseId());
if (StringUtils.isNotBlank(qo.getBusinessType())) {
filter.append("businessType", qo.getBusinessType());
}
if (StringUtils.isNotBlank(qo.getOptType())) {
filter.append("optType", qo.getOptType());
}
if (StringUtils.isNoneBlank(qo.getStartDate(),qo.getEndDate())) {
String endDate = qo.getEndDate() + " 23:59:59";
String startDate = qo.getStartDate() + " 00:00:00";
try {
Date startDateD = DateUtils.parseDate(startDate, "yyyy-MM-dd HH:mm:ss");
Date endDateD = DateUtils.parseDate(endDate, "yyyy-MM-dd HH:mm:ss");
filter.append("createTime", new BasicDBObject("$gte", startDateD).append("$lte",endDateD));
} catch (Exception e) {
e.printStackTrace();
}
}
// if(null == loginUser || StringUtils.isBlank(loginUser.getOperationUserName())) {
// filter.append("ywFlag", new BasicDBObject("$ne",1)) ;
// }
LOGGER.info(JSON.toJSONString(filter));
doc.setFilter(filter);
Bson sort = new BasicDBObject().append("createTime", -1);
doc.setSort(sort);
doc.setSingleObject(new GicLogRecordBean());
Map<String, String> map = new HashMap<String, String>();
if (StringUtils.isNotBlank(qo.getSearch())) {
filter.append("content",new BasicDBObject("$regex",qo.getSearch()));
}
if (StringUtils.isNotBlank(qo.getOptUser())) {
filter.append("userId",qo.getOptUser());
}
DocumentResultDTO documentResultDTO = mongoOperationService.queryManyDocumentForMongo(doc);
Page<Object> retPage = new Page<>();
retPage.setResult(documentResultDTO.getDocList());
retPage.setTotalCount(Long.valueOf(documentResultDTO.getTotalCount()).intValue());
retPage.setPageSize(pageSize);
retPage.setCurrentPage(pageNum);
return this.success(retPage);
}
/**
* 获取 业务模块
* @return
*/
@RequestMapping("business-types")
@ResponseBody
public Response businessTypes(){
List<LogRecordTypeVO> ret=new ArrayList<>();
GicLogRecordCategoryEnum[] values = GicLogRecordCategoryEnum.values();
for (GicLogRecordCategoryEnum value : values) {
if (Objects.equals(value.getSystemType(), systemType)) {
LogRecordTypeVO mid = new LogRecordTypeVO();
mid.setKey(value.getType());
mid.setValue(value.getName());
ret.add(mid);
}
}
return this.success(ret);
}
/**
* 获取 操作类型
* @return
*/
@RequestMapping("opt-types")
@ResponseBody
public Response optTypes(){
List<LogRecordTypeVO> ret=new ArrayList<>();
GicLogRecordOptTypeEnum[] values = GicLogRecordOptTypeEnum.values();
for (GicLogRecordOptTypeEnum value : values) {
if (Objects.equals(value.getSystemType(), systemType)) {
LogRecordTypeVO mid = new LogRecordTypeVO();
mid.setKey(value.getType());
mid.setValue(value.getName());
ret.add(mid);
}
}
return this.success(ret);
}
}
package com.gic.haoban.manage.web.qo.logrecord;
import java.io.Serializable;
/**
* 日志入参
*/
public class LogRecordQo implements Serializable {
private String businessType;
private String optType;
private String optUser;
private String search;
private String startDate;
private String endDate;
private String enterpriseId;
/**
* 好办字段
*/
private String wxEnterpriseId;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getBusinessType() {
return businessType;
}
public void setBusinessType(String businessType) {
this.businessType = businessType;
}
public String getOptType() {
return optType;
}
public void setOptType(String optType) {
this.optType = optType;
}
public String getOptUser() {
return optUser;
}
public void setOptUser(String optUser) {
this.optUser = optUser;
}
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public LogRecordQo setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
return this;
}
}
package com.gic.haoban.manage.web.vo.logrecord;
import java.io.Serializable;
/**
* 日志出参
*/
public class LogRecordTypeVO implements Serializable {
private String key;
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
......@@ -113,4 +113,7 @@
timeout="10000" retries="0" check="false" />
<dubbo:reference id="hmQrcodeApiService" interface="com.gic.haoban.manage.api.service.hm.HmQrcodeApiService"
timeout="10000" retries="0" check="false" />
<dubbo:reference id="mongoOperationService" interface="com.gic.dsmongo.api.service.MongoOperationService"
timeout="10000" retries="0" check="false"/>
</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