完整的
public QueryResult listProject(String year,String allotId,Pager pager,String regionNo){
String yearString=null;
if(isNotBlank(year)){
year = year.replace("\"", "");
}
if(isNotBlank(year)){
yearString = year.substring(0, 4);
}
String region = "";//需要获取登录用户所属区,待接口
if(!BizCodeTypeConstants.SHANGHAI.equals(regionNo)){
// Region dicRegion = RegionUtils.getInstance().getCacheRegionBycode(BizCodeTypeConstants.ISSTANDARD,regionNo);//拿到的是用户区划code,数据库业务表存的id,转一下
region = regionNo;
}
Cnd cnd = Cnd.NEW();
cnd.where().setTop(false);
and(cnd,"a.BSHX0042","=",yearString);
and(cnd,"a.ALLOT_ID","=",allotId);
and(cnd,"b.PARENT_CODE","=",region);
Sql sql = Sqls.create("select a.* from DFJG_PROJECT a,dc_region b where a.BSHA0008 = b.id and $cnd");
sql.setPager(pager);
sql.setCallback(Sqls.callback.entities());
sql.setEntity(dao.getEntity(DfjgProjectDO.class));
sql.setVar("cnd",cnd);
dao.execute(sql);
Long count = Daos.queryCount(dao,sql);
List<DfjgProjectDO> list = sql.getList(DfjgProjectDO.class);
List<DfjgProjectVO> listVO = new ArrayList<DfjgProjectVO>();
if (list != null) {
for (int i=0;i<list.size();i++){
DfjgProjectDO dfjgProjectDO = list.get(i);
DfjgProjectVO vo = new DfjgProjectVO();
vo.setId(dfjgProjectDO.getId());//项目ID
vo.setYear(dfjgProjectDO.getYear());
vo.setPlanName(dfjgProjectDO.getPlanName());//项目名称
DfjgQuotaAllotDO dfjgQuotaAllotDO = getIssuedDefine(dfjgProjectDO.getAllotId());
vo.setQuotaName(dfjgQuotaAllotDO.getQuotaName());//指标名称
vo.setAddress(dfjgProjectDO.getAddress());//地址
if(dfjgProjectDO.getCivilMan() != null){
vo.setLinkMan(dfjgProjectDO.getCivilMan());//如果是医疗机构指标 set区联系人
vo.setContactNum(dfjgProjectDO.getCivilPhone());
}else{
vo.setLinkMan(dfjgProjectDO.getLinkMan());//联系人
vo.setContactNum(dfjgProjectDO.getContactNum());
}
String progress = sumProjectProgress(dfjgProjectDO.getId(),dfjgProjectDO.getAllotId());
vo.setEndPlan(progress);
if(region == ""){
Region regionById = RegionUtils.getInstance().getCacheRegionById(BizCodeTypeConstants.ISSTANDARD,dfjgProjectDO.getRegion());
Region area = RegionUtils.getInstance().getCacheRegionBycode(BizCodeTypeConstants.ISSTANDARD,regionById.getParentCode());
vo.setAreaName(area.getName());
}
listVO.add(vo);
}
}
QueryResult qr = new QueryResult();
qr.setList(listVO);
pager.setRecordCount(count.intValue());
qr.setPager(pager);
return qr;
}