123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- package com.ghsc.partybuild.service.impl;
- import com.ghsc.partybuild.mapper.*;
- import com.ghsc.partybuild.model.*;
- import com.ghsc.partybuild.service.CheckDataService;
- import com.ghsc.partybuild.service.UserService;
- import com.ghsc.partybuild.util.StringUtils;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Propagation;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.*;
- import java.util.stream.Collectors;
- @Service("checkDataService")
- public class CheckDataServiceImpl implements CheckDataService {
- @Autowired
- PtCheckpartyMapper checkpartyMapper;
- @Autowired
- PtChecknamelistMapper checknamelistMapper;
- @Autowired
- PtCheckdataCQuery checkdataCQuery;
- @Autowired
- PtCheckdataMapper CheckdataMapper;
- @Autowired
- PtCheckscoreMapper checkscoreMapper;
- @Autowired
- PtCheckquestionMapper checkquestionMapper;
- @Autowired
- CfUsersCQuery cfUsersCQuery;
- @Autowired
- UserService userService;
- @Autowired
- StringUtils stringUtils;
- @Override
- public PageInfo<HashMap<String, Object>> getCheckNameList(int pageIndex, int pageSize, Integer year, Integer quarter, String dzzdm, String checkUserName, String partyCode, Integer recordStatus) {
- PageHelper.startPage(pageIndex, pageSize);
- List<HashMap<String, Object>> list = checkdataCQuery.selectCheckNameList(year, quarter, dzzdm, checkUserName, partyCode, recordStatus, null);
- PageInfo<HashMap<String, Object>> result = new PageInfo(list);
- return result;
- }
- @Override
- public List<HashMap<String, Object>> getCheckPartyList(Integer year, Integer quarter) {
- List<HashMap<String, Object>> list = checkdataCQuery.selectCheckPartyList(year, quarter);
- return list;
- }
- @Override
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
- public int saveCheckNameList(PtChecknamelist item, List<PtCheckparty> checkPartyList) {
- PtChecknamelist dbItem = checknamelistMapper.selectByPrimaryKey(item.getNameid());
- if (dbItem == null) {
- item.setCreatetime(new Date());
- item.setRecordstatus(1);
- item.setNameid(UUID.randomUUID().toString());
- checknamelistMapper.insertSelective(item);
- } else {
- checknamelistMapper.updateByPrimaryKey(item);
- }
- PtCheckpartyExample example = new PtCheckpartyExample();
- example.or().andNameidEqualTo(item.getNameid());
- checkpartyMapper.deleteByExample(example);
- checkPartyList.forEach(it -> {
- it.setNameid(item.getNameid());
- it.setPartyid(UUID.randomUUID().toString());
- checkpartyMapper.insertSelective(it);
- });
- assetrCheckScore(item.getYear(),item.getQuarter(),item.getCheckuserid(),item.getCheckusername(),checkPartyList);
- // 查询选择的用户是否有检查人员权限
- List<HashMap<String, Object>> userInfo = cfUsersCQuery.selectUserAllByUserID(item.getCheckuserid());
- if (!userInfo.isEmpty()) {
- // 查询该用户是否绑定了检查人员角色
- List<HashMap<String, Object>> roleList = cfUsersCQuery.GetRoleByUserId(item.getCheckuserid());
- HashMap<String, Object> jcRole = roleList.stream().filter(it -> it.get("ROLEID").equals("27f0fd61-3107-486f-9240-4f9ef909103e")).findFirst().orElse(null);
- if (jcRole == null) {
- // 没有检查人员角色的,绑定一个
- userService.saveUserRoleList("27f0fd61-3107-486f-9240-4f9ef909103e", item.getCheckuserid(), false);
- }
- }
- return 1;
- }
- /**
- * 生成考核评分
- * @param year
- * @param quarter
- * @param checkUserId
- * @param checkUserName
- * @param checkPartyList
- */
- private void assetrCheckScore(Integer year, Integer quarter,String checkUserId,String checkUserName, List<PtCheckparty> checkPartyList) {
- List<String> partyCodes = checkPartyList.stream().map(x -> x.getPartycode()).collect(Collectors.toList());
- checkPartyList.forEach(party -> {
- PtCheckscoreExample example = new PtCheckscoreExample();
- example.or().andYearEqualTo(year).andQuarterEqualTo(quarter).andDzzdmEqualTo(party.getPartycode());
- PtCheckscore partyScore = checkscoreMapper.selectByExample(example).stream().findFirst().orElse(null);
- if (partyScore==null) {
- partyScore =new PtCheckscore();
- partyScore.setScoreid(UUID.randomUUID().toString());
- partyScore.setYear(year);
- partyScore.setQuarter(quarter);
- partyScore.setCheckuserid(checkUserId);
- partyScore.setDzzdm(party.getPartycode());
- partyScore.setCheckusername(checkUserName);
- partyScore.setRecordstatus(0);
- checkscoreMapper.insert(partyScore);
- }else{
- partyScore.setCheckuserid(UUID.randomUUID().toString());
- partyScore.setCheckuserid(checkUserId);
- checkscoreMapper.updateByPrimaryKeySelective(partyScore);
- }
- });
- }
- @Override
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
- public Integer deleteCheckNameList(List<String> nameIdList) {
- PtCheckpartyExample example = new PtCheckpartyExample();
- example.or().andNameidIn(nameIdList);
- checkpartyMapper.deleteByExample(example);
- PtChecknamelistExample ckExp = new PtChecknamelistExample();
- ckExp.or().andNameidIn(nameIdList);
- checknamelistMapper.deleteByExample(ckExp);
- PtCheckdataExample cdExp = new PtCheckdataExample();
- cdExp.or().andDataidIn(nameIdList);
- CheckdataMapper.deleteByExample(cdExp);
- return 1;
- }
- @Override
- public Integer changeCheckNameListStatus(List<String> nameIdList, Integer recordStatus) {
- PtChecknamelist record = new PtChecknamelist();
- record.setRecordstatus(recordStatus);
- PtChecknamelistExample ckExp = new PtChecknamelistExample();
- ckExp.or().andNameidIn(nameIdList);
- checknamelistMapper.updateByExampleSelective(record, ckExp);
- return 1;
- }
- @Override
- public HashMap<String, Object> getCheckName(String id) {
- List<HashMap<String, Object>> list = checkdataCQuery.selectCheckNameList(null, null, null, null, null, null, null);
- HashMap<String, Object> item = list.stream().filter(x -> x.get("nameid").toString().equals(id)).findFirst().orElse(null);
- return item;
- }
- @Override
- public PageInfo<HashMap<String, Object>> getCheckDataList(int pageIndex, int pageSize, Integer year, String dzzdm, String remark, String roleID, String userid) {
- // 如果是核查人员,只允许查询用户核查名单中存在的组织的材料数据
- String dzzdmInStr = null;
- if (!stringUtils.IsNullOrEmpty(roleID) && roleID.equals("27f0fd61-3107-486f-9240-4f9ef909103e")) {
- List<HashMap<String, Object>> checkNameList = checkdataCQuery.selectCheckNameList(null, null, null, null, null, null, userid);
- // 获取党组织代码
- List<String> distinctDzzdmList = checkNameList.stream()
- .map(item -> item.get("partcodes"))
- .filter(Objects::nonNull)
- .map(Object::toString).distinct().collect(Collectors.toList());
- if (!distinctDzzdmList.isEmpty()) {
- // 拼接in查询条件
- dzzdmInStr = distinctDzzdmList.stream()
- .map(s -> "'" + s.replace("'", "''") + "'")
- .collect(Collectors.joining(",", "", ""));
- }
- }
- PageHelper.startPage(pageIndex, pageSize);
- List<HashMap<String, Object>> list = checkdataCQuery.selectCheckDataList(year, dzzdm, remark, dzzdmInStr);
- PageInfo<HashMap<String, Object>> result = new PageInfo(list);
- return result;
- }
- @Override
- public List<HashMap<String, Object>> getCheckDataFleList(String year) {
- List<HashMap<String, Object>> list = checkdataCQuery.selectCheckDataFleList(year);
- return list;
- }
- @Override
- public int saveCheckdata(PtCheckdata item, String userid, String username) {
- PtCheckdata dbItem = CheckdataMapper.selectByPrimaryKey(item.getDataid());
- if (dbItem == null) {
- item.setCheckdatauserid(userid);
- item.setCheckdatausername(username);
- item.setRecordstatus(1);
- item.setCreatetime(new Date());
- item.setCreateuserid(userid);
- item.setCreateusername(username);
- return CheckdataMapper.insert(item);
- } else {
- item.setUpdatetime(new Date());
- item.setUpdateuserid(userid);
- item.setUpdateusername(username);
- return CheckdataMapper.updateByPrimaryKeySelective(item);
- }
- }
- @Override
- public PtCheckdata getCheckdata(String id) {
- return CheckdataMapper.selectByPrimaryKey(id);
- }
- @Override
- public PageInfo<HashMap<String, Object>> getCheckScoreList(int pageIndex, int pageSize, Integer year, Integer quarter, String dzzdm, String checkUserName, Float minScore,Float maxScore,Integer recordStatus,String checkuserid, String roleID, String userid) {
- // 如果是核查人员,只允许查询用户核查名单中存在的组织的材料数据
- String dzzdmInStr = null;
- if (!stringUtils.IsNullOrEmpty(roleID) && roleID.equals("27f0fd61-3107-486f-9240-4f9ef909103e")) {
- List<HashMap<String, Object>> checkNameList = checkdataCQuery.selectCheckNameList(null, null, null, null, null, null, userid);
- // 获取党组织代码
- List<String> distinctDzzdmList = checkNameList.stream()
- .map(item -> item.get("partcodes"))
- .filter(Objects::nonNull)
- .map(Object::toString).distinct().collect(Collectors.toList());
- if (!distinctDzzdmList.isEmpty()) {
- // 拼接in查询条件
- dzzdmInStr = distinctDzzdmList.stream()
- .map(s -> "'" + s.replace("'", "''") + "'")
- .collect(Collectors.joining(",", "", ""));
- }
- }
- PageHelper.startPage(pageIndex, pageSize);
- List<HashMap<String, Object>> list = checkdataCQuery.selectCheckScoreList( year, quarter, dzzdm, checkUserName, minScore, maxScore, recordStatus,checkuserid,dzzdmInStr);
- PageInfo<HashMap<String, Object>> result = new PageInfo(list);
- return result;
- }
- @Override
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
- public int saveCheckScore(PtCheckscore item ,List<PtCheckquestion> questionList) {
- PtCheckscore dbItem = checkscoreMapper.selectByPrimaryKey(item.getScoreid());
- dbItem.setScore(item.getScore());
- dbItem.setUpdatetime(new Date());
- dbItem.setUpdateuserid(item.getUpdateuserid());
- dbItem.setUpdateusername(item.getUpdateusername());
- if (dbItem.getScore() != null) {
- dbItem.setRecordstatus(1);
- } else {
- dbItem.setRecordstatus(2);
- }
- checkscoreMapper.updateByPrimaryKeySelective(dbItem);
- PtCheckquestionExample example=new PtCheckquestionExample();
- example.or().andScoreidEqualTo(item.getScoreid());
- checkquestionMapper.deleteByExample(example);
- questionList.forEach(x->{
- x.setQuestionid(UUID.randomUUID().toString());
- x.setScoreid(item.getScoreid());
- checkquestionMapper.insert(x);
- });
- return 1;
- }
- @Override
- public List<PtCheckquestion> getCheckquestionList(String scoreId) {
- PtCheckquestionExample example=new PtCheckquestionExample();
- example.or().andScoreidEqualTo(scoreId);
- return checkquestionMapper.selectByExample(example);
- }
- }
|