Browse Source

部门管理superid逻辑修改

Michael 8 years ago
parent
commit
d4863abeb5

+ 6 - 0
src/main/java/com/goafanti/common/dao/OrganizationManagementMapper.java

@@ -103,4 +103,10 @@ public interface OrganizationManagementMapper {
 	int updateByNumber(OrganizationListOut olo);
 	
 	int selectCountBySuperId(String superId);
+	
+	String selectIdByName(String name);
+	
+	String selectNameById(String id);
+	
+	String selectDepNoById(String id);
 }

+ 21 - 0
src/main/java/com/goafanti/common/mapper/OrganizationManagementMapper.xml

@@ -541,4 +541,25 @@
 		where
 		super_id=#{superId,jdbcType=VARCHAR}
   	</select>
+  	<select id="selectIdByName" parameterType="java.lang.String" resultType="java.lang.String">
+  		select
+  		id
+  		from department_management 		
+  		where
+  		name=#{name,jdbcType=VARCHAR} 		
+  	</select>
+  	<select id="selectNameById" parameterType="java.lang.String" resultType="java.lang.String">
+  		select
+  		name
+  		from department_management 		
+  		where
+  		id=#{id,jdbcType=VARCHAR} 		
+  	</select>
+  	<select id="selectDepNoById" resultType="String">
+		select
+		dep_no as depNo
+		from department_management
+		where
+		id=#{id,jdbcType=VARCHAR}
+	</select>
 </mapper>

+ 4 - 4
src/main/java/com/goafanti/organization/controller/OrganizationManagementController.java

@@ -16,7 +16,7 @@ import com.goafanti.organization.bo.OrganizationListOut;
 import com.goafanti.organization.service.OrganizationService;
 
 @RestController
-@RequestMapping("api/admin/organization")
+@RequestMapping("open/api/admin/organization")
 public class OrganizationManagementController extends BaseApiController{
 	@Resource
 	private OrganizationService organizationService;
@@ -91,9 +91,9 @@ public class OrganizationManagementController extends BaseApiController{
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "id"));
 			return res;
 		}
-		OrganizationListOut olo=organizationManagementMapper.selectAllById(id);
-		String superId=olo.getName();
-		int subordinate=organizationManagementMapper.selectCountBySuperId(superId);
+		/*OrganizationListOut olo=organizationManagementMapper.selectAllById(id);
+		String superId=olo.getName();*/
+		int subordinate=organizationManagementMapper.selectCountBySuperId(id);
 		if(subordinate>0){
 			res.getError().add(buildError("","存在下级组织不能删除"));
 			return res;

+ 17 - 9
src/main/java/com/goafanti/organization/service/impl/OrganizationServiceImpl.java

@@ -28,8 +28,13 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 		/*olo.setCreateId(TokenManager.getAdminId());*/
 		Map<String,Object> params =disposeParams(olo);
 		@SuppressWarnings("unchecked")
-		Pagination<OrganizationListOut> list=(Pagination<OrganizationListOut>)findPage("selectOrganizationList","selectOrganizationCount",params,pageNo,pageSize);
-		return list;
+		Pagination<OrganizationListOut> p=(Pagination<OrganizationListOut>)findPage("selectOrganizationList","selectOrganizationCount",params,pageNo,pageSize);
+		@SuppressWarnings("unchecked")
+		List<OrganizationListOut> list=(List<OrganizationListOut>) p.getList();
+		for(OrganizationListOut i:list){
+			i.setSuperId(organizationManagementMapper.selectNameById(i.getSuperId()));
+		}
+		return p;
 	}
 	private Map<String,Object> disposeParams(OrganizationListOut olo){
 		Map<String,Object> params = new HashMap<String, Object>();		
@@ -97,6 +102,7 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 			}
 			om.setDepNo(dep);
 		}
+		superId=organizationManagementMapper.selectIdByName(superId);
 		om.setSuperId(superId);
 		om.setRemarks(remarks);
 		om.setStatus("0");
@@ -111,6 +117,7 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 	@Override
 	public OrganizationListOut selectAllById(String id) {
 		OrganizationListOut olo=organizationManagementMapper.selectAllById(id);
+		olo.setSuperId(organizationManagementMapper.selectNameById(olo.getSuperId()));
 		return olo;
 	}
 	@Override
@@ -127,8 +134,8 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 		om.setType(type);
 		om.setUpdateTime(now);
 		om.setManagerId(managerId);
-		om.setSuperId(superId);
 		String sdepNo=organizationManagementMapper.selectDepNoByName(superId);
+		superId=organizationManagementMapper.selectIdByName(superId);
 		int Count=organizationManagementMapper.selectDepNoCount(superId);
 		if(Count<10){
 			String dep=sdepNo+"0"+Count;
@@ -154,15 +161,16 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 			}
 			om.setDepNo(dep);
 		}
+		om.setSuperId(superId);
 		om.setStatus(status);
 		om.setRemarks(remarks);
 		om.setId(id);
 		organizationManagementMapper.updateByPrimaryKeySelective(om);
 		//*******下级编号修改
 		int n=0;
-		List<OrganizationListOut> Nos =organizationManagementMapper.selectIDNBySuperId(name);
+		List<OrganizationListOut> Nos =organizationManagementMapper.selectIDNBySuperId(id);
 		for(OrganizationListOut i:Nos){			
-			sdepNo=organizationManagementMapper.selectDepNoByName(i.getSuperId());
+			sdepNo=organizationManagementMapper.selectDepNoById(i.getSuperId());
 			if(n<10){
 				String dep=sdepNo+"0"+n;			
 				if(n>=10){
@@ -182,10 +190,10 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 			
 			//*******下下级编号修改
 			int m=0;
-			List<OrganizationListOut> Noss =organizationManagementMapper.selectIDNBySuperId(i.getName());
+			List<OrganizationListOut> Noss =organizationManagementMapper.selectIDNBySuperId(i.getId());
 			System.out.println("noss="+Noss);
 			for(OrganizationListOut o:Noss){			
-				sdepNo=organizationManagementMapper.selectDepNoByName(o.getSuperId());
+				sdepNo=organizationManagementMapper.selectDepNoById(o.getSuperId());
 				if(m<10){
 					String dep=sdepNo+"0"+m;			
 					if(m>=10){
@@ -205,9 +213,9 @@ public class OrganizationServiceImpl extends BaseMybatisDao<OrganizationManageme
 				
 				//*******下下级编号修改
 				int z=0;
-				List<OrganizationListOut> Nosss =organizationManagementMapper.selectIDNBySuperId(o.getName());
+				List<OrganizationListOut> Nosss =organizationManagementMapper.selectIDNBySuperId(o.getId());
 				for(OrganizationListOut p:Nosss){			
-					sdepNo=organizationManagementMapper.selectDepNoByName(p.getSuperId());
+					sdepNo=organizationManagementMapper.selectDepNoById(p.getSuperId());
 					if(z<10){
 						String dep=sdepNo+"0"+z;			
 						if(z>=10){