Commit aa1ada8b by 徐高华

审批查询

parent 593cf22d
......@@ -8,21 +8,14 @@ import com.gic.haoban.manage.service.entity.TabHaobanAudit;
import com.github.pagehelper.Page;
public interface TabHaobanAuditMapper {
int deleteByPrimaryKey(String auditId);
int insert(TabHaobanAudit record);
int insertSelective(TabHaobanAudit record);
TabHaobanAudit selectByPrimaryKey(String auditId);
int updateByPrimaryKeySelective(TabHaobanAudit record);
int updateByPrimaryKey(TabHaobanAudit record);
Page<TabHaobanAudit> page(@Param("auditType")Integer auditType, @Param("storeIds")List<String> storeIds,@Param("staffIds")List<String>staffIds,@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId,@Param("auditStatus")Integer auditStatus,@Param("auditFlag")Integer auditFlag );
Page<TabHaobanAudit> pageForStoreIdsAndstaffIds(@Param("auditType")Integer auditType, @Param("storeIds")List<String> storeIds,@Param("staffIds")List<String>staffIds,@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId,@Param("auditStatus")Integer auditStatus,@Param("auditFlag")Integer auditFlag );
Page<TabHaobanAudit> page(@Param("auditType")Integer auditType, @Param("storeIds")List<String> storeIds,@Param("searchParams") String search, @Param("enterpriseId")String enterpriseId,@Param("auditStatus")Integer auditStatus,@Param("auditFlag")Integer auditFlag );
List<TabHaobanAudit> listByStoreId(String storeId);
......
......@@ -45,9 +45,18 @@ public class TabHaobanAudit implements Serializable {
private String relatedId;
private String auditStaffId;
private String commitStoreName ;
private static final long serialVersionUID = 1L;
public String getCommitStoreName() {
return commitStoreName;
}
public void setCommitStoreName(String commitStoreName) {
this.commitStoreName = commitStoreName;
}
public String getAuditStaffId() {
return auditStaffId;
}
......
package com.gic.haoban.manage.service.service.out.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
......@@ -10,12 +9,13 @@ import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
......@@ -26,7 +26,6 @@ import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.EnterpriseSettingDTO;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreDetailDTO;
import com.gic.enterprise.api.dto.StoreVo;
import com.gic.enterprise.api.dto.StoreWidgetDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
......@@ -38,7 +37,6 @@ import com.gic.haoban.communicate.api.service.SyncHaobanToGicServiceApi;
import com.gic.haoban.manage.api.dto.AuditDTO;
import com.gic.haoban.manage.api.dto.AuditStaffDTO;
import com.gic.haoban.manage.api.dto.BatchAuditLogDTO;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StoreAddressDTO;
import com.gic.haoban.manage.api.enums.AuditRsultType;
......@@ -50,7 +48,6 @@ import com.gic.haoban.manage.api.enums.StoreFieldEnum;
import com.gic.haoban.manage.api.service.AuditApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanAuditMapper;
......@@ -67,7 +64,8 @@ import cn.hutool.core.collection.CollectionUtil;
*/
@Service
public class AuditApiServiceImpl implements AuditApiService {
private static final Logger logger = LoggerFactory.getLogger(AuditApiServiceImpl.class);
private static final Logger logger = LogManager.getLogger(AuditApiService.class);
@Autowired
private TabHaobanAuditMapper auditMapper;
......@@ -88,8 +86,6 @@ public class AuditApiServiceImpl implements AuditApiService {
@Autowired
private ClerkService clerkService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private PowerService powerService ;
@Autowired
private StoreWidgetService storeWidgetService ;
......@@ -97,52 +93,13 @@ public class AuditApiServiceImpl implements AuditApiService {
@Override
public Page<AuditDTO> page(Integer auditType, String search, String wxEnterpriseId,
String enterpriseId, Integer auditStatus, Integer auditFlag, BasePageInfo pageInfo , String clerkId) {
//部门关联表修改,服务层调整
List<String> staffIds = new ArrayList<>();
List<String> storeIds = new ArrayList<>();
if (StringUtils.isNotEmpty(search)) {
//获取企业列表
List<String> enterpriseIds = new ArrayList<>();
if (StringUtils.isEmpty(enterpriseId)) {
List<EnterpriseDetailDTO> enterprises = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtil.isNotEmpty(enterprises)) {
List<String> searchEnterpriseIds = enterprises.stream().map(s -> s.getEnterpriseId()).collect(Collectors.toList());
enterpriseIds.addAll(searchEnterpriseIds);
}
} else {
enterpriseIds.add(enterpriseId);
}
//调gic接口查storeIds
String[] strArray = new String[enterpriseIds.size()];
enterpriseIds.toArray(strArray);
List<StoreVo> list = storeService.queryStoreByName(strArray, search);
if (CollectionUtil.isNotEmpty(list)) {
List<String> storeIds1 = list.stream().map(s -> s.getStoreId()).collect(Collectors.toList());
storeIds.addAll(storeIds1);
}
//模糊查staffName
List<TabHaobanStaff> staffList = staffMapper.listLikeName(search, wxEnterpriseId);
if (CollectionUtil.isNotEmpty(staffList)) {
List<String> staffIds2 = staffList.stream().map(s -> s.getStaffId()).collect(Collectors.toList());
staffIds.addAll(staffIds2);
}
if (CollectionUtil.isEmpty(staffIds)) {
staffIds.add("-999");
}
if (CollectionUtil.isEmpty(storeIds)) {
storeIds.add("-999");
}
}
List<String> storeIdList = this.getStoreIdList(enterpriseId, clerkId) ;
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
com.github.pagehelper.Page<TabHaobanAudit> page = new com.github.pagehelper.Page<TabHaobanAudit>();
if (CollectionUtil.isNotEmpty(storeIds) && CollectionUtil.isNotEmpty(staffIds)) {
page = auditMapper.pageForStoreIdsAndstaffIds(auditType, storeIds, staffIds, wxEnterpriseId, enterpriseId, auditStatus, auditFlag);
} else {
page = auditMapper.page(auditType, storeIds, staffIds, wxEnterpriseId, enterpriseId, auditStatus, auditFlag);
}
page = auditMapper.page(auditType, storeIdList, search, enterpriseId, auditStatus, auditFlag);
if (CollectionUtil.isNotEmpty(page.getResult())) {
List<String> commitStaffIds = page.getResult().stream().map(s -> s.getCommitStaffId()).collect(Collectors.toList());
List<String> commitStaffIds = page.getResult().stream().filter(item->StringUtils.isBlank(item.getCommitStaffName())).map(s -> s.getCommitStaffId()).collect(Collectors.toList());
logger.info(JSON.toJSONString(commitStaffIds));
if (CollectionUtil.isNotEmpty(commitStaffIds)) {
List<TabHaobanStaff> staffList = staffMapper.listByIds(commitStaffIds);
Map<String, TabHaobanStaff> map = com.gic.commons.util.CollectionUtil.toMap(staffList, "staffId");
......@@ -180,7 +137,6 @@ public class AuditApiServiceImpl implements AuditApiService {
}
this.editStoreInfo(storeId, changeField, oldValue, newValue);
//发送消息
String title = "门店信息修改通知";
String content = StoreFieldEnum.getValueName(changeField);
content = "[" + content + "]" + "修改审核通过";
TabHaobanAudit tab2 = auditMapper.selectByPrimaryKey(auditId);
......@@ -299,23 +255,17 @@ public class AuditApiServiceImpl implements AuditApiService {
TabHaobanAudit tab2 = auditMapper.selectByPrimaryKey(auditId);
int auditType = tab2.getAuditType();
String oldValue = tab2.getOldValue();
String enterpriseId = tab2.getEnterpriseId();
//发送消息
if (auditType == AuditType.STORE_CHANGE.getCode()) {
String changeField = tab2.getChangeField();
// String title = "门店信息修改通知";
String content = StoreFieldEnum.getValueName(changeField);
// content = "["+content+"]"+"被拒绝。拒绝理由:"+auditReason;
String staffId = tab2.getCommitStaffId();
String storeId = tab2.getCommitStoreId();
this.sendMessageByStaffId(staffId, storeId, true, content, auditReason);
} else if (auditType == AuditType.CLERK_BIND.getCode()) {
AuditStaffDTO obj = JSONObject.parseObject(oldValue, AuditStaffDTO.class);
String staffId = tab2.getCommitStaffId();
staffDepartmentRelatedApiService.sendBindAuditMessage(auditId, staffId, obj.getClerkId(), auditReason, true);
// staffDepartmentRelatedApiService.sendStaffBind(obj.getStaffId(), obj.getClerkCode(), tab2.getCommitStoreId(), 2, auditReason);
} else if (auditType == AuditType.CLERK_ADD.getCode()) {
AuditStaffDTO obj = JSONObject.parseObject(oldValue, AuditStaffDTO.class);
staffDepartmentRelatedApiService.sendClerkAdd(obj.getClerkName(), obj.getClerkCode(), tab2.getCommitStoreId(), 2, auditReason);
......@@ -343,6 +293,10 @@ public class AuditApiServiceImpl implements AuditApiService {
tab.setCommitStaffImg(staff.getHeadImg());
tab.setCommitStaffName(staff.getStaffName());
tab.setCommitStoreId(commitStoreId);
StoreDTO store =this.storeService.getStore(commitStoreId) ;
if(null != store) {
tab.setCommitStoreName(store.getStoreName());
}
tab.setCommitTime(new Date());
tab.setCreateTime(new Date());
tab.setWxEnterpriseId(wxEnterpriseId);
......@@ -351,7 +305,7 @@ public class AuditApiServiceImpl implements AuditApiService {
tab.setOldValue(oldValue);
tab.setStatusFlag(1);
tab.setUpdateTime(new Date());
return auditMapper.insertSelective(tab);
return auditMapper.insert(tab);
}
@Override
......@@ -383,7 +337,6 @@ public class AuditApiServiceImpl implements AuditApiService {
private void getStoreDTO(StoreDetailDTO store, String changeField, String oldValue, String newValue) {
logger.info("==========================>changeField={}", changeField);
if (StoreFieldEnum.BUSINESS_TIME_STRING.getValue().equals(changeField)) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
//营业时间
String[] newValues = newValue.split("-");
String openTime = newValues[0];
......@@ -463,7 +416,7 @@ public class AuditApiServiceImpl implements AuditApiService {
audit.setAuditId(com.gic.haoban.common.utils.StringUtil.randomUUID());
audit.setCreateTime(new Date());
audit.setUpdateTime(new Date());
auditMapper.insertSelective(EntityUtil.changeEntityByJSON(TabHaobanAudit.class, audit));
auditMapper.insert(EntityUtil.changeEntityByJSON(TabHaobanAudit.class, audit));
}
@Override
......@@ -528,10 +481,12 @@ public class AuditApiServiceImpl implements AuditApiService {
}
public int getAuditCount(String enterpriseId , String clerkId) {
// 如果null,说明是所有门店
List<String> storeIdList = this.getStoreIdList(enterpriseId, clerkId) ;
return this.auditMapper.getAuditCount(enterpriseId, storeIdList) ;
}
@SuppressWarnings("unchecked")
public List<String> getStoreIdList(String enterpriseId , String clerkId) {
EnterpriseSettingDTO enterpriseSetting = enterpriseService.getEnterpriseSettingByEnterpriseId(enterpriseId) ;
if (enterpriseSetting.getEnableAccessControl() != null && enterpriseSetting.getEnableAccessControl() == 1) {
......
......@@ -23,11 +23,12 @@
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR" />
<result column="related_id" property="relatedId" jdbcType="VARCHAR" />
<result column="audit_staff_id" property="auditStaffId" jdbcType="VARCHAR" />
<result column="commit_store_name" property="commitStoreName"/>
</resultMap>
<sql id="Base_Column_List" >
audit_id, audit_type, commit_name, commit_staff_id, commit_staff_name, commit_staff_img,
commit_store_id, change_field, old_value, new_value, commit_time, enterprise_id,
audit_name, audit_status, audit_reason, create_time, update_time, status_flag, wx_enterprise_id,related_id,audit_staff_id
audit_name, audit_status, audit_reason, create_time, update_time, status_flag, wx_enterprise_id,related_id,audit_staff_id , commit_store_name
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
......@@ -35,17 +36,14 @@
from tab_haoban_audit
where audit_id = #{auditId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from tab_haoban_audit
where audit_id = #{auditId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanAudit" >
insert into tab_haoban_audit (audit_id, audit_type, commit_name,
commit_staff_id, commit_staff_name, commit_staff_img,
commit_store_id, change_field, old_value,
new_value, commit_time, enterprise_id,
audit_name, audit_status, audit_reason,
create_time, update_time, status_flag,
create_time, update_time, status_flag, commit_store_name
wx_enterprise_id,related_id,audit_staff_id)
values (#{auditId,jdbcType=VARCHAR}, #{auditType,jdbcType=INTEGER}, #{commitName,jdbcType=VARCHAR},
#{commitStaffId,jdbcType=VARCHAR}, #{commitStaffName,jdbcType=VARCHAR}, #{commitStaffImg,jdbcType=VARCHAR},
......@@ -53,141 +51,9 @@
#{newValue,jdbcType=VARCHAR}, #{commitTime,jdbcType=TIMESTAMP}, #{enterpriseId,jdbcType=VARCHAR},
#{auditName,jdbcType=VARCHAR}, #{auditStatus,jdbcType=INTEGER}, #{auditReason,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{statusFlag,jdbcType=INTEGER},
#{wxEnterpriseId,jdbcType=VARCHAR},#{relatedId,jdbcType=VARCHAR},#{auditStaffId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanAudit" >
insert into tab_haoban_audit
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="auditId != null" >
audit_id,
</if>
<if test="auditType != null" >
audit_type,
</if>
<if test="commitName != null" >
commit_name,
</if>
<if test="commitStaffId != null" >
commit_staff_id,
</if>
<if test="commitStaffName != null" >
commit_staff_name,
</if>
<if test="commitStaffImg != null" >
commit_staff_img,
</if>
<if test="commitStoreId != null" >
commit_store_id,
</if>
<if test="changeField != null" >
change_field,
</if>
<if test="oldValue != null" >
old_value,
</if>
<if test="newValue != null" >
new_value,
</if>
<if test="commitTime != null" >
commit_time,
</if>
<if test="enterpriseId != null" >
enterprise_id,
</if>
<if test="auditName != null" >
audit_name,
</if>
<if test="auditStatus != null" >
audit_status,
</if>
<if test="auditReason != null" >
audit_reason,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="statusFlag != null" >
status_flag,
</if>
<if test="wxEnterpriseId != null" >
wx_enterprise_id,
</if>
<if test="relatedId != null" >
related_id,
</if>
<if test="auditStaffId != null" >
audit_staff_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="auditId != null" >
#{auditId,jdbcType=VARCHAR},
</if>
<if test="auditType != null" >
#{auditType,jdbcType=INTEGER},
</if>
<if test="commitName != null" >
#{commitName,jdbcType=VARCHAR},
</if>
<if test="commitStaffId != null" >
#{commitStaffId,jdbcType=VARCHAR},
</if>
<if test="commitStaffName != null" >
#{commitStaffName,jdbcType=VARCHAR},
</if>
<if test="commitStaffImg != null" >
#{commitStaffImg,jdbcType=VARCHAR},
</if>
<if test="commitStoreId != null" >
#{commitStoreId,jdbcType=VARCHAR},
</if>
<if test="changeField != null" >
#{changeField,jdbcType=VARCHAR},
</if>
<if test="oldValue != null" >
#{oldValue,jdbcType=VARCHAR},
</if>
<if test="newValue != null" >
#{newValue,jdbcType=VARCHAR},
</if>
<if test="commitTime != null" >
#{commitTime,jdbcType=TIMESTAMP},
</if>
<if test="enterpriseId != null" >
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="auditName != null" >
#{auditName,jdbcType=VARCHAR},
</if>
<if test="auditStatus != null" >
#{auditStatus,jdbcType=INTEGER},
</if>
<if test="auditReason != null" >
#{auditReason,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="statusFlag != null" >
#{statusFlag,jdbcType=INTEGER},
</if>
<if test="wxEnterpriseId != null" >
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="relatedId != null" >
#{relatedId,jdbcType=VARCHAR},
</if>
<if test="auditStaffId != null" >
#{auditStaffId,jdbcType=VARCHAR},
</if>
</trim>
#{wxEnterpriseId,jdbcType=VARCHAR},#{relatedId,jdbcType=VARCHAR},#{auditStaffId,jdbcType=VARCHAR}) , #{commitStoreName}
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanAudit" >
update tab_haoban_audit
<set >
......@@ -254,30 +120,7 @@
</set>
where audit_id = #{auditId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanAudit" >
update tab_haoban_audit
set audit_type = #{auditType,jdbcType=INTEGER},
commit_name = #{commitName,jdbcType=VARCHAR},
commit_staff_id = #{commitStaffId,jdbcType=VARCHAR},
commit_staff_name = #{commitStaffName,jdbcType=VARCHAR},
commit_staff_img = #{commitStaffImg,jdbcType=VARCHAR},
commit_store_id = #{commitStoreId,jdbcType=VARCHAR},
change_field = #{changeField,jdbcType=VARCHAR},
old_value = #{oldValue,jdbcType=VARCHAR},
new_value = #{newValue,jdbcType=VARCHAR},
commit_time = #{commitTime,jdbcType=TIMESTAMP},
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
audit_name = #{auditName,jdbcType=VARCHAR},
audit_status = #{auditStatus,jdbcType=INTEGER},
audit_reason = #{auditReason,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status_flag = #{statusFlag,jdbcType=INTEGER},
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
related_id = #{relatedId,jdbcType=VARCHAR},
audit_staff_id = #{auditStaffId,jdbcType=VARCHAR}
where audit_id = #{auditId,jdbcType=VARCHAR}
</update>
<sql id="storeSql">
<if test="null != storeIds and storeIds.size gt 0">
and commit_store_id in
......@@ -298,13 +141,7 @@
select
<include refid="Base_Column_List" />
from tab_haoban_audit
where 1=1
<if test = "wxEnterpriseId != null">
and wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
</if>
<if test = "enterpriseId != null and enterpriseId !=''">
and enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
</if>
where enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
<if test = "auditType != null">
and audit_type = #{auditType,jdbcType=INTEGER}
</if>
......@@ -317,8 +154,10 @@
<if test = "auditStatus != null">
and audit_status = #{auditStatus,jdbcType=INTEGER}
</if>
<if test=" null != searchParams">
and (commit_staff_name like '%${searchParams}%' or commit_store_name like '%${searchParams}%')
</if>
<include refid="storeSql"/>
<include refid="staffSql"/>
order by commit_time desc
</select>
......
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