use of com.bc.pmpheep.back.vo.WriterUserManagerVO in project pmph by BCSquad.
the class MigrationStageSix method declaration.
/**
* 作家申报表
*/
protected void declaration() {
// 要迁移的旧库表名
String tableName = "writer_declaration";
// 增加new_pk字段
JdbcHelper.addColumn(tableName);
String sql = "select wd.writerid,wd.materid,wd.writername,s.usercode,s.username," + "wd.sex,wd.birthdate,wd.seniority,wd.duties,wd.positional,wd.address," + "wd.postcode,wd.handset,wd.email,wd.idcardtype," + "IFNULL(wd.idcardtype,0) idcardtype," + "wd.idcard,wd.linktel,wd.fax,tm.new_pk tm_materid," + "s.new_pk sys_userid,wd.unitid,bo.new_pk org_id,wd.workunit,bo.orgcode," + "case when wd.submittype=10 then 0 " + "when wd.submittype=11 and ta.auditstate=10 then 1 " + "when ta.auditstate=12 and wd.submittype=11 then 2 " + "when ta.auditstate=11 and wd.submittype=11 then 3 " + "when wd.submittype=11 then 1 " + "when wd.submittype=12 then 2 " + "end online_progress,wd.submittype,ta.auditstate,ta.auditdate," + "case when eup.new_pk is not null then eup.new_pk else null " + "end auth_user_id," + "case when ta.isreceivedpaper=1 then 2 " + "when ta.isreceivedpaper=0 then 0 " + "when ta.isreceivedpaper is null then 0 " + "end offline_progress," + "ta.isreceivedpaper,ta.editauditstate," + "case when wd.submittype=10 then 1 " + "else 0 end is_staging,wd.submittype,ta.editauditdate," + "wd.userid,s.sysflag,su.usertype " + "from writer_declaration wd " + "left join teach_material tm on tm.materid=wd.materid " + "left join ba_organize bo on bo.orgid=wd.unitid " + "left join sys_user s on s.userid=wd.userid " + "left join sys_userext su on su.userid=wd.userid " + "left join (select writerid,auditstate,auditid,editauditid,auditdate," + "isreceivedpaper,editauditstate,editauditdate " + "from teach_applyposition group by writerid) ta " + "left join sys_user eup on eup.userid = ta.editauditid " + "on ta.writerid=wd.writerid ";
// 查询所有数据
List<Map<String, Object>> maps = JdbcHelper.getJdbcTemplate().queryForList(sql);
// 迁移成功的条目数
int count = 0;
int materialidCount = 0;
int sysflagCount = 0;
int usertypeCount = 0;
int useridCount = 0;
int decCount = 0;
int realNameCount = 0;
List<Map<String, Object>> excel = new LinkedList<>();
Map<String, Object> result = new LinkedHashMap<>();
// 统计正常数据的数量
int correctCount = 0;
// 判断该数据是否有相应异常情况的标识
int[] state = { 0, 0, 0, 0, 0, 0, 0 };
StringBuilder reason = new StringBuilder();
StringBuilder dealWith = new StringBuilder();
/* 开始遍历查询结果 */
for (Map<String, Object> map : maps) {
StringBuilder sb = new StringBuilder();
// 旧表主键值
String id = (String) map.get("writerid");
// 教材id
Long materialid = (Long) map.get("tm_materid");
// 作家id
Long userid = (Long) map.get("sys_userid");
// 申报表作家姓名
String realName = (String) map.get("writername");
// 性别
String sexJudge = (String) map.get("sex");
// 教龄
String experienceNum = (String) map.get("seniority");
// 邮编
String postCode = (String) map.get("postcode");
// 申报单位id
Long orgId = (Long) map.get("org_id");
// 审核进度
Long onlineProgressJudge = (Long) map.get("online_progress");
// 审核人id
Long authUserid = (Long) map.get("auth_user_id");
// 纸质表进度
Long offlineProgressJudge = (Long) map.get("offline_progress");
// 是否暂存
Long isStagingJudge = (Long) map.get("is_staging");
// 旧表申报单位id
String unitid = (String) map.get("unitid");
// 0为后台用户,1为前台用户
Integer sysflag = (Integer) map.get("sysflag");
// 2为学校管理员
Integer usertype = (Integer) map.get("usertype");
// 机构代码去除空格截取
// 机构代码
String orgcode = (String) map.get("orgcode");
String orgCodes = null;
if (orgcode != null && !orgcode.equals("") && orgcode.length() > 3) {
// 去除空格截取
orgCodes = orgcode.trim().substring(0, 3);
}
if (ObjectUtil.isNull(sysflag) || sysflag.equals(0)) {
map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("找到为后台用户申报教材。"));
excel.add(map);
logger.debug("找到为后台用户申报教材,此结果将被记录在Excel中");
sysflagCount++;
if (state[0] == 0) {
reason.append("申报教材的对应人员为社内用户。");
dealWith.append("放弃迁移。");
state[0] = 1;
}
continue;
}
if (usertype.equals(2)) {
map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("找到为用户类型为学校管理员申报教材。"));
excel.add(map);
logger.debug("找到为用户类型为学校管理员申报教材,此结果将被记录在Excel中");
usertypeCount++;
if (state[1] == 0) {
reason.append("申报教材的对应人员为机构管理员用户。");
dealWith.append("放弃迁移。");
state[1] = 1;
}
continue;
}
Declaration declaration = new Declaration();
if (ObjectUtil.isNull(materialid) || materialid.intValue() == 0) {
map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("未找到教材对应的关联结果。"));
excel.add(map);
logger.debug("未找到教材对应的关联结果,此结果将被记录在Excel中");
materialidCount++;
if (state[2] == 0) {
reason.append("找不到用户申报的教材。");
dealWith.append("放弃迁移。");
state[2] = 1;
}
continue;
}
declaration.setMaterialId(materialid);
if (ObjectUtil.isNull(userid) || userid.intValue() == 0) {
map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("未找到作家对应的关联结果。"));
excel.add(map);
logger.debug("未找到作家对应的关联结果,此结果将被记录在Excel中");
useridCount++;
if (state[3] == 0) {
reason.append("找不到申报人员是哪一位用户。");
dealWith.append("放弃迁移。");
state[3] = 1;
}
continue;
} else {
if ("7d4856e6-99ca-48fb-9205-3704c01a109e".equals(id)) {
WriterUserManagerVO vo = new WriterUserManagerVO();
vo.setUsername("18045661072");
PageParameter<WriterUserManagerVO> param = new PageParameter<>(1, 1, vo);
PageResult<WriterUserManagerVO> list = writerUserService.getListWriterUser(param, null);
if (list.getRows().isEmpty()) {
map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("未找到'18045661072-李勇'对应的关联结果。"));
excel.add(map);
logger.debug("未找到'18045661072-李勇'对应的关联结果,此结果将被记录在Excel中");
useridCount++;
if (state[4] == 0) {
reason.append("未找到申报人员李勇所对应的系统用户。");
dealWith.append("放弃迁移。");
state[4] = 1;
}
continue;
}
declaration.setUserId(list.getRows().get(0).getId());
} else {
declaration.setUserId(userid);
}
}
if (StringUtil.isEmpty(realName) && isStagingJudge.intValue() == 0) {
// 申报表作家姓名为空并且没有暂存
map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("找到申报表作家姓名为空并且没有暂存。"));
realNameCount++;
if (state[5] == 0) {
reason.append("已提交申报表的作家找不到真实姓名。");
dealWith.append("照常迁入。");
state[5] = 1;
}
/*excel.add(map);
logger.debug("找到申报表作家姓名为空并且没有暂存,此结果将被记录在Excel中");
continue;*/
} else {
declaration.setRealname(realName);
}
if (StringUtil.isEmpty(sexJudge)) {
declaration.setSex(1);
} else {
// 性别
Integer sex = Integer.parseInt(sexJudge.trim());
declaration.setSex(sex);
}
// 生日
declaration.setBirthday((Date) map.get("birthdate"));
if (JdbcHelper.judgeExperience(experienceNum)) {
experienceNum = JdbcHelper.correctExperience(experienceNum);
}
// 教龄
declaration.setExperience(Integer.parseInt(experienceNum));
// 工作单位
declaration.setOrgName((String) map.get("workunit"));
// 职务
declaration.setPosition((String) map.get("duties"));
// 职称
declaration.setTitle((String) map.get("positional"));
// 联系地址
declaration.setAddress((String) map.get("address"));
if (StringUtil.strLength(postCode) > 20 || "55894b98-6b15-4210-9460-11bdf6e8e89c".equals(id)) {
declaration.setPostcode("100000");
} else if ("097674e55b094bb58e99c09f12b4e124".equals(id)) {
declaration.setPostcode("434020");
} else if ("245328b530b04523ab26e6b70d7764d8".equals(id)) {
declaration.setPostcode("211199");
} else {
// 邮编
declaration.setPostcode(postCode);
}
// 手机
declaration.setHandphone((String) map.get("handset"));
// 邮箱
declaration.setEmail((String) map.get("email"));
// 证件类型
declaration.setIdtype((Short) map.get("idcardtype1"));
// 手机
declaration.setHandphone((String) map.get("handset"));
String idcard = (String) map.get("idcard");
if (StringUtil.notEmpty(idcard)) {
if (idcard.length() > 20) {
idcard = idcard.substring(0, 19);
}
}
// 证件号码
declaration.setIdcard(idcard);
// 证件类型
declaration.setIdtype((Short) map.get("idcardtype1"));
// 联系电话
declaration.setTelephone((String) map.get("linktel"));
// 传真
declaration.setFax((String) map.get("fax"));
// 服从调剂
declaration.setIsDispensed(false);
// 参与本科教学评估认证
declaration.setIsUtec(false);
// 学历
declaration.setDegree(0);
// 专业特长
declaration.setExpertise(null);
/* 修改一个特殊情况 */
if ("a4大小、128g铜板、彩印、正反面、2000册,印刷费1600元".equals(declaration.getHandphone())) {
declaration.setHandphone(null);
// 证件号码
declaration.setIdcard(null);
// 联系电话
declaration.setTelephone(null);
// 传真
declaration.setFax(null);
}
// 旧表申报单位id为5的或者机构代码截取为15-的把orgid设置成0
if ("5".equals(unitid) || "15-".equals(orgCodes) || (ObjectUtil.isNull(orgId) && isStagingJudge.intValue() == 0)) {
// 0为人民卫生出版社
declaration.setOrgId(0L);
} else {
// 申报单位id
declaration.setOrgId(orgId);
}
if (ObjectUtil.notNull(onlineProgressJudge)) {
// 审核进度
Integer onlineProgress = onlineProgressJudge.intValue();
declaration.setOnlineProgress(onlineProgress);
} else {
declaration.setOnlineProgress(0);
}
declaration.setAuthUserId(authUserid);
// 审核通过时间
declaration.setAuthDate((Timestamp) map.get("auditdate"));
if (ObjectUtil.notNull(offlineProgressJudge)) {
// 纸质表进度
Integer offlineProgress = offlineProgressJudge.intValue();
declaration.setOfflineProgress(offlineProgress);
} else {
declaration.setOfflineProgress(0);
}
// 纸质表收到时间
declaration.setPaperDate((Timestamp) map.get("editauditdate"));
// 退回原因
declaration.setReturnCause(null);
if (ObjectUtil.isNull(isStagingJudge)) {
declaration.setIsStaging(false);
} else {
// 是否暂存
Integer isStaging = isStagingJudge.intValue();
if (isStaging.equals(0)) {
declaration.setIsStaging(false);
} else {
declaration.setIsStaging(true);
}
}
// 是否被逻辑删除
declaration.setIsDeleted(false);
if (declaration.getUserId() == null) {
logger.info("userId为空的作家名称为:{}", declaration.getRealname());
} else {
// logger.info("当前执行的作家id:{}", declaration.getUserId().toString());
}
Declaration dec = declarationService.getDeclarationByMaterialIdAndUserId(declaration.getMaterialId(), declaration.getUserId());
if (dec != null) {
map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("已存在教材id和作家id均相同的记录。"));
excel.add(map);
logger.error("已存在教材id和作家id均相同的记录,本条数据放弃插入,material_id={},user_id={}", declaration.getMaterialId(), declaration.getUserId());
decCount++;
if (state[6] == 0) {
reason.append("同一用户申报同一教材的记录多于1条。");
dealWith.append("放弃迁移。");
state[6] = 1;
}
continue;
}
declaration = declarationService.addDeclaration(declaration);
long pk = declaration.getId();
// 更新旧表中new_pk字段
JdbcHelper.updateNewPrimaryKey(tableName, pk, "writerid", id);
count++;
if (null == map.get("exception")) {
correctCount++;
}
}
if (excel.size() > 0) {
try {
excelHelper.exportFromMaps(excel, "作家申报表", "declaration");
} catch (IOException ex) {
logger.error("异常数据导出到Excel失败", ex);
}
}
if (correctCount != maps.size()) {
result.put(SQLParameters.EXCEL_HEADER_TABLENAME, "declaration");
result.put(SQLParameters.EXCEL_HEADER_DESCRIPTION, "作家申报表");
result.put(SQLParameters.EXCEL_HEADER_SUM_DATA, maps.size());
result.put(SQLParameters.EXCEL_HEADER_MIGRATED_DATA, count);
result.put(SQLParameters.EXCEL_HEADER_CORECT_DATA, correctCount);
result.put(SQLParameters.EXCEL_HEADER_TRANSFERED_DATA, count - correctCount);
result.put(SQLParameters.EXCEL_HEADER_NO_MIGRATED_DATA, maps.size() - count);
result.put(SQLParameters.EXCEL_HEADER_EXCEPTION_REASON, reason.toString());
result.put(SQLParameters.EXCEL_HEADER_DEAL_WITH, dealWith.toString());
SQLParameters.STATISTICS_RESULT.add(result);
}
logger.info("申报表作家姓名为空并且不是暂存表数量:{}", realNameCount);
logger.info("后台用户申报教材数量:{}", sysflagCount);
logger.info("用户类型为学校管理员申报教材数量:{}", usertypeCount);
logger.info("未找到作家对应的关联结果数量:{}", useridCount);
logger.info("教材id和作家id均相同的记录数量:{}", decCount);
logger.info("未找到教材对应的关联结果数量:{}", materialidCount);
logger.info("writer_declaration表迁移完成,异常条目数量:{}", excel.size());
logger.info("原数据库中共有{}条数据,迁移了{}条数据", maps.size(), count);
// 记录信息
Map<String, Object> msg = new HashMap<>();
msg.put("result", "" + tableName + " 表迁移完成" + count + "/" + maps.size());
SQLParameters.STATISTICS.add(msg);
}
use of com.bc.pmpheep.back.vo.WriterUserManagerVO in project pmph by BCSquad.
the class WriterUserServiceImpl method getTeacherCheckList.
@Override
public PageResult<WriterUserManagerVO> getTeacherCheckList(PageParameter<WriterUserManagerVO> pageParameter) throws CheckedServiceException {
PageResult<WriterUserManagerVO> pageResult = new PageResult<WriterUserManagerVO>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
List<WriterUserManagerVO> writerUserManagerVOList = writerUserDao.getTeacherCheckList(pageParameter);
for (WriterUserManagerVO writerUserManagerVO : writerUserManagerVOList) {
switch(writerUserManagerVO.getRank()) {
case 0:
writerUserManagerVO.setRankName("普通用户");
break;
case 1:
writerUserManagerVO.setRankName("教师用户");
break;
case 2:
writerUserManagerVO.setRankName("作家用户");
break;
case 3:
writerUserManagerVO.setRankName("专家用户");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "该用户没有身份");
}
}
if (CollectionUtil.isNotEmpty(writerUserManagerVOList)) {
Integer count = writerUserManagerVOList.get(0).getCount();
pageResult.setTotal(count);
pageResult.setRows(writerUserManagerVOList);
}
return pageResult;
}
use of com.bc.pmpheep.back.vo.WriterUserManagerVO in project pmph by BCSquad.
the class WriterUserServiceImpl method getListWriterUser.
/**
* 功能描述:分页查询作家用户
*
* @param page
* 传入的查询数据
* @return 需要的Page对象
*/
@Override
public PageResult<WriterUserManagerVO> getListWriterUser(PageParameter<WriterUserManagerVO> pageParameter, Long groupId) throws CheckedServiceException {
String name = pageParameter.getParameter().getName();
if (StringUtil.notEmpty(name)) {
pageParameter.getParameter().setName(name);
}
String orgName = pageParameter.getParameter().getOrgName();
if (StringUtil.notEmpty(orgName)) {
pageParameter.getParameter().setOrgName(orgName);
}
PageResult<WriterUserManagerVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
// 当rank为1的时候 查询教师用户
int total = 0;
if (pageParameter.getParameter().getRank() == null || pageParameter.getParameter().getRank() != 1) {
// 当rank不为1的时候
total = writerUserDao.getListWriterUserTotal(pageParameter);
if (total > 0) {
List<WriterUserManagerVO> list = writerUserDao.getListWriterUser(pageParameter);
for (WriterUserManagerVO vo : list) {
switch(vo.getRank()) {
case 0:
vo.setRankName("普通用户");
break;
case 1:
vo.setRankName("教师用户");
break;
case 2:
vo.setRankName("作家用户");
break;
case 3:
vo.setRankName("专家用户");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "该用户没有身份");
}
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
} else {
total = writerUserDao.getLsitisTeacherTotal(pageParameter);
if (total > 0) {
List<WriterUserManagerVO> list = writerUserDao.getLsitisTeacher(pageParameter);
for (WriterUserManagerVO vo : list) {
switch(vo.getRank()) {
case 0:
vo.setRankName("普通用户");
break;
case 1:
vo.setRankName("教师用户");
break;
case 2:
vo.setRankName("作家用户");
break;
case 3:
vo.setRankName("专家用户");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "该用户没有身份");
}
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
}
// 设置职位
if (null != pageResult.getRows() && pageResult.getRows().size() > 0 && null != groupId) {
// 清空职位
for (WriterUserManagerVO writerUserManagerVO : pageResult.getRows()) {
writerUserManagerVO.setPosition("无");
}
// 设置职位
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
Long bookId = pmphGroup.getBookId();
if (null != bookId && bookId.intValue() > 0) {
// 查询这本书的发布职位
List<DecPositionPublished> publisheds = decPositionPublishedService.getDecPositionPublishedListByBookId(bookId);
if (null != publisheds && publisheds.size() > 0) {
Map<Long, String> userIdsAndPostions = new HashMap<Long, String>();
for (DecPositionPublished published : publisheds) {
Declaration declaration = declarationService.getDeclarationById(published.getDeclarationId());
String postiton = "无";
if (published.getChosenPosition().intValue() == 4 && null != published.getRank() && published.getRank() == 1) {
postiton = "主编(第一主编)";
} else if (published.getChosenPosition().intValue() == 4) {
postiton = "主编";
} else if (published.getChosenPosition().intValue() == 12 && null != published.getRank() && published.getRank() == 1) {
postiton = "主编(第一主编),数字编委";
} else if (published.getChosenPosition().intValue() == 12) {
postiton = "主编,数字编委";
} else if (published.getChosenPosition().intValue() == 2) {
postiton = "副主编";
} else if (published.getChosenPosition().intValue() == 10) {
postiton = "副主编,数字编委";
} else if (published.getChosenPosition().intValue() == 1) {
postiton = "编委";
} else if (published.getChosenPosition().intValue() == 9) {
postiton = "编委,数字编委";
}
userIdsAndPostions.put(declaration.getUserId(), postiton);
}
for (WriterUserManagerVO writerUserManagerVO : pageResult.getRows()) {
String postion = userIdsAndPostions.get(writerUserManagerVO.getId());
if (null != postion) {
writerUserManagerVO.setPosition(postion);
}
}
}
}
}
// 设置职位 end
return pageResult;
}
use of com.bc.pmpheep.back.vo.WriterUserManagerVO in project pmph by BCSquad.
the class SchoolAndTeacherCheckController method writerList.
/**
* <pre>
* 功能描述:获取教师审核列表
* 使用示范:
*
* @param pageNumber 当前页
* @param pageSize 页面大小
* @param writerUserManagerVO
* @return 分页数据集
* </pre>
*/
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "查询系统消息列表")
@RequestMapping(value = "/writerList", method = RequestMethod.GET)
public ResponseBean writerList(@RequestParam(name = "pageNumber", defaultValue = "1") Integer pageNumber, @RequestParam(name = "pageSize") Integer pageSize, @RequestParam("realname") String realname, @RequestParam("orgName") String orgName, @RequestParam("progress") Short progress) {
PageParameter pageParameter = new PageParameter<>();
WriterUserManagerVO writerUserManagerVO = new WriterUserManagerVO();
if (StringUtil.notEmpty(orgName)) {
// 去除空格
writerUserManagerVO.setOrgName(orgName.replaceAll(" ", ""));
}
if (StringUtil.notEmpty(realname)) {
writerUserManagerVO.setRealname(realname.replaceAll(" ", ""));
}
writerUserManagerVO.setProgress(progress);
pageParameter.setPageNumber(pageNumber);
pageParameter.setPageSize(pageSize);
pageParameter.setParameter(writerUserManagerVO);
return new ResponseBean(writerUserService.getTeacherCheckList(pageParameter));
}
use of com.bc.pmpheep.back.vo.WriterUserManagerVO in project pmph by BCSquad.
the class WriterUserController method writerUser.
/**
* 功能描述:分页查询作家用户
*
* @param page
* 分页条件
* @param writerUserManagerVO
* 查询条件
* @return 分好页的结果集
*/
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "分页查询作家用户")
@RequestMapping(value = "/list/writerUser", method = RequestMethod.GET)
public ResponseBean writerUser(Long groupId, @RequestParam("pageSize") Integer pageSize, @RequestParam("pageNumber") Integer pageNumber, @RequestParam("name") String name, @RequestParam("rank") Integer rank, @RequestParam("orgName") String orgName) {
PageParameter pageParameter = new PageParameter<>();
WriterUserManagerVO writerUserManagerVO = new WriterUserManagerVO();
if (StringUtil.notEmpty(name)) {
// 去除空格
writerUserManagerVO.setName(name.replaceAll(" ", ""));
}
if (StringUtil.notEmpty(orgName)) {
writerUserManagerVO.setOrgName(orgName.replaceAll(" ", ""));
}
writerUserManagerVO.setRank(rank);
pageParameter.setPageNumber(pageNumber);
pageParameter.setPageSize(pageSize);
pageParameter.setParameter(writerUserManagerVO);
return new ResponseBean(writerUserService.getListWriterUser(pageParameter, groupId));
}
Aggregations