ProjectIntelligentDeclarationService.java 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  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.apache.tomcat.util.bcel.Const;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Service;
  10. import org.springframework.transaction.annotation.Transactional;
  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.dao.CompanyDao;
  21. import platform.modules.build.entity.Company;
  22. import platform.modules.build.entity.CompanyContact;
  23. import platform.modules.build.service.BuildInfoService;
  24. import platform.modules.build.service.CompanyContactService;
  25. import platform.modules.build.service.CompanyService;
  26. import platform.modules.company.dao.ProjectIntelligentDao;
  27. import platform.modules.company.dao.ProjectProvincesDao;
  28. import platform.modules.company.entity.ProjectApplicationCompanyInfo;
  29. import platform.modules.company.entity.ProjectIntelligent;
  30. import platform.modules.company.entity.ProjectProvinces;
  31. import platform.modules.company.service.MessageDetailService;
  32. import platform.modules.company.service.ProjectApplicationCompanyInfoService;
  33. import platform.modules.company.service.ProjectProvincesService;
  34. import platform.modules.government.dao.AttachmentDao;
  35. import platform.modules.government.dao.ProjectIntelligentDeclarationDao;
  36. import platform.modules.government.dao.ProjectProvincesDeclarationDao;
  37. import platform.modules.government.dao.ProjectServiceCategoryDao;
  38. import platform.modules.government.dto.ParamApplication;
  39. import platform.modules.government.dto.ProjectIntelligentDto;
  40. import platform.modules.government.dto.ProjectMessageDto;
  41. import platform.modules.government.dto.ProjectProvincesDto;
  42. import platform.modules.government.entity.*;
  43. import platform.modules.sys.dao.ApprovalDao;
  44. import platform.modules.sys.entity.*;
  45. import platform.modules.sys.service.*;
  46. import tk.mybatis.mapper.entity.Example;
  47. import java.util.*;
  48. @Service
  49. @Transactional
  50. public class ProjectIntelligentDeclarationService extends BaseService<ProjectIntelligentDeclaration> {
  51. @Autowired
  52. private ProjectIntelligentDeclarationDao projectIntelligentDeclarationDao;
  53. @Autowired
  54. private ProjectServiceTypeService projectServiceTypeService;
  55. @Autowired
  56. private ProjectIntelligentDao projectIntelligentDao;
  57. @Autowired
  58. private MessageService messageService;
  59. @Autowired
  60. private MessageDetailService messageDetailService;
  61. @Autowired
  62. private AttachmentDao attachmentDao;
  63. @Autowired
  64. private CompanyService companyService;
  65. @Autowired
  66. private StreetService streetService;
  67. @Autowired
  68. private GroupService groupService;
  69. @Autowired
  70. private UserGroupService userGroupService;
  71. @Autowired
  72. private UserService userService;
  73. @Autowired
  74. private ApprovalDao approvalDao;
  75. @Autowired
  76. private DepartmentService departmentService;
  77. @Autowired
  78. private DictionaryItemService dictionaryItemService;
  79. @Autowired
  80. private ApprovalService approvalService;
  81. @Autowired
  82. private AttachmentService attachmentService;
  83. @Autowired
  84. private CompanyContactService companyContactService;
  85. @Autowired
  86. private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService;
  87. @Autowired
  88. private ProjectServiceCategoryService projectServiceCategoryService;
  89. @Autowired
  90. private WaitToDoService waitToDoService;
  91. @Autowired
  92. private CompanyDao companyDao;
  93. public PageInfo<ProjectIntelligentDeclaration> findPageInfo(String projectName, String projectType, String projectSource, Integer pageNum, Integer pagesize) {
  94. PageHelper.startPage(pageNum, pagesize);
  95. List<ProjectIntelligentDeclaration> list = projectIntelligentDeclarationDao.findPageInfo(projectName, projectType, projectSource);
  96. List<DictionaryItem> projectTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SERVICE_SUPER_TYPE);
  97. for (DictionaryItem dictionaryItem : projectTypeList) {
  98. for (ProjectIntelligentDeclaration projectDeclaration : list) {
  99. if (StringUtils.isNotBlank(projectDeclaration.getProject_service_type())) {
  100. String name = projectServiceTypeService.findById(projectDeclaration.getProject_service_type()).get(0).getService_type_name();
  101. projectDeclaration.setProject_service_type_name(name);
  102. }
  103. }
  104. }
  105. return new PageInfo<ProjectIntelligentDeclaration>(list);
  106. }
  107. public Integer save(ProjectIntelligentDeclaration projectIntelligentDeclaration) {
  108. this.insertAndGetId(projectIntelligentDeclaration);
  109. Integer id = projectIntelligentDeclaration.getId();
  110. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId());
  111. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId(), projectIntelligentDeclaration.getFileDown().getFile_id());
  112. updateProjectServiceCategory(projectIntelligentDeclaration);
  113. return id;
  114. }
  115. public Integer update(ProjectIntelligentDeclaration projectIntelligentDeclaration) {
  116. this.updateSelective(projectIntelligentDeclaration);
  117. Integer id = projectIntelligentDeclaration.getId();
  118. /*List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId(), null);
  119. if (null != attachments && attachments.size() > 0) {
  120. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  121. if (!fileDown.getFile_id().equals(projectIntelligentDeclaration.getFileDown().getFile_id())) {*/
  122. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId());
  123. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectIntelligentDeclaration.getId(), projectIntelligentDeclaration.getFileDown().getFile_id());
  124. /* }
  125. }*/
  126. updateProjectServiceCategory(projectIntelligentDeclaration);
  127. return id;
  128. }
  129. public ProjectIntelligentDeclaration selectById(String id) {
  130. ProjectIntelligentDeclaration projectDeclaration = projectIntelligentDeclarationDao.selectById(id);
  131. //服务事项类别
  132. List<ProjectServiceCategory> temp = projectServiceCategoryService.selectByProjectDeclarationId(id);
  133. List<ProjectServiceCategory> temp_new = new ArrayList<>();
  134. for (ProjectServiceCategory category_c : temp) {
  135. if (null != category_c.getPid()) {
  136. for (ProjectServiceCategory category_f : temp) {
  137. if (Objects.equals(category_c.getPid(), category_f.getId())) {
  138. ProjectServiceCategory item = new ProjectServiceCategory();
  139. item.setProject_type_name1(category_f.getProject_type_name());
  140. item.setProject_type_name2(category_c.getProject_type_name());
  141. item.setDepartment_id(category_c.getDepartment_id());
  142. //item.setDepartment_name(departmentService.findById(category_c.getDepartment_id()).getName());
  143. if (StringUtils.isNotBlank(category_c.getType())) {
  144. item.setType(category_c.getType());
  145. item.setType_name(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_TYPE, category_c.getType()));
  146. }
  147. temp_new.add(item);
  148. }
  149. }
  150. }
  151. }
  152. projectDeclaration.setProjectServiceCategory(temp_new);
  153. //责任单位
  154. if (StringUtils.isNotBlank(projectDeclaration.getDepartment_id())) {
  155. projectDeclaration.setDepartment_name(departmentService.findById(Integer.parseInt(projectDeclaration.getDepartment_id())).getName());
  156. } else {
  157. projectDeclaration.setDepartment_name("");
  158. }
  159. //服务事项
  160. String serviceType = projectDeclaration.getProject_service_type();
  161. if (StringUtils.isNotBlank(serviceType)) {
  162. List<ProjectServiceType> projectServiceTypeList = projectServiceTypeService.findById(serviceType);
  163. if (!CollectionUtils.isEmpty(projectServiceTypeList)) {
  164. projectDeclaration.setProject_service_type_name(projectServiceTypeList.get(0).getService_type_name());
  165. }
  166. }
  167. //项目来源
  168. String source = projectDeclaration.getProject_source();
  169. if (StringUtils.isNotBlank(source)) {
  170. DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, source);
  171. if (null != sourceItem) {
  172. projectDeclaration.setProject_source_name(sourceItem.getName());
  173. }
  174. }
  175. //文件
  176. List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_INTELLIGENT_DEC, projectDeclaration.getId(), null);
  177. if (null != attachments && attachments.size() > 0) {
  178. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  179. projectDeclaration.setFileDown(fileDown);
  180. }
  181. return projectDeclaration;
  182. }
  183. public PageInfo<ProjectIntelligentDto> findPage(Integer pageNum, Integer pageSize, ParamApplication paramApplication, String type) {
  184. paramApplication.setApproval_type(Constant.DictionaryType.PROJECT_INTELLIGENT);
  185. if (Objects.equals("1", type)) {
  186. //待审批
  187. paramApplication.setProjectIds(getProjectIdsByGroup());//新逻辑
  188. } else if (Objects.equals("2", type)) {
  189. //已审批
  190. paramApplication.setProjectIds(getProjectIdsy());
  191. } else if (Objects.equals("3", type)) {
  192. //查看所有
  193. paramApplication.setProjectIds(getProjectIdsc());
  194. }
  195. PageHelper.startPage(pageNum, pageSize);
  196. List<ProjectIntelligentDto> applicationDtoList = projectIntelligentDao.findPage(paramApplication);
  197. for (ProjectIntelligentDto app : applicationDtoList) {
  198. if (null != app.getApprove_status()) {
  199. String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_INTELLIGENT_APPROVE_STATUS, app.getApprove_status());
  200. app.setApprove_status_desc(status_name);
  201. }
  202. if (null != app.getType()) {
  203. String type_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_TYPE, app.getType());
  204. app.setType_name(type_name);
  205. }
  206. }
  207. return new PageInfo<ProjectIntelligentDto>(applicationDtoList);
  208. }
  209. //获取项目申报id 查看所有
  210. public List<String> getProjectIdsc() {
  211. List<String> result = new ArrayList<>();
  212. Example example = new Example(ProjectIntelligent.class);
  213. Example.Criteria criteria = example.createCriteria();
  214. criteria.orEqualTo("del_flag", "0");//不显示删除的
  215. List<String> company_ids = new ArrayList<>();
  216. if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  217. Example example1 = new Example(Company.class);
  218. Example.Criteria criteria1 = example1.createCriteria();
  219. criteria1.andEqualTo("street_id", ShiroUtils.getStreetId());
  220. List<Company> companyList = companyDao.selectByExample(example1);
  221. for (Company company : companyList) {
  222. company_ids.add(company.getId() + "");
  223. }
  224. }
  225. if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  226. criteria.andIn("company_id", company_ids);
  227. }
  228. List<ProjectIntelligent> projectList = projectIntelligentDao.selectByExample(example);
  229. for (ProjectIntelligent project : projectList) {
  230. result.add(project.getId().toString());
  231. }
  232. return result;
  233. }
  234. //获取项目申报id 已审批
  235. public List<String> getProjectIdsy() {
  236. int currentUserId = ShiroUtils.getUserId();
  237. List<Approval> approvalList = approvalDao.selectAllApproval(Constant.DictionaryType.PROJECT_INTELLIGENT);
  238. Set<String> projectApplicationIds = new HashSet<String>();
  239. //if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) {
  240. if (!CollectionUtils.isEmpty(approvalList)) {
  241. for (Approval approval : approvalList) {
  242. String checkerIds = approval.getChecker() + "";
  243. if (checkerIds != null && checkerIds != "") {
  244. if (Objects.equals(checkerIds, String.valueOf(currentUserId))) {
  245. projectApplicationIds.add(approval.getApply_id().toString());
  246. }
  247. }
  248. }
  249. }
  250. //}
  251. List<String> result = new ArrayList<>(projectApplicationIds);
  252. return result;
  253. }
  254. //根据用户组获取可查询到的项目
  255. public List<String> getProjectIdsByGroup() {
  256. List<ProjectIntelligent> projectLists = new ArrayList<>();
  257. Integer user_id = ShiroUtils.getUserId();
  258. Integer department_id = ShiroUtils.getUserEntity().getDepartment_id();
  259. Group group = null;
  260. List<UserGroup> userGroups = null;
  261. List<String> apply_status_list = new ArrayList<>();
  262. List<String> company_ids = new ArrayList<>();
  263. if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  264. Example example3 = new Example(Company.class);
  265. Example.Criteria criteria3 = example3.createCriteria();
  266. criteria3.andEqualTo("del_flag", "0");
  267. criteria3.andEqualTo("street_id", ShiroUtils.getStreetId());
  268. List<Company> companies = companyDao.selectByExample(example3);
  269. if (!CollectionUtils.isEmpty(companies)) {
  270. for (Company company : companies) {
  271. company_ids.add(company.getId().toString());
  272. }
  273. } else {
  274. company_ids.add("");
  275. }
  276. group = groupService.findByName(Constant.QJZNZZJDSLZ, null);
  277. if (null == group) {
  278. return new ArrayList<>();
  279. }
  280. userGroups = userGroupService.findByGroupId(group.getId());
  281. if (null == userGroups) {
  282. apply_status_list.add("");
  283. }
  284. for (UserGroup userGroup : userGroups) {
  285. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  286. apply_status_list.add(Constant.ProjectIntelligentStatus.LOCAL_AUDIT);
  287. break;
  288. }
  289. }
  290. } else {
  291. //材料受理
  292. group = groupService.findByName(Constant.QJZNZZCLSLZ, null);
  293. if (null == group) {
  294. apply_status_list.add("");
  295. }
  296. userGroups = userGroupService.findByGroupId(group.getId());
  297. if (null == userGroups) {
  298. apply_status_list.add("");
  299. }
  300. for (UserGroup userGroup : userGroups) {
  301. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  302. apply_status_list.add(Constant.ProjectIntelligentStatus.CENTRE_AUDIT);
  303. apply_status_list.add(Constant.ProjectIntelligentStatus.PAPER_MATERIAL);
  304. projectLists.addAll(projectIntelligentDao.findByProjectIdAndApproveStatus(apply_status_list, company_ids));
  305. break;
  306. }
  307. }
  308. }
  309. if (apply_status_list.size() <= 0) {
  310. apply_status_list.add("");
  311. }
  312. projectLists.addAll(projectIntelligentDao.findByProjectIdAndApproveStatus(apply_status_list, company_ids));
  313. List<String> result = new ArrayList<>();
  314. for (ProjectIntelligent project : projectLists) {
  315. result.add(project.getId().toString());
  316. }
  317. return result;
  318. }
  319. //通过
  320. public Boolean pass(Integer projectId, String comment) throws ClientException, InterruptedException {
  321. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_INTELLIGENT);
  322. Approval a = new Approval();
  323. a.setApply_id(projectId);
  324. a.setType(Constant.DictionaryType.PROJECT_INTELLIGENT);
  325. if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) {
  326. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  327. a.setDepartment(departmentname);
  328. }
  329. a.setApproval_comment(comment);
  330. a.setChecker(ShiroUtils.getUserId());
  331. a.setOper_type(Constant.OperType.APPROVED);
  332. a.setDeal_time(DateUtil.getTimeString(new Date()));
  333. ProjectIntelligent projectApplication = projectIntelligentDao.findApplyById(projectId);
  334. User companyAdmin = userService.findCompanyAdmin(projectApplication.getCompany_id());
  335. //短信参数
  336. Map<String, String> params = new HashMap<>();
  337. params.put("project_no", projectApplication.getApply_no());
  338. params.put("apply_name", Constant.ProjectType.PROJECT_INTELLIGENT);
  339. String templateCode = Constant.SMS_TemplateCode.RPOJECT_APPROVAL_REMIND;
  340. if (Objects.equals(Constant.ProjectIntelligentStatus.LOCAL_AUDIT, approval.getAfter_approvalstatus())) {
  341. Integer streetid = ShiroUtils.getStreetId();
  342. Street streetInfo = streetService.findById(streetid);
  343. a.setDepartment(streetInfo.getName());
  344. //待属地审核--》待中心审核
  345. a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.LOCAL_AUDIT);
  346. a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.CENTRE_AUDIT);
  347. Group group = groupService.findByNameOnly(Constant.QJZNZZCLSLZ);
  348. if (null == group) {
  349. throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  350. }
  351. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  352. ProjectIntelligentDeclaration projectProvincesDeclaration = this.selectById(projectApplication.getDeclaration_id().toString());
  353. List<User> users = userService.findListByWhere(new User());
  354. StringBuffer sb = new StringBuffer("");
  355. Company company = companyService.findById(projectApplication.getCompany_id());
  356. String projectName = projectProvincesDeclaration.getProject_name();
  357. Message messages = new Message();
  358. messages.setApply_id(projectId);
  359. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  360. messages.setTitle("提醒中心审核");
  361. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  362. for (UserGroup userGroup : userGroups) {
  363. for (User user : users) {
  364. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  365. sb.append(userGroup.getUser_id() + ",");
  366. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  367. messages.setContent(message);
  368. int[] streetArrInt = new int[1];
  369. streetArrInt[0] = userGroup.getUser_id();
  370. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  371. waitToDoService.newTODO("区级智能制造审核", "/government/projectIntelligent/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  372. Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  373. //发送短信
  374. // AlibabaSMSUtil.sendSMSMessage(
  375. // user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  376. }
  377. }
  378. }
  379. a.setNextchecker(sb.toString());
  380. if (sb.length() == 0) {
  381. throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  382. }
  383. ProjectIntelligent pa = new ProjectIntelligent();
  384. pa.setId(projectId);
  385. pa.setApprove_status(Constant.ProjectIntelligentStatus.CENTRE_AUDIT);
  386. pa.setApply_status(Constant.ProjectProvincesStatus_Company.IN_AUDIT);
  387. projectIntelligentDao.updateByPrimaryKeySelective(pa);
  388. approvalService.insertAndGetId(a);
  389. return true;
  390. } else if (Objects.equals(Constant.ProjectIntelligentStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) {
  391. //属地通过或企业直接提交到中心,待中心审核--》待提交纸质档
  392. a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.CENTRE_AUDIT);
  393. a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL);
  394. Group group = groupService.findByNameOnly(Constant.QJZNZZCLSLZ);
  395. if (null == group) {
  396. throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  397. }
  398. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  399. ProjectIntelligentDeclaration projectProvincesDeclaration = this.selectById(projectApplication.getDeclaration_id().toString());
  400. List<User> users = userService.findListByWhere(new User());
  401. StringBuffer sb = new StringBuffer("");
  402. Company company = companyService.findById(projectApplication.getCompany_id());
  403. String projectName = projectProvincesDeclaration.getProject_name();
  404. Message messages = new Message();
  405. messages.setApply_id(projectId);
  406. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  407. messages.setTitle("提醒中心审核");
  408. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  409. for (UserGroup userGroup : userGroups) {
  410. for (User user : users) {
  411. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  412. sb.append(userGroup.getUser_id() + ",");
  413. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  414. messages.setContent(message);
  415. int[] streetArrInt = new int[1];
  416. streetArrInt[0] = userGroup.getUser_id();
  417. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  418. waitToDoService.newTODO("区级智能制造审核", "/government/projectIntelligent/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  419. Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  420. //发送短信
  421. // AlibabaSMSUtil.sendSMSMessage(
  422. // user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  423. }
  424. }
  425. }
  426. a.setNextchecker(sb.toString());
  427. if (sb.length() == 0) {
  428. throw new BaseException("操作失败,区级智能制造材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  429. }
  430. ProjectIntelligent pa = new ProjectIntelligent();
  431. pa.setId(projectId);
  432. pa.setApprove_status(Constant.ProjectIntelligentStatus.PAPER_MATERIAL);
  433. pa.setApply_status(Constant.ProjectIntelligentStatus_Company.PAPER_MATERIAL);
  434. projectIntelligentDao.updateByPrimaryKeySelective(pa);
  435. approvalService.insertAndGetId(a);
  436. //给企业发消息
  437. String message = company.getCompany_name() + ",您好。您提交的单号为"+ projectApplication.getApply_no()
  438. +"的智能制造申报申请,已到提交申报材料纸质档阶段,请打印申报的材料,前往苏州高新区企业服务中心(苏州高新区科技城科灵路37号科技金融广场一楼)进行核准。谢谢!";
  439. messages.setContent(message);
  440. int[] streetArrInt = new int[1];
  441. streetArrInt[0] = companyAdmin.getId();
  442. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  443. //发送短信(提醒企业提交材料)
  444. String tempCode = Constant.SMS_TemplateCode.REMINSD_COMPNAY_PREPARE_MATERIALS;
  445. AlibabaSMSUtil.sendSMS(
  446. companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  447. return true;
  448. } else if (Objects.equals(Constant.ProjectIntelligentStatus.PAPER_MATERIAL, approval.getAfter_approvalstatus())) {
  449. //待提交申报材料纸质档--》待通过
  450. ProjectIntelligentDeclaration projectIntelligentDeclaration = this.selectById(projectApplication.getDeclaration_id().toString());
  451. ProjectIntelligent pa = new ProjectIntelligent();
  452. pa.setId(projectId);
  453. a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL);
  454. a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.SUCCESS);
  455. Company company = companyService.findById(projectApplication.getCompany_id());
  456. String projectName = projectIntelligentDeclaration.getProject_name();
  457. Message messages = new Message();
  458. messages.setApply_id(projectId);
  459. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  460. messages.setTitle("提醒企业审核通过");
  461. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  462. String message = projectApplication.getCreate_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请已经审核通过。谢谢。";
  463. messages.setContent(message);
  464. int[] streetArrInt = new int[1];
  465. streetArrInt[0] = projectApplication.getCreate_by();
  466. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  467. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  468. waitToDoService.newTODO("区级智能制造审核", "/company/projectIntelligent/check/" + projectApplication.getId(), Constant.WaitToDo_OperType.CONFIRM_AND_NOTIFY, projectApplication.getId(),
  469. Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  470. pa.setApprove_status(Constant.ProjectIntelligentStatus.SUCCESS);
  471. pa.setApply_status(Constant.ProjectIntelligentStatus_Company.SUCCESS);
  472. projectIntelligentDao.updateByPrimaryKeySelective(pa);
  473. approvalService.insertAndGetId(a);
  474. //发送短信
  475. String tempCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_PASS;
  476. AlibabaSMSUtil.sendSMS(
  477. companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  478. return true;
  479. }
  480. return false;
  481. }
  482. //退回
  483. public boolean untread(Integer projectId, String comment) throws ClientException, InterruptedException {
  484. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_INTELLIGENT);
  485. Approval a = new Approval();
  486. a.setApply_id(projectId);
  487. a.setType(Constant.DictionaryType.PROJECT_INTELLIGENT);
  488. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  489. a.setDepartment(departmentname);
  490. if(Objects.equals(ShiroUtils.getUserType(),Constant.UserType.STREET)){
  491. Integer streetid = ShiroUtils.getStreetId();
  492. Street streetInfo = streetService.findById(streetid);
  493. a.setDepartment(streetInfo.getName());
  494. }
  495. a.setApproval_comment(comment);
  496. a.setChecker(ShiroUtils.getUserId());
  497. a.setOper_type(Constant.OperType.REJECT);
  498. a.setDeal_time(DateUtil.getTimeString(new Date()));
  499. ProjectIntelligent projectApplication = projectIntelligentDao.findApplyById(projectId);
  500. User companyAdmin = userService.findCompanyAdmin(projectApplication.getCompany_id());
  501. Message messages = new Message();
  502. messages.setApply_id(projectApplication.getId());
  503. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  504. messages.setTitle("提醒企业");
  505. String message = "您有单号为"+ projectApplication.getApply_no() +"的"+
  506. Constant.ProjectType.PROJECT_INTELLIGENT +",经审核被退回,要求修改,详情请登录平台查看。退回原因:" + comment;
  507. messages.setContent(message);
  508. int[] streetArrInt = new int[1];
  509. streetArrInt[0] = projectApplication.getCompany_id();
  510. Map<String, String> params = new HashMap<>();
  511. params.put("project_no", projectApplication.getApply_no());
  512. params.put("apply_name", Constant.ProjectType.PROJECT_INTELLIGENT);
  513. String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_REJECT;
  514. if (Objects.equals(Constant.ProjectProvincesStatus.LOCAL_AUDIT, approval.getAfter_approvalstatus())) {
  515. //属地审核退回
  516. a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.LOCAL_AUDIT);
  517. a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY);
  518. a.setNextchecker(projectApplication.getCreate_by().toString());
  519. ProjectIntelligent p = new ProjectIntelligent();
  520. p.setId(projectId);
  521. p.setApply_status(Constant.ProjectIntelligentStatus_Company.REJECT_TO_COMPANY);
  522. p.setApprove_status(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY);
  523. projectIntelligentDao.updateByPrimaryKeySelective(p);
  524. approvalService.insertAndGetId(a);
  525. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  526. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  527. waitToDoService.newTODO("智能制造编辑", "/projectIntelligent/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  528. Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  529. //发送短信
  530. AlibabaSMSUtil.sendSMS(
  531. companyAdmin.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  532. return true;
  533. } else if (Objects.equals(Constant.ProjectIntelligentStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) {
  534. //中心审核退回
  535. a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.CENTRE_AUDIT);
  536. a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY);
  537. a.setNextchecker(projectApplication.getCreate_by().toString());
  538. ProjectIntelligent p = new ProjectIntelligent();
  539. p.setId(projectId);
  540. p.setApply_status(Constant.ProjectIntelligentStatus_Company.REJECT_TO_COMPANY);
  541. p.setApprove_status(Constant.ProjectIntelligentStatus.REJECT_TO_COMPANY);
  542. projectIntelligentDao.updateByPrimaryKeySelective(p);
  543. approvalService.insertAndGetId(a);
  544. messageService.saveMessageAndPushToUser(messages, streetArrInt, Constant.UserType.COMPANY);
  545. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  546. waitToDoService.newTODO("智能制造编辑", "/projectIntelligent/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  547. Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  548. //发送短信
  549. AlibabaSMSUtil.sendSMS(
  550. companyAdmin.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  551. return true;
  552. } else if (Objects.equals(Constant.ProjectIntelligentStatus.PAPER_MATERIAL, approval.getAfter_approvalstatus())) {
  553. //待提交纸质材料有误 非退回 仅通知企业
  554. a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL);
  555. a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.PAPER_MATERIAL);
  556. List<User> userss = userService.findListByWhere(new User());
  557. StringBuffer sb = new StringBuffer("");
  558. Group group = groupService.findByNameOnly(Constant.QJZNZZCLSLZ);
  559. if (null == group) {
  560. throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  561. }
  562. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  563. for (UserGroup userGroup : userGroups) {
  564. for (User user : userss) {
  565. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  566. sb.append(userGroup.getUser_id() + ",");
  567. }
  568. }
  569. }
  570. a.setNextchecker(sb.toString());
  571. ProjectIntelligent p = new ProjectIntelligent();
  572. p.setId(projectId);
  573. p.setApply_status(Constant.ProjectIntelligentStatus_Company.PAPER_MATERIAL_ERROR);
  574. p.setApprove_status(Constant.ProjectIntelligentStatus.PAPER_MATERIAL);
  575. projectIntelligentDao.updateByPrimaryKeySelective(p);
  576. approvalService.insertAndGetId(a);
  577. message = "您好。您单号为"+ projectApplication.getApply_no() +"的"+ Constant.ProjectType.PROJECT_INTELLIGENT +
  578. ",申报材料纸质档有误,"+ comment +"," + "请根据意见修改并重新打印申报材料纸质档,交至高新区企业服务服务中心(苏州高新区科技城科灵路37号科技金融广场一楼)";
  579. messages.setContent(message);
  580. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  581. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  582. waitToDoService.newTODO("智能制造编辑", "/projectIntelligent/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  583. Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  584. //发送短信
  585. String tempCode = Constant.SMS_TemplateCode.DOCUMENTS_INCORRECT;
  586. AlibabaSMSUtil.sendSMS(
  587. companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  588. return true;
  589. }
  590. return false;
  591. }
  592. //拒绝
  593. public boolean refuse(Integer projectId, String comment) throws ClientException, InterruptedException {
  594. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_INTELLIGENT);
  595. Approval a = new Approval();
  596. a.setApply_id(projectId);
  597. a.setType(Constant.DictionaryType.PROJECT_INTELLIGENT);
  598. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  599. a.setDepartment(departmentname);
  600. if(Objects.equals(ShiroUtils.getUserType(),Constant.UserType.STREET)){
  601. Integer streetid = ShiroUtils.getStreetId();
  602. Street streetInfo = streetService.findById(streetid);
  603. a.setDepartment(streetInfo.getName());
  604. }
  605. a.setApproval_comment(comment);
  606. a.setChecker(ShiroUtils.getUserId());
  607. a.setOper_type(Constant.OperType.NOTAPPROVED);
  608. a.setDeal_time(DateUtil.getTimeString(new Date()));
  609. ProjectIntelligent projectApplication = projectIntelligentDao.findApplyById(projectId);
  610. User companyAdmin = userService.findCompanyAdmin(projectApplication.getCompany_id());
  611. a.setAfter_approvalstatus(Constant.ProjectIntelligentStatus.FAILURE);
  612. a.setNextchecker(projectApplication.getCreate_by().toString());
  613. ProjectIntelligent p = new ProjectIntelligent();
  614. p.setId(projectId);
  615. p.setApply_status(Constant.ProjectIntelligentStatus_Company.FAILURE);
  616. p.setApprove_status(Constant.ProjectIntelligentStatus.FAILURE);
  617. projectIntelligentDao.updateByPrimaryKeySelective(p);
  618. a.setBefore_approvalstatus(Constant.ProjectIntelligentStatus.FAILURE);
  619. approvalService.insertAndGetId(a);
  620. ProjectIntelligentDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  621. String projectName = projectDeclaration.getProject_name();
  622. Company company = companyService.findById(projectApplication.getCompany_id());
  623. Message messages = new Message();
  624. messages.setApply_id(projectApplication.getId());
  625. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  626. messages.setTitle("提醒企业");
  627. String message = company.getCompany_name() + ",您好。您提交的" + projectName + "审核不通过,请知悉。不通过原因:" + comment;
  628. messages.setContent(message);
  629. int[] streetArrInt = new int[1];
  630. streetArrInt[0] = projectApplication.getCompany_id();
  631. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  632. //发送短信
  633. Map<String, String> params = new HashMap<>();
  634. params.put("project_no", projectApplication.getApply_no());
  635. params.put("apply_name", Constant.ProjectType.PROJECT_INTELLIGENT);
  636. String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_UNPASS;
  637. AlibabaSMSUtil.sendSMS(
  638. companyAdmin.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  639. return true;
  640. }
  641. //区级智能制造发送短信
  642. public Boolean sendProjectSMS(ProjectIntelligent projectApplication) throws ClientException, InterruptedException {
  643. if (null != projectApplication) {
  644. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  645. String status = projectApplication.getApply_status();
  646. String statusName = "";
  647. if (status.equals(Constant.ProjectApplyStatus.NOTAPPROVED)) {
  648. statusName = Constant.OperType.NOTAPPROVED;
  649. } else if (status.equals(Constant.ProjectApplyStatus.APPROVED)) {
  650. statusName = Constant.OperType.APPROVED;
  651. } else if (status.equals(Constant.ProjectApplyStatus.REJECT)) {
  652. statusName = Constant.OperType.REJECT;
  653. }
  654. if (StringUtils.isNotBlank(statusName)) {
  655. return sendProjectSMSToCompany(departmentname, projectApplication, statusName);
  656. }
  657. }
  658. return false;
  659. }
  660. public Boolean sendProjectSMSToCompany(String departmentname, ProjectIntelligent projectApplication,
  661. String status) throws ClientException, InterruptedException {
  662. String phone = "";
  663. CompanyContact contact = companyContactService.findFirstByCompanyId(projectApplication.getCompany_id());
  664. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  665. if (null != companyInfo && null != companyInfo.getContact_phone()) {
  666. phone = companyInfo.getContact_phone();
  667. } else if (null != contact) {
  668. phone = contact.getPhone();
  669. }
  670. if (StringUtils.isNotBlank(phone)) {
  671. //${department_name}提醒您,您申请的${project_name}单据已审核 ${approve_status}。具体信息请登录PC端查看。感谢您的支持。
  672. ProjectIntelligentDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  673. String project_name = projectDeclaration.getProject_name();
  674. String templateParam = "{\"department_name\":\"" + departmentname + "\",\"project_name\":\"" + project_name + "\",\"approve_status\":\"" + status + "\"}";
  675. AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.PROJECT_APPLICATION_NOTIFY, "企业提升发展服务平台", templateParam);
  676. return true;
  677. } else {
  678. return false;
  679. }
  680. }
  681. public PageInfo<ProjectIntelligentDeclaration> findFillingPageInfo(String projectName, String projectType, String projectSource, Integer pageNum, Integer pagesize) {
  682. PageHelper.startPage(pageNum, pagesize);
  683. List<ProjectIntelligentDeclaration> list = projectIntelligentDeclarationDao.findFillingPageInfo(projectName, projectType, projectSource);
  684. for (ProjectIntelligentDeclaration projectFillingDeclaration : list) {
  685. if (StringUtils.isNotBlank(projectFillingDeclaration.getProject_service_type())) {
  686. String name = projectServiceTypeService.findById(projectFillingDeclaration.getProject_service_type()).get(0).getService_type_name();
  687. projectFillingDeclaration.setProject_service_type_name(name);
  688. }
  689. }
  690. return new PageInfo<ProjectIntelligentDeclaration>(list);
  691. }
  692. /**
  693. * 功能描述: 批量更新项目类别大类小类
  694. *
  695. * @param:
  696. * @return:
  697. * @auther: huZhiHao
  698. * @date: 2018/8/14 17:02
  699. */
  700. public void updateProjectServiceCategory(ProjectIntelligentDeclaration projectIntelligentDeclaration) {
  701. projectServiceCategoryService.deleteByProjectDeclarationId(projectIntelligentDeclaration.getId());
  702. List<ProjectServiceCategory> categoryList = projectIntelligentDeclaration.getProjectServiceCategory();
  703. //将大类名称去重
  704. List<String> temp_list = new ArrayList<>();
  705. for (ProjectServiceCategory projectServiceCategory : categoryList) {
  706. temp_list.add(projectServiceCategory.getProject_type_name1());
  707. }
  708. Set no_repeat = new HashSet(temp_list);
  709. List<String> category_f = new ArrayList<>(no_repeat);
  710. Integer project_declaration_id = projectIntelligentDeclaration.getId();
  711. String project_service_type_id = projectIntelligentDeclaration.getProject_service_type();
  712. if (category_f.size() >= 1 && !Objects.equals(category_f.get(0), "")) {
  713. for (String f_name : category_f) {
  714. List<ProjectServiceCategory> categoryList_c = new ArrayList<>();
  715. //插入大类并获取id作为子类父id 我也不想循环啊-..-!
  716. ProjectServiceCategory projectServiceCategory = new ProjectServiceCategory();
  717. projectServiceCategory.setPid(0);
  718. projectServiceCategory.setProject_declaration_id(project_declaration_id);
  719. //projectServiceCategory.setProject_service_type_id(Integer.parseInt(project_service_type_id));
  720. projectServiceCategory.setProject_type_name(f_name);
  721. projectServiceCategory.setBusiness_type(Constant.DictionaryType.PROJECT_INTELLIGENT);
  722. projectServiceCategoryService.insertAndGetId(projectServiceCategory);
  723. Integer fid = projectServiceCategory.getId();
  724. //装配子类
  725. for (ProjectServiceCategory category : categoryList) {
  726. if (Objects.equals(f_name, category.getProject_type_name1())) {
  727. ProjectServiceCategory projectCategory = new ProjectServiceCategory();
  728. projectCategory.setPid(fid);
  729. projectCategory.setProject_declaration_id(project_declaration_id);
  730. //projectCategory.setProject_service_type_id(Integer.parseInt(project_service_type_id));
  731. projectCategory.setProject_type_name(category.getProject_type_name2());
  732. projectCategory.setDepartment_id(category.getDepartment_id());
  733. projectCategory.setType(category.getType());
  734. projectCategory.setBusiness_type(Constant.DictionaryType.PROJECT_INTELLIGENT);
  735. categoryList_c.add(projectCategory);
  736. }
  737. }
  738. projectServiceCategoryService.insertBatch(categoryList_c);
  739. }
  740. }
  741. }
  742. }