| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- package platform.modules.sys.service;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.stream.Collectors;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.github.pagehelper.PageHelper;
- import org.springframework.transaction.annotation.Transactional;
- import platform.common.Constant;
- import platform.common.base.model.BaseEntity;
- import platform.common.base.model.DictionaryItem;
- import platform.common.base.service.BaseService;
- import platform.common.base.service.DictionaryItemService;
- import platform.common.util.ShiroUtils;
- import platform.common.util.WebUtil;
- import platform.modules.company.service.StockLandService;
- import platform.modules.government.dao.AttachmentDao;
- import platform.modules.government.dto.*;
- import platform.modules.government.entity.Attachment;
- import platform.modules.government.entity.FileDown;
- import platform.modules.government.entity.User;
- import platform.modules.government.service.AttachmentService;
- import platform.modules.government.service.UserService;
- import platform.modules.sys.dao.ApprovalDao;
- import platform.modules.sys.entity.Approval;
- import platform.modules.sys.entity.Department;
- import tk.mybatis.mapper.entity.Example;
- @Service
- public class ApprovalService extends BaseService<Approval> {
- @Autowired
- private ApprovalDao approvalDao;
- @Autowired
- private DictionaryItemService dictionaryItemService;
- @Autowired
- private AttachmentService attachmentService;
- @Autowired
- private StockLandService stockLandService;
- @Autowired
- private UserService userService;
- @Autowired
- private DepartmentService departmentService;
- public Approval getLatestApproval(Integer apply_id, String type) {
- return approvalDao.getLatestApproval(apply_id, type);
- }
- //查找最近一条审核记录,含撤回的记录 不判断del_flag
- public Approval getLatestApprovalAll(Integer apply_id, String type) {
- return approvalDao.getLatestApprovalAll(apply_id, type);
- }
- //获取存量用地审核流程数据
- public List<Approval> getApprovalList(Integer apply_id) {
- //合规性审查只能看到自己部门的审核信息
- //1.查出合规性审查小组的userId,根据审核流程来查找
- String userIds = stockLandService.findComplianceAuditUserIds(apply_id);
- String[] userIdArr = userIds.split(",");
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("type", Constant.DictionaryType.STOCKLAND);
- criteria.andEqualTo("del_flag", false);
- criteria.andEqualTo("apply_id", apply_id);
- List<Approval> approvals = this.selectByExample(example);
- //如果当前用户是合规性审查小组成员,查出当前用户所属的部门id
- List<String> list = Arrays.asList(userIdArr);
- int currentUserId = ShiroUtils.getUserId();
- if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) {
- if (list.contains(String.valueOf(currentUserId))) {
- Integer departmentId = userService.findDepartmentIdByUserId(currentUserId);
- if (null != departmentId) {
- approvals = approvals.stream().filter(approval -> !(null != approval.getChecker() && !departmentId.equals(userService.findDepartmentIdByUserId(approval.getChecker()))
- && null != approval.getBefore_approvalstatus() && approval.getBefore_approvalstatus().equals(Constant.LandApproveStatus.COMPLIANCE_AUDIT))).collect(Collectors.toList());
- }
- }
- //排序 合规性审核 按照部门排序
- approvals = approvals.stream().sorted((x, y) -> {
- if (x.getBefore_approvalstatus().equals(Constant.LandApproveStatus.COMPLIANCE_AUDIT)
- && y.getBefore_approvalstatus().equals(Constant.LandApproveStatus.COMPLIANCE_AUDIT)) {
- return x.getDepartment().compareTo(y.getDepartment());
- } else {
- return x.getCreate_time().compareTo(y.getCreate_time());
- }
- }).collect(Collectors.toList());
- if (Arrays.asList(stockLandService.findUserIdByGroupName(Constant.XTGZXZ).split(",")).contains(String.valueOf(ShiroUtils.getUserId()))) {
- //协调工作小组成员,可以看到那个局审批了,哪个局未审批-2018-06-07
- //一共需要哪些局进行合规性审核,还剩哪些没审核
- List<Department> pendingAuditDepts = getPendingAuditDepts(apply_id, list, approvals);
- for (Department dept : pendingAuditDepts) {
- Approval approval = new Approval(Constant.LandApproveStatus.COMPLIANCE_AUDIT, Constant.OperType.PENDING, dept.getName());
- approvals.add(approval);
- }
- //
- }
- } else if (ShiroUtils.getUserType().equals(Constant.UserType.COMPANY)) {
- approvals = approvals.stream().filter(approval -> (approval.getOper_type().equals(Constant.OperType.CONFIRM_AND_NOTIFY))).collect(Collectors.toList());
- }
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- //绑定审核材料
- getApproveFiles(approval);
- }
- return approvals;
- }
- //存量用地合规性审核 ,还没审核的部门
- private List<Department> getPendingAuditDepts(Integer apply_id, List<String> userIdArr, List<Approval> approvals) {
- //总共需要审核的部门
- List<Department> allDepts = departmentService.getAllUserDepts(userIdArr);
- if (approvals.size() == 0){
- try {
- throw new Exception("没有审批流程");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- Approval latestApproval = approvals.get(approvals.size() - 1);
- int approvalRound = latestApproval.getApproval_round();
- List<Approval> list = approvals.stream().filter(a -> approvalRound == a.getApproval_round())
- .collect(Collectors.toList());
- for (Approval approval : list) {
- //过滤掉已经审核过的部门
- allDepts = allDepts.stream().filter(d -> !d.getName().equals(approval.getDepartment())).collect(Collectors.toList());
- }
- return allDepts;
- }
- //获取存量用地审核流程数据,申请查询页面,只显示街道确认并通知的信息
- public List<Approval> getApplyApprovalList(Integer apply_id) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("apply_id", apply_id);
- criteria.andEqualTo("type", Constant.DictionaryType.STOCKLAND);
- criteria.andEqualTo("del_flag", false);
- List<Approval> approvals = this.selectByExample(example);
- approvals = approvals.stream().filter(approval -> (approval.getOper_type().equals(Constant.OperType.CONFIRM_AND_NOTIFY))).collect(Collectors.toList());
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- //绑定审核材料
- getApproveFiles(approval);
- }
- return approvals;
- }
- //获取注册审核流程数据
- public List<Approval> getRegisterApprovalList(Integer apply_id) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("apply_id", apply_id);
- List<Approval> approvals = this.selectByExample(example);
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- //绑定审核材料
- getApproveFiles(approval);
- }
- return approvals;
- }
- //绑定审核的审核材料
- public Approval getApproveFiles(Approval approval) {
- //绑定审核材料
- List<Attachment> approveFiles = attachmentService.selectByIdAndBusinessId(Constant.Attachment.STOCKLAND_APPROVE, approval.getId(), null);
- if (null != approveFiles && approveFiles.size() > 0) {
- List<FileDown> fileDowns = new ArrayList<FileDown>();
- for (int i = 0; i < approveFiles.size(); i++) {
- FileDown fileDown = new FileDown(approveFiles.get(i).getId(), approveFiles.get(i).getFile_name(), approveFiles.get(i).getFile_url(), approveFiles.get(i).getDownload_uri());
- fileDowns.add(fileDown);
- }
- approval.setFileDowns(fileDowns);
- }
- return approval;
- }
- //该用户审核的最近一条
- public Approval getLatestApprovalByUser(Integer apply_id, String type, Integer user_id) {
- return approvalDao.getLatestApprovalByUser(apply_id, type, user_id);
- }
- public Approval findLastByCheckerAndBeforeStatu(Integer id, String type, Integer userId, String complianceAudit) {
- Approval approval = approvalDao.findLastByCheckerAndBeforeStatu(id, type, userId, complianceAudit);
- return approval;
- }
- public List<String> findDepartmentNameByApplyId(int id) {
- List<String> list = approvalDao.findDepartmentNameByApplyId(id);
- return list;
- }
- //找出审核节点的item
- public List<DictionaryItem> findProcessNodes(Integer apply_id, String statusType) {
- return approvalDao.findProcessNodes(apply_id, statusType);
- }
- //查询企业通过审核的时间
- public Approval findLatelyTime(Integer id, String type) {
- Approval approval = approvalDao.getLatestApproval(id, type);
- return approval;
- }
- //查询项目申报流程信息
- public List<Approval> getProjectApprovalList(Integer apply_id) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("apply_id", apply_id);
- criteria.andEqualTo("type", Constant.DictionaryType.PROJECT_APPLICATION);
- List<Approval> approvals = this.selectByExample(example);
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- //绑定审核材料
- //getApproveFiles(approval);
- }
- return approvals;
- }
- //查询用户最近一条已审核记录
- public Approval getLatestApprovalAllByUser(Integer id, String type, Integer userId) {
- return approvalDao.getLatestApprovalAllByUser(id, type, userId);
- }
- //查询项目申报流程信息
- public List<Approval> getProjectProvincesApprovalList(Integer apply_id) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("apply_id", apply_id);
- criteria.andEqualTo("type", Constant.DictionaryType.PROJECT_PROVINCES);
- List<Approval> approvals = this.selectByExample(example);
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_PROVINCES_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- }
- return approvals;
- }
- //查询项目申报流程信息
- public List<Approval> getProjectMattersApprovalList(Integer apply_id) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("apply_id", apply_id);
- criteria.andEqualTo("type", Constant.DictionaryType.PROJECT_MATTERS);
- List<Approval> approvals = this.selectByExample(example);
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_MATTERS_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- }
- return approvals;
- }
- //查询项目申报流程信息
- public List<Approval> getProjectIntelligentApprovalList(Integer apply_id) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("apply_id", apply_id);
- criteria.andEqualTo("type", Constant.DictionaryType.PROJECT_INTELLIGENT);
- List<Approval> approvals = this.selectByExample(example);
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_INTELLIGENT_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- }
- return approvals;
- }
- //查询项目申报流程信息
- public List<Approval> getProjectFillingApprovalList(Integer apply_id) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("apply_id", apply_id);
- criteria.andEqualTo("type", Constant.DictionaryType.PROJECT_FILLING);
- List<Approval> approvals = this.selectByExample(example);
- for (Approval approval : approvals) {
- if (StringUtils.isNotBlank(approval.getBefore_approvalstatus())) {
- approval.setBefore_approvalstatus_str(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_FILLING_APPROVE_STATUS, approval.getBefore_approvalstatus()));
- }
- }
- return approvals;
- }
- public List<CenterBusiness> getCenterBusiness(BusinessSearchDto businessSearchDto) {
- return approvalDao.getCenterBusiness(businessSearchDto);
- }
- @Transactional(readOnly = true)
- public int getBusinessVolume(BusinessSearchDto businessSearchDto) {
- return approvalDao.getBusinessVolume(businessSearchDto);
- }
- public CenterWindow getWindowBusiness(BusinessSearchDto businessSearchDto) {
- return approvalDao.getWindowBusiness(businessSearchDto);
- }
- public CenterWindow getMonthStatistical(BusinessSearchDto businessSearchDto, Integer xnum) {
- businessSearchDto.setXnum(xnum);
- return approvalDao.getMonthStatistical(businessSearchDto);
- }
- public List<GovStatisticsDto> getOverallAnalysis(SearchCondition searchCondition) {
- return approvalDao.getOverallAnalysis(searchCondition);
- }
- public AffairsTrackingDto getDepartmentTrack(List<User> userList) {
- return approvalDao.getDepartmentTrack(userList);
- }
- public CheckTrackingNum getTrackByUser(Integer userId) {
- return approvalDao.getTrackByUser(userId);
- }
- public List<Approval> getDocumentByUser(SearchCondition searchCondition) {
- return approvalDao.getDocumentByUser(searchCondition);
- }
- public List<CheckTrackingNum> getSearchDocumentByUser(SearchCondition searchCondition) {
- return approvalDao.getSearchDocumentByUser(searchCondition);
- }
- public List<Approval> getNear3MonthStatistical(int i) {
- return approvalDao.getNear3MonthStatistical(i);
- }
- public int getBusinessAcceptNum(BusinessSearchDto businessSearchDto) {
- return approvalDao.getBusinessAcceptNum(businessSearchDto);
- }
- /**
- * 获取流程信息
- *
- * @param apply_id
- * @param type
- * @return
- */
- public List<Approval> getListByApplyIdAndType(Integer apply_id, String type) {
- Example example = new Example(Approval.class);
- Example.Criteria criteria = example.createCriteria();
- criteria.andEqualTo("type", type);
- criteria.andEqualTo("del_flag", false);
- criteria.andEqualTo("apply_id", apply_id);
- example.orderBy("create_time").asc();
- List<Approval> approvals = this.selectByExample(example);
- return approvals;
- }
- }
|