Commit fd4216a2 by zhangyu

导出

parent ac2f6459
...@@ -46,5 +46,27 @@ ...@@ -46,5 +46,27 @@
AND verif_id=#{verifId} AND verif_id=#{verifId}
</if> </if>
</select> </select>
<select id="findDepartByList" resultType="com.ejweb.modules.depart.entity.DepartEntity">
SELECT
fu.id,
fu.depart_name,
fu.is_verif,
fu.is_risk,
f.depart_id
FROM `foc_user_depart_type` f
INNER JOIN foc_user_depart fu on f.depart_id = fu.id AND fu.del_flag='0'
WHERE f.del_flag = '0'
<if test="type != null and type !=''">
AND f.type=#{type}
</if>
</select>
<select id="findDepartAllList" resultType="com.ejweb.modules.depart.entity.DepartTypeEntity">
SELECT
a.id,
a.is_verif,
a.is_risk,
a.depart_name
FROM foc_user_depart a
WHERE a.del_flag = '0'
</select>
</mapper> </mapper>
\ No newline at end of file
package com.ejweb.modules.depart.api; package com.ejweb.modules.depart.api;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ejweb.core.api.RequestBean; import com.ejweb.core.api.RequestBean;
import com.ejweb.core.api.ResponseBean; import com.ejweb.core.api.ResponseBean;
import com.ejweb.core.conf.ErrorCode; import com.ejweb.core.conf.ErrorCode;
import com.ejweb.core.conf.GConstants; import com.ejweb.core.conf.GConstants;
import com.ejweb.modules.depart.bean.DepartBean; import com.ejweb.modules.depart.bean.DepartBean;
import com.ejweb.modules.depart.bean.DepartTypeBean;
import com.ejweb.modules.depart.entity.DepartEntity; import com.ejweb.modules.depart.entity.DepartEntity;
import com.ejweb.modules.depart.entity.DepartTypeEntity;
import com.ejweb.modules.depart.service.DepartService; import com.ejweb.modules.depart.service.DepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/** /**
* Airport Controller * Airport Controller
*
* @author zhanglg * @author zhanglg
* @version 2016-8-23 * @version 2016-8-23
*/ */
@Controller @Controller
@RequestMapping(value = "/api/depart") @RequestMapping(value = "/api/depart")
public class DepartController{ public class DepartController {
@Autowired @Autowired
private DepartService departService; private DepartService departService;
@ResponseBody @ResponseBody
@RequestMapping(value = "list") @RequestMapping(value = "list")
public ResponseBean list(RequestBean requestBean,BindingResult errors) { public ResponseBean list(RequestBean requestBean, BindingResult errors) {
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
DepartBean bean = requestBean.getObjectBean(DepartBean.class); DepartBean bean = requestBean.getObjectBean(DepartBean.class);
String message = departService.validate(bean,errors); String message = departService.validate(bean, errors);
if(message == null){// 通过参数校验 if (message == null) {// 通过参数校验
List<DepartEntity> list = departService.findAllList(bean.getIsVerif()); List<DepartEntity> list = departService.findAllList(bean.getIsVerif());
if(list == null){// 数据为空 if (list == null) {// 数据为空
responseBean.setMessage(GConstants.EMPTY); responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001); responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
}
responseBean.setData(list);
return responseBean; return responseBean;
} }
responseBean.setData(list); responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean; return responseBean;
}
responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
} }
@ResponseBody @ResponseBody
@RequestMapping(value = "risklist") @RequestMapping(value = "risklist")
public ResponseBean risklist(RequestBean requestBean,BindingResult errors) { public ResponseBean risklist(RequestBean requestBean, BindingResult errors) {
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
DepartBean bean = requestBean.getObjectBean(DepartBean.class); DepartBean bean = requestBean.getObjectBean(DepartBean.class);
String message = departService.validate(bean,errors); String message = departService.validate(bean, errors);
if(message == null){// 通过参数校验 if (message == null) {// 通过参数校验
List<DepartEntity> list = departService.findRiskList(bean); List<DepartEntity> list = departService.findRiskList(bean);
if(list == null){// 数据为空 if (list == null) {// 数据为空
responseBean.setMessage(GConstants.EMPTY); responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001); responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
}
responseBean.setData(list);
return responseBean; return responseBean;
} }
responseBean.setData(list); responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean; return responseBean;
}
responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
} }
@ResponseBody @ResponseBody
@RequestMapping(value = "getByuserCode") @RequestMapping(value = "getByuserCode")
public ResponseBean getByUserCode(RequestBean requestBean,BindingResult errors){ public ResponseBean getByUserCode(RequestBean requestBean, BindingResult errors) {
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
DepartBean bean = requestBean.getObjectBean(DepartBean.class); DepartBean bean = requestBean.getObjectBean(DepartBean.class);
String message = departService.validate(bean,errors); String message = departService.validate(bean, errors);
if(message == null){// 通过参数校验 if (message == null) {// 通过参数校验
DepartEntity entity= departService.getByUserCode(bean.getUserCode()); DepartEntity entity = departService.getByUserCode(bean.getUserCode());
if(entity == null){// 查询结果为空 if (entity == null) {// 查询结果为空
responseBean.setMessage(GConstants.EMPTY); responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001); responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean; return responseBean;
}else{ } else {
responseBean.setData(entity); responseBean.setData(entity);
responseBean.setMessage(GConstants.OK); responseBean.setMessage(GConstants.OK);
responseBean.setStatus(ErrorCode.STATUS_CODE_2000); responseBean.setStatus(ErrorCode.STATUS_CODE_2000);
...@@ -96,4 +100,28 @@ public class DepartController{ ...@@ -96,4 +100,28 @@ public class DepartController{
return responseBean; return responseBean;
} }
@ResponseBody
@RequestMapping(value = "departList")
public ResponseBean departList(RequestBean requestBean, BindingResult errors) {
ResponseBean responseBean = new ResponseBean();
DepartTypeBean bean = requestBean.getObjectBean(DepartTypeBean.class);
String message = departService.validate(bean, errors);
// 通过参数校验
if (message == null) {
List<DepartTypeEntity> list = departService.findDepartList(bean);
// 数据为空
if (list == null) {
responseBean.setMessage(GConstants.EMPTY);
responseBean.setStatus(ErrorCode.STATUS_CODE_2001);
return responseBean;
}
responseBean.setData(list);
return responseBean;
}
responseBean.setMessage(message);
responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
return responseBean;
}
} }
/**
*
*/
package com.ejweb.modules.depart.bean;
import com.ejweb.core.base.GenericBean;
import org.hibernate.validator.constraints.NotEmpty;
/**
*
* @team IT Team
* @author zhanglg
* @version 1.0
* @time 2016年9月9日
*/
public class DepartTypeBean extends GenericBean {
@NotEmpty(message = "type不能为空")
String type;
String verifId;
String isVerif;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getVerifId() {
return verifId;
}
public void setVerifId(String verifId) {
this.verifId = verifId;
}
public String getIsVerif() {
return isVerif;
}
public void setIsVerif(String isVerif) {
this.isVerif = isVerif;
}
}
package com.ejweb.modules.depart.dao; package com.ejweb.modules.depart.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ejweb.core.base.BaseDao; import com.ejweb.core.base.BaseDao;
import com.ejweb.modules.depart.bean.DepartBean; import com.ejweb.modules.depart.bean.DepartBean;
import com.ejweb.modules.depart.entity.DepartEntity; import com.ejweb.modules.depart.entity.DepartEntity;
import com.ejweb.modules.depart.entity.DepartTypeEntity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* *
...@@ -19,4 +19,6 @@ public interface DepartDao extends BaseDao{ ...@@ -19,4 +19,6 @@ public interface DepartDao extends BaseDao{
public List<DepartEntity> findAllList(DepartEntity departEntity); public List<DepartEntity> findAllList(DepartEntity departEntity);
public DepartEntity getByUserCode(@Param(value="userCode") String userCode); public DepartEntity getByUserCode(@Param(value="userCode") String userCode);
public List<DepartEntity> findRiskList(DepartBean bean); public List<DepartEntity> findRiskList(DepartBean bean);
public List<DepartEntity> findDepartByList(@Param(value="type") String type, @Param(value = "isVerif") String isVerif);
public List<DepartTypeEntity> findDepartAllList();
} }
\ No newline at end of file
package com.ejweb.modules.depart.entity;
import com.ejweb.core.base.BaseEntity;
/**
*
* 论证部门Entity
* @author zhanglg
* @version 2016-08-24
*/
public class DepartTypeEntity extends BaseEntity{
private static final long serialVersionUID = 1L;
private String id;
private String departName;
private String isVerif;
private String isRisk;
private Boolean check=false;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Boolean getCheck() {
return check;
}
public void setCheck(Boolean check) {
this.check = check;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getDepartName() {
return departName;
}
public void setDepartName(String departName) {
this.departName = departName;
}
public String getIsVerif() {
return isVerif;
}
public void setIsVerif(String isVerif) {
this.isVerif = isVerif;
}
public String getIsRisk() {
return isRisk;
}
public void setIsRisk(String isRisk) {
this.isRisk = isRisk;
}
}
\ No newline at end of file
package com.ejweb.modules.depart.service; package com.ejweb.modules.depart.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ejweb.core.base.BaseService; import com.ejweb.core.base.BaseService;
import com.ejweb.modules.depart.bean.DepartBean; import com.ejweb.modules.depart.bean.DepartBean;
import com.ejweb.modules.depart.bean.DepartTypeBean;
import com.ejweb.modules.depart.dao.DepartDao; import com.ejweb.modules.depart.dao.DepartDao;
import com.ejweb.modules.depart.entity.DepartEntity; import com.ejweb.modules.depart.entity.DepartEntity;
import com.ejweb.modules.depart.entity.DepartTypeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* Depart Service * Depart Service
...@@ -39,5 +40,22 @@ public class DepartService extends BaseService<DepartDao> { ...@@ -39,5 +40,22 @@ public class DepartService extends BaseService<DepartDao> {
return departDao.findRiskList(bean); return departDao.findRiskList(bean);
} }
public List<DepartTypeEntity> findDepartList(DepartTypeBean departTypeBean){
//查询所有的部门
List<DepartTypeEntity> allList = departDao.findDepartAllList();
// 根据类型type值查询对应的部门信息
String type = departTypeBean.getType();
List<DepartEntity> byList = departDao.findDepartByList(type,departTypeBean.getIsVerif());
if (byList != null) {
for (DepartTypeEntity udAll : allList) {
for (DepartEntity udBy : byList) {
if (udAll.getId() == udBy.getId() || udAll.getId().equals(udBy.getId())) {
udAll.setCheck(true);
}
}
}
}
return allList;
}
} }
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