use of com.bc.pmpheep.back.po.Declaration in project pmph by BCSquad.
the class TextbookLogServiceImpl method addTextbookLog.
@Override
public void addTextbookLog(List<DecPosition> oldlist, Long textbookId, Long updaterId, int userType) throws CheckedServiceException {
if (null == textbookId) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "书籍为空!");
}
if (null == updaterId) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "修改者为空!");
}
List<DecPosition> newlist = decPositionService.listChosenDecPositionsByTextbookId(textbookId);
int addSumZhuBian = 0;
StringBuilder addZhuBian = new StringBuilder("");
int redSumZhuBian = 0;
StringBuilder redZhuBian = new StringBuilder("");
int addSumFuZhuBian = 0;
StringBuilder addFuZhuBian = new StringBuilder("");
int redSumFuZhuBian = 0;
StringBuilder redFuZhuBian = new StringBuilder("");
int addSumBianWei = 0;
StringBuilder addBianWei = new StringBuilder("");
int redSumBianWei = 0;
StringBuilder redBianWei = new StringBuilder("");
int addSumShuZiBianWei = 0;
StringBuilder addShuZiBianWei = new StringBuilder("");
int redSumShuZiBianWei = 0;
StringBuilder redShuZiBianWei = new StringBuilder("");
// 新旧申报的id
List<Long> ids = new ArrayList<>(oldlist.size() + newlist.size());
for (DecPosition oldDecPosition : oldlist) {
ids.add(oldDecPosition.getDeclarationId());
}
for (DecPosition newDecPosition : newlist) {
ids.add(newDecPosition.getDeclarationId());
}
List<Declaration> declarations = declarationService.getDeclarationByIds(ids);
// 增加的
for (DecPosition newDecPosition : newlist) {
// 申报者
Long declarationId = newDecPosition.getDeclarationId();
// 新的申报表
Declaration declaration = new Declaration();
for (Declaration tempDeclaration : declarations) {
if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
declaration = tempDeclaration;
break;
}
}
// 新选的职位
Integer newChosenPosition = newDecPosition.getChosenPosition();
// 是否是新增
boolean isAdd = true;
// 遍历出所有的旧的信息
for (DecPosition oldDecPosition : oldlist) {
if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue()) {
isAdd = false;
break;
}
}
if (isAdd) {
// 新增的主编
if (null != newChosenPosition && (newChosenPosition == 4 || newChosenPosition == 12)) {
addSumZhuBian++;
addZhuBian.append("," + declaration.getRealname());
}
// 新增的副主编
if (null != newChosenPosition && (newChosenPosition == 2 || newChosenPosition == 10)) {
addSumFuZhuBian++;
addFuZhuBian.append("," + declaration.getRealname());
}
// 新增的编委
if (null != newChosenPosition && (newChosenPosition == 1 || newChosenPosition == 9)) {
addSumBianWei++;
addBianWei.append("," + declaration.getRealname());
}
// 新增的数字编委
if (null != newChosenPosition && (newChosenPosition == 8 || newChosenPosition == 12 || newChosenPosition == 10 || newChosenPosition == 9)) {
addSumShuZiBianWei++;
addShuZiBianWei.append("," + declaration.getRealname());
}
}
}
// 减少的
for (DecPosition oldDecPosition : oldlist) {
// 申报者
Long declarationId = oldDecPosition.getDeclarationId();
// 老的申报表
Declaration declaration = new Declaration();
for (Declaration tempDeclaration : declarations) {
if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
declaration = tempDeclaration;
break;
}
}
// 老的的职位
Integer oldChosenPosition = oldDecPosition.getChosenPosition();
// 是否删除
boolean isDel = true;
// 遍历出所有新的信息
for (DecPosition newDecPosition : newlist) {
if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue()) {
isDel = false;
break;
}
}
if (isDel) {
// 移除了主编
if (null != oldChosenPosition && (oldChosenPosition == 4 || oldChosenPosition == 12)) {
redSumZhuBian++;
redZhuBian.append("," + declaration.getRealname());
}
// 移除了副主编
if (null != oldChosenPosition && (oldChosenPosition == 2 || oldChosenPosition == 10)) {
redSumFuZhuBian++;
redFuZhuBian.append("," + declaration.getRealname());
}
// 移除了编委
if (null != oldChosenPosition && (oldChosenPosition == 1 || oldChosenPosition == 9)) {
redSumBianWei++;
redBianWei.append("," + declaration.getRealname());
}
// 移除了编委
if (null != oldChosenPosition && (oldChosenPosition == 8 || oldChosenPosition == 12 || oldChosenPosition == 10 || oldChosenPosition == 9)) {
redSumShuZiBianWei++;
redShuZiBianWei.append("," + declaration.getRealname());
}
}
}
// 职位被修改的
StringBuilder updateString = new StringBuilder("");
boolean allUpdate = false;
for (DecPosition newDecPosition : newlist) {
// 申报者
Long declarationId = newDecPosition.getDeclarationId();
// 新的申报表
Declaration declaration = new Declaration();
for (Declaration tempDeclaration : declarations) {
if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
declaration = tempDeclaration;
break;
}
}
// 新选的职位
Integer newChosenPosition = newDecPosition.getChosenPosition();
Integer newRank = newDecPosition.getRank();
newRank = newRank == null ? 0 : newRank;
// 是否是新增
boolean isUpdate = false;
// 遍历出所有的旧的信息
for (DecPosition oldDecPosition : oldlist) {
Integer oldChosenPosition = oldDecPosition.getChosenPosition();
Integer oldRank = oldDecPosition.getRank();
oldRank = oldRank == null ? 0 : oldRank;
// 修改的是职位或者排序 都算
if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue() && !(newChosenPosition.intValue() == oldChosenPosition.intValue() && newRank.intValue() == oldRank.intValue())) {
isUpdate = true;
break;
}
}
if (isUpdate) {
allUpdate = true;
updateString.append("," + declaration.getRealname());
}
}
// 遍历错误信息
if (addSumZhuBian > 0 || redSumZhuBian > 0 || addSumFuZhuBian > 0 || redSumFuZhuBian > 0 || addSumBianWei > 0 || redSumBianWei > 0 || addSumShuZiBianWei > 0 || redSumShuZiBianWei > 0 || allUpdate) {
StringBuilder detail = new StringBuilder("");
if (redSumZhuBian > 0) {
detail.append("移除了" + redSumZhuBian + "位主编:[" + redZhuBian.toString().substring(1) + "];");
}
if (redSumFuZhuBian > 0) {
detail.append("移除了" + redSumFuZhuBian + "位副主编:[" + redFuZhuBian.toString().substring(1) + "];");
}
if (redSumBianWei > 0) {
detail.append("移除了" + redSumBianWei + "位编委:[" + redBianWei.toString().substring(1) + "];");
}
if (redSumShuZiBianWei > 0) {
detail.append("移除了" + redSumShuZiBianWei + "位数字编辑:[" + redShuZiBianWei.toString().substring(1) + "];");
}
if (addSumZhuBian > 0) {
detail.append("增加了" + addSumZhuBian + "位主编:[" + addZhuBian.toString().substring(1) + "];");
}
if (addSumFuZhuBian > 0) {
detail.append("增加了" + addSumFuZhuBian + "位副主编:[" + addFuZhuBian.toString().substring(1) + "];");
}
if (addSumBianWei > 0) {
detail.append("增加了" + addSumBianWei + "位编委:[" + addBianWei.toString().substring(1) + "];");
}
if (addSumShuZiBianWei > 0) {
detail.append("增加了" + addSumShuZiBianWei + "位数字编辑:[" + addShuZiBianWei.toString().substring(1) + "];");
}
if (allUpdate) {
detail.append("修改了:[" + updateString.toString().substring(1) + "]的职位信息;");
}
String detail2 = detail.toString();
// 去掉最后一个;
detail2 = detail2.substring(0, detail2.length() - 1);
TextbookLog textbookLog = new TextbookLog();
textbookLog.setDetail(detail2.length() >= 100 ? detail2.substring(0, 95) + "..." : detail2);
textbookLog.setIsPmphUpdater(userType == 1);
textbookLog.setTextbookId(textbookId);
textbookLog.setUpdaterId(updaterId);
textbookLogDao.addTextbookLog(textbookLog);
}
}
use of com.bc.pmpheep.back.po.Declaration in project pmph by BCSquad.
the class TextbookServiceImpl method updateTextbookAndMaterial.
@Override
public Integer updateTextbookAndMaterial(Long[] ids, String sessionId, Long materialId) throws CheckedServiceException, Exception {
// 获取当前用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
// if (!pmphUser.getIsAdmin()) {
// throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
// CheckedExceptionResult.ILLEGAL_PARAM,
// "该用户没有操作权限");
// }
// 教材权限的检查
List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
Integer power = null;
// 系统管理员权限检查
for (PmphRole pmphRole : pmphRoles) {
if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName())) {
// 我是系统管理原
power = 1;
}
}
// 教材主任检查
Material material = materialService.getMaterialById(materialId);
if (null == power) {
if (null != material && null != material.getDirector() && pmphUser.getId().equals(material.getDirector())) {
// 我是教材的主任
power = 2;
}
}
List<Textbook> textbooks = textbookDao.getTextbooks(ids);
if (textbooks.size() > 0) {
for (Textbook textbook : textbooks) {
// 是否存在策划编辑
if (ObjectUtil.isNull(textbook.getPlanningEditor())) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未选择策划编辑,不能进行公布");
}
// 是否发布主编
if (!textbook.getIsChiefPublished()) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未发布主编/副主编,不能进行公布");
}
List<DecPosition> decPosition = decPositionService.getDecPositionByTextbookId(textbook.getId());
// 是否确认编委
if (decPosition.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未确认编委,不能进行公布");
}
}
}
Material materials = new Material();
List<Long> textBookIds = new ArrayList<>(textbooks.size());
for (Textbook textbook : textbooks) {
// if(Const.TRUE==textbook.getIsPublished()){
// throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK,
// CheckedExceptionResult.ILLEGAL_PARAM,"名单已确认");
// }
// if(textbook.getIsPublished()) {
Textbook textbook2 = new Textbook(textbook.getId(), textbook.getRevisionTimes().intValue() + 1).setIsPublished(true);
textbook2.setRevisionTimes(textbook.getRevisionTimes().intValue() + 1);
textbookDao.updateTextbook(textbook2);
// }else {
// Textbook textbook2 = new Textbook(textbook.getId(), 0).setIsPublished(true);
// textbook2.setRevisionTimes(0) ;
// textbookDao.updateTextbook(textbook2);
// }
materials.setId(textbook.getMaterialId());
textBookIds.add(textbook.getId());
}
// textbookDao.updateBookPublished(textBooks);
// textbookDao.updateTextbook(textbook);
/**
* 下面是发布更新最终结果表的数据
*/
// 获取这些书的申报者
List<DecPosition> lst = decPositionService.listDecPositionsByTextBookIds(textBookIds);
// 这些书的被遴选者
List<DecPositionPublished> decPositionPublishedLst = new ArrayList<DecPositionPublished>(lst.size());
for (DecPosition decPosition : lst) {
if (null == decPosition || null == decPosition.getChosenPosition() || decPosition.getChosenPosition() <= 0) {
continue;
}
DecPositionPublished decPositionPublished = new DecPositionPublished();
decPositionPublished.setPublisherId(pmphUser.getId());
decPositionPublished.setDeclarationId(decPosition.getDeclarationId());
decPositionPublished.setTextbookId(decPosition.getTextbookId());
decPositionPublished.setPresetPosition(decPosition.getPresetPosition());
decPositionPublished.setIsOnList(true);
decPositionPublished.setChosenPosition(decPosition.getChosenPosition());
decPositionPublished.setRank(decPosition.getRank());
decPositionPublished.setSyllabusId(decPosition.getSyllabusId());
decPositionPublished.setSyllabusName(decPosition.getSyllabusName());
decPositionPublishedLst.add(decPositionPublished);
}
List<DecPositionPublished> olds = decPositionPublishedService.getDecPositionPublishedListByBookIds(textBookIds);
List<DecPositionPublished> sends = new ArrayList<>();
for (DecPositionPublished now : decPositionPublishedLst) {
if (ObjectUtil.notNull(now.getRank())) {
sends.add(now);
} else {
DecPositionPublished published = decPositionPublishedService.getDecPositionByDeclarationId(now.getDeclarationId(), now.getTextbookId());
if (ObjectUtil.isNull(published)) {
sends.add(now);
}
for (DecPositionPublished old : olds) {
if (old.getDeclarationId().equals(now.getDeclarationId()) && old.getTextbookId().equals(now.getTextbookId())) {
if (!old.getChosenPosition().equals(now.getChosenPosition())) {
sends.add(now);
} else {
if (null == now.getRank() && null == now.getRank()) {
} else if (null != now.getRank() && null != now.getRank()) {
if (!now.getRank().equals(now.getRank())) {
sends.add(now);
}
} else {
sends.add(now);
}
}
}
}
}
}
// 先删除dec_position_published表中的所有数据
decPositionPublishedService.deleteDecPositionPublishedByBookIds(textBookIds);
// 向dec_position_published插入新数据
decPositionPublishedService.batchInsertDecPositionPublished(decPositionPublishedLst);
/**
* 发布更新最终结果表的数据 ---end ---
*/
// List<Textbook> books = materialDao.getMaterialAndTextbook(materials);
List<Textbook> books = textbookService.getTextbookByMaterialId(materials.getId());
Integer count = 0;
/* 通过遍历查看教材下面所有书籍是否公布,当数据全部公布则该教材改为最终公布 */
for (Textbook book : books) {
if (book.getIsPublished()) {
count++;
}
}
if (count == books.size()) {
// 检查有没有再次公布
PageResult<BookPositionVO> listBookPosition = this.listBookPosition(1, 9999999, null, null, null, materials.getId(), sessionId);
boolean haveNo = true;
for (BookPositionVO bookPositionVO : listBookPosition.getRows()) {
if (bookPositionVO.getIsPublished() && bookPositionVO.getRepub()) {
haveNo = false;
break;
}
}
if (haveNo) {
count = materialDao.updateMaterialPublished(materials);
}
}
// 发送消息
for (Textbook textbook : textbooks) {
systemMessageService.sendWhenPubfinalResult(textbook.getId(), sends);
}
// 当教材遴选结束时给为遴选上的用户推送消息
Material material2 = materialService.getMaterialById(materialId);
if (ObjectUtil.notNull(material2)) {
if (material2.getIsAllTextbookPublished()) {
List<Declaration> declaration = declarationService.getPositionChooseLossByMaterialId(materialId);
systemMessageService.sendWhenPositionChooserLoss(materialId, declaration);
}
}
// 遍历被遴选人发送动态 和被修改成专家
for (DecPositionPublished decPositionPublished : decPositionPublishedLst) {
if (null == decPositionPublished || null == decPositionPublished.getChosenPosition() || decPositionPublished.getChosenPosition() <= 0) {
continue;
}
// 获取申报表
Declaration declarationById = declarationService.getDeclarationById(decPositionPublished.getDeclarationId());
// 修改成专家
WriterUser writerUser = new WriterUser();
writerUser.setId(declarationById.getUserId());
writerUser.setIsExpert(true);
writerUser.setRank(3);
writerUserService.update(writerUser);
// 获取书籍
Textbook textbook = textbookService.getTextbookById(decPositionPublished.getTextbookId());
// 作家遴选
String showChosenPosition = "";
if (decPositionPublished.getChosenPosition() != 0) {
switch(decPositionPublished.getChosenPosition()) {
case 1:
showChosenPosition = "编委";
break;
case 2:
showChosenPosition = "副主编";
break;
case 3:
showChosenPosition = "副主编,编委";
break;
case 4:
showChosenPosition = "主编";
break;
case 5:
showChosenPosition = "主编,编委";
break;
case 6:
showChosenPosition = "主编,副主编";
break;
case 7:
showChosenPosition = "主编,副主编,编委";
break;
case 8:
showChosenPosition = "数字编委";
break;
case 9:
showChosenPosition = "编委,数字编委";
break;
case 10:
showChosenPosition = "副主编,数字编委";
break;
case 11:
showChosenPosition = "副主编,编委,数字编委";
break;
case 12:
showChosenPosition = "主编,数字编委";
break;
case 13:
showChosenPosition = "主编,编委,数字编委";
break;
case 14:
showChosenPosition = "主编,副主编,数字编委";
break;
case 15:
showChosenPosition = "主编,副主编,编委,数字编委";
break;
default:
break;
}
}
// 添加动态信息
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(declarationById.getUserId());
// 自己可见
writerUserTrendst.setIsPublic(false);
writerUserTrendst.setType(8);
String detail = "";
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", CheckedExceptionBusiness.MATERIAL);
map.put("content", "您已被遴选为《" + textbook.getTextbookName() + "》的" + showChosenPosition + "。");
map.put("img", 1);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(declarationById.getMaterialId());
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
}
return count;
}
use of com.bc.pmpheep.back.po.Declaration 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.po.Declaration in project pmph by BCSquad.
the class DeclarationServiceImpl method getDeclarationEtcBOs.
@Override
public List<DeclarationEtcBO> getDeclarationEtcBOs(Long materialId) {
List<DeclarationEtcBO> declarationEtcBOs = new ArrayList<>(20);
List<Declaration> declarations = declarationDao.getDeclarationByMaterialId(materialId);
if (CollectionUtil.isEmpty(declarations)) {
return null;
}
int count = 1;
for (Declaration declaration : declarations) {
// 学习经历
ArrayList<DecEduExp> decEduExps = (ArrayList<DecEduExp>) decEduExpDao.getListDecEduExpByDeclarationId(declaration.getId());
// 工作经历
ArrayList<DecWorkExp> decWorkExps = (ArrayList<DecWorkExp>) decWorkExpDao.getListDecWorkExpByDeclarationId(declaration.getId());
// 教学经历
ArrayList<DecTeachExp> decTeachExps = (ArrayList<DecTeachExp>) decTeachExpDao.getListDecTeachExpByDeclarationId(declaration.getId());
// 兼职学术
ArrayList<DecAcade> decAcades = (ArrayList<DecAcade>) decAcadeDao.getListDecAcadeByDeclarationId(declaration.getId());
// 上套教材
ArrayList<DecLastPosition> decLastPositions = (ArrayList<DecLastPosition>) decLastPositionDao.getListDecLastPositionByDeclarationId(declaration.getId());
// 精品课程建设情况
ArrayList<DecCourseConstruction> decCourseConstructions = (ArrayList<DecCourseConstruction>) decCourseConstructionDao.getDecCourseConstructionByDeclarationId(declaration.getId());
// 主编国家级规划
ArrayList<DecNationalPlan> decNationalPlans = (ArrayList<DecNationalPlan>) decNationalPlanDao.getListDecNationalPlanByDeclarationId(declaration.getId());
// 教材编写
ArrayList<DecTextbook> decTextbooks = (ArrayList<DecTextbook>) decTextbookDao.getListDecTextbookByDeclarationId(declaration.getId());
// 作家科研
ArrayList<DecResearch> decResearchs = (ArrayList<DecResearch>) decResearchDao.getListDecResearchByDeclarationId(declaration.getId());
/*
* ArrayList<DecAchievement> decAchievements = (ArrayList<DecAchievement>)
* decAchievementDao .getDecAchievementByDeclarationId(declaration.getId());
*/
DeclarationEtcBO declarationEtcBO = new DeclarationEtcBO();
declarationEtcBO.setRealname("欧阳望月".concat(String.valueOf(count)));
declarationEtcBO.setUsername("Smith");
// declarationEtcBO.setTextbookName("人体解剖学与组织胚胎学");
// declarationEtcBO.setPresetPosition("副主编");
declarationEtcBO.setChosenOrgName("人民卫生出版社");
declarationEtcBO.setSex("女");
declarationEtcBO.setBirthday("1975年11月22日");
declarationEtcBO.setAddress("浙江省金华市婺城区婺州街1188号");
declarationEtcBO.setExperience(23);
declarationEtcBO.setOrgName("金华职业技术学院医学院");
declarationEtcBO.setPosition("教师");
declarationEtcBO.setTitle("教授");
declarationEtcBO.setPostcode("321017");
declarationEtcBO.setHandphone("13857989881");
declarationEtcBO.setEmail("test10001test@163.com");
declarationEtcBO.setFax("01065930013");
declarationEtcBO.setTelephone("010-65930013");
declarationEtcBO.setDecEduExps(decEduExps);
declarationEtcBO.setDecWorkExps(decWorkExps);
declarationEtcBO.setDecTeachExps(decTeachExps);
declarationEtcBO.setDecAcades(decAcades);
declarationEtcBO.setDecLastPositions(decLastPositions);
declarationEtcBO.setDecCourseConstructions(decCourseConstructions);
declarationEtcBO.setDecNationalPlans(decNationalPlans);
declarationEtcBO.setDecTextbooks(decTextbooks);
declarationEtcBO.setDecResearchs(decResearchs);
// declarationEtcBO.setDecAchievement(decAchievements.get(0));
declarationEtcBOs.add(declarationEtcBO);
count++;
if (count > 21) {
break;
}
}
return declarationEtcBOs;
}
use of com.bc.pmpheep.back.po.Declaration 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;
}
Aggregations