ProjectFillingDeclarationService.java 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228
  1. package platform.modules.government.service;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.aliyuncs.exceptions.ClientException;
  4. import com.github.pagehelper.PageHelper;
  5. import com.github.pagehelper.PageInfo;
  6. import org.apache.commons.lang3.StringUtils;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import org.springframework.transaction.annotation.Transactional;
  10. import org.springframework.ui.ModelMap;
  11. import org.springframework.util.CollectionUtils;
  12. import platform.common.Constant;
  13. import platform.common.base.model.DictionaryItem;
  14. import platform.common.base.service.BaseService;
  15. import platform.common.base.service.DictionaryItemService;
  16. import platform.common.exception.BaseException;
  17. import platform.common.util.AlibabaSMSUtil;
  18. import platform.common.util.DateUtil;
  19. import platform.common.util.ShiroUtils;
  20. import platform.modules.build.entity.Company;
  21. import platform.modules.build.entity.CompanyContact;
  22. import platform.modules.build.service.BuildInfoService;
  23. import platform.modules.build.service.CompanyContactService;
  24. import platform.modules.build.service.CompanyService;
  25. import platform.modules.company.dao.ProjectApplicationDao;
  26. import platform.modules.company.dao.ProjectFillingDao;
  27. import platform.modules.company.dao.ProjectMaterialDao;
  28. import platform.modules.company.entity.*;
  29. import platform.modules.company.service.ProjectApplicationCompanyInfoService;
  30. import platform.modules.company.service.ProjectApplicationService;
  31. import platform.modules.company.service.ProjectFillingService;
  32. import platform.modules.company.service.ProjectMaterialService;
  33. import platform.modules.government.dao.AttachmentDao;
  34. import platform.modules.government.dao.ProjectDao;
  35. import platform.modules.government.dao.ProjectDeclarationDao;
  36. import platform.modules.government.dao.ProjectFillingDeclarationDao;
  37. import platform.modules.government.dto.*;
  38. import platform.modules.government.entity.*;
  39. import platform.modules.home.request.FindRequest;
  40. import platform.modules.home.response.FindResponseProject;
  41. import platform.modules.sys.dao.ApprovalDao;
  42. import platform.modules.sys.entity.*;
  43. import platform.modules.sys.service.*;
  44. import tk.mybatis.mapper.entity.Example;
  45. import java.text.ParseException;
  46. import java.text.SimpleDateFormat;
  47. import java.util.*;
  48. @Service
  49. @Transactional
  50. public class ProjectFillingDeclarationService extends BaseService<ProjectFillingDeclaration> {
  51. @Autowired
  52. private ProjectFillingDeclarationDao projectFillingDeclarationDao;
  53. @Autowired
  54. private ProjectServiceTypeService projectServiceTypeService;
  55. @Autowired
  56. private NoticesService noticesService;
  57. @Autowired
  58. private NoticesAcceptService noticesAcceptService;
  59. @Autowired
  60. private MessageService messageService;
  61. @Autowired
  62. private AttachmentDao attachmentDao;
  63. @Autowired
  64. private StreetService streetService;
  65. @Autowired
  66. private BuildInfoService buildInfoService;
  67. @Autowired
  68. private CompanyService companyService;
  69. @Autowired
  70. private GroupService groupService;
  71. @Autowired
  72. private UserGroupService userGroupService;
  73. @Autowired
  74. private UserService userService;
  75. @Autowired
  76. private ProjectApplicationDao projectApplicationDao;
  77. @Autowired
  78. private ProjectDao projectDao;
  79. @Autowired
  80. private ApprovalDao approvalDao;
  81. @Autowired
  82. private DepartmentService departmentService;
  83. @Autowired
  84. private DictionaryItemService dictionaryItemService;
  85. @Autowired
  86. private ApprovalService approvalService;
  87. @Autowired
  88. private ProjectMaterialDao projectMaterialDao;
  89. @Autowired
  90. private ProjectMaterialService projectMaterialDaoService;
  91. @Autowired
  92. private AttachmentService attachmentService;
  93. @Autowired
  94. private ProjectTypeService projectTypeService;
  95. @Autowired
  96. private CompanyContactService companyContactService;
  97. @Autowired
  98. private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService;
  99. @Autowired
  100. private ProjectApplicationService projectApplicationService;
  101. @Autowired
  102. private WaitToDoService waitToDoService;
  103. @Autowired
  104. private ProjectFillingService projectFillingService;
  105. @Autowired
  106. private ProjectFillingDao projectFillingDao;
  107. public PageInfo<ProjectFillingDeclaration> findPageInfo(String projectName, String projectType, String projectSource, Integer pageNum, Integer pagesize) {
  108. PageHelper.startPage(pageNum, pagesize);
  109. List<ProjectFillingDeclaration> list = projectFillingDeclarationDao.findPageInfo(projectName, projectType, projectSource);
  110. List<DictionaryItem> projectTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE);
  111. for (DictionaryItem dictionaryItem : projectTypeList) {
  112. for (ProjectFillingDeclaration projectFillingDeclaration : list) {
  113. if (Objects.equals(dictionaryItem.getValue(), projectFillingDeclaration.getProject_type())) {
  114. projectFillingDeclaration.setProject_type_name(dictionaryItem.getName());
  115. }
  116. if (StringUtils.isNotBlank(projectFillingDeclaration.getProject_service_type())) {
  117. String name = projectServiceTypeService.findById(projectFillingDeclaration.getProject_service_type()).get(0).getService_type_name();
  118. projectFillingDeclaration.setProject_service_type_name(name);
  119. }
  120. String companyIds = projectFillingDeclaration.getPush_company_ids();
  121. if (StringUtils.isNotBlank(companyIds)) {
  122. String[] companyIdsArr = companyIds.split(",");
  123. projectFillingDeclaration.setTotal(companyIdsArr.length);
  124. } else {
  125. projectFillingDeclaration.setTotal(0);
  126. }
  127. projectFillingDeclaration.setCount(projectFillingService.getQuantityByDeclarationId(projectFillingDeclaration.getId().toString()));
  128. }
  129. }
  130. return new PageInfo<ProjectFillingDeclaration>(list);
  131. }
  132. public Integer save(ProjectFillingDeclaration projectDeclaration) {
  133. if (StringUtils.isNotBlank(projectDeclaration.getProject_service_type())) {
  134. String name = projectServiceTypeService.findById(projectDeclaration.getProject_service_type()).get(0).getService_type_name();
  135. String year = projectDeclaration.getYear();
  136. String jy = projectDeclaration.getSeason_or_month();
  137. String projectNames = "";
  138. if (StringUtils.isNotBlank(year)) {
  139. projectNames += year + "年";
  140. }
  141. if (StringUtils.isNotBlank(jy)) {
  142. if (Objects.equals("J", jy)) {
  143. projectNames += "第" + projectDeclaration.getSeason() + "季度";
  144. } else if (Objects.equals("Y", jy)) {
  145. projectNames += "第" + projectDeclaration.getMonth() + "月度";
  146. }
  147. }
  148. projectNames += name;
  149. projectDeclaration.setProject_name(projectNames);
  150. }
  151. this.insertAndGetId(projectDeclaration);
  152. Integer activityId = projectDeclaration.getId();
  153. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_FILLING_DEC, projectDeclaration.getId());
  154. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_FILLING_DEC, projectDeclaration.getId(), projectDeclaration.getFileDown().getFile_id());
  155. if ("1".equals(projectDeclaration.getStatus())) {
  156. pushNotices(projectDeclaration);
  157. //TODO 初始化企业填报数据
  158. initFillingData(projectDeclaration);
  159. }
  160. /*if (projectDeclaration.getStatus().equals(Constant.ProjectDeclarationStatus.RELEASE)) {
  161. //所有企业
  162. List<Company> companies = companyService.findCompanyList();
  163. String companyids = "";
  164. for (Company company : companies) {
  165. companyids += company.getId() + ",";
  166. }
  167. //所有街道
  168. List<Street> streets = streetService.findList();
  169. String streetids = "";
  170. for (Street street : streets) {
  171. streetids += street.getId() + ",";
  172. }
  173. //中心窗口
  174. StringBuffer governmentids = new StringBuffer("");
  175. Group group = groupService.findByName(Constant.XMSBCLSLZ, null);
  176. if (null == group) {
  177. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  178. }
  179. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  180. for (UserGroup userGroup : userGroups) {
  181. governmentids.append(userGroup.getUser_id() + ",");
  182. }
  183. //处室
  184. group = groupService.findByName(Constant.XMSBCLSHZ, null);
  185. if (null == group) {
  186. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  187. }
  188. userGroups = userGroupService.findByGroupId(group.getId());
  189. for (UserGroup userGroup : userGroups) {
  190. governmentids.append(userGroup.getUser_id() + ",");
  191. }
  192. //财政
  193. group = groupService.findByName(Constant.XMSBCZSHZ, null);
  194. if (null == group) {
  195. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  196. }
  197. userGroups = userGroupService.findByGroupId(group.getId());
  198. for (UserGroup userGroup : userGroups) {
  199. governmentids.append(userGroup.getUser_id() + ",");
  200. }
  201. Message messages = new Message();
  202. messages.setApply_id(activityId);
  203. messages.setTitle("项目申报发布通知");
  204. String projectName = projectDeclaration.getProject_name();
  205. String message = "您好,“" + projectName + "项目”可以进行申报。谢谢。";
  206. messages.setContent(message);
  207. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  208. if (!StringUtils.isEmpty(streetids)) {
  209. String[] streetArr = streetids.split(",");
  210. Set<String> set = new HashSet<>();
  211. for (int i = 0; i < streetArr.length; i++) {
  212. set.add(streetArr[i]);
  213. }
  214. String[] streetArrs = (String[]) set.toArray(new String[set.size()]);
  215. int[] streetArrInt = new int[streetArrs.length];
  216. for (int i = 0; i < streetArrs.length; i++) {
  217. streetArrInt[i] = Integer.parseInt(streetArrs[i]);
  218. }
  219. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.STREET);
  220. }
  221. if (!StringUtils.isEmpty(companyids)) {
  222. String[] companyArr = companyids.split(",");
  223. Set<String> set = new HashSet<>();
  224. for (int i = 0; i < companyArr.length; i++) {
  225. set.add(companyArr[i]);
  226. }
  227. String[] companyArrs = (String[]) set.toArray(new String[set.size()]);
  228. int[] companyArrInt = new int[companyArrs.length];
  229. for (int i = 0; i < companyArrs.length; i++) {
  230. companyArrInt[i] = Integer.parseInt(companyArrs[i]);
  231. }
  232. messageService.saveMessageAndPush(messages, companyArrInt, Constant.UserType.COMPANY);
  233. }
  234. if (!StringUtils.isEmpty(governmentids.toString())) {
  235. String[] governmentArr = governmentids.toString().split(",");
  236. Set<String> set = new HashSet<>();
  237. for (int i = 0; i < governmentArr.length; i++) {
  238. set.add(governmentArr[i]);
  239. }
  240. String[] governmentArrs = (String[]) set.toArray(new String[set.size()]);
  241. int[] governmentArrInt = new int[governmentArrs.length];
  242. for (int i = 0; i < governmentArrs.length; i++) {
  243. governmentArrInt[i] = Integer.parseInt(governmentArrs[i]);
  244. }
  245. messageService.saveMessageAndPush(messages, governmentArrInt, Constant.UserType.GOVERNMENT);
  246. }
  247. }*/
  248. return activityId;
  249. }
  250. //初始化空的企业填报数据
  251. public void initFillingData(ProjectFillingDeclaration projectDeclaration) {
  252. String companyIds = projectDeclaration.getNew_push_company_ids();
  253. if (StringUtils.isNotBlank(companyIds)) {
  254. String[] companyIdsArr = companyIds.split(",");
  255. if (companyIdsArr.length > 0) {
  256. for (String id : companyIdsArr) {
  257. ProjectFilling filling = new ProjectFilling();
  258. filling.setCompany_id(Integer.valueOf(id));
  259. filling.setDeclaration_id(projectDeclaration.getId());
  260. filling.setApply_status(Constant.ProjectFillingStatus_Company.PENDING_SUBMIT);
  261. projectFillingService.saveSelective(filling);
  262. }
  263. }
  264. }
  265. }
  266. public Integer update(ProjectFillingDeclaration projectDeclaration) {
  267. if (StringUtils.isNotBlank(projectDeclaration.getProject_service_type())) {
  268. String name = projectServiceTypeService.findById(projectDeclaration.getProject_service_type()).get(0).getService_type_name();
  269. String year = projectDeclaration.getYear();
  270. String jy = projectDeclaration.getSeason_or_month();
  271. String projectNames = "";
  272. if (StringUtils.isNotBlank(year)) {
  273. projectNames += year + "年";
  274. }
  275. if (StringUtils.isNotBlank(jy)) {
  276. if (Objects.equals("J", jy)) {
  277. projectNames += "第" + projectDeclaration.getSeason() + "季度";
  278. } else if (Objects.equals("Y", jy)) {
  279. projectNames += "第" + projectDeclaration.getMonth() + "月度";
  280. }
  281. }
  282. projectNames += name;
  283. projectDeclaration.setProject_name(projectNames);
  284. }
  285. this.updateSelective(projectDeclaration);
  286. Integer activityId = projectDeclaration.getId();
  287. // List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_FILLING_DEC, projectDeclaration.getId(), null);
  288. // if (null != attachments && attachments.size() > 0) {
  289. // FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  290. // if (!fileDown.getFile_id().equals(projectDeclaration.getFileDown().getFile_id())) {
  291. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_FILLING_DEC, projectDeclaration.getId());
  292. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_FILLING_DEC, projectDeclaration.getId(), projectDeclaration.getFileDown().getFile_id());
  293. // }
  294. // }
  295. if ("1".equals(projectDeclaration.getStatus())) {
  296. pushNotices(projectDeclaration);
  297. initFillingData(projectDeclaration);
  298. }
  299. return activityId;
  300. }
  301. @Transactional
  302. public void pushNotices(ProjectFillingDeclaration projectDeclaration) {
  303. if (null != projectDeclaration.getNew_push_company_ids()) {
  304. try {
  305. updatePushDetails(projectDeclaration, projectDeclaration.getNew_push_street_ids(), projectDeclaration.getNew_push_build_ids(), projectDeclaration.getNew_push_company_ids());
  306. } catch (Exception e) {
  307. e.printStackTrace();
  308. }
  309. String company_ids = projectDeclaration.getNew_push_company_ids();
  310. projectDeclaration.setPush_company_ids(company_ids);
  311. }
  312. if (Objects.equals(projectDeclaration.getStatus(), "1") && projectDeclaration.getPush_company_ids() != null && !projectDeclaration.getPush_company_ids().isEmpty()) {
  313. Notices notice = new Notices();
  314. if (Objects.equals(projectDeclaration.getApp_notice(), "1")) {
  315. notice.setNotice_type(Constant.NOTICE_TYPE.APP);
  316. if (Objects.equals(projectDeclaration.getMes_notice(), "1")) {
  317. notice.setNotice_type(Constant.NOTICE_TYPE.APP_MSG);
  318. }
  319. } else {
  320. if (Objects.equals(projectDeclaration.getMes_notice(), "1")) {
  321. notice.setNotice_type(Constant.NOTICE_TYPE.MSG);
  322. }
  323. }
  324. notice.setMessage_content("");
  325. notice.setRecorde_id(projectDeclaration.getId().toString());
  326. noticesService.insertAndGetId(notice);
  327. Integer noticesId = notice.getId();
  328. String companyIds = projectDeclaration.getPush_company_ids();
  329. String[] companyIdsArr = companyIds.split(",");
  330. List<NoticesAccept> ids = new ArrayList<NoticesAccept>();
  331. if (companyIdsArr.length > 0) {
  332. for (String id : companyIdsArr) {
  333. NoticesAccept noticesAccept = new NoticesAccept();
  334. noticesAccept.setNotice_id(noticesId);
  335. noticesAccept.setRead_statu(0);
  336. noticesAccept.setUser_type(Constant.UserType.COMPANY);
  337. noticesAccept.setRecorde_type(2);
  338. noticesAccept.setRecorde_id(projectDeclaration.getId());
  339. noticesAccept.setUser_id(Integer.parseInt(id));
  340. noticesAccept.setUser_type(3);
  341. noticesAcceptService.insertAndGetId(noticesAccept);
  342. //发送短信通知
  343. User companyAdmin = userService.findCompanyAdmin(Integer.parseInt(id));
  344. Map<String, String> params = new HashMap<>();
  345. params.put("project_no", projectDeclaration.getProject_name());
  346. params.put("start_time", projectDeclaration.getApply_startdate());
  347. params.put("end_time", projectDeclaration.getApply_enddate());
  348. String tempalteCode = Constant.SMS_TemplateCode.REMIND_COMPANY_APPLY_PROJECT;
  349. try {
  350. AlibabaSMSUtil.sendSMS(
  351. companyAdmin.getPhone(), tempalteCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  352. } catch (ClientException | InterruptedException e) {
  353. e.printStackTrace();
  354. }
  355. }
  356. }
  357. }
  358. }
  359. /**
  360. * 更新通知推送单位
  361. */
  362. public Boolean updatePushDetails(ProjectFillingDeclaration projectDeclaration, String street_ids, String build_ids, String company_ids) throws Exception {
  363. String alreadyPushStreets = projectDeclaration.getPush_street_ids() == null ? "" : projectDeclaration.getPush_street_ids();
  364. String alreadyPushBuilds = projectDeclaration.getPush_build_ids() == null ? "" : projectDeclaration.getPush_build_ids();
  365. String alreadyPushCompanys = projectDeclaration.getPush_company_ids() == null ? "" : projectDeclaration.getPush_company_ids();
  366. if (StringUtils.isNotBlank(street_ids)) {
  367. String[] idsArr = street_ids.split(",");
  368. if (idsArr.length > 0) {
  369. for (int i = 0; i < idsArr.length; i++) {
  370. if (!alreadyPushStreets.contains(idsArr[i])) {
  371. if (StringUtils.isBlank(alreadyPushStreets)) {
  372. alreadyPushStreets += idsArr[i];
  373. } else {
  374. alreadyPushStreets += "," + idsArr[i];
  375. }
  376. }
  377. }
  378. } else {
  379. alreadyPushStreets = street_ids;
  380. }
  381. }
  382. if (StringUtils.isNotBlank(build_ids)) {
  383. String[] idsArr = build_ids.split(",");
  384. if (idsArr.length > 0) {
  385. for (int i = 0; i < idsArr.length; i++) {
  386. if (!alreadyPushBuilds.contains(idsArr[i])) {
  387. if (StringUtils.isBlank(alreadyPushBuilds)) {
  388. alreadyPushBuilds += idsArr[i];
  389. } else {
  390. alreadyPushBuilds += "," + idsArr[i];
  391. }
  392. }
  393. }
  394. } else {
  395. alreadyPushBuilds = build_ids;
  396. }
  397. }
  398. if (StringUtils.isNotBlank(company_ids)) {
  399. String[] idsArr = company_ids.split(",");
  400. if (idsArr.length > 0) {
  401. for (int i = 0; i < idsArr.length; i++) {
  402. if (!alreadyPushCompanys.contains(idsArr[i])) {
  403. if (StringUtils.isBlank(alreadyPushCompanys)) {
  404. alreadyPushCompanys += idsArr[i];
  405. } else {
  406. alreadyPushCompanys += "," + idsArr[i];
  407. }
  408. }
  409. }
  410. } else {
  411. alreadyPushCompanys = company_ids;
  412. }
  413. }
  414. projectDeclaration.setPush_street_ids(alreadyPushStreets.substring(0, alreadyPushStreets.length()));
  415. projectDeclaration.setPush_build_ids(alreadyPushBuilds.substring(0, alreadyPushBuilds.length()));
  416. projectDeclaration.setPush_company_ids(alreadyPushCompanys.substring(0, alreadyPushCompanys.length()));
  417. return this.updateSelective(projectDeclaration) > 0;
  418. }
  419. /**
  420. * 批量修改启用禁用状态
  421. *
  422. * @param idList
  423. */
  424. public void updateForbiddenStateBatch(List<String> idList, ProjectFillingDeclaration projectFillingDeclaration) {
  425. projectFillingDeclarationDao.updateForbiddenStateBatch(idList, projectFillingDeclaration);
  426. }
  427. public ProjectFillingDeclaration selectById(String id) {
  428. ProjectFillingDeclaration projectDeclaration = projectFillingDeclarationDao.selectById(id);
  429. //责任单位
  430. if (null != projectDeclaration.getDepartment_id()) {
  431. Department dept = departmentService.findById(projectDeclaration.getDepartment_id());
  432. if (null != dept) {
  433. projectDeclaration.setDepartment_name(dept.getName());
  434. }
  435. }
  436. //项目大类
  437. String superType = projectDeclaration.getProject_type();
  438. if (StringUtils.isNotBlank(superType)) {
  439. DictionaryItem superTypeItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE, superType);
  440. if (null != superTypeItem) {
  441. projectDeclaration.setProject_type_name(superTypeItem.getName());
  442. }
  443. }
  444. //服务事项
  445. String serviceType = projectDeclaration.getProject_service_type();
  446. if (StringUtils.isNotBlank(serviceType)) {
  447. List<ProjectServiceType> projectServiceTypeList = projectServiceTypeService.findById(serviceType);
  448. if (!CollectionUtils.isEmpty(projectServiceTypeList)) {
  449. projectDeclaration.setProject_service_type_name(projectServiceTypeList.get(0).getService_type_name());
  450. }
  451. }
  452. //项目来源
  453. String source = projectDeclaration.getProject_source();
  454. if (StringUtils.isNotBlank(source)) {
  455. DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, source);
  456. if (null != sourceItem) {
  457. projectDeclaration.setProject_source_name(sourceItem.getName());
  458. }
  459. }
  460. //文件
  461. List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_FILLING_DEC, projectDeclaration.getId(), null);
  462. if (null != attachments && attachments.size() > 0) {
  463. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  464. projectDeclaration.setFileDown(fileDown);
  465. }
  466. String companyIds = projectDeclaration.getPush_company_ids();
  467. String[] companyIdsArr = companyIds.split(",");
  468. projectDeclaration.setTotal(companyIdsArr.length);
  469. projectDeclaration.setCount(projectFillingService.getQuantityByDeclarationId(projectDeclaration.getId().toString()));
  470. try {
  471. projectDeclaration = getPushNames(projectDeclaration);
  472. } catch (Exception e) {
  473. e.printStackTrace();
  474. }
  475. return projectDeclaration;
  476. }
  477. //查询推送单位名称
  478. public ProjectFillingDeclaration getPushNames(ProjectFillingDeclaration projectDeclaration) throws Exception {
  479. String pushNames = "";
  480. if (StringUtils.isNotBlank(projectDeclaration.getPush_street_ids())) {
  481. List<String> streetNames = new ArrayList<String>();
  482. String[] streetIds = projectDeclaration.getPush_street_ids().split(",");
  483. for (int i = 0; i < streetIds.length; i++) {
  484. String name = streetService.getStreetName(Integer.valueOf(streetIds[i]));
  485. streetNames.add(name);
  486. }
  487. projectDeclaration.setPush_street_names(String.join(",", streetNames));
  488. pushNames += String.join(",", streetNames);
  489. }
  490. if (StringUtils.isNotBlank(projectDeclaration.getPush_build_ids())) {
  491. List<String> buildNames = new ArrayList<String>();
  492. String[] buildIds = projectDeclaration.getPush_build_ids().split(",");
  493. for (int i = 0; i < buildIds.length; i++) {
  494. String name = buildInfoService.getBuildName(Integer.valueOf(buildIds[i]));
  495. buildNames.add(name);
  496. }
  497. projectDeclaration.setPush_build_names(String.join(",", buildNames));
  498. pushNames += " ; " + String.join(",", buildNames);
  499. }
  500. if (StringUtils.isNotBlank(projectDeclaration.getPush_company_ids())) {
  501. List<String> companyNames = new ArrayList<String>();
  502. String[] companyIds = projectDeclaration.getPush_company_ids().split(",");
  503. for (int i = 0; i < companyIds.length; i++) {
  504. if (StringUtils.isNotEmpty(companyIds[i])){
  505. String name = companyService.getCompanyName(Integer.valueOf(companyIds[i]));
  506. companyNames.add(name);
  507. }
  508. }
  509. projectDeclaration.setPush_company_names(String.join(",", companyNames));
  510. pushNames += " ; " + String.join(",", companyNames);
  511. }
  512. projectDeclaration.setPush_names(pushNames);
  513. return projectDeclaration;
  514. }
  515. public PageInfo<ProjectFillingDto> findPage(Integer pageNum, Integer pageSize, ParamApplication paramApplication, String type) {
  516. paramApplication.setApproval_type(Constant.DictionaryType.PROJECT_FILLING);
  517. if (Objects.equals("1", type)) {
  518. //待审批
  519. //paramApplication.setProjectIds(getProjectIdsd());
  520. paramApplication.setProjectIds(getProjectIdsByGroup());
  521. } else if (Objects.equals("2", type)) {
  522. //已审批
  523. paramApplication.setProjectIds(getProjectIdsy());
  524. }
  525. PageHelper.startPage(pageNum, pageSize);
  526. List<ProjectFillingDto> applicationDtoList = projectFillingDao.findPage(paramApplication);
  527. for (ProjectFillingDto app : applicationDtoList) {
  528. if (null != app.getProject_type()) {
  529. //ProjectType projectType = projectTypeService.findById(Integer.parseInt(app.getProject_type()));
  530. String type_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE, app.getProject_type());
  531. app.setProject_type_desc(type_name);
  532. }
  533. if (null != app.getProject_service_type()) {
  534. String name = projectServiceTypeService.findById(Integer.parseInt(app.getProject_service_type())).getService_type_name();
  535. app.setProject_service_type_desc(name);
  536. }
  537. if (null != app.getApprove_status()) {
  538. String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_FILLING_APPROVE_STATUS, app.getApprove_status());
  539. app.setApprove_status_desc(status_name);
  540. }
  541. }
  542. return new PageInfo<ProjectFillingDto>(applicationDtoList);
  543. }
  544. //根据用户组获取可查询到的项目
  545. public List<String> getProjectIdsByGroup() {
  546. List<ProjectFilling> projectLists = new ArrayList<>();
  547. Integer user_id = ShiroUtils.getUserId();
  548. Group group = null;
  549. List<UserGroup> userGroups = null;
  550. List<String> apply_status_list = new ArrayList<>();
  551. //中心
  552. group = groupService.findByName(Constant.XMTBCLSHZ, null);
  553. userGroups = userGroupService.findByGroupId(group.getId());
  554. for (UserGroup userGroup : userGroups) {
  555. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  556. apply_status_list.add(Constant.ProjectFillingStatus.E_DOC_AUDIT);
  557. break;
  558. }
  559. }
  560. if (apply_status_list.size() <= 0) {
  561. apply_status_list.add("");
  562. }
  563. projectLists.addAll(projectFillingDao.findByProjectIdAndApproveStatus(apply_status_list));
  564. List<String> result = new ArrayList<>();
  565. for (ProjectFilling project : projectLists) {
  566. result.add(project.getId().toString());
  567. }
  568. return result;
  569. }
  570. //获取项目申报id 待审批
  571. public List<String> getProjectIdsd() {
  572. int currentUserId = ShiroUtils.getUserId();
  573. List<Approval> approvalList = approvalDao.selectAllApprovalDistinct(Constant.DictionaryType.PROJECT_FILLING);
  574. Set<String> projectApplicationIds = new HashSet<String>();
  575. if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) {
  576. if (!CollectionUtils.isEmpty(approvalList)) {
  577. for (Approval approval : approvalList) {
  578. String nextCheckerIds = approval.getNextchecker();
  579. if (nextCheckerIds != null && nextCheckerIds != "") {
  580. String[] userIdArr = nextCheckerIds.split(",");
  581. List<String> list = Arrays.asList(userIdArr);
  582. if (list.contains(String.valueOf(currentUserId))) {
  583. projectApplicationIds.add(approval.getApply_id().toString());
  584. }
  585. }
  586. }
  587. }
  588. }
  589. List<String> result = new ArrayList<>(projectApplicationIds);
  590. return result;
  591. }
  592. //获取项目申报id 已审批
  593. public List<String> getProjectIdsy() {
  594. int currentUserId = ShiroUtils.getUserId();
  595. List<Approval> approvalList = approvalDao.selectAllApproval(Constant.DictionaryType.PROJECT_FILLING);
  596. Set<String> projectApplicationIds = new HashSet<String>();
  597. if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) {
  598. if (!CollectionUtils.isEmpty(approvalList)) {
  599. for (Approval approval : approvalList) {
  600. String checkerIds = approval.getChecker() + "";
  601. if (checkerIds != null && checkerIds != "") {
  602. if (Objects.equals(checkerIds, String.valueOf(currentUserId))) {
  603. projectApplicationIds.add(approval.getApply_id().toString());
  604. }
  605. }
  606. }
  607. }
  608. }
  609. List<String> result = new ArrayList<>(projectApplicationIds);
  610. return result;
  611. }
  612. //通过
  613. public Boolean pass(Integer projectId, String comment) {
  614. // Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_FILLING);
  615. Approval a = new Approval();
  616. a.setApply_id(projectId);
  617. a.setType(Constant.DictionaryType.PROJECT_FILLING);
  618. if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) {
  619. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  620. a.setDepartment(departmentname);
  621. }
  622. a.setApproval_comment(comment);
  623. a.setChecker(ShiroUtils.getUserId());
  624. a.setOper_type(Constant.OperType.APPROVED);
  625. a.setDeal_time(DateUtil.getTimeString(new Date()));
  626. a.setBefore_approvalstatus(Constant.ProjectFillingStatus.E_DOC_AUDIT);
  627. a.setAfter_approvalstatus(Constant.ProjectFillingStatus.APPROVED);
  628. ProjectFilling projectApplication = projectFillingDao.findApplyById(projectId);
  629. ProjectFilling pa = projectFillingService.findById(projectId);
  630. pa.setApply_status(Constant.ProjectFillingStatus_Company.APPROVED);
  631. pa.setApprove_status(Constant.ProjectFillingStatus.APPROVED);
  632. projectFillingDao.updateByPrimaryKeySelective(pa);
  633. approvalService.insertAndGetId(a);
  634. ProjectFillingDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  635. String projectName = projectDeclaration.getProject_name();
  636. Company company = companyService.findById(projectApplication.getCompany_id());
  637. Message messages = new Message();
  638. messages.setApply_id(projectApplication.getId());
  639. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  640. messages.setTitle("提醒企业");
  641. String message = company.getCompany_name() + ",您好。您提交的" + projectName + "报表填报,已审批通过";
  642. messages.setContent(message);
  643. int[] streetArrInt = new int[1];
  644. streetArrInt[0] = projectApplication.getCompany_id();
  645. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  646. // List<User> users = userService.findUsersByCompanyId(projectApplication.getCompany_id());
  647. User user = userService.findCompanyAdmin(projectApplication.getCompany_id());
  648. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_FILLING);
  649. // for (User user : users) {
  650. waitToDoService.newTODO("报表填报查看", "/company/projectFilling/check/" + projectApplication.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, projectApplication.getId(),
  651. Constant.DictionaryType.PROJECT_FILLING, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  652. // }
  653. //发送短信
  654. Map<String, String> params = new HashMap<>();
  655. params.put("project_no", projectApplication.getApply_no());
  656. params.put("apply_name", Constant.ProjectType.PROJECT_FILLING);
  657. String templateCode = Constant.SMS_TemplateCode.RPOJECT_FILLING_AUDIT;
  658. try {
  659. AlibabaSMSUtil.sendSMS(
  660. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  661. } catch (ClientException | InterruptedException e) {
  662. e.printStackTrace();
  663. }
  664. return true;
  665. // if (Objects.equals(Constant.ProjectFillingStatus.E_DOC_AUDIT, approval.getAfter_approvalstatus())) {
  666. // //电子档通过,通知提交纸质档
  667. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.E_DOC_AUDIT);
  668. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.P_DOC_AUDIT);
  669. //
  670. // Group group = groupService.findByName(Constant.XMTBCLSLZ, null);
  671. // if (null == group) {
  672. // throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  673. // }
  674. // List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  675. // ProjectFillingDeclaration projectFillingDeclaration = this.selectById(projectApplication.getDeclaration_id().toString());
  676. // //List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(projectFillingDeclaration.getDepartment_id().toString());
  677. // List<User> users = userService.findListByWhere(new User());
  678. // StringBuffer sb = new StringBuffer("");
  679. // Company company = companyService.findById(projectApplication.getCompany_id());
  680. // String projectName = projectFillingDeclaration.getProject_name();
  681. // Message messages = new Message();
  682. // messages.setApply_id(projectId);
  683. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  684. // messages.setTitle("提醒中心审核");
  685. //
  686. // waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_FILLING);
  687. // for (UserGroup userGroup : userGroups) {
  688. // for (User user : users) {
  689. // if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  690. // sb.append(userGroup.getUser_id() + ",");
  691. // String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  692. // messages.setContent(message);
  693. // int[] streetArrInt = new int[1];
  694. // streetArrInt[0] = userGroup.getUser_id();
  695. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  696. // waitToDoService.newTODO("项目填报审核", "/projectFilling/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  697. // Constant.DictionaryType.PROJECT_FILLING, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  698. // }
  699. // }
  700. // }
  701. // a.setNextchecker(sb.toString());
  702. // if (null == sb || sb.length() == 0) {
  703. // throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  704. // }
  705. // ProjectFilling pa = new ProjectFilling();
  706. // pa.setId(projectId);
  707. // pa.setApprove_status(Constant.ProjectFillingStatus.P_DOC_AUDIT);
  708. // projectFillingDao.updateByPrimaryKeySelective(pa);
  709. // approvalService.insertAndGetId(a);
  710. // return true;
  711. //
  712. // } else if (Objects.equals(Constant.ProjectFillingStatus.P_DOC_AUDIT, approval.getAfter_approvalstatus())) {
  713. // //纸质档通过,进入处室 待留档确认
  714. //
  715. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.P_DOC_AUDIT);
  716. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.FILE_CONFIRMATION);
  717. //
  718. // Group group = groupService.findByName(Constant.XMTBCLSHZ, null);
  719. // if (null == group) {
  720. // throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  721. // }
  722. // List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  723. // ProjectFillingDeclaration projectFillingDeclaration = this.selectById(projectApplication.getDeclaration_id().toString());
  724. // List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(projectFillingDeclaration.getDepartment_id().toString());
  725. // //List<User> users = userService.findListByWhere(new User());
  726. // StringBuffer sb = new StringBuffer("");
  727. // Company company = companyService.findById(projectApplication.getCompany_id());
  728. // String projectName = projectFillingDeclaration.getProject_name();
  729. // Message messages = new Message();
  730. // messages.setApply_id(projectId);
  731. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  732. // messages.setTitle("提醒处室审核");
  733. //
  734. // waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_FILLING);
  735. // for (UserGroup userGroup : userGroups) {
  736. // for (User user : users) {
  737. // if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  738. // sb.append(userGroup.getUser_id() + ",");
  739. // String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  740. // messages.setContent(message);
  741. // int[] streetArrInt = new int[1];
  742. // streetArrInt[0] = userGroup.getUser_id();
  743. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  744. // waitToDoService.newTODO("项目填报审核", "/projectFilling/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  745. // Constant.DictionaryType.PROJECT_FILLING, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  746. // }
  747. // }
  748. // }
  749. // a.setNextchecker(sb.toString());
  750. // if (null == sb || sb.length() == 0) {
  751. // throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  752. // }
  753. // ProjectFilling pa = new ProjectFilling();
  754. // pa.setId(projectId);
  755. // pa.setApprove_status(Constant.ProjectFillingStatus.FILE_CONFIRMATION);
  756. // projectFillingDao.updateByPrimaryKeySelective(pa);
  757. // approvalService.insertAndGetId(a);
  758. // return true;
  759. //
  760. // } else if (Objects.equals(Constant.ProjectFillingStatus.FILE_CONFIRMATION, approval.getAfter_approvalstatus())) {
  761. // // 留档确认 留档完成
  762. //
  763. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.FILE_CONFIRMATION);
  764. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.FILE_COMPLETION);
  765. //
  766. // ProjectFilling pa = new ProjectFilling();
  767. // pa.setId(projectId);
  768. // pa.setApply_status(Constant.ProjectFillingStatus_Company.APPROVED);
  769. // pa.setApprove_status(Constant.ProjectFillingStatus.FILE_COMPLETION);
  770. // projectFillingDao.updateByPrimaryKeySelective(pa);
  771. // approvalService.insertAndGetId(a);
  772. // return true;
  773. //
  774. // } else if (Objects.equals(Constant.ProjectFillingStatus.WAITING_FOR_CONFIRM, approval.getAfter_approvalstatus())) {
  775. // //报表填报 待确定 通过 变为 已通过
  776. //
  777. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.WAITING_FOR_CONFIRM);
  778. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.CONFIRMED);
  779. //
  780. // ProjectFilling pa = new ProjectFilling();
  781. // pa.setId(projectId);
  782. // pa.setApply_status(Constant.ProjectFillingStatus_Company.CONFIRMED);
  783. // pa.setApprove_status(Constant.ProjectFillingStatus.CONFIRMED);
  784. // projectFillingDao.updateByPrimaryKeySelective(pa);
  785. // approvalService.insertAndGetId(a);
  786. // return true;
  787. //
  788. // }
  789. // return false;
  790. }
  791. //退回
  792. public boolean untread(Integer projectId, String comment) {
  793. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_FILLING);
  794. Approval a = new Approval();
  795. a.setApply_id(projectId);
  796. a.setType(Constant.DictionaryType.PROJECT_FILLING);
  797. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  798. a.setDepartment(departmentname);
  799. a.setApproval_comment(comment);
  800. a.setChecker(ShiroUtils.getUserId());
  801. a.setOper_type(Constant.OperType.REJECT);
  802. a.setDeal_time(DateUtil.getTimeString(new Date()));
  803. ProjectFilling projectApplication = projectFillingDao.findApplyById(projectId);
  804. //项目填报退回 退回至企业
  805. a.setBefore_approvalstatus(Constant.ProjectFillingStatus.E_DOC_AUDIT);
  806. a.setAfter_approvalstatus(Constant.ProjectFillingStatus.REJECT);
  807. ProjectFilling pa = projectFillingService.findById(projectId);
  808. pa.setApply_status(Constant.ProjectFillingStatus_Company.REJECT);
  809. pa.setApprove_status(Constant.ProjectFillingStatus.REJECT);
  810. projectFillingDao.updateByPrimaryKeySelective(pa);
  811. approvalService.insertAndGetId(a);
  812. ProjectFillingDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  813. String projectName = projectDeclaration.getProject_name();
  814. Company company = companyService.findById(projectApplication.getCompany_id());
  815. Message messages = new Message();
  816. messages.setApply_id(projectApplication.getId());
  817. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  818. messages.setTitle("提醒企业");
  819. String message = company.getCompany_name() + ",您好。您提交的" + projectName + "报表填报,请修改后重新提交,谢谢。退回原因:" + comment;
  820. messages.setContent(message);
  821. int[] streetArrInt = new int[1];
  822. streetArrInt[0] = projectApplication.getCompany_id();
  823. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  824. List<User> users = userService.findUsersByCompanyId(projectApplication.getCompany_id());
  825. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_FILLING);
  826. for (User user : users) {
  827. waitToDoService.newTODO("项目申报编辑", "/company/projectFilling/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  828. Constant.DictionaryType.PROJECT_FILLING, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  829. }
  830. //发送短信
  831. Map<String, String> params = new HashMap<>();
  832. params.put("project_no", projectApplication.getApply_no());
  833. params.put("apply_name", Constant.ProjectType.PROJECT_FILLING);
  834. String templateCode = Constant.SMS_TemplateCode.RPOJECT_FILLING_REJECT;
  835. User user = userService.findCompanyAdmin(company.getId());
  836. try {
  837. AlibabaSMSUtil.sendSMS(
  838. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  839. } catch (ClientException | InterruptedException e) {
  840. e.printStackTrace();
  841. }
  842. return true;
  843. // if (Objects.equals(Constant.ProjectFillingStatus.E_DOC_AUDIT, approval.getAfter_approvalstatus())) {
  844. // //电子档退回
  845. //
  846. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.E_DOC_AUDIT);
  847. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.REJECT_TO_COMPANY);
  848. // a.setNextchecker(projectApplication.getCreate_by().toString());
  849. // ProjectFilling p = new ProjectFilling();
  850. // p.setId(projectId);
  851. // p.setApply_status(Constant.ProjectFillingStatus_Company.REJECT);
  852. // p.setApprove_status(Constant.ProjectFillingStatus.REJECT_TO_COMPANY);
  853. // projectFillingDao.updateByPrimaryKeySelective(p);
  854. // approvalService.insertAndGetId(a);
  855. //
  856. // ProjectFillingDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  857. // String projectName = projectDeclaration.getProject_name();
  858. // Company company = companyService.findById(projectApplication.getCompany_id());
  859. //
  860. // Message messages = new Message();
  861. // messages.setApply_id(projectApplication.getId());
  862. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  863. // messages.setTitle("提醒企业");
  864. // String message = company.getCompany_name() + ",您好。您提交的" + projectName + "项目申报,请修改后重新提交,谢谢。退回原因:" + comment;
  865. // messages.setContent(message);
  866. // int[] streetArrInt = new int[1];
  867. // streetArrInt[0] = projectApplication.getCompany_id();
  868. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  869. //
  870. // List<User> users = userService.findUsersByCompanyId(projectApplication.getCompany_id());
  871. // waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  872. // for (User user : users) {
  873. // waitToDoService.newTODO("项目申报编辑", "/company/projectFilling/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  874. // Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  875. // }
  876. // return true;
  877. //
  878. // } else if (Objects.equals(Constant.ProjectFillingStatus.P_DOC_AUDIT, approval.getAfter_approvalstatus())) {
  879. // //纸质档退回
  880. //
  881. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.P_DOC_AUDIT);
  882. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.REJECT_TO_COMPANY);
  883. // a.setNextchecker(projectApplication.getCreate_by().toString());
  884. // ProjectFilling p = new ProjectFilling();
  885. // p.setId(projectId);
  886. // p.setApply_status(Constant.ProjectFillingStatus_Company.REJECT);
  887. // p.setApprove_status(Constant.ProjectFillingStatus.REJECT_TO_COMPANY);
  888. // projectFillingDao.updateByPrimaryKeySelective(p);
  889. // approvalService.insertAndGetId(a);
  890. //
  891. // ProjectFillingDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  892. // String projectName = projectDeclaration.getProject_name();
  893. // Company company = companyService.findById(projectApplication.getCompany_id());
  894. //
  895. // Message messages = new Message();
  896. // messages.setApply_id(projectApplication.getId());
  897. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  898. // messages.setTitle("提醒企业");
  899. // String message = company.getCompany_name() + ",您好。您提交的" + projectName + "项目申报,请修改后重新提交,谢谢。退回原因:" + comment;
  900. // messages.setContent(message);
  901. // int[] streetArrInt = new int[1];
  902. // streetArrInt[0] = projectApplication.getCompany_id();
  903. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  904. //
  905. // List<User> users = userService.findUsersByCompanyId(projectApplication.getCompany_id());
  906. // waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  907. // for (User user : users) {
  908. // waitToDoService.newTODO("项目申报编辑", "/company/projectFilling/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  909. // Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  910. // }
  911. // return true;
  912. //
  913. // } else if (Objects.equals(Constant.ProjectFillingStatus.FILE_CONFIRMATION, approval.getAfter_approvalstatus())) {
  914. // //待留档确认退回 退回至中心
  915. //
  916. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.FILE_CONFIRMATION);
  917. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.REJECT);
  918. // Group group = groupService.findByName(Constant.XMTBCLSLZ, null);
  919. // List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  920. // //List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString());
  921. // List<User> users = userService.findListByWhere(new User());
  922. // StringBuffer sb = new StringBuffer("");
  923. // ProjectFillingDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  924. // String projectName = projectDeclaration.getProject_name();
  925. // Company company = companyService.findById(projectApplication.getCompany_id());
  926. //
  927. // Message messages = new Message();
  928. // messages.setApply_id(projectApplication.getId());
  929. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  930. // messages.setTitle("提醒中心");
  931. // waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_FILLING);
  932. // for (UserGroup userGroup : userGroups) {
  933. // for (User user : users) {
  934. // if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  935. // sb.append(userGroup.getUser_id() + ",");
  936. // String message = company.getCompany_name() + ",您好。您提交的" + projectName + ",项目返回修改请复审。谢谢。退回原因:" + comment;
  937. // messages.setContent(message);
  938. // int[] streetArrInt = new int[1];
  939. // streetArrInt[0] = projectApplication.getCompany_id();
  940. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  941. //
  942. // waitToDoService.newTODO("项目填报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  943. // Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  944. // }
  945. // }
  946. // }
  947. // a.setNextchecker(sb.toString());
  948. // ProjectFilling p = new ProjectFilling();
  949. // p.setId(projectId);
  950. // p.setApply_status(Constant.ProjectFillingStatus_Company.REJECT);
  951. // p.setApprove_status(Constant.ProjectFillingStatus.REJECT_TO_CENTER);
  952. // projectFillingDao.updateByPrimaryKeySelective(p);
  953. // approvalService.insertAndGetId(a);
  954. //
  955. // return true;
  956. //
  957. // } else if (Objects.equals(Constant.ProjectFillingStatus.REJECT, approval.getAfter_approvalstatus())) {
  958. // //项目申报退回 待通知
  959. //
  960. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.REJECT);
  961. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.REJECT);
  962. //
  963. // ProjectFilling pa = new ProjectFilling();
  964. // pa.setId(projectId);
  965. // pa.setApply_status(Constant.ProjectApplyStatus.REJECT);
  966. // pa.setApprove_status(Constant.ProjectFillingStatus.REJECT_TO_COMPANY);
  967. // projectFillingDao.updateByPrimaryKeySelective(pa);
  968. // approvalService.insertAndGetId(a);
  969. // return true;
  970. //
  971. // } else if (Objects.equals(Constant.ProjectFillingStatus.WAITING_FOR_CONFIRM, approval.getAfter_approvalstatus())) {
  972. // //项目填报退回 退回至企业
  973. //
  974. // a.setBefore_approvalstatus(Constant.ProjectFillingStatus.REJECT);
  975. // a.setAfter_approvalstatus(Constant.ProjectFillingStatus.REJECT);
  976. //
  977. // ProjectFilling pa = new ProjectFilling();
  978. // pa.setId(projectId);
  979. // pa.setApply_status(Constant.ProjectApplyStatus.REJECT);
  980. // pa.setApprove_status(Constant.ProjectFillingStatus.REJECT_TO_COMPANY);
  981. // projectFillingDao.updateByPrimaryKeySelective(pa);
  982. // approvalService.insertAndGetId(a);
  983. // return true;
  984. //
  985. // }
  986. // return false;
  987. }
  988. //发送短信
  989. public Boolean sendProjectSMS(ProjectFilling projectApplication) throws ClientException, InterruptedException {
  990. if (null != projectApplication) {
  991. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  992. String status = projectApplication.getApply_status();
  993. String statusName = "";
  994. if (status.equals(Constant.ProjectFillingStatus.NOTAPPROVED)) {
  995. statusName = Constant.OperType.NOTAPPROVED;
  996. } else if (status.equals(Constant.ProjectFillingStatus.APPROVED)) {
  997. statusName = Constant.OperType.APPROVED;
  998. } else if (status.equals(Constant.ProjectFillingStatus.REJECT)) {
  999. statusName = Constant.OperType.REJECT;
  1000. }
  1001. if (StringUtils.isNotBlank(statusName)) {
  1002. return sendProjectSMSToCompany(departmentname, projectApplication, statusName);
  1003. }
  1004. }
  1005. return false;
  1006. }
  1007. public Boolean sendProjectSMSToCompany(String departmentname, ProjectFilling projectApplication,
  1008. String status) throws ClientException, InterruptedException {
  1009. String phone = "";
  1010. CompanyContact contact = companyContactService.findFirstByCompanyId(projectApplication.getCompany_id());
  1011. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1012. if (null != companyInfo && null != companyInfo.getContact_phone()) {
  1013. phone = companyInfo.getContact_phone();
  1014. } else if (null != contact) {
  1015. phone = contact.getPhone();
  1016. }
  1017. if (StringUtils.isNotBlank(phone)) {
  1018. //${department_name}提醒您,您申请的${project_name}单据已审核 ${approve_status}。具体信息请登录PC端查看。感谢您的支持。
  1019. ProjectFillingDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1020. String project_name = projectDeclaration.getProject_name();
  1021. String templateParam = "{\"department_name\":\"" + departmentname + "\",\"project_name\":\"" + project_name + "\",\"approve_status\":\"" + status + "\"}";
  1022. AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.PROJECT_APPLICATION_NOTIFY, "企业提升发展服务平台", templateParam);
  1023. return true;
  1024. } else {
  1025. return false;
  1026. }
  1027. }
  1028. public PageInfo<ProjectFillingDeclaration> findFillingPageInfo(String projectName, String projectType,
  1029. String projectSource, Integer pageNum, Integer pagesize) {
  1030. PageHelper.startPage(pageNum, pagesize);
  1031. List<ProjectFillingDeclaration> list = projectFillingDeclarationDao.findFillingPageInfo(projectName, projectType, projectSource);
  1032. List<DictionaryItem> projectTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE);
  1033. for (DictionaryItem dictionaryItem : projectTypeList) {
  1034. for (ProjectFillingDeclaration projectFillingDeclaration : list) {
  1035. if (Objects.equals(dictionaryItem.getValue(), projectFillingDeclaration.getProject_type())) {
  1036. projectFillingDeclaration.setProject_type_name(dictionaryItem.getName());
  1037. }
  1038. if (StringUtils.isNotBlank(projectFillingDeclaration.getProject_service_type())) {
  1039. String name = projectServiceTypeService.findById(projectFillingDeclaration.getProject_service_type()).get(0).getService_type_name();
  1040. projectFillingDeclaration.setProject_service_type_name(name);
  1041. }
  1042. // String companyIds = projectFillingDeclaration.getPush_company_ids();
  1043. // String[] companyIdsArr = companyIds.split(",");
  1044. List<ProjectFilling> projectFillingList = projectFillingService.findByDeclarationId(projectFillingDeclaration.getId());
  1045. projectFillingDeclaration.setTotal(projectFillingList.size());
  1046. projectFillingDeclaration.setCount(projectFillingService.getQuantityByDeclarationId(projectFillingDeclaration.getId().toString()));
  1047. }
  1048. }
  1049. return new PageInfo<ProjectFillingDeclaration>(list);
  1050. }
  1051. public PageInfo<ProjectMessageDto> findMessageByIdAndType(Integer pageNum, Integer pageSize, String id) {
  1052. PageHelper.startPage(pageNum, pageSize);
  1053. List<ProjectMessageDto> applys = projectFillingDao.findMessageByIdAndType(id, Constant.Message_Business_type.PROJECT_PROVINCES_APPLY);
  1054. return new PageInfo<ProjectMessageDto>(applys);
  1055. }
  1056. public Boolean fail(Integer projectId, String comment) {
  1057. Approval a = new Approval();
  1058. a.setApply_id(projectId);
  1059. a.setType(Constant.DictionaryType.PROJECT_FILLING);
  1060. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1061. a.setDepartment(departmentname);
  1062. a.setApproval_comment(comment);
  1063. a.setChecker(ShiroUtils.getUserId());
  1064. a.setOper_type(Constant.OperType.REJECT);
  1065. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1066. ProjectFilling projectApplication = projectFillingDao.findApplyById(projectId);
  1067. //项目填报退回 退回至企业
  1068. a.setBefore_approvalstatus(Constant.ProjectFillingStatus.E_DOC_AUDIT);
  1069. a.setAfter_approvalstatus(Constant.ProjectFillingStatus.NOTAPPROVED);
  1070. ProjectFilling pa = projectFillingService.findById(projectId);
  1071. pa.setApply_status(Constant.ProjectFillingStatus_Company.NOTAPPROVED);
  1072. pa.setApprove_status(Constant.ProjectFillingStatus.NOTAPPROVED);
  1073. projectFillingDao.updateByPrimaryKeySelective(pa);
  1074. approvalService.insertAndGetId(a);
  1075. ProjectFillingDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1076. String projectName = projectDeclaration.getProject_name();
  1077. Company company = companyService.findById(projectApplication.getCompany_id());
  1078. Message messages = new Message();
  1079. messages.setApply_id(projectApplication.getId());
  1080. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_FILING_APPLY);
  1081. messages.setTitle("提醒企业");
  1082. String message = company.getCompany_name() + ",您好。您提交的" + projectName + "报表填报,审核不通过。不通过原因:" + comment;
  1083. messages.setContent(message);
  1084. int[] streetArrInt = new int[1];
  1085. streetArrInt[0] = projectApplication.getCompany_id();
  1086. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  1087. List<User> users = userService.findUsersByCompanyId(projectApplication.getCompany_id());
  1088. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_FILLING);
  1089. for (User user : users) {
  1090. waitToDoService.newTODO("报表填报查看", "/company/projectFilling/check/" + projectApplication.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, projectApplication.getId(),
  1091. Constant.DictionaryType.PROJECT_FILLING, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1092. }
  1093. //发送短信
  1094. Map<String, String> params = new HashMap<>();
  1095. params.put("project_no", projectApplication.getApply_no());
  1096. params.put("apply_name", Constant.ProjectType.PROJECT_FILLING);
  1097. String templateCode = Constant.SMS_TemplateCode.RPOJECT_FILLING_UNPASS;
  1098. User user = userService.findCompanyAdmin(company.getId());
  1099. try {
  1100. AlibabaSMSUtil.sendSMS(
  1101. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1102. } catch (ClientException | InterruptedException e) {
  1103. e.printStackTrace();
  1104. }
  1105. return true;
  1106. }
  1107. public List<ProjectFillingDeclaration> findAll(StaticSearchCondition searchCondition) {
  1108. return projectFillingDeclarationDao.findAll(searchCondition);
  1109. }
  1110. }