Commit c25c57d6 by 陶光胜

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

parents c6e7bc9b 1229a6c9
...@@ -42,6 +42,10 @@ public class DepartmentDTO implements Serializable { ...@@ -42,6 +42,10 @@ public class DepartmentDTO implements Serializable {
private String storeCode; private String storeCode;
private Integer bindFlag; private Integer bindFlag;
private String relatedCode;
private String gicEnterpriseName;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -196,6 +200,22 @@ public class DepartmentDTO implements Serializable { ...@@ -196,6 +200,22 @@ public class DepartmentDTO implements Serializable {
public void setBindFlag(Integer bindFlag) { public void setBindFlag(Integer bindFlag) {
this.bindFlag = bindFlag; this.bindFlag = bindFlag;
} }
public String getRelatedCode() {
return relatedCode;
}
public void setRelatedCode(String relatedCode) {
this.relatedCode = relatedCode;
}
public String getGicEnterpriseName() {
return gicEnterpriseName;
}
public void setGicEnterpriseName(String gicEnterpriseName) {
this.gicEnterpriseName = gicEnterpriseName;
}
......
...@@ -18,4 +18,12 @@ public interface WxApplicationApiService { ...@@ -18,4 +18,12 @@ public interface WxApplicationApiService {
* @param suiteId * @param suiteId
*/ */
void cancelSuite(String corpId, String suiteId); void cancelSuite(String corpId, String suiteId);
/**
*
* @param wxEnterpriseId
* @param type
* @return
*/
WxApplicationDTO selectByWxEnterpriseIdAndApplicationType(String wxEnterpriseId, int type);
} }
...@@ -33,6 +33,8 @@ public class TabHaobanDepartment implements Serializable { ...@@ -33,6 +33,8 @@ public class TabHaobanDepartment implements Serializable {
private Integer sort; private Integer sort;
private String wxEnterpriseId; private String wxEnterpriseId;
private String relatedCode;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -155,6 +157,14 @@ public class TabHaobanDepartment implements Serializable { ...@@ -155,6 +157,14 @@ public class TabHaobanDepartment implements Serializable {
public void setChainName(String chainName) { public void setChainName(String chainName) {
this.chainName = chainName; this.chainName = chainName;
} }
public String getRelatedCode() {
return relatedCode;
}
public void setRelatedCode(String relatedCode) {
this.relatedCode = relatedCode;
}
} }
\ No newline at end of file
...@@ -37,7 +37,7 @@ public class StaffServiceImpl implements StaffService { ...@@ -37,7 +37,7 @@ public class StaffServiceImpl implements StaffService {
tab.setUpdateTime(now); tab.setUpdateTime(now);
tab.setStaffId(StringUtil.randomUUID()); tab.setStaffId(StringUtil.randomUUID());
tab.setStatusFlag(1); tab.setStatusFlag(1);
if(StringUtils.isBlank(tab.getStaffId())){ if(StringUtils.isBlank(tab.getWxUserId())){
tab.setWxUserId(tab.getStaffId()); tab.setWxUserId(tab.getStaffId());
} }
mapper.insertSelective(tab); mapper.insertSelective(tab);
......
...@@ -91,6 +91,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -91,6 +91,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO)); logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO));
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { if(application != null) {
Integer sort = department.getSort();
if(sort == null) {
int maxSort = departmentMapper.selectMaxSort(department.getParentDepartmentId());
department.setSort(maxSort + 1);
}
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO(); com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
dto.setCorpid(enterpriseDTO.getCorpid()); dto.setCorpid(enterpriseDTO.getCorpid());
dto.setName(department.getDepartmentName()); dto.setName(department.getDepartmentName());
...@@ -157,6 +163,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -157,6 +163,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
hr.setErrorCode(1); hr.setErrorCode(1);
List<TabHaobanDepartment> list = departmentService.listByParentId(departmentId); List<TabHaobanDepartment> list = departmentService.listByParentId(departmentId);
logger.info("【部门删除】list.size={}",list.size());
if(!list.isEmpty()) { if(!list.isEmpty()) {
hr.setErrorCode(0); hr.setErrorCode(0);
hr.setMessage("存在子部门,删除部门失败"); hr.setMessage("存在子部门,删除部门失败");
...@@ -164,6 +171,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -164,6 +171,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
} }
List<TabHaobanStaffDepartmentRelated> staffList = staffDepartmentService.listByDepartmentId(departmentId); List<TabHaobanStaffDepartmentRelated> staffList = staffDepartmentService.listByDepartmentId(departmentId);
logger.info("【部门删除】staffList.size={}",staffList.size());
if(!staffList.isEmpty()) { if(!staffList.isEmpty()) {
hr.setErrorCode(0); hr.setErrorCode(0);
hr.setMessage("存在成员,删除部门失败"); hr.setMessage("存在成员,删除部门失败");
...@@ -198,6 +206,22 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -198,6 +206,22 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
public HaobanResponse recycle(String departmentId) { public HaobanResponse recycle(String departmentId) {
HaobanResponse hr = new HaobanResponse(); HaobanResponse hr = new HaobanResponse();
hr.setErrorCode(1); hr.setErrorCode(1);
List<TabHaobanDepartment> list = departmentService.listByParentId(departmentId);
logger.info("【部门删除】list.size={}",list.size());
if(!list.isEmpty()) {
hr.setErrorCode(0);
hr.setMessage("存在子部门,删除部门失败");
return hr;
}
List<TabHaobanStaffDepartmentRelated> staffList = staffDepartmentService.listByDepartmentId(departmentId);
logger.info("【部门删除】staffList.size={}",staffList.size());
if(!staffList.isEmpty()) {
hr.setErrorCode(0);
hr.setMessage("存在成员,删除部门失败");
return hr;
}
//调微信的新增接口 //调微信的新增接口
TabHaobanDepartment department = departmentService.selectById(departmentId); TabHaobanDepartment department = departmentService.selectById(departmentId);
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
......
...@@ -75,6 +75,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -75,6 +75,7 @@ public class MessageApiServiceImpl implements MessageApiService {
departmentDTO.setDepartmentName(dto.getName()); departmentDTO.setDepartmentName(dto.getName());
departmentDTO.setIsStore(dto.getType() != GicDataType.STORE.getCode() ? 0 : 1); departmentDTO.setIsStore(dto.getType() != GicDataType.STORE.getCode() ? 0 : 1);
departmentDTO.setRelatedId(dto.getId()); departmentDTO.setRelatedId(dto.getId());
log.info("【部门同步】dto={}",JSON.toJSONString(dto));
DepartmentDTO parentDepartment = this.getParentDepartment(dto.getParentChain(), dto.getType(), enterprise.getWxEnterpriseId()); DepartmentDTO parentDepartment = this.getParentDepartment(dto.getParentChain(), dto.getType(), enterprise.getWxEnterpriseId());
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId()); departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId(parentDepartment.getChainId()+ Constant.ID_SEPARATOR + parentDepartment.getDepartmentId()); departmentDTO.setChainId(parentDepartment.getChainId()+ Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
...@@ -110,6 +111,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -110,6 +111,7 @@ public class MessageApiServiceImpl implements MessageApiService {
@Override @Override
public void dealWxMessage(String param) { public void dealWxMessage(String param) {
QywxCallBackDTO dto = JSON.parseObject(param, QywxCallBackDTO.class); QywxCallBackDTO dto = JSON.parseObject(param, QywxCallBackDTO.class);
log.info("【处理微信回调】dto={}",JSON.toJSONString(dto));
if(dto.getChangeType().endsWith("party")){ if(dto.getChangeType().endsWith("party")){
this.dealDepartment(dto); this.dealDepartment(dto);
}else { }else {
...@@ -121,18 +123,22 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -121,18 +123,22 @@ public class MessageApiServiceImpl implements MessageApiService {
DepartmentDTO departmentDTO = new DepartmentDTO(); DepartmentDTO departmentDTO = new DepartmentDTO();
departmentDTO.setDepartmentName(qywxCallBackDTO.getDepartmentName()); departmentDTO.setDepartmentName(qywxCallBackDTO.getDepartmentName());
departmentDTO.setIsStore(0); departmentDTO.setIsStore(0);
departmentDTO.setRelatedId(qywxCallBackDTO.getId()+""); //departmentDTO.setRelatedId(qywxCallBackDTO.getId()+"");
TabHaobanWxEnterprise enterprise = this.enterpriseService.getEnterpriseBycorpId(qywxCallBackDTO.getAuthCorpId()); TabHaobanWxEnterprise enterprise = this.enterpriseService.getEnterpriseBycorpId(qywxCallBackDTO.getAuthCorpId());
TabHaobanDepartment parentDepartment = this.departmentService.getByWxId(qywxCallBackDTO.getParentId() + "", enterprise.getWxEnterpriseId()); TabHaobanDepartment parentDepartment = this.departmentService.getByWxId(qywxCallBackDTO.getParentId() + "", enterprise.getWxEnterpriseId());
if(parentDepartment == null){ if(!qywxCallBackDTO.getChangeType().equals(WxEditType.DELETEDEPART.getCode())){
return; if(parentDepartment == null){
log.info("微信同步父部门不存在");
return;
}
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId(parentDepartment.getChainId()+ Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
departmentDTO.setChainName(parentDepartment.getChainName() + Constant.NAME_SEPARATOR + parentDepartment.getChainName());
departmentDTO.setLevel(parentDepartment.getLevel() + 1);
} }
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId(parentDepartment.getChainId()+ Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
departmentDTO.setChainName(parentDepartment.getChainName() + Constant.NAME_SEPARATOR + parentDepartment.getChainName());
departmentDTO.setLevel(parentDepartment.getLevel() + 1);
departmentDTO.setWxEnterpriseId(enterprise.getWxEnterpriseId()); departmentDTO.setWxEnterpriseId(enterprise.getWxEnterpriseId());
departmentDTO.setWxDepartmentId(qywxCallBackDTO.getId()+""); departmentDTO.setWxDepartmentId(qywxCallBackDTO.getId()+"");
departmentDTO.setSort(qywxCallBackDTO.getOrder());
if(qywxCallBackDTO.getChangeType().equals(WxEditType.ADDDEPART.getCode())){ if(qywxCallBackDTO.getChangeType().equals(WxEditType.ADDDEPART.getCode())){
String response = this.departmentService.add(departmentDTO); String response = this.departmentService.add(departmentDTO);
log.info("微信同步新增部门:{}", JSON.toJSONString(response)); log.info("微信同步新增部门:{}", JSON.toJSONString(response));
...@@ -151,7 +157,11 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -151,7 +157,11 @@ public class MessageApiServiceImpl implements MessageApiService {
if(department == null){ if(department == null){
log.info("微信同步删除部门不存在"); log.info("微信同步删除部门不存在");
}else { }else {
this.departmentService.del(departmentDTO.getDepartmentId()); if(StringUtils.isBlank(department.getRelatedId())){
this.departmentService.del(department.getDepartmentId());
}else{
this.departmentApiService.recycle(department.getDepartmentId());
}
log.info("企业微信删除同步完成"); log.info("企业微信删除同步完成");
} }
} }
......
...@@ -92,6 +92,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -92,6 +92,7 @@ public class StaffApiServiceImpl implements StaffApiService {
HaobanResponse hr = new HaobanResponse(); HaobanResponse hr = new HaobanResponse();
hr.setErrorCode(1); hr.setErrorCode(1);
Integer activeFlag = staff.getActiveFlag(); Integer activeFlag = staff.getActiveFlag();
staff.setActiveFlag(0);
TabHaobanStaff tab = EntityUtil.changeEntityByJSON(TabHaobanStaff.class, staff); TabHaobanStaff tab = EntityUtil.changeEntityByJSON(TabHaobanStaff.class, staff);
String staffId = staffService.add(tab); String staffId = staffService.add(tab);
//调接口获取 //调接口获取
...@@ -203,9 +204,11 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -203,9 +204,11 @@ public class StaffApiServiceImpl implements StaffApiService {
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { if(application != null) {
JSONResponse jp = qywxUserApiService.deleteWorkWxUser(enterpriseDTO.getCorpid(), application.getSiteId(), staff.getWxUserId()); JSONResponse jp = qywxUserApiService.deleteWorkWxUser(enterpriseDTO.getCorpid(), application.getSiteId(), staff.getWxUserId());
logger.info("【删除成员】jp={}",JSON.toJSONString(jp));
} }
} }
staffDepartmentRelatedService.del(related); staffDepartmentRelatedService.del(related);
staffService.delByuserid(relatedList.get(0).getStaffId());
//走修改流程 //走修改流程
}else { }else {
String departmentIds = ""; String departmentIds = "";
...@@ -246,6 +249,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -246,6 +249,7 @@ public class StaffApiServiceImpl implements StaffApiService {
tab.setNickName(user.getName()); tab.setNickName(user.getName());
tab.setNationCode("86"); tab.setNationCode("86");
tab.setSex(Integer.parseInt(user.getGender())); tab.setSex(Integer.parseInt(user.getGender()));
tab.setActiveFlag(1);
String staffId = staffService.add(tab); String staffId = staffService.add(tab);
Integer[] departmentId = user.getDepartment(); Integer[] departmentId = user.getDepartment();
......
...@@ -39,4 +39,9 @@ public class WxApplicationApiServiceImpl implements WxApplicationApiService{ ...@@ -39,4 +39,9 @@ public class WxApplicationApiServiceImpl implements WxApplicationApiService{
} }
log.info("企业未绑定过,{}", corpId); log.info("企业未绑定过,{}", corpId);
} }
@Override
public WxApplicationDTO selectByWxEnterpriseIdAndApplicationType(String wxEnterpriseId, int type) {
return EntityUtil.changeEntityByJSON(WxApplicationDTO.class, wxApplicationService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, type));
}
} }
...@@ -38,44 +38,38 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi ...@@ -38,44 +38,38 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
List<TabHaobanWxEnterpriseRelated> relatedList = wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId); List<TabHaobanWxEnterpriseRelated> relatedList = wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId);
List<EnterpriseDetailDTO> result = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, relatedList); List<EnterpriseDetailDTO> result = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, relatedList);
for (EnterpriseDetailDTO enterpriseDetailDTO : result) { for (EnterpriseDetailDTO enterpriseDetailDTO : result) {
String enterpriseId = enterpriseDetailDTO.getEnterpriseId(); // String enterpriseId = enterpriseDetailDTO.getEnterpriseId();
int nodeCount = 0; int nodeCount = 0;
// List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,1, null); // List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,null, null);
// for (GicTreeDTO gicTreeDTO : departmentList) { // for (GicTreeDTO gicTreeDTO : departmentList) {
// if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) { // if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
// nodeCount ++; // nodeCount ++;
// } // }
// nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType()); // nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
// } // }
// List<GicTreeDTO> departmentList2 = storeGroupService.listGicTree(enterpriseId,2, null);
// for (GicTreeDTO gicTreeDTO : departmentList2) {
// if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
// nodeCount ++;
// }
// nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
// }
enterpriseDetailDTO.setNodeCount(nodeCount); enterpriseDetailDTO.setNodeCount(nodeCount);
} }
return result; return result;
} }
public int getNodeCount(String enterpriseId,String parentId,int type) { // public int getNodeCount(String enterpriseId,String parentId,int type) {
int nodeCount = 0; // int nodeCount = 0;
List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,type, parentId); // List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,type, parentId);
for (GicTreeDTO gicTreeDTO : departmentList) { // for (GicTreeDTO gicTreeDTO : departmentList) {
if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) { // if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
nodeCount ++; // nodeCount ++;
} // }
} // List<GicTreeDTO> departmentList2 = storeGroupService.listGicTree(enterpriseId,gicTreeDTO.getType(), gicTreeDTO.getId());
// while(!departmentList2.isEmpty()) {
while(departmentList.isEmpty()) { // for (GicTreeDTO gicTreeDTO2 : departmentList) {
for (GicTreeDTO gicTreeDTO : departmentList) { // nodeCount += getNodeCount(enterpriseId,gicTreeDTO2.getId(),gicTreeDTO2.getType());
nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType()); // }
} // }
} // }
return nodeCount; //
// return nodeCount;
} //
// }
@Override @Override
public int wxEnterpriseBind(String enterpriseId, String wxEnterpriseId, public int wxEnterpriseBind(String enterpriseId, String wxEnterpriseId,
String version) { String version) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<result column="department_name" property="departmentName" jdbcType="VARCHAR" /> <result column="department_name" property="departmentName" jdbcType="VARCHAR" />
<result column="parent_department_id" property="parentDepartmentId" jdbcType="VARCHAR" /> <result column="parent_department_id" property="parentDepartmentId" jdbcType="VARCHAR" />
<result column="related_id" property="relatedId" jdbcType="VARCHAR" /> <result column="related_id" property="relatedId" jdbcType="VARCHAR" />
<result column="related_code" property="relatedCode" jdbcType="VARCHAR" />
<result column="chain_id" property="chainId" jdbcType="VARCHAR" /> <result column="chain_id" property="chainId" jdbcType="VARCHAR" />
<result column="chain_name" property="chainName" jdbcType="VARCHAR" /> <result column="chain_name" property="chainName" jdbcType="VARCHAR" />
<result column="is_store" property="isStore" jdbcType="INTEGER" /> <result column="is_store" property="isStore" jdbcType="INTEGER" />
...@@ -19,7 +20,7 @@ ...@@ -19,7 +20,7 @@
<result column="level" property="level" jdbcType="INTEGER" /> <result column="level" property="level" jdbcType="INTEGER" />
</resultMap> </resultMap>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
department_id, department_name, parent_department_id, related_id, chain_id, is_store, department_id, department_name, parent_department_id, related_id, related_code,chain_id, is_store,
status_flag, recycle_flag, create_time, update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name status_flag, recycle_flag, create_time, update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name
</sql> </sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
...@@ -34,11 +35,11 @@ ...@@ -34,11 +35,11 @@
</delete> </delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" > <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" >
insert into tab_haoban_department (department_id, department_name, parent_department_id, insert into tab_haoban_department (department_id, department_name, parent_department_id,
related_id, chain_id, is_store, related_id,related_code, chain_id, is_store,
status_flag, recycle_flag, create_time, status_flag, recycle_flag, create_time,
update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name) update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name)
values (#{departmentId,jdbcType=VARCHAR}, #{departmentName,jdbcType=VARCHAR}, #{parentDepartmentId,jdbcType=VARCHAR}, values (#{departmentId,jdbcType=VARCHAR}, #{departmentName,jdbcType=VARCHAR}, #{parentDepartmentId,jdbcType=VARCHAR},
#{relatedId,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR}, #{isStore,jdbcType=INTEGER}, #{relatedId,jdbcType=VARCHAR},#{relatedCode,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR}, #{isStore,jdbcType=INTEGER},
#{statusFlag,jdbcType=INTEGER}, #{recycleFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{statusFlag,jdbcType=INTEGER}, #{recycleFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},#{wxDepartmentId},#{sort},#{level},#{wxEnterpriseId},#{chainName}) #{updateTime,jdbcType=TIMESTAMP},#{wxDepartmentId},#{sort},#{level},#{wxEnterpriseId},#{chainName})
</insert> </insert>
...@@ -57,6 +58,9 @@ ...@@ -57,6 +58,9 @@
<if test="relatedId != null" > <if test="relatedId != null" >
related_id, related_id,
</if> </if>
<if test="relatedCode != null" >
related_code,
</if>
<if test="chainId != null" > <if test="chainId != null" >
chain_id, chain_id,
</if> </if>
...@@ -101,6 +105,9 @@ ...@@ -101,6 +105,9 @@
<if test="relatedId != null" > <if test="relatedId != null" >
#{relatedId,jdbcType=VARCHAR}, #{relatedId,jdbcType=VARCHAR},
</if> </if>
<if test="relatedCode != null" >
#{relatedCode,jdbcType=VARCHAR},
</if>
<if test="chainId != null" > <if test="chainId != null" >
#{chainId,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR},
</if> </if>
...@@ -145,6 +152,9 @@ ...@@ -145,6 +152,9 @@
<if test="relatedId != null" > <if test="relatedId != null" >
related_id = #{relatedId,jdbcType=VARCHAR}, related_id = #{relatedId,jdbcType=VARCHAR},
</if> </if>
<if test="relatedCode != null" >
related_code = #{relatedCode,jdbcType=VARCHAR},
</if>
<if test="chainId != null" > <if test="chainId != null" >
chain_id = #{chainId,jdbcType=VARCHAR}, chain_id = #{chainId,jdbcType=VARCHAR},
</if> </if>
...@@ -186,6 +196,7 @@ ...@@ -186,6 +196,7 @@
set department_name = #{departmentName,jdbcType=VARCHAR}, set department_name = #{departmentName,jdbcType=VARCHAR},
parent_department_id = #{parentDepartmentId,jdbcType=VARCHAR}, parent_department_id = #{parentDepartmentId,jdbcType=VARCHAR},
related_id = #{relatedId,jdbcType=VARCHAR}, related_id = #{relatedId,jdbcType=VARCHAR},
related_code = #{relatedCode,jdbcType=VARCHAR},
chain_id = #{chainId,jdbcType=VARCHAR}, chain_id = #{chainId,jdbcType=VARCHAR},
chain_name = #{chainName,jdbcType=VARCHAR}, chain_name = #{chainName,jdbcType=VARCHAR},
wx_department_id = #{wxDepartmentId,jdbcType=VARCHAR}, wx_department_id = #{wxDepartmentId,jdbcType=VARCHAR},
...@@ -245,7 +256,7 @@ ...@@ -245,7 +256,7 @@
and wx_enterprise_id = #{wxEnterpriseId} and wx_enterprise_id = #{wxEnterpriseId}
</if> </if>
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
and department_name like CONCAT('%',#{keyword},'%') and (department_name like CONCAT('%',#{keyword},'%') or wx_department_id like CONCAT('%',#{keyword},'%') or related_code like CONCAT('%',#{keyword},'%'))
</if> </if>
<if test="recycleFlag != null"> <if test="recycleFlag != null">
and recycle_flag = #{recycleFlag} and recycle_flag = #{recycleFlag}
...@@ -253,6 +264,7 @@ ...@@ -253,6 +264,7 @@
<if test="storeFlag != null"> <if test="storeFlag != null">
and is_store = #{storeFlag} and is_store = #{storeFlag}
</if> </if>
order by sort asc
</select> </select>
<select id="listByDepartmentIds" resultMap="BaseResultMap" > <select id="listByDepartmentIds" resultMap="BaseResultMap" >
...@@ -351,13 +363,14 @@ ...@@ -351,13 +363,14 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from tab_haoban_department from tab_haoban_department
where status_flag = 1 where status_flag = 1
and recycle_flag != 1
<if test="parentId != null and parentId != ''"> <if test="parentId != null and parentId != ''">
and parent_department_id = #{parentId} and parent_department_id = #{parentId}
</if> </if>
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
and (department_name like CONCAT('%',#{keyword},'%') or department_id like CONCAT('%',#{keyword},'%')) and (department_name like CONCAT('%',#{keyword},'%') or wx_department_id like CONCAT('%',#{keyword},'%'))
</if> </if>
order by sort asc
</select> </select>
......
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
from tab_haoban_staff from tab_haoban_staff
where status_flag = 1 where status_flag = 1
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
and (staff_name like CONCAT('%',#{keyWord},'%') or phone_number like CONCAT('%',#{keyWord},'%')) and (staff_name like CONCAT('%',#{keyword},'%') or phone_number like CONCAT('%',#{keyword},'%'))
</if> </if>
<if test="activeFlag != null"> <if test="activeFlag != null">
and active_flag = #{activeFlag} and active_flag = #{activeFlag}
......
...@@ -16,8 +16,11 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,8 +16,11 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.GicTreeDTO; import com.gic.enterprise.api.dto.GicTreeDTO;
import com.gic.enterprise.api.dto.StoreDTO; import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreGroupDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreGroupService; import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreService; import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
...@@ -37,6 +40,8 @@ import com.gic.haoban.manage.web.vo.LoginVO; ...@@ -37,6 +40,8 @@ import com.gic.haoban.manage.web.vo.LoginVO;
import com.gic.haoban.manage.web.vo.StoreVo; import com.gic.haoban.manage.web.vo.StoreVo;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import okhttp3.internal.http2.ErrorCode;
@RestController @RestController
public class DepartmentContoller extends WebBaseController{ public class DepartmentContoller extends WebBaseController{
...@@ -50,6 +55,9 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -50,6 +55,9 @@ public class DepartmentContoller extends WebBaseController{
private StoreService storeService; private StoreService storeService;
@Autowired @Autowired
private StaffApiService staffApiService; private StaffApiService staffApiService;
@Autowired
private EnterpriseService enterpriseService;
@RequestMapping("department-list") @RequestMapping("department-list")
public HaobanResponse departmentList(String parentId,BasePageInfo pageInfo,String keyWord) { public HaobanResponse departmentList(String parentId,BasePageInfo pageInfo,String keyWord) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser(); LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
...@@ -100,9 +108,28 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -100,9 +108,28 @@ public class DepartmentContoller extends WebBaseController{
list.add(dto); list.add(dto);
} }
for (DepartmentDTO departmentDTO : list) { for (DepartmentDTO departmentDTO : list) {
if(StringUtils.isBlank(departmentDTO.getRelatedId())){ String relatedId = departmentDTO.getRelatedId();
if(StringUtils.isBlank(relatedId)){
departmentDTO.setBindFlag(0); departmentDTO.setBindFlag(0);
}else{ }else{
String gicEnterpriseName = "";
String gicEnterpriseId = "";
if(departmentDTO.getIsStore() == 1){
StoreDTO store = storeService.getStore(relatedId);
if(store != null){
gicEnterpriseId = store.getEnterpriseId();
}
}else{
StoreGroupDTO department = storeGroupService.getStoreGroupById(relatedId);
if(department != null){
gicEnterpriseId = department.getEnterpriseId();
}
}
EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(gicEnterpriseId);
if(enterprise != null){
gicEnterpriseName = enterprise.getEnterpriseName();
}
departmentDTO.setGicEnterpriseName(gicEnterpriseName);
departmentDTO.setBindFlag(1); departmentDTO.setBindFlag(1);
} }
} }
...@@ -127,9 +154,12 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -127,9 +154,12 @@ public class DepartmentContoller extends WebBaseController{
department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId()); department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId());
department.setIsStore(0); department.setIsStore(0);
department.setLevel(dto.getLevel() + 1); department.setLevel(dto.getLevel() + 1);
departmentApiService.add(department); HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1){
return resultResponse(HaoBanErrCode.ERR_DEFINE, hr.getMessage(), null, hr.getMessage());
}
return resultResponse(HaoBanErrCode.ERR_1,department); return resultResponse(HaoBanErrCode.ERR_1,hr.getResult());
} }
...@@ -139,7 +169,7 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -139,7 +169,7 @@ public class DepartmentContoller extends WebBaseController{
if(dto == null || dto.getStatusFlag() == 0) { if(dto == null || dto.getStatusFlag() == 0) {
return resultResponse(HaoBanErrCode.ERR_10001); return resultResponse(HaoBanErrCode.ERR_10001);
} }
dto.setDepartmentName(dto.getDepartmentName()); dto.setDepartmentName(departmentName);
departmentApiService.edit(dto); departmentApiService.edit(dto);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
...@@ -183,7 +213,7 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -183,7 +213,7 @@ public class DepartmentContoller extends WebBaseController{
} }
if(hr.getErrorCode() == 0) { if(hr.getErrorCode() == 0) {
return resultResponse(HaoBanErrCode.ERR_0, hr.getMessage()); return resultResponse(HaoBanErrCode.ERR_0, hr.getMessage(),null,hr.getMessage());
} }
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
...@@ -207,8 +237,13 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -207,8 +237,13 @@ public class DepartmentContoller extends WebBaseController{
} }
Integer type = departmentAddQO.getType(); Integer type = departmentAddQO.getType();
Integer isStore = 0; Integer isStore = 0;
String storeCode = "";
if(type != null && type == 3){ if(type != null && type == 3){
isStore = 1; isStore = 1;
StoreDTO store = storeService.getStore(departmentAddQO.getRelatedId());
if(store != null){
storeCode = store.getStoreCode();
}
} }
DepartmentDTO department = new DepartmentDTO(); DepartmentDTO department = new DepartmentDTO();
department.setParentDepartmentId(parentId); department.setParentDepartmentId(parentId);
...@@ -225,6 +260,7 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -225,6 +260,7 @@ public class DepartmentContoller extends WebBaseController{
department.setSort(departmentAddQO.getSort()); department.setSort(departmentAddQO.getSort());
department.setLevel(dto.getLevel() + 1); department.setLevel(dto.getLevel() + 1);
department.setRelatedId(departmentAddQO.getRelatedId()); department.setRelatedId(departmentAddQO.getRelatedId());
department.setStoreCode(storeCode);
HaobanResponse hr = departmentApiService.add(department); HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1) { if(hr.getErrorCode() != 1) {
continue; continue;
...@@ -381,8 +417,13 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -381,8 +417,13 @@ public class DepartmentContoller extends WebBaseController{
for (DepartmentAddQO departmentAddQO : list) { for (DepartmentAddQO departmentAddQO : list) {
Integer type = departmentAddQO.getType(); Integer type = departmentAddQO.getType();
Integer isStore = 0; Integer isStore = 0;
String storeCode = "";
if(type != null && type == 3){ if(type != null && type == 3){
isStore = 1; isStore = 1;
StoreDTO store = storeService.getStore(departmentAddQO.getRelatedId());
if(store != null){
storeCode = store.getStoreCode();
}
} }
String sonParentId = ""; String sonParentId = "";
DepartmentDTO dto = departmentApiService.selectById(parentId); DepartmentDTO dto = departmentApiService.selectById(parentId);
...@@ -411,6 +452,7 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -411,6 +452,7 @@ public class DepartmentContoller extends WebBaseController{
department.setIsStore(isStore); department.setIsStore(isStore);
} }
department.setRelatedId(departmentAddQO.getRelatedId()); department.setRelatedId(departmentAddQO.getRelatedId());
department.setStoreCode(storeCode);
HaobanResponse hr = departmentApiService.add(department); HaobanResponse hr = departmentApiService.add(department);
if(hr.getErrorCode() != 1) { if(hr.getErrorCode() != 1) {
continue; continue;
......
...@@ -86,6 +86,18 @@ public class LoginController extends WebBaseController{ ...@@ -86,6 +86,18 @@ public class LoginController extends WebBaseController{
} }
@RequestMapping("login_local")
public HaobanResponse login() {
LoginVO loginVO = new LoginVO();
StaffDTO staff = staffApiService.selectById("1");
logger.info("【好办登录】staff={}",JSON.toJSONString(staff));
loginVO.setWxEnterpriseId(staff.getWxEnterpriseId());
loginVO.setStaffDTO(staff);
AuthRequestUtil.setSessionUser(loginVO);
return resultResponse(HaoBanErrCode.ERR_1,loginVO);
}
@RequestMapping("get-login-info") @RequestMapping("get-login-info")
public HaobanResponse getLoginInfo(){ public HaobanResponse getLoginInfo(){
LoginVO loginVO = (LoginVO) AuthRequestUtil.getSessionUser(); LoginVO loginVO = (LoginVO) AuthRequestUtil.getSessionUser();
......
...@@ -18,15 +18,18 @@ import com.gic.haoban.common.utils.HaobanResponse; ...@@ -18,15 +18,18 @@ import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO; import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO; import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO; import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService; 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.StaffDepartmentRelatedApiService; import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.web.auth.AuthRequestUtil; import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.StaffEditJsonQO; import com.gic.haoban.manage.web.qo.StaffEditJsonQO;
import com.gic.haoban.manage.web.vo.LoginVO; import com.gic.haoban.manage.web.vo.LoginVO;
import com.google.gson.JsonArray; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.squareup.moshi.Json;
@RestController @RestController
...@@ -39,6 +42,12 @@ public class StaffController extends WebBaseController{ ...@@ -39,6 +42,12 @@ public class StaffController extends WebBaseController{
private DepartmentApiService departmentApiService; private DepartmentApiService departmentApiService;
@Autowired @Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService; private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private WxApplicationApiService wxApplicationApiService;
@RequestMapping("staff-add") @RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO,String departmentIds){ public HaobanResponse staffAdd(StaffDTO staffDTO,String departmentIds){
...@@ -131,6 +140,32 @@ public class StaffController extends WebBaseController{ ...@@ -131,6 +140,32 @@ public class StaffController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
@RequestMapping("staff-invite")
public HaobanResponse staffInvite(String staffIds){
if(StringUtils.isBlank(staffIds)){
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffArr = staffIds.split(",");
List<String> userArr = new ArrayList<>();
String wxEnterpriseId = "";
for (String staffId : staffArr) {
StaffDTO staff = staffApiService.selectById(staffId);
if(staff != null){
String userId = staff.getWxUserId();
wxEnterpriseId = staff.getWxEnterpriseId();
userArr.add(userId);
}
}
WxEnterpriseDTO enterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,1);
if(enterpriseDTO != null) {
if(application != null) {
qywxUserApiService.inviteUser(enterpriseDTO.getCorpid(), application.getSiteId(), userArr);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-batch-edit-department") @RequestMapping("staff-batch-edit-department")
public HaobanResponse staffBatchEditDepartment(String params){ public HaobanResponse staffBatchEditDepartment(String params){
......
...@@ -38,6 +38,7 @@ public class WebBaseController { ...@@ -38,6 +38,7 @@ public class WebBaseController {
public HaobanResponse resultResponse(HaoBanErrCode errCode, String message,Object data,String detailError) { public HaobanResponse resultResponse(HaoBanErrCode errCode, String message,Object data,String detailError) {
HaobanResponse response = new HaobanResponse(); HaobanResponse response = new HaobanResponse();
response.setMessage(message); response.setMessage(message);
response.setDetailError(detailError);
response.setErrorCode(errCode.getCode()); response.setErrorCode(errCode.getCode());
return response; return response;
} }
......
...@@ -13,6 +13,8 @@ public class DepartmentEditQO implements Serializable{ ...@@ -13,6 +13,8 @@ public class DepartmentEditQO implements Serializable{
private String departmentName; private String departmentName;
private Integer sort; private Integer sort;
private String parentDepartmentId;
public String getDepartmentId() { public String getDepartmentId() {
return departmentId; return departmentId;
...@@ -23,7 +25,7 @@ public class DepartmentEditQO implements Serializable{ ...@@ -23,7 +25,7 @@ public class DepartmentEditQO implements Serializable{
} }
public String getParentId() { public String getParentId() {
return parentId; return parentDepartmentId;
} }
public void setParentId(String parentId) { public void setParentId(String parentId) {
...@@ -53,6 +55,14 @@ public class DepartmentEditQO implements Serializable{ ...@@ -53,6 +55,14 @@ public class DepartmentEditQO implements Serializable{
public void setSort(Integer sort) { public void setSort(Integer sort) {
this.sort = sort; this.sort = sort;
} }
public String getParentDepartmentId() {
return parentDepartmentId;
}
public void setParentDepartmentId(String parentDepartmentId) {
this.parentDepartmentId = parentDepartmentId;
}
......
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