StockLandApproveService.java 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  1. package platform.modules.company.service;
  2. import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse;
  3. import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
  4. import com.aliyuncs.exceptions.ClientException;
  5. import com.github.pagehelper.PageHelper;
  6. import com.github.pagehelper.PageInfo;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.slf4j.Logger;
  9. import org.slf4j.LoggerFactory;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import platform.common.Constant;
  14. import platform.common.base.model.DictionaryItem;
  15. import platform.common.base.service.BaseService;
  16. import platform.common.base.service.DictionaryItemService;
  17. import platform.common.base.service.DictionaryTypeService;
  18. import platform.common.exception.BaseException;
  19. import platform.common.util.AlibabaSMSUtil;
  20. import platform.common.util.DateUtil;
  21. import platform.common.util.ShiroUtils;
  22. import platform.modules.build.entity.Company;
  23. import platform.modules.build.entity.CompanyContact;
  24. import platform.modules.build.service.CompanyContactService;
  25. import platform.modules.build.service.CompanyService;
  26. import platform.modules.company.dao.StockLandDao;
  27. import platform.modules.company.dto.StockLandApprovalDto;
  28. import platform.modules.company.dto.TypeAndStreetDto;
  29. import platform.modules.company.entity.ProcessFeedback;
  30. import platform.modules.company.entity.ProjectApplicationCompanyInfo;
  31. import platform.modules.company.entity.StockLand;
  32. import platform.modules.government.dao.AttachmentDao;
  33. import platform.modules.government.entity.FileDown;
  34. import platform.modules.government.entity.User;
  35. import platform.modules.government.service.UserService;
  36. import platform.modules.home.request.FindRequest;
  37. import platform.modules.sys.dao.UserGroupDao;
  38. import platform.modules.sys.entity.Approval;
  39. import platform.modules.sys.entity.Group;
  40. import platform.modules.sys.entity.Message;
  41. import platform.modules.sys.entity.UserGroup;
  42. import platform.modules.sys.report.UserData;
  43. import platform.modules.sys.service.ApprovalService;
  44. import platform.modules.sys.service.GroupService;
  45. import platform.modules.sys.service.MessageService;
  46. import platform.modules.sys.service.UserGroupService;
  47. import platform.modules.sys.service.WaitToDoService;
  48. import java.text.ParseException;
  49. import java.text.SimpleDateFormat;
  50. import java.util.*;
  51. /**
  52. * 存量用地审核Service
  53. *
  54. * @author hp
  55. */
  56. @Service
  57. @Transactional
  58. public class StockLandApproveService extends BaseService<StockLand> {
  59. private static final Logger logger = LoggerFactory.getLogger(StockLandApproveService.class);
  60. @Autowired
  61. private StockLandService stockLandService;
  62. @Autowired
  63. private MessageService messageService;
  64. @Autowired
  65. private ApprovalService approvalService;
  66. @Autowired
  67. private UserGroupDao userGroupDao;
  68. @Autowired
  69. private StockLandDao stockLandDao;
  70. @Autowired
  71. private AttachmentDao attachmentDao;
  72. @Autowired
  73. private ProcessFeedbackService processFeedbackService;
  74. @Autowired
  75. private UserService userService;
  76. @Autowired
  77. private GroupService groupService;
  78. @Autowired
  79. private UserGroupService userGroupService;
  80. @Autowired
  81. private DictionaryItemService dictionaryItemService;
  82. @Autowired
  83. private DictionaryTypeService dictionaryTypeService;
  84. @Autowired
  85. private CompanyContactService companyContactService;
  86. @Autowired
  87. private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService;
  88. @Autowired
  89. private WaitToDoService waitToDoService;
  90. /**
  91. * 审核列表数据
  92. *
  93. * @param pageNum
  94. * @param pageSize
  95. * @param param
  96. * @param searchCondition
  97. * @return
  98. * @throws Exception
  99. */
  100. @Transactional(readOnly = true)
  101. public PageInfo<StockLand> findPage(Integer pageNum, Integer pageSize, String param, StockLand searchCondition) throws Exception {
  102. Approval approvalCondition = new Approval();
  103. approvalCondition.setNextchecker(String.valueOf(ShiroUtils.getUserId()));
  104. approvalCondition.setType(Constant.DictionaryType.STOCKLAND);
  105. FindRequest request = new FindRequest();
  106. request.setKeyword(param);
  107. Integer userType = ShiroUtils.getUserType();
  108. if (userType.equals(Constant.UserType.STREET)) {
  109. Integer streetId = ShiroUtils.getStreetId();
  110. request.setStreet_id(streetId);
  111. }
  112. PageHelper.startPage(pageNum, pageSize);
  113. List<StockLand> landApplys = stockLandDao.findApprovePageInfo(request, searchCondition, approvalCondition);
  114. for (StockLand stockLand : landApplys) {
  115. stockLandService.getFullLandInfo(stockLand);
  116. //绑定处理时间 、绑定是否需要街道通知企业
  117. if (searchCondition.getIsPendingAudit() == Constant.PendingAuditStatus.PENDING_AUDIT) {
  118. //剩余或超出时间
  119. Approval latestApproval = approvalService.getLatestApproval(stockLand.getId(), Constant.DictionaryType.STOCKLAND);
  120. if (null != latestApproval) {
  121. Integer overTime = 5;
  122. if (stockLand.getApply_type().equals(Constant.LandApplyType.RENT)) {
  123. overTime = 10;
  124. }
  125. String overTimeStr = DateUtil.getOverTimeStr(latestApproval.getCreate_time(), overTime);
  126. stockLand.setOverTimeStr(overTimeStr);
  127. }
  128. //是否是政府返回的申请数据,需要确认并通知
  129. if (isPendingNotify(stockLand)) {
  130. stockLand.setIsPendingNotify(Constant.PendingNotifyStatus.PENDING_NOTIFY);
  131. }
  132. //是否到了登录用户的审核层级
  133. String[] userIds = latestApproval.getNextchecker().split(",");
  134. User currUser = ShiroUtils.getUserEntity();
  135. if (userIds.length > 0) {
  136. for (String userId : userIds) {
  137. User user = userService.findById(Integer.valueOf(userId));
  138. if (null != user.getApprove_level() && null != currUser.getApprove_level() && user.getApprove_level() > currUser.getApprove_level()) {
  139. stockLand.setIsApproval(0);
  140. }
  141. }
  142. }
  143. if (stockLand.getCanEdit() || null != stockLand.getProcess_status()
  144. || !isPendingAudit(stockLand)) {
  145. //不能审核
  146. stockLand.setIsApproval(0);
  147. }
  148. } else {
  149. //已处理的数据,处理时间
  150. Approval latestApproval = approvalService.getLatestApprovalByUser(stockLand.getId(), Constant.DictionaryType.STOCKLAND, ShiroUtils.getUserId());
  151. if (null != latestApproval) {
  152. Integer overTime = 5;
  153. if (stockLand.getApply_type().equals(Constant.LandApplyType.RENT)) {
  154. overTime = 10;
  155. }
  156. String dealTimeStr = DateUtil.getDealTimeStr(latestApproval.getCreate_time(), latestApproval.getDeal_time(), overTime);
  157. stockLand.setOverTimeStr(dealTimeStr);
  158. //审核时间
  159. stockLand.setDeal_time(latestApproval.getCreate_time());
  160. }
  161. //最近一次是否是当前用户审核的,如果是且没有撤回,则可撤回
  162. if (!(stockLand.getApprove_status().equals(Constant.LandApproveStatus.APPROVED) || stockLand.getApprove_status().equals(Constant.LandApproveStatus.PASSED)
  163. || stockLand.getApprove_status().equals(Constant.LandApproveStatus.NOTPASSED))) {
  164. Approval latestAllApproval = approvalService.getLatestApprovalAll(stockLand.getId(), Constant.DictionaryType.STOCKLAND);
  165. if (null != latestAllApproval) {
  166. if (null == latestAllApproval.getIs_withdraw() && !latestAllApproval.getOper_type().equals(Constant.OperType.CONFIRM_AND_NOTIFY)) {
  167. //没有撤回过,不是确认并通知
  168. if (null != latestAllApproval.getChecker() && latestAllApproval.getChecker().equals(ShiroUtils.getUserId())) {
  169. //最后一次操作是当前用户
  170. stockLand.setCanWithdraw(Constant.True_False.TRUE);
  171. }
  172. }
  173. }
  174. //stockLand.setCanWithdraw(this.canWithdraw(stockLand,ShiroUtils.getUserId()));
  175. }
  176. }
  177. }
  178. return new PageInfo<StockLand>(landApplys);
  179. }
  180. //当前单据是否可以撤回
  181. private Integer canWithdraw(StockLand stockLand, int userId) {
  182. Approval latestAllApprovalByUser = approvalService.getLatestApprovalAllByUser(stockLand.getId(), Constant.DictionaryType.STOCKLAND, userId);
  183. if (null == latestAllApprovalByUser.getIs_withdraw() && latestAllApprovalByUser.getCan_withdraw().equals(Constant.True_False.TRUE)) {
  184. return Constant.True_False.TRUE;
  185. }
  186. return Constant.True_False.FASLE;
  187. }
  188. //审核方法
  189. public Boolean approve(StockLandApprovalDto approval) {
  190. StockLand apply = stockLandService.findLandApplyById(approval.getApply_id());
  191. if (null != apply) {
  192. if (apply.getApply_type().equals(Constant.LandApplyType.RENT)) {
  193. //房屋出租
  194. return rentAuditLocal(apply, approval);
  195. } else {
  196. return auditLocal(apply, approval);
  197. }
  198. }
  199. return false;
  200. }
  201. //房屋出租审核街道属地初审
  202. private Boolean rentAuditLocal(StockLand apply, StockLandApprovalDto approval) {
  203. Boolean flag = true;
  204. approval.setApproval_department(ShiroUtils.getUserEntity().getStreet_name());
  205. if (approval.getStatus().equals(Constant.ApproveButtonStatus.REJECT)) {
  206. //退回
  207. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  208. if (null != latestApproval) {
  209. String nextChecker = latestApproval.getNextchecker();
  210. //2.找出下一审核人
  211. String[] nextCheckerArr = nextChecker.split(",");
  212. if (null != nextCheckerArr && nextCheckerArr.length > 0) {
  213. //“街道合规性审核小组”最后一个人审核(退回)
  214. /*if(nextCheckerArr.length == 1){
  215. //apply.setApprove_status(Constant.LandApproveStatus.REJECT);
  216. apply.setTemporary_state(Constant.LandApproveStatus.REJECT);//记录状态
  217. //街道所有工业用地审核组的人都可以确认并通知
  218. if(StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  219. nextChecker = get_HGXSHXZ_Checkers();
  220. }else {
  221. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  222. }
  223. }else{
  224. //不是最后一个人审核
  225. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  226. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  227. stockLandService.sendAuditMessage(apply,Constant.UserType.STREET,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  228. }*/
  229. //2018-05-11 - 街道办事员也可以退回
  230. apply.setTemporary_state(Constant.LandApproveStatus.REJECT);//记录状态
  231. //街道所有工业用地审核组的人都可以确认并通知
  232. if (StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  233. nextChecker = get_HGXSHXZ_Checkers();
  234. } else {
  235. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  236. }
  237. }
  238. insertApproval(apply, Constant.OperType.REJECT, nextChecker, approval);
  239. //新增待办
  240. String handler = nextChecker;
  241. waitToDoService.newTODO("存量用地确认并通知", "/stockLand/confirmPage/" + apply.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, apply.getId(),
  242. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  243. }
  244. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.APPROVED)) {
  245. //通过
  246. apply.setApprove_status(Constant.LandApproveStatus.APPROVED);
  247. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  248. if (null != latestApproval) {
  249. String nextChecker = latestApproval.getNextchecker();
  250. //2.找出下一审核人
  251. //String [] nextCheckerArr = nextChecker.split(",");
  252. //判断是第几级审核,每一级只要一个审核过了就过了。 --20180528--
  253. nextChecker = getNextLevelChecker(ShiroUtils.getUserId(), nextChecker);
  254. if (StringUtils.isNotBlank(nextChecker)) {
  255. //还有下级审核
  256. //不是最后一个人审核
  257. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  258. stockLandService.sendAuditMessage(apply, Constant.UserType.STREET, null, stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  259. } else {
  260. //没有下级审核领导审核通过
  261. //apply.setApprove_status(Constant.LandApproveStatus.APPROVED);
  262. apply.setTemporary_state(Constant.LandApproveStatus.APPROVED);//记录状态
  263. //街道所有工业用地审核组的人都可以确认并通知
  264. if (StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  265. nextChecker = get_HGXSHXZ_Checkers();
  266. } else {
  267. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  268. }
  269. }
  270. /* 每一级用户所有人都要审核
  271. * if(null != nextCheckerArr && nextCheckerArr.length > 0){
  272. //“街道合规性审核小组”最后一个人审核(通过)
  273. if(nextCheckerArr.length == 1){
  274. //apply.setApprove_status(Constant.LandApproveStatus.APPROVED);
  275. apply.setTemporary_state(Constant.LandApproveStatus.APPROVED);//记录状态
  276. //街道所有工业用地审核组的人都可以确认并通知
  277. if(StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  278. nextChecker = get_HGXSHXZ_Checkers();
  279. }else {
  280. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  281. }
  282. }else{
  283. //不是最后一个人审核
  284. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  285. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  286. stockLandService.sendAuditMessage(apply,Constant.UserType.STREET,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  287. }
  288. }*/
  289. insertApproval(apply, Constant.OperType.APPROVED, nextChecker, approval);
  290. //新增待办
  291. String handler = nextChecker;
  292. waitToDoService.newTODO("存量用地确认并通知", "/stockLand/confirmPage/" + apply.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, apply.getId(),
  293. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  294. }
  295. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.NOTAPPROVED)) {
  296. //不通过,直接不通过,无需再审核
  297. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  298. if (null != latestApproval) {
  299. String nextChecker = latestApproval.getNextchecker();
  300. /*
  301. //2.找出下一审核人
  302. String [] nextCheckerArr = nextChecker.split(",");
  303. if(null != nextCheckerArr && nextCheckerArr.length > 0){
  304. //“街道合规性审核小组”最后一个人审核(退回)
  305. if(nextCheckerArr.length == 1){
  306. //apply.setApprove_status(Constant.LandApproveStatus.NOTAPPROVED);
  307. apply.setTemporary_state(Constant.LandApproveStatus.NOTAPPROVED);//记录状态
  308. //nextChecker = String.valueOf(apply.getCreate_by());
  309. //街道所有工业用地审核组的人都可以确认并通知
  310. if(StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  311. nextChecker = get_HGXSHXZ_Checkers();
  312. }else {
  313. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  314. }
  315. }else{
  316. //不是最后一个人审核
  317. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  318. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  319. stockLandService.sendAuditMessage(apply,Constant.UserType.STREET,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  320. }
  321. }*/
  322. //apply.setApprove_status(Constant.LandApproveStatus.NOTAPPROVED);
  323. apply.setTemporary_state(Constant.LandApproveStatus.NOTAPPROVED);//记录状态
  324. //nextChecker = String.valueOf(apply.getCreate_by());
  325. //街道所有工业用地审核组的人都可以确认并通知
  326. if (StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  327. nextChecker = get_HGXSHXZ_Checkers();
  328. } else {
  329. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  330. }
  331. insertApproval(apply, Constant.OperType.NOTAPPROVED, nextChecker, approval);
  332. //新增待办
  333. String handler = nextChecker;
  334. waitToDoService.newTODO("存量用地确认并通知", "/stockLand/confirmPage/" + apply.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, apply.getId(),
  335. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  336. }
  337. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.SUBMIT_COMMENT)) {
  338. //提交审核意见
  339. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  340. if (null != latestApproval) {
  341. String nextChecker = latestApproval.getNextchecker();
  342. //2.找出下一审核人
  343. nextChecker = getNextLevelChecker(ShiroUtils.getUserId(), nextChecker);
  344. if (StringUtils.isNotBlank(nextChecker)) {
  345. //还有下级审核
  346. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  347. //nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  348. stockLandService.sendAuditMessage(apply, Constant.UserType.STREET, null, stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  349. //新增待办
  350. String handler = nextChecker;
  351. waitToDoService.newTODO("存量用地审核", "/stockLand/approvePage/" + apply.getId(), Constant.WaitToDo_OperType.AUDIT, apply.getId(),
  352. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  353. }
  354. /*String [] nextCheckerArr = nextChecker.split(",");
  355. if(null != nextCheckerArr && nextCheckerArr.length > 0){
  356. //街道合规性审核小组不是最后一个人审核
  357. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  358. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  359. stockLandService.sendAuditMessage(apply,Constant.UserType.STREET,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  360. }*/
  361. insertApproval(apply, Constant.OperType.SUBMIT_COMMENT, nextChecker, approval);
  362. }
  363. }
  364. flag = stockLandService.updateSelective(apply) > 0;
  365. return flag;
  366. }
  367. //找到下一级审核人
  368. private String getNextLevelChecker(Integer currCheckerId, String nextChecker) {
  369. String[] nextCheckerArr = nextChecker.split(",");
  370. User currChecker = userService.findById(currCheckerId);
  371. Integer level = currChecker.getApprove_level();
  372. if (null == level) {
  373. throw new BaseException("当前用户没有审核层级,请检查");
  374. }
  375. //去除相同级别的checker
  376. for (String userId : nextCheckerArr) {
  377. User checker = userService.findById(Integer.valueOf(userId));
  378. if (null == checker.getApprove_level()) {
  379. throw new BaseException("审核组有审核人员没有审核层级,请检查");
  380. }
  381. if (null != checker.getApprove_level() && checker.getApprove_level().equals(level)) {
  382. nextChecker = nextChecker.replace(userId + ",", "");
  383. }
  384. }
  385. return nextChecker;
  386. }
  387. //其他三种审核-街道属地初审
  388. private Boolean auditLocal(StockLand apply, StockLandApprovalDto approval) {
  389. Boolean flag = true;
  390. approval.setApproval_department(ShiroUtils.getUserEntity().getStreet_name());
  391. if (approval.getStatus().equals(Constant.ApproveButtonStatus.REJECT)) {
  392. //退回
  393. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  394. if (null != latestApproval) {
  395. String nextChecker = latestApproval.getNextchecker();
  396. //2.找出下一审核人
  397. String[] nextCheckerArr = nextChecker.split(",");
  398. if (null != nextCheckerArr && nextCheckerArr.length > 0) {
  399. //“街道合规性审核小组”最后一个人审核(退回)
  400. /*if(nextCheckerArr.length == 1){
  401. apply.setApprove_status(Constant.LandApproveStatus.REJECT);
  402. nextChecker = String.valueOf(apply.getCreate_by());
  403. apply.setApprove_status(Constant.LandApproveStatus.REJECT);//记录状态
  404. //街道所有工业用地审核组的人都可以确认并通知
  405. //根据工作组名称查出工作组
  406. if(StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  407. nextChecker = get_HGXSHXZ_Checkers();
  408. }else {
  409. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  410. }
  411. }else{
  412. //不是最后一个人审核
  413. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  414. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  415. stockLandService.sendAuditMessage(apply,Constant.UserType.GOVERNMENT,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  416. }*/
  417. //2018-05-11 - 街道办事员也可以退回
  418. apply.setApprove_status(Constant.LandApproveStatus.REJECT);//记录状态
  419. //街道所有工业用地审核组的人都可以确认并通知
  420. //根据工作组名称查出工作组
  421. if (StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  422. nextChecker = get_HGXSHXZ_Checkers();
  423. } else {
  424. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  425. }
  426. }
  427. insertApproval(apply, Constant.OperType.REJECT, nextChecker, approval);
  428. //新增待办
  429. String handler = nextChecker;
  430. waitToDoService.newTODO("存量用地确认并通知", "/stockLand/confirmPage/" + apply.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, apply.getId(),
  431. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  432. }
  433. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.APPROVED)) {
  434. //通过
  435. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  436. if (null != latestApproval) {
  437. String nextChecker = latestApproval.getNextchecker();
  438. //2.找出下一审核人
  439. //String [] nextCheckerArr = nextChecker.split(",");
  440. //判断是第几级审核,每一级只要一个审核过了就过了。 --20180528--
  441. nextChecker = getNextLevelChecker(ShiroUtils.getUserId(), nextChecker);
  442. if (StringUtils.isNotBlank(nextChecker)) {
  443. //还有下级审核
  444. //不是最后一个人审核
  445. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  446. stockLandService.sendAuditMessage(apply, Constant.UserType.STREET, null, stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  447. //新增待办
  448. String handler = nextChecker;
  449. waitToDoService.newTODO("存量用地审核", "/stockLand/approvePage/" + apply.getId(), Constant.WaitToDo_OperType.AUDIT, apply.getId(),
  450. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  451. } else {
  452. //没有下级审核领导审核通过
  453. apply.setApprove_status(Constant.LandApproveStatus.PENDING_DISTRIBUTE);
  454. nextChecker = userGroupDao.findUserIdsByGroupName(Constant.GroupName.UNITEDWORKGROUP) + ",";
  455. if (StringUtils.isBlank(nextChecker)) {
  456. throw new BaseException("协调工作组暂无审核人员,请联系政府管理员配置!");
  457. }
  458. List<Integer> checkerIds = new ArrayList<Integer>();
  459. for (String checkerId : nextChecker.split(",")) {
  460. checkerIds.add(Integer.valueOf(checkerId));
  461. }
  462. stockLandService.sendAuditMessage(apply, Constant.UserType.GOVERNMENT, null, checkerIds);
  463. //新增待办
  464. String handler = nextChecker;
  465. waitToDoService.newTODO("存量用地审核", "/areaManager/approval?id=" + apply.getId(), Constant.WaitToDo_OperType.AUDIT, apply.getId(),
  466. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  467. }
  468. /*String [] nextCheckerArr = nextChecker.split(",");
  469. if(null != nextCheckerArr && nextCheckerArr.length > 0){
  470. //“街道合规性审核小组”最后一个人审核
  471. if(nextCheckerArr.length == 1){
  472. apply.setApprove_status(Constant.LandApproveStatus.PENDING_DISTRIBUTE);
  473. nextChecker = userGroupDao.findUserIdsByGroupName(Constant.GroupName.UNITEDWORKGROUP);
  474. if(StringUtils.isBlank(nextChecker)) {
  475. throw new BaseException("协调工作组暂无审核人员,请联系政府管理员配置!");
  476. }
  477. List<Integer> checkerIds = new ArrayList<Integer>();
  478. for(String checkerId : nextChecker.split(",")) {
  479. checkerIds.add(Integer.valueOf(checkerId));
  480. }
  481. stockLandService.sendAuditMessage(apply,Constant.UserType.GOVERNMENT,null,checkerIds);
  482. }else{
  483. //不是最后一个人审核
  484. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  485. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  486. stockLandService.sendAuditMessage(apply,Constant.UserType.STREET,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  487. }
  488. }*/
  489. insertApproval(apply, Constant.OperType.APPROVED, nextChecker, approval);
  490. }
  491. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.NOTAPPROVED)) {
  492. //不通过
  493. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  494. if (null != latestApproval) {
  495. String nextChecker = latestApproval.getNextchecker();
  496. //2.找出下一审核人
  497. /*String [] nextCheckerArr = nextChecker.split(",");
  498. if(null != nextCheckerArr && nextCheckerArr.length > 0){
  499. //“街道合规性审核小组”最后一个人审核
  500. if(nextCheckerArr.length == 1){
  501. apply.setApprove_status(Constant.LandApproveStatus.NOTAPPROVED);//记录状态
  502. //街道所有工业用地审核组的人都可以确认并通知
  503. //根据工作组名称查出工作组
  504. if(StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  505. nextChecker = get_HGXSHXZ_Checkers();
  506. }else {
  507. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  508. }
  509. }else{
  510. //不是最后一个人审核
  511. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  512. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  513. stockLandService.sendAuditMessage(apply,Constant.UserType.STREET,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  514. }
  515. }*/
  516. apply.setApprove_status(Constant.LandApproveStatus.NOTAPPROVED);//记录状态
  517. //nextChecker = String.valueOf(apply.getCreate_by());
  518. //街道所有工业用地审核组的人都可以确认并通知
  519. if (StringUtils.isNotBlank(get_HGXSHXZ_Checkers())) {
  520. nextChecker = get_HGXSHXZ_Checkers();
  521. } else {
  522. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  523. }
  524. insertApproval(apply, Constant.OperType.NOTAPPROVED, nextChecker, approval);
  525. //新增待办
  526. String handler = nextChecker;
  527. waitToDoService.newTODO("存量用地确认并通知", "/stockLand/confirmPage/" + apply.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, apply.getId(),
  528. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  529. }
  530. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.SUBMIT_COMMENT)) {
  531. //提交审核意见
  532. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  533. if (null != latestApproval) {
  534. String nextChecker = latestApproval.getNextchecker();
  535. //2.找出下一审核人
  536. nextChecker = getNextLevelChecker(ShiroUtils.getUserId(), nextChecker);
  537. if (StringUtils.isNotBlank(nextChecker)) {
  538. //还有下级审核
  539. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  540. //nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  541. stockLandService.sendAuditMessage(apply, Constant.UserType.STREET, null, stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  542. }
  543. /*String [] nextCheckerArr = nextChecker.split(",");
  544. if(null != nextCheckerArr && nextCheckerArr.length > 0){
  545. //街道合规性审核小组不是最后一个人审核
  546. apply.setApprove_status(Constant.LandApproveStatus.LOCAL_AUDIT);
  547. nextChecker = nextChecker.replace(ShiroUtils.getUserId()+",","");
  548. stockLandService.sendAuditMessage(apply,Constant.UserType.STREET,null,stockLandService.getNextCheckersByLevelAndIdsStr(nextChecker));
  549. }*/
  550. insertApproval(apply, Constant.OperType.SUBMIT_COMMENT, nextChecker, approval);
  551. //新增待办
  552. String handler = nextChecker;
  553. waitToDoService.newTODO("存量用地审核", "/stockLand/approvePage/" + apply.getId(), Constant.WaitToDo_OperType.AUDIT, apply.getId(),
  554. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  555. }
  556. }
  557. flag = stockLandService.updateSelective(apply) > 0;
  558. return flag;
  559. }
  560. //确认并通知企业
  561. public Boolean confirm(Message message) {
  562. logger.info("==== 进行单据处理 ====");
  563. logger.info("当前消息message:{}", message);
  564. StockLand apply = stockLandService.findById(message.getApply_id());
  565. logger.info("当前消息apply:{}", apply);
  566. if (null != apply) {
  567. int[] pushIds = {apply.getCompany_id()};
  568. message.setBusiness_type(Constant.Message_Business_type.STOCKLAND);
  569. message.setBusiness_type_name(Constant.DictionaryType.STOCKLAND);
  570. messageService.saveMessageAndPush(message, pushIds, Constant.UserType.COMPANY);
  571. //2018-08-23 如果是受理员申请的,同时通知受理
  572. User createUser = userService.findById(apply.getCreate_by());
  573. if (null != createUser) {
  574. int[] pushStreetIds = {apply.getCreate_by()};
  575. if (createUser.getUser_type().equals(Constant.UserType.STREET)) {
  576. messageService.saveMessageAndPushToUser(message, pushStreetIds, Constant.UserType.STREET);
  577. }
  578. }
  579. //通知企业,给applystatus赋值,企业可以看到状态改变
  580. if (apply.getApply_type().equals(Constant.LandApplyType.RENT)) {
  581. apply.setApprove_status(apply.getTemporary_state());
  582. }
  583. // 不建议这种写法,会出现空指针
  584. // if(apply.getApprove_status().equals(Constant.LandApproveStatus.REJECT)) {
  585. // apply.setApply_status(Constant.LandApplyStatus.REJECT);
  586. // }else if(apply.getApprove_status().equals(Constant.LandApproveStatus.APPROVED)) {
  587. // apply.setApply_status(Constant.LandApplyStatus.APPROVED);
  588. // apply.setProcess_status(Constant.ProcessStatus.IN_PROGRESS);
  589. // }else if(apply.getApprove_status().equals(Constant.LandApproveStatus.NOTAPPROVED)) {
  590. // apply.setApply_status(Constant.LandApplyStatus.NOTAPPROVED);
  591. // }
  592. if (Objects.equals(apply.getApprove_status(), Constant.LandApproveStatus.REJECT)) {
  593. apply.setApply_status(Constant.LandApplyStatus.REJECT);
  594. }
  595. if (Objects.equals(apply.getApprove_status(), Constant.LandApproveStatus.APPROVED)
  596. || Objects.equals(apply.getApprove_status(), Constant.LandApproveStatus.EASY_PROCESS_APPROVED)) {
  597. apply.setApply_status(Constant.LandApplyStatus.APPROVED);
  598. apply.setProcess_status(Constant.ProcessStatus.IN_PROGRESS);
  599. }
  600. if (Objects.equals(apply.getApprove_status(), Constant.LandApproveStatus.NOTAPPROVED)
  601. || Objects.equals(apply.getApprove_status(), Constant.LandApproveStatus.EASY_PROCESS_DENY)) {
  602. apply.setApply_status(Constant.LandApplyStatus.NOTAPPROVED);
  603. }
  604. // else {
  605. logger.info("===单据信息====");
  606. logger.info("单据的状态:{}", apply.getApprove_status());
  607. logger.info("单据数据:{}", apply);
  608. logger.info("消息数据:{}", message);
  609. logger.info("============");
  610. // throw new RuntimeException("错误的单据状态:" + apply.getApprove_status());
  611. // }
  612. stockLandService.updateSelective(apply);
  613. //置空临时状态
  614. stockLandService.updateTempporaryStateToNull(apply.getId());
  615. //如果街道确认并通知企业,插入街道通知企业的数据,不然审核流一直停留在街道
  616. StockLandApprovalDto approval = new StockLandApprovalDto();
  617. approval.setApproval_department(ShiroUtils.getUserEntity().getStreet_name());
  618. String nextChecker = String.valueOf(apply.getCreate_by());
  619. if (apply.getApprove_status().equals(Constant.LandApproveStatus.APPROVED)) {
  620. nextChecker = "";
  621. }
  622. approval.setApproval_comment(message.getContent());
  623. insertApproval(apply, Constant.OperType.CONFIRM_AND_NOTIFY, nextChecker, approval);
  624. if (apply.getApprove_status().equals(Constant.LandApproveStatus.REJECT)) {
  625. //新增待办
  626. String handler = String.valueOf(apply.getCreate_by());
  627. waitToDoService.newTODO("存量用地编辑", "/stockLand/editApply/" + apply.getId(), Constant.WaitToDo_OperType.EDIT, apply.getId(),
  628. Constant.DictionaryType.STOCKLAND, apply.getApply_no(), handler, Constant.WaitToDo_IsSerial.IS_SERIAL);
  629. } else {
  630. waitToDoService.completeAllTODO(apply.getId(), Constant.DictionaryType.STOCKLAND);
  631. }
  632. return true;
  633. }
  634. return false;
  635. }
  636. public Boolean sendMsg(Message message) {
  637. StockLand apply = stockLandService.findById(message.getApply_id());
  638. //发送短信通知企业
  639. try {
  640. Boolean flag = sendSMSToCompany(apply, message);
  641. return flag;
  642. } catch (ClientException | InterruptedException e) {
  643. throw new BaseException("短信接口异常!发送短信失败!");
  644. }
  645. }
  646. private Boolean sendSMSToCompany(StockLand apply, Message message) throws ClientException, InterruptedException {
  647. String phone = "";
  648. CompanyContact contact = companyContactService.findFirstByCompanyId(apply.getCompany_id());
  649. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(apply.getId(), Constant.DictionaryType.STOCKLAND);
  650. if (null != companyInfo && null != companyInfo.getContact_phone()) {
  651. phone = companyInfo.getContact_phone();
  652. } else if (null != contact) {
  653. phone = contact.getPhone();
  654. }
  655. if (StringUtils.isNotBlank(phone)) {
  656. // ${street_name}提醒您,您的存量用地申请 :${apply_type}(单号:${apply_no})单据已审核,
  657. // 状态为: ${approve_status} ! 具体信息请登录PC端查看。感谢您的支持。
  658. String apply_no = apply.getApply_no();
  659. String apply_type = "";
  660. if (StringUtils.isNotBlank(apply.getApply_type())) {
  661. apply_type = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.STOCKLAND, apply.getApply_type());
  662. }
  663. String approve_status = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS, apply.getApprove_status());
  664. String street_name = ShiroUtils.getUserEntity().getStreet_name();
  665. String templateParam = "{\"street_name\":\"" + street_name + "\",\"apply_type\":\"" + apply_type + "\",\"apply_no\":\"" + apply_no + "\",\"approve_status\":\"" + approve_status + "\"}";
  666. AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.STOCKLAND_CONFIRM_AND_NOTIFY, "企业提升发展服务平台", templateParam);
  667. return true;
  668. } else {
  669. return false;
  670. }
  671. }
  672. //插审核工作流表,审核材料
  673. public void insertApproval(StockLand apply, String oper_type, String nextChecker, StockLandApprovalDto approval) {
  674. Approval latestApproval = approvalService.getLatestApproval(apply.getId(), Constant.DictionaryType.STOCKLAND);
  675. //设置审核完成时间
  676. latestApproval.setDeal_time(DateUtil.getTimeString(new Date()));
  677. approvalService.updateSelective(latestApproval);
  678. //添加新审核流
  679. Approval approvalInfo = new Approval();
  680. approvalInfo.setApply_id(apply.getId());
  681. approvalInfo.setBefore_approvalstatus(latestApproval.getAfter_approvalstatus());
  682. approvalInfo.setAfter_approvalstatus(apply.getApprove_status());
  683. approvalInfo.setApproval_round(latestApproval.getApproval_round());
  684. approvalInfo.setChecker(ShiroUtils.getUserId());
  685. approvalInfo.setNextchecker(nextChecker);
  686. approvalInfo.setType(Constant.DictionaryType.STOCKLAND);
  687. approvalInfo.setOper_type(oper_type);
  688. approvalInfo.setDepartment(approval.getApproval_department());
  689. approvalInfo.setApproval_comment(approval.getApproval_comment());
  690. approvalService.insertAndGetId(approvalInfo);
  691. //插入审核材料
  692. if (null != approval.getFileDowns() && approval.getFileDowns().size() > 0) {
  693. for (FileDown file : approval.getFileDowns()) {
  694. if (null != file && null != file.getFile_id()) {
  695. attachmentDao.updateAttachment(Constant.Attachment.STOCKLAND_APPROVE, approvalInfo.getId(), file.getFile_id());
  696. }
  697. }
  698. }
  699. }
  700. //是否等待通知企业-申请状态与审核状态不一样时,通知企业
  701. public Boolean isPendingNotify(StockLand apply) {
  702. String approveStatus = apply.getApprove_status();
  703. String applyStatus = apply.getApply_status();
  704. if (isApprovalStatusApproved(approveStatus)
  705. && !applyStatus.equals(Constant.LandApplyStatus.APPROVED)) {
  706. return true;
  707. }
  708. if (approveStatus.equals(Constant.LandApproveStatus.NOTAPPROVED)
  709. && !applyStatus.equals(Constant.LandApplyStatus.NOTAPPROVED)) {
  710. return true;
  711. }
  712. if (isApprovalStatusRejected(approveStatus)
  713. && !applyStatus.equals(Constant.LandApplyStatus.REJECT)) {
  714. return true;
  715. }
  716. String temporary_state = apply.getTemporary_state();
  717. if (StringUtils.isNotBlank(temporary_state)) {
  718. return true;
  719. }
  720. return false;
  721. }
  722. private boolean isApprovalStatusRejected(String approveStatus) {
  723. return approveStatus.equals(Constant.LandApproveStatus.REJECT)
  724. || approveStatus.equals(Constant.LandApproveStatus.EASY_PROCESS_DENY);
  725. }
  726. private boolean isApprovalStatusApproved(String approveStatus) {
  727. return approveStatus.equals(Constant.LandApproveStatus.APPROVED)
  728. || approveStatus.equals(Constant.LandApproveStatus.EASY_PROCESS_APPROVED);
  729. }
  730. //是否待审批状态
  731. public Boolean isPendingAudit(StockLand apply) {
  732. String approveStatus = apply.getApprove_status();
  733. if (approveStatus.equals(Constant.LandApproveStatus.APPROVED) || approveStatus.equals(Constant.LandApproveStatus.NOTAPPROVED)
  734. || approveStatus.equals(Constant.LandApproveStatus.REJECT)) {
  735. return false;
  736. }
  737. return true;
  738. }
  739. //添加/编辑进程反馈
  740. public Boolean processFeedback(ProcessFeedback feedback) {
  741. StockLand apply = stockLandService.findById(feedback.getApply_id());
  742. if (null != apply) {
  743. if (null == feedback.getId()) {
  744. feedback.setType(Constant.DictionaryType.STOCKLAND);
  745. processFeedbackService.saveFeedback(feedback);
  746. } else {
  747. processFeedbackService.updateFeedback(feedback);
  748. }
  749. apply.setProcess_status(feedback.getProcess_status());//给申请的线下处理状态processStatus赋值
  750. if (feedback.getProcess_status().equals(Constant.ProcessStatus.PASS)) {
  751. apply.setApprove_status(Constant.LandApproveStatus.PASSED);
  752. apply.setApply_status(Constant.LandApplyStatus.PASSED);
  753. } else if (feedback.getProcess_status().equals(Constant.ProcessStatus.NOTPASS)) {
  754. apply.setApprove_status(Constant.LandApproveStatus.NOTPASSED);
  755. apply.setApply_status(Constant.LandApplyStatus.NOTPASSED);
  756. }
  757. stockLandService.updateSelective(apply);
  758. return true;
  759. }
  760. return false;
  761. }
  762. public Boolean isLeader(String groupName) {
  763. //登录用户的审核层级是不是工作组最高级,最高级则是领导,可以选择通过/不通过/退回
  764. Integer level = 0;
  765. User currUser = ShiroUtils.getUserEntity();
  766. level = groupService.getHighestApproveLevel(groupName, Constant.UserType.STREET);
  767. if (null != level && currUser.getApprove_level().equals(level)) {
  768. return true;
  769. }
  770. return false;
  771. }
  772. //获取街道合规性审核小组所有人员
  773. public String get_HGXSHXZ_Checkers() {
  774. //根据工作组名称查出工作组
  775. Group group = groupService.findByNameAndUserType(Constant.HGXSHXZ, null, Constant.UserType.STREET, null);
  776. //如果不为空
  777. if (null != group) {
  778. //根据工作组id查出UserGroup
  779. List<UserGroup> list = userGroupService.findByGroupId(group.getId());
  780. if (null == list || list.size() == 0) {
  781. throw new BaseException("街道工业用地合规性审核组没有配置人员,请联系街道管理员配置!");
  782. }
  783. //构建一个StringBuffer 存放下一审核人id
  784. StringBuffer sb = new StringBuffer("");
  785. for (UserGroup userGroup : list) {
  786. Integer userId = userGroup.getUser_id();
  787. sb.append(userId + ",");
  788. }
  789. return sb.toString();
  790. }
  791. return null;
  792. }
  793. /**
  794. * findApprovePassPage(查询审批通过列表)
  795. *
  796. * @param pageNum
  797. * @param pagesize
  798. * @param keyword
  799. * @param company_name
  800. * @param apply_type
  801. * @param itemId
  802. * @param street_id
  803. * @return PageInfo<StockLand>
  804. * @throws ParseException
  805. */
  806. @Transactional(readOnly = true)
  807. public PageInfo<StockLand> findApprovePassPage(
  808. Integer pageNum, Integer pagesize, String keyword, String company_name, String apply_type, Integer itemId, Integer street_id, Integer applyUserType) throws ParseException {
  809. if (StringUtils.isNotBlank(keyword)) {
  810. keyword = keyword.trim();
  811. }
  812. if (StringUtils.isNotBlank(company_name)) {
  813. company_name = company_name.trim();
  814. }
  815. Integer user_type = ShiroUtils.getUserEntity().getUser_type();
  816. UserData userData = new UserData();
  817. if (user_type.equals(Constant.UserType.STREET)) {
  818. userData.setStreet_id(ShiroUtils.getUserEntity().getStreet_id());
  819. //超级管理员
  820. }
  821. String approve = Constant.LandApproveStatus.APPROVED;
  822. //获取存量用地type id
  823. Integer stockLandId = dictionaryTypeService.getDictionaryType(Constant.DictionaryType.STOCKLAND).getId();
  824. //存量用地审核状态 id
  825. Integer approvedId = dictionaryTypeService.getDictionaryType(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS).getId();
  826. //通过的状态
  827. List<String> statusList = new ArrayList<String>();
  828. statusList.add(Constant.LandApproveStatus.APPROVED);
  829. statusList.add(Constant.LandApproveStatus.PASSED);
  830. PageHelper.startPage(pageNum, pagesize);
  831. List<StockLand> stockLandList = stockLandDao.findApprovePassPage(keyword, company_name, apply_type, approve, userData, stockLandId, approvedId, itemId, street_id, applyUserType, statusList);
  832. for (StockLand stockLand : stockLandList) {
  833. stockLand.setPassTime(stockLand.getCreate_time());
  834. //是否是重大项目
  835. Integer is_zdxm = stockLand.getIs_zdxm();
  836. if (is_zdxm != null) {
  837. if (is_zdxm == 1) {
  838. stockLand.setIs_zdxm_str("是");
  839. } else {
  840. stockLand.setIs_zdxm_str("否");
  841. }
  842. }
  843. }
  844. return new PageInfo<StockLand>(stockLandList);
  845. }
  846. /**
  847. * findSelectPage(查询所有审核状态下列表)
  848. *
  849. * @param pageNum
  850. * @param pagesize
  851. * @param keyword
  852. * @param company_name
  853. * @param apply_type
  854. * @param approve_status
  855. * @param itemId
  856. * @param street_id
  857. * @return PageInfo<StockLand>
  858. */
  859. public PageInfo<StockLand> findSelectPage(
  860. Integer pageNum, Integer pagesize, String keyword, String company_name, String apply_type,
  861. String approve_status, Integer itemId, Integer street_id, Integer applyUserType) {
  862. if (StringUtils.isNotBlank(keyword)) {
  863. keyword = keyword.trim();
  864. }
  865. if (StringUtils.isNotBlank(company_name)) {
  866. company_name = company_name.trim();
  867. }
  868. Integer user_type = ShiroUtils.getUserEntity().getUser_type();
  869. UserData userData = new UserData();
  870. if (user_type.equals(Constant.UserType.STREET)) {
  871. userData.setStreet_id(ShiroUtils.getUserEntity().getStreet_id());
  872. //超级管理员
  873. }
  874. //获取存量用地type id
  875. Integer stockLandId = dictionaryTypeService.getDictionaryType(Constant.DictionaryType.STOCKLAND).getId();
  876. //存量用地审核状态 id
  877. Integer approvedId = dictionaryTypeService.getDictionaryType(Constant.DictionaryType.STOCKLAND_APPROVE_STATUS).getId();
  878. PageHelper.startPage(pageNum, pagesize);
  879. String rejectStatus = Constant.LandApproveStatus.REJECT;
  880. List<StockLand> stockLandList = stockLandDao.findSelectPage(stockLandId, approvedId, itemId, street_id, keyword, company_name, approve_status, userData, applyUserType, rejectStatus);
  881. for (StockLand stockLand : stockLandList) {
  882. stockLand.setPassTime(stockLand.getCreate_time());
  883. //是否是重大项目
  884. Integer is_zdxm = stockLand.getIs_zdxm();
  885. if (is_zdxm != null) {
  886. if (is_zdxm == 1) {
  887. stockLand.setIs_zdxm_str("是");
  888. } else {
  889. stockLand.setIs_zdxm_str("否");
  890. }
  891. }
  892. }
  893. return new PageInfo<StockLand>(stockLandList);
  894. }
  895. //审核撤回
  896. public void withDraw(Integer apply_id) {
  897. StockLand apply = stockLandService.findById(apply_id);
  898. if (stockLandService.canWithdraw(apply, ShiroUtils.getUserId()).equals(Constant.True_False.FASLE)) {
  899. throw new BaseException("当前单据已不可撤回!");
  900. }
  901. Approval latestApproval = approvalService.getLatestApprovalAll(apply_id, Constant.DictionaryType.STOCKLAND);
  902. if (latestApproval.getBefore_approvalstatus().equals(Constant.LandApproveStatus.COMPLIANCE_AUDIT)
  903. && (apply.getApprove_status().equals(Constant.LandApproveStatus.COMPLIANCE_AUDIT) || apply.getApprove_status().equals(Constant.LandApproveStatus.HGXSCTG))) {
  904. //合规性审核撤回
  905. if (latestApproval.getChecker().equals(ShiroUtils.getUserId())) {
  906. //最近一条就是当前用户审核的
  907. latestApproval.setIs_withdraw(Constant.True_False.TRUE);
  908. latestApproval.setDel_flag(true);
  909. approvalService.updateSelective(latestApproval);
  910. apply.setApprove_status(latestApproval.getBefore_approvalstatus());
  911. stockLandService.updateSelective(apply);
  912. } else {
  913. //最近一条不是当前用户审核的
  914. Approval latestAllApprovalByUser = approvalService.getLatestApprovalAllByUser(apply.getId(), Constant.DictionaryType.STOCKLAND, ShiroUtils.getUserId());
  915. latestAllApprovalByUser.setIs_withdraw(Constant.True_False.TRUE);
  916. latestAllApprovalByUser.setDel_flag(true);
  917. approvalService.updateSelective(latestAllApprovalByUser);
  918. latestApproval.setNextchecker(latestApproval.getNextchecker() + ShiroUtils.getUserId() + ",");
  919. approvalService.updateSelective(latestApproval);
  920. apply.setApprove_status(latestApproval.getBefore_approvalstatus());
  921. stockLandService.updateSelective(apply);
  922. }
  923. } else {
  924. latestApproval.setIs_withdraw(Constant.True_False.TRUE);
  925. latestApproval.setDel_flag(true);
  926. approvalService.updateSelective(latestApproval);
  927. //撤回,更改单据状态为原状态
  928. //StockLand apply = stockLandService.findById(apply_id);
  929. apply.setApprove_status(latestApproval.getBefore_approvalstatus());
  930. if (StringUtils.isNotBlank(apply.getTemporary_state())) {
  931. //清空临时状态
  932. stockLandService.updateTempporaryStateToNull(apply_id);
  933. }
  934. stockLandService.updateSelective(apply);
  935. }
  936. }
  937. //是否是当前审核人
  938. public Boolean isCurrChecker(Integer apply_id, StockLandApprovalDto approvalInfo) {
  939. Boolean isNextChecker = false;
  940. Approval latestApproval = approvalService.getLatestApproval(apply_id, Constant.DictionaryType.STOCKLAND);
  941. User currUser = ShiroUtils.getUserEntity();
  942. Integer currUserId = currUser.getId();
  943. String[] userIds = latestApproval.getNextchecker().split(",");
  944. if (userIds.length > 0) {
  945. for (String userId : userIds) {
  946. if (userId.equals(String.valueOf(currUserId))) {
  947. isNextChecker = true;
  948. }
  949. }
  950. if (isNextChecker) {
  951. //是否到了登录用户的审核层级
  952. if (currUser.getUser_type().equals(Constant.UserType.GOVERNMENT)) {
  953. for (String userId : userIds) {
  954. User user = userService.findById(Integer.valueOf(userId));
  955. if (null != user.getDepartment_id() && user.getDepartment_id().equals(currUser.getDepartment_id())) {
  956. if (null != user.getApprove_level() && null != currUser.getApprove_level() && user.getApprove_level() > currUser.getApprove_level()) {
  957. //没有到当前用户审核层级
  958. isNextChecker = false;
  959. }
  960. }
  961. }
  962. } else if (currUser.getUser_type().equals(Constant.UserType.STREET)) {
  963. for (String userId : userIds) {
  964. User user = userService.findById(Integer.valueOf(userId));
  965. if (null != user.getApprove_level() && null != currUser.getApprove_level() && user.getApprove_level() > currUser.getApprove_level()) {
  966. //没有到当前用户审核层级
  967. isNextChecker = false;
  968. }
  969. }
  970. }
  971. if (isNextChecker) {
  972. //当前节点是否已经审核过(两个用户同时审核)
  973. if (StringUtils.isNotBlank(approvalInfo.getStatu())) {
  974. if (!(approvalInfo.getStatu().equals(Constant.LandApproveStatus.JYLCHQ)
  975. || approvalInfo.getStatu().equals(Constant.LandApproveStatus.COMPLIANCE_AUDIT)
  976. || approvalInfo.getStatu().equals(Constant.LandApproveStatus.LOCAL_AUDIT)))
  977. if (stockLandService.isApproved(apply_id, approvalInfo.getStatu())) {
  978. isNextChecker = false;
  979. }
  980. }
  981. }
  982. }
  983. }
  984. return isNextChecker;
  985. }
  986. }