Commit d70f60aa by qwmqiuwenmin

fix

parent 195005bc
......@@ -46,6 +46,8 @@ public class DepartmentDTO implements Serializable {
private String relatedCode;
private String gicEnterpriseName;
private String enterpriseId;
private static final long serialVersionUID = 1L;
......@@ -216,6 +218,14 @@ public class DepartmentDTO implements Serializable {
public void setGicEnterpriseName(String gicEnterpriseName) {
this.gicEnterpriseName = gicEnterpriseName;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
......
......@@ -49,4 +49,6 @@ public interface DepartmentMapper {
List<TabHaobanDepartment> listByChainId(@Param("chainId")String chainId, @Param("wxEnterpriseId")String wxEnterpriseId);
Integer departmentRecycleCount(@Param("wxEnterpriseId")String wxEnterpriseId);
int countSyncDepartmentByEnterpriseId(@Param("enterpriseId")String enterpriseId);
}
\ No newline at end of file
......@@ -35,6 +35,8 @@ public class TabHaobanDepartment implements Serializable {
private String wxEnterpriseId;
private String relatedCode;
private String enterpriseId;
private static final long serialVersionUID = 1L;
......@@ -165,6 +167,14 @@ public class TabHaobanDepartment implements Serializable {
public void setRelatedCode(String relatedCode) {
this.relatedCode = relatedCode;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
}
\ No newline at end of file
......@@ -38,4 +38,6 @@ public interface DepartmentService {
Integer departmentRecycleCount(String wxEnterpriseId);
int countSyncDepartmentByEnterpriseId(String enterpriseId);
}
......@@ -149,4 +149,9 @@ public class DepartmentServiceImpl implements DepartmentService {
return mapper.departmentRecycleCount(wxEnterpriseId);
}
@Override
public int countSyncDepartmentByEnterpriseId(String enterpriseId) {
return mapper.countSyncDepartmentByEnterpriseId(enterpriseId);
}
}
......@@ -21,6 +21,10 @@ import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreGroupDTO;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.PageUtil;
......@@ -66,6 +70,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
@Autowired
private WxApplicationService wxApplicationService;
@Autowired
private StoreService storeService;
@Autowired
private StoreGroupService storeGroupService;
@Override
public List<DepartmentDTO> listByParentId(String parentId) {
......@@ -115,6 +125,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
logger.info("【部门新增】wxDepartmentId = {}",wxDepartmentId);
department.setWxDepartmentId(wxDepartmentId);
department.setLevel(parent.getLevel() + 1);
setGicEnterpriseId(department);
String departmentId = departmentService.add(department);
department.setDepartmentId(departmentId);
hr.setResult(department);
......@@ -124,6 +135,28 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
return hr;
}
private void setGicEnterpriseId(DepartmentDTO department) {
String relatedId = department.getRelatedId();
if(StringUtils.isNotBlank(relatedId)){
Integer storeFlag = department.getIsStore();
if(storeFlag == 1){
StoreDTO store = storeService.getStore(relatedId);
if(store != null){
department.setEnterpriseId(store.getEnterpriseId());
}
}else{
com.gic.enterprise.api.dto.DepartmentDTO departmentDTO = gicDepartmentService.getDeptment(relatedId);
if(departmentDTO != null){
department.setEnterpriseId(departmentDTO.getEnterpriseId());
}
StoreGroupDTO storeGroup = storeGroupService.getStoreGroupById(relatedId);
if(storeGroup != null){
department.setEnterpriseId(storeGroup.getEnterpriseId());
}
}
}
}
@Override
public HaobanResponse edit(DepartmentDTO department) {
HaobanResponse hr = new HaobanResponse();
......
......@@ -38,15 +38,10 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
List<TabHaobanWxEnterpriseRelated> relatedList = wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId);
List<EnterpriseDetailDTO> result = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, relatedList);
for (EnterpriseDetailDTO enterpriseDetailDTO : result) {
// String enterpriseId = enterpriseDetailDTO.getEnterpriseId();
int nodeCount = 0;
// List<GicTreeDTO> departmentList = storeGroupService.listGicTree(enterpriseId,null, null);
// for (GicTreeDTO gicTreeDTO : departmentList) {
// if(departmentService.getByRelatedId(gicTreeDTO.getId()) == null) {
// nodeCount ++;
// }
// nodeCount += getNodeCount(enterpriseId,gicTreeDTO.getId(),gicTreeDTO.getType());
// }
String enterpriseId = enterpriseDetailDTO.getEnterpriseId();
int gicAllCount = storeGroupService.gicDepartmentCount(enterpriseId);
int syncCount = departmentService.countSyncDepartmentByEnterpriseId(enterpriseId);
int nodeCount = gicAllCount - syncCount;
enterpriseDetailDTO.setNodeCount(nodeCount);
}
return result;
......
......@@ -16,12 +16,13 @@
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="wx_department_id" property="wxDepartmentId" jdbcType="VARCHAR" />
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR" />
<result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR" />
<result column="sort" property="sort" jdbcType="INTEGER" />
<result column="level" property="level" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
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,enterprise_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
......@@ -37,11 +38,11 @@
insert into tab_haoban_department (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)
update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name,enterprise_id)
values (#{departmentId,jdbcType=VARCHAR}, #{departmentName,jdbcType=VARCHAR}, #{parentDepartmentId,jdbcType=VARCHAR},
#{relatedId,jdbcType=VARCHAR},#{relatedCode,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR}, #{isStore,jdbcType=INTEGER},
#{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},#{enterpriseId})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" >
insert into tab_haoban_department
......@@ -85,6 +86,12 @@
<if test="wxDepartmentId != null" >
wx_department_id,
</if>
<if test="wxEnterpriseId != null" >
wx_enterprise_id,
</if>
<if test="enterpriseId != null" >
enterprise_id,
</if>
<if test="sort != null" >
sort,
</if>
......@@ -132,6 +139,12 @@
<if test="wxDepartmentId != null" >
#{wxDepartmentId},
</if>
<if test="wxEnterpriseId != null" >
#{wxEnterpriseId},
</if>
<if test="enterpriseId != null" >
#{enterpriseId},
</if>
<if test="sort != null" >
#{sort},
</if>
......@@ -182,6 +195,9 @@
<if test="wxEnterpriseId != null" >
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null" >
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="sort != null" >
sort = #{sort,jdbcType=INTEGER},
</if>
......@@ -208,7 +224,8 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
wx_enterprise_id = #{wxEnterpriseId}
wx_enterprise_id = #{wxEnterpriseId},
enterprise_id = #{enterpriseId}
where department_id = #{departmentId,jdbcType=VARCHAR}
</update>
......@@ -391,4 +408,11 @@
and recycle_flag = 1
</select>
<select id="countSyncDepartmentByEnterpriseId" resultType="java.lang.Integer" parameterType="java.lang.String" >
select
count(1)
from tab_haoban_department
where enterprise_id = #{enterpriseId}
and status_flag = 1
</select>
</mapper>
\ No newline at end of file
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