Browse Source

1.组织用户需求详情;
2.需求管理-获取组织用户下拉;
3.需求管理-获取个人用户下拉

Antiloveg 8 years ago
parent
commit
a286665252

+ 73 - 37
src/main/java/com/goafanti/admin/controller/AdminDemandApiController.java

@@ -1,7 +1,7 @@
 package com.goafanti.admin.controller;
 
-
 import java.util.Arrays;
+import java.util.List;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -25,33 +25,67 @@ import com.goafanti.common.model.Demand;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.demand.bo.InputDemand;
 import com.goafanti.demand.service.DemandService;
+import com.goafanti.user.service.UserService;
 
 @RestController
 @RequestMapping(value = "/api/admin/demand")
 public class AdminDemandApiController extends CertifyApiController {
 	@Resource
-	private DemandService demandService;
-	
-	
+	private DemandService	demandService;
+	@Resource
+	private UserService		userService;
+
+	/**
+	 * 需求管理--获取组织用户下拉
+	 */
+	@RequestMapping(value = "/unitNames", method = RequestMethod.GET)
+	public Result getUnitNames() {
+		Result res = new Result();
+		res.setData(userService.selectDemandUnitNames());
+		return res;
+	}
 	
 	/**
+	 * 需求管理--获取个人用户下拉
+	 */
+	@RequestMapping(value = "/userNames", method = RequestMethod.GET)
+	public Result getUserNames() {
+		Result res = new Result();
+		res.setData(userService.selectDemandUserNames());
+		return res;
+	}
+
+	/**
+	 * 组织用户详情
+	 */
+	@RequestMapping(value = "/orgDemandDetail", method = RequestMethod.GET)
+	public Result orgDemandDetail(String id) {
+		Result res = new Result();
+
+		if (StringUtils.isBlank(id)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
+			return res;
+		}
+
+		res.setData(demandService.selectOrgDemandDetail(id));
+		return res;
+	}
+
+	/**
 	 * 个人需求详情
 	 */
-	@RequestMapping(value = "/userDemandDeatail", method = RequestMethod.GET)
-	public Result userDemandDetail(String id){
+	@RequestMapping(value = "/userDemandDetail", method = RequestMethod.GET)
+	public Result userDemandDetail(String id) {
 		Result res = new Result();
-		
-		if (StringUtils.isBlank(id)){
+
+		if (StringUtils.isBlank(id)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
 			return res;
 		}
-		
+
 		res.setData(demandService.selectUserDemandDetail(id));
 		return res;
 	}
-	
-	
-	
 
 	/**
 	 * 个人用户--需求列表
@@ -81,7 +115,8 @@ public class AdminDemandApiController extends CertifyApiController {
 	 * 个人用户新增需求
 	 */
 	@RequestMapping(value = "/userApply", method = RequestMethod.POST)
-	public Result userApply(@Valid InputDemand demand, BindingResult bindingResult, String validityPeriodFormattedDate) {
+	public Result userApply(@Valid InputDemand demand, BindingResult bindingResult,
+			String validityPeriodFormattedDate) {
 		Result res = new Result();
 		if (bindingResult.hasErrors()) {
 			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
@@ -89,38 +124,39 @@ public class AdminDemandApiController extends CertifyApiController {
 			return res;
 		}
 		res = disposeDemand(res, demand);
-		if (!res.getError().isEmpty()){
+		if (!res.getError().isEmpty()) {
 			return res;
 		}
-		
+
 		Demand d = new Demand();
 		BeanUtils.copyProperties(demand, d);
 		demandService.saveUserDemandByManager(d, validityPeriodFormattedDate);
 		return res;
 	}
-	
+
 	/**
 	 * 修改个人用户需求
 	 */
 	@RequestMapping(value = "/userUpdate", method = RequestMethod.POST)
-	public Result updateUser(@Valid InputDemand demand, BindingResult bindingResult, String validityPeriodFormattedDate){
+	public Result updateUser(@Valid InputDemand demand, BindingResult bindingResult,
+			String validityPeriodFormattedDate) {
 		Result res = new Result();
 		if (bindingResult.hasErrors()) {
 			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
 					DemandFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
 		}
-		
-		if (StringUtils.isBlank(demand.getId())){
+
+		if (StringUtils.isBlank(demand.getId())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
 			return res;
 		}
-		
+
 		res = disposeDemand(res, demand);
-		if (!res.getError().isEmpty()){
+		if (!res.getError().isEmpty()) {
 			return res;
 		}
-		
+
 		Demand d = new Demand();
 		BeanUtils.copyProperties(demand, d);
 		res.setData(demandService.updateUserDemandByManager(d, validityPeriodFormattedDate));
@@ -150,18 +186,18 @@ public class AdminDemandApiController extends CertifyApiController {
 				releaseDateStartDate, releaseDateEndDate, pNo, pSize));
 		return res;
 	}
-	
+
 	/**
 	 * 需求资料--图片上传
 	 */
 	@RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
 	public Result uploadPicture(HttpServletRequest req, String sign, String uid) {
 		Result res = new Result();
-		if (StringUtils.isBlank(uid)){
+		if (StringUtils.isBlank(uid)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
 			return res;
 		}
-		
+
 		AttachmentType attachmentType = AttachmentType.getField(sign);
 
 		if (attachmentType == AttachmentType.DEMAND_PICTURE) {
@@ -169,22 +205,22 @@ public class AdminDemandApiController extends CertifyApiController {
 		} else {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
 		}
-		
+
 		return res;
 	}
-	
+
 	/**
 	 * 需求资料--文本文件上传
 	 */
 	@RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
-	public Result uploadTextFile(HttpServletRequest req, String sign, String uid){
+	public Result uploadTextFile(HttpServletRequest req, String sign, String uid) {
 		Result res = new Result();
-	
-		if (StringUtils.isBlank(uid)){
+
+		if (StringUtils.isBlank(uid)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
 			return res;
 		}
-		
+
 		AttachmentType attachmentType = AttachmentType.getField(sign);
 
 		if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
@@ -194,12 +230,12 @@ public class AdminDemandApiController extends CertifyApiController {
 		}
 		return res;
 	}
-	
+
 	/**
 	 * 删除需求(个人&团体)
 	 */
 	@RequestMapping(value = "/delete", method = RequestMethod.POST)
-	public Result delete(@RequestParam(name = "ids[]", required = false) String[] ids){
+	public Result delete(@RequestParam(name = "ids[]", required = false) String[] ids) {
 		Result res = new Result();
 		if (ids == null || ids.length < 1) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
@@ -208,14 +244,14 @@ public class AdminDemandApiController extends CertifyApiController {
 		}
 		return res;
 	}
-	
-	private Result disposeDemand(Result res, InputDemand demand){
+
+	private Result disposeDemand(Result res, InputDemand demand) {
 		if (StringUtils.isBlank(demand.getName())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求名称", "需求名称"));
 			return res;
 		}
-		
-		if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())){
+
+		if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "数据类型"));
 			return res;
 		}

+ 2 - 0
src/main/java/com/goafanti/common/dao/DemandMapper.java

@@ -21,4 +21,6 @@ public interface DemandMapper {
 	DemandManageDetailBo selectUserDemandDetail(String id);
 
 	int batchDeleteByPrimaryKey(List<String> id);
+
+	DemandManageDetailBo selectOrgDemandDetail(String id);
 }

+ 7 - 0
src/main/java/com/goafanti/common/dao/OrganizationIdentityMapper.java

@@ -8,6 +8,7 @@ import com.goafanti.user.bo.OrgBasicInfoBo;
 import com.goafanti.user.bo.OrgIdentityBo;
 import com.goafanti.user.bo.OrgIdentityDetailBo;
 import com.goafanti.user.bo.OrgUnitNames;
+import com.goafanti.user.bo.UserNames;
 
 public interface OrganizationIdentityMapper {
     int deleteByPrimaryKey(String id);
@@ -33,4 +34,10 @@ public interface OrganizationIdentityMapper {
 	OrgIdentityDetailBo selectOrgIdentityDetailByUserId(String uid);
 
 	AuditorOrgIdentityDetailBo selectAuditorOrgIdentityDetailByUserId(String uid);
+
+	List<OrgUnitNames> selectManagerUnitNames(String aid);
+
+	List<UserNames> selectManagerUserNames(String aid);
+
+	List<UserNames> selectAllUserNames(String aid);
 }

+ 24 - 1
src/main/java/com/goafanti/common/mapper/DemandMapper.xml

@@ -700,13 +700,36 @@
   		d.industry_category_b as industryCategoryB, d.problem_des as problemDes, d.technical_requirements as technicalRequirements,
   		d.picture_url as pictureUrl, d.text_file_url as textFileUrl, d.video_url as videoUrl,
   		d.budget_cost as budgetCost, d.fixed_cycle as fixedCycle, d.people_number as peopleNumber,
-  		d.fixed_scheme as fixedScheme, d.cost_escrow as costEscrow, d.employer_id as employerId
+  		d.fixed_scheme as fixedScheme, d.cost_escrow as costEscrow, d.employer_id as employerId,
+  		info.postal_address as address, u.email as mailbox,  u.mobile as mobile
   	from demand d 
   	left join user_identity ui on ui.uid = d.employer_id
   	left join admin a on a.id = d.principal_id
+  	left join user_info info on info.uid = d.employer_id
+  	left join user u on u.id = d.employer_id
   	where d.data_category = 0 and d.id = #{id,jdbcType=VARCHAR}
   </select>
   
+  
+   <select id="selectOrgDemandDetail" parameterType="java.lang.String" resultType="com.goafanti.demand.bo.DemandManageDetailBo">
+  	select 
+  		d.id, d.serial_number as serialNumber, d.data_category as dataCategory,
+  		d.name, d.keyword, d.info_sources as infoSources,
+  		oi.unit_name as username, d.demand_type as demandType, d.validity_period as validityPeriod,
+  		oi.licence_province as province, d.status, d.release_status as releaseStatus,
+  		d.release_date as releaseDate, a.name as principalId, d.industry_category_a as industryCategoryA,
+  		d.industry_category_b as industryCategoryB, d.problem_des as problemDes, d.technical_requirements as technicalRequirements,
+  		d.picture_url as pictureUrl, d.text_file_url as textFileUrl, d.video_url as videoUrl,
+  		d.budget_cost as budgetCost, d.fixed_cycle as fixedCycle, d.people_number as peopleNumber,
+  		d.fixed_scheme as fixedScheme, d.cost_escrow as costEscrow, d.employer_id as employerId,
+  		oi.postal_address as address, u.email as mailbox,  oi.contacts 
+  	from demand d 
+  	left join organization_identity oi on oi.uid = d.employer_id
+  	left join admin a on a.id = d.principal_id
+  	left join user u on u.id = d.employer_id
+  	where d.data_category = 1 and d.id = #{id,jdbcType=VARCHAR}
+  </select>
+  
   <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
   	update demand set deleted_sign = 1
   	where  id in 

+ 39 - 0
src/main/java/com/goafanti/common/mapper/OrganizationIdentityMapper.xml

@@ -1111,6 +1111,45 @@
 		LEFT JOIN organization_identity oi on oi.uid = u.id
 		where uid = #{uid,jdbcType=VARCHAR}
 	</select>
+	
+	<select id="selectManagerUnitNames" resultType="com.goafanti.user.bo.OrgUnitNames"
+		parameterType="java.lang.String">
+		select u.id as uid, i.unit_name as unitName
+		from user u INNER JOIN
+		organization_identity i on u.id = i.uid and u.lvl = 1
+		and
+		i.audit_status = 5
+		where 1 = 1
+		<if test="_parameter != null">
+			and u.mid = #{aid,jdbcType=VARCHAR}
+		</if>
+	</select>
+	
+	<select id="selectManagerUserNames" resultType="com.goafanti.user.bo.UserNames"
+		parameterType="java.lang.String">
+		select u.id as uid, i.username
+		from user u INNER JOIN
+		user_identity i on u.id = i.uid and u.lvl = 1
+		and
+		i.audit_status = 5
+		where 1 = 1
+		<if test="_parameter != null">
+			and u.mid = #{aid,jdbcType=VARCHAR}
+		</if>
+	</select>
+	
+	<select id="selectAllUserNames" resultType="com.goafanti.user.bo.UserNames"
+		parameterType="java.lang.String">
+		select u.id as uid, i.username
+		from user u INNER JOIN
+		user_identity i on u.id = i.uid and u.lvl = 1
+		and
+		i.audit_status = 5
+		where 1 = 1
+		<if test="_parameter != null">
+			and u.aid = #{aid,jdbcType=VARCHAR}
+		</if>
+	</select>
 
 
 </mapper>

+ 42 - 1
src/main/java/com/goafanti/demand/bo/DemandManageDetailBo.java

@@ -33,6 +33,15 @@ public class DemandManageDetailBo extends DemandManageListBo {
 
 	private String		employerId;
 
+	private String		address;
+
+	private String		contactsName;
+
+	private String		mobile;
+
+	private String		mailbox;
+
+
 	@JsonFormat(shape = Shape.STRING)
 	public Integer getIndustryCategoryA() {
 		return industryCategoryA;
@@ -41,7 +50,7 @@ public class DemandManageDetailBo extends DemandManageListBo {
 	public void setIndustryCategoryA(Integer industryCategoryA) {
 		this.industryCategoryA = industryCategoryA;
 	}
-	
+
 	@JsonFormat(shape = Shape.STRING)
 	public Integer getIndustryCategoryB() {
 		return industryCategoryB;
@@ -138,6 +147,38 @@ public class DemandManageDetailBo extends DemandManageListBo {
 	public void setEmployerId(String employerId) {
 		this.employerId = employerId;
 	}
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	public String getContactsName() {
+		return contactsName;
+	}
+
+	public void setContactsName(String contactsName) {
+		this.contactsName = contactsName;
+	}
+
+	public String getMobile() {
+		return mobile;
+	}
+
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+
+	public String getMailbox() {
+		return mailbox;
+	}
+
+	public void setMailbox(String mailbox) {
+		this.mailbox = mailbox;
+	}
 	
 	
 

+ 2 - 0
src/main/java/com/goafanti/demand/service/DemandService.java

@@ -27,4 +27,6 @@ public interface DemandService {
 
 	int deleteByPrimaryKey(List<String> asList);
 
+	DemandManageDetailBo selectOrgDemandDetail(String id);
+
 }

+ 5 - 0
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -364,4 +364,9 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 	public int deleteByPrimaryKey(List<String> id) {
 		return demandMapper.batchDeleteByPrimaryKey(id);
 	}
+
+	@Override
+	public DemandManageDetailBo selectOrgDemandDetail(String id) {
+		return demandMapper.selectOrgDemandDetail(id);
+	}
 }

+ 27 - 0
src/main/java/com/goafanti/user/bo/UserNames.java

@@ -0,0 +1,27 @@
+package com.goafanti.user.bo;
+
+public class UserNames {
+
+	private String	uid;
+
+	private String	username;
+
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+	
+	
+
+}

+ 6 - 0
src/main/java/com/goafanti/user/service/UserService.java

@@ -6,8 +6,10 @@ import java.util.List;
 import com.goafanti.common.model.User;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.user.bo.OrgListBo;
+import com.goafanti.user.bo.OrgUnitNames;
 import com.goafanti.user.bo.UserDownLoadBo;
 import com.goafanti.user.bo.UserListBo;
+import com.goafanti.user.bo.UserNames;
 import com.goafanti.user.bo.UserPageHomeBo;
 
 public interface UserService {
@@ -36,4 +38,8 @@ public interface UserService {
 
 	List<OrgListBo> selectUserByAid(String adminId);
 
+	List<OrgUnitNames> selectDemandUnitNames();
+
+	List<UserNames> selectDemandUserNames();
+
 }

+ 29 - 0
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -20,9 +20,12 @@ import com.goafanti.common.model.User;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.user.bo.OrgListBo;
+import com.goafanti.user.bo.OrgUnitNames;
 import com.goafanti.user.bo.UserDownLoadBo;
 import com.goafanti.user.bo.UserListBo;
+import com.goafanti.user.bo.UserNames;
 import com.goafanti.user.bo.UserPageHomeBo;
 import com.goafanti.user.service.UserService;
 
@@ -216,6 +219,32 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 		return userMapper.selectUserByAid(aid);
 	}
 
+	@Override
+	public List<OrgUnitNames> selectDemandUnitNames() {
+		String aid = TokenManager.getAdminId();
+		if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)){
+			return organizationIdentityMapper.selectManagerUnitNames(aid);
+		} else {
+			if (TokenManager.hasRole(AFTConstants.SUPERADMIN)){
+				aid = null;
+			}
+			return organizationIdentityMapper.selectAllOrgIndentity(aid);
+		}
+	}
+
+	@Override
+	public List<UserNames> selectDemandUserNames() {
+		String aid = TokenManager.getAdminId();
+		if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)){
+			return organizationIdentityMapper.selectManagerUserNames(aid);
+		} else {
+			if (TokenManager.hasRole(AFTConstants.SUPERADMIN)){
+				aid = null;
+			}
+			return organizationIdentityMapper.selectAllUserNames(aid);
+		}
+	}
+