ProjectDeclarationService.java 127 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427
  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.poi.ss.usermodel.Cell;
  8. import org.apache.poi.ss.usermodel.Row;
  9. import org.apache.poi.ss.usermodel.Sheet;
  10. import org.apache.poi.ss.usermodel.Workbook;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import org.springframework.transaction.annotation.Transactional;
  14. import org.springframework.ui.ModelMap;
  15. import org.springframework.util.CollectionUtils;
  16. import platform.common.Constant;
  17. import platform.common.base.model.DictionaryItem;
  18. import platform.common.base.service.BaseService;
  19. import platform.common.base.service.DictionaryItemService;
  20. import platform.common.exception.BaseException;
  21. import platform.common.util.AlibabaSMSUtil;
  22. import platform.common.util.DateUtil;
  23. import platform.common.util.ExportExcel;
  24. import platform.common.util.ShiroUtils;
  25. import platform.modules.build.entity.Company;
  26. import platform.modules.build.entity.CompanyContact;
  27. import platform.modules.build.service.BuildInfoService;
  28. import platform.modules.build.service.CompanyContactService;
  29. import platform.modules.build.service.CompanyService;
  30. import platform.modules.company.dao.ProjectApplicationDao;
  31. import platform.modules.company.dao.ProjectMaterialDao;
  32. import platform.modules.company.dto.ProjectApplicationSearchCondition;
  33. import platform.modules.company.entity.*;
  34. import platform.modules.company.service.ProjectApplicationCompanyInfoService;
  35. import platform.modules.company.service.ProjectApplicationService;
  36. import platform.modules.company.service.ProjectFillingService;
  37. import platform.modules.company.service.ProjectMaterialService;
  38. import platform.modules.government.dao.AttachmentDao;
  39. import platform.modules.government.dao.ProjectDao;
  40. import platform.modules.government.dao.ProjectDeclarationDao;
  41. import platform.modules.government.dto.*;
  42. import platform.modules.government.entity.*;
  43. import platform.modules.home.request.FindRequest;
  44. import platform.modules.home.response.FindResponseProject;
  45. import platform.modules.sys.dao.ApprovalDao;
  46. import platform.modules.sys.entity.*;
  47. import platform.modules.sys.report.OrderExports;
  48. import platform.modules.sys.service.*;
  49. import tk.mybatis.mapper.entity.Example;
  50. import javax.annotation.Resource;
  51. import javax.servlet.http.HttpServletResponse;
  52. import java.io.InputStream;
  53. import java.text.ParseException;
  54. import java.text.SimpleDateFormat;
  55. import java.time.LocalDateTime;
  56. import java.time.format.DateTimeFormatter;
  57. import java.util.*;
  58. import java.util.concurrent.*;
  59. @Service
  60. @Transactional
  61. public class ProjectDeclarationService extends BaseService<ProjectDeclaration> {
  62. @Resource
  63. private ProjectDeclarationDao projectDeclarationDao;
  64. @Autowired
  65. private NoticesService noticesService;
  66. @Autowired
  67. private NoticesAcceptService noticesAcceptService;
  68. @Autowired
  69. private MessageService messageService;
  70. @Resource
  71. private AttachmentDao attachmentDao;
  72. @Autowired
  73. private StreetService streetService;
  74. @Autowired
  75. private BuildInfoService buildInfoService;
  76. @Autowired
  77. private CompanyService companyService;
  78. @Autowired
  79. private GroupService groupService;
  80. @Autowired
  81. private UserGroupService userGroupService;
  82. @Autowired
  83. private UserService userService;
  84. @Autowired
  85. private ProjectApplicationDao projectApplicationDao;
  86. @Autowired
  87. private ProjectApplicationService projectApplicationService;
  88. @Resource
  89. private ProjectDao projectDao;
  90. @Resource
  91. private ApprovalDao approvalDao;
  92. @Autowired
  93. private DepartmentService departmentService;
  94. @Autowired
  95. private DictionaryItemService dictionaryItemService;
  96. @Autowired
  97. private ApprovalService approvalService;
  98. @Resource
  99. private ProjectMaterialDao projectMaterialDao;
  100. @Autowired
  101. private ProjectMaterialService projectMaterialDaoService;
  102. @Autowired
  103. private AttachmentService attachmentService;
  104. @Autowired
  105. private ProjectTypeService projectTypeService;
  106. @Autowired
  107. private CompanyContactService companyContactService;
  108. @Autowired
  109. private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService;
  110. @Autowired
  111. private WaitToDoService waitToDoService;
  112. @Autowired
  113. private ProjectFillingService projectFillingService;
  114. @Autowired
  115. private ProjectService projectService;
  116. public PageInfo<ProjectDeclaration> findPageInfo(String projectName, Integer pageNum, Integer pagesize,
  117. String startTime1, String startTime2, String endTime1, String endTime2) {
  118. PageHelper.startPage(pageNum, pagesize);
  119. List<ProjectDeclaration> list = projectDeclarationDao.findPageInfo(projectName, startTime1, startTime2, endTime1, endTime2);
  120. for (ProjectDeclaration projectDeclaration : list) {
  121. if (Objects.equals(projectDeclaration.getStatus(), "0")) {
  122. projectDeclaration.setStatus_name("待发布");
  123. } else {
  124. try {
  125. String end = projectDeclaration.getApply_enddate();
  126. if (end.length() <= 10) end += " 23:59:59";
  127. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  128. Date endtime = sdf.parse(end);
  129. String start = projectDeclaration.getApply_startdate();
  130. if (start.length() <= 10) start += " 00:00:00";
  131. Date starttime = sdf.parse(start);
  132. Date now = new Date();
  133. if (now.after(endtime)) {
  134. projectDeclaration.setStatus_name("失效");
  135. } else if (now.before(starttime)) {
  136. projectDeclaration.setStatus_name("未开始");
  137. } else {
  138. projectDeclaration.setStatus_name("申请中");
  139. }
  140. } catch (Exception e) {
  141. projectDeclaration.setStatus_name("申请中");
  142. }
  143. }
  144. }
  145. return new PageInfo<ProjectDeclaration>(list);
  146. }
  147. public Integer save(ProjectDeclaration projectDeclaration) {
  148. //String apply_date_range = projectDeclaration.getApply_date_range();
  149. /*if (apply_date_range != null && apply_date_range != "") {
  150. if (apply_date_range.contains(" 至 ")) {
  151. String[] dateRange = apply_date_range.split(" 至 ");
  152. if (dateRange[0] == null || dateRange[0] == "" || dateRange[0] == "null") {
  153. projectDeclaration.setApply_startdate("");
  154. } else {
  155. projectDeclaration.setApply_startdate(dateRange[0]);
  156. }
  157. if (dateRange[1] == null || dateRange[1] == "" || dateRange[1] == "null") {
  158. projectDeclaration.setApply_enddate("");
  159. } else {
  160. projectDeclaration.setApply_enddate(dateRange[1]);
  161. }
  162. } else {
  163. projectDeclaration.setApply_startdate("");
  164. projectDeclaration.setApply_enddate("");
  165. }
  166. } else {
  167. projectDeclaration.setApply_startdate("");
  168. projectDeclaration.setApply_enddate("");
  169. }*/
  170. this.insertAndGetId(projectDeclaration);
  171. Integer activityId = projectDeclaration.getId();
  172. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId());
  173. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId(), projectDeclaration.getFileDown().getFile_id());
  174. pushNotices(projectDeclaration);
  175. if (projectDeclaration.getStatus().equals(Constant.ProjectDeclarationStatus.RELEASE)) {
  176. //所有企业
  177. List<Company> companies = companyService.findCompanyList();
  178. String companyids = "";
  179. for (Company company : companies) {
  180. companyids += company.getId() + ",";
  181. }
  182. //所有街道
  183. List<Street> streets = streetService.findList();
  184. String streetids = "";
  185. for (Street street : streets) {
  186. streetids += street.getId() + ",";
  187. }
  188. //中心窗口
  189. StringBuffer governmentids = new StringBuffer("");
  190. Group group = groupService.findByName(Constant.XMSBCLSLZ, null);
  191. if (null == group) {
  192. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  193. }
  194. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  195. for (UserGroup userGroup : userGroups) {
  196. governmentids.append(userGroup.getUser_id() + ",");
  197. }
  198. //处室
  199. group = groupService.findByName(Constant.XMSBCLSHZ, null);
  200. if (null == group) {
  201. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  202. }
  203. userGroups = userGroupService.findByGroupId(group.getId());
  204. for (UserGroup userGroup : userGroups) {
  205. governmentids.append(userGroup.getUser_id() + ",");
  206. }
  207. //财政
  208. group = groupService.findByName(Constant.XMSBCZSHZ, null);
  209. if (null == group) {
  210. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  211. }
  212. userGroups = userGroupService.findByGroupId(group.getId());
  213. for (UserGroup userGroup : userGroups) {
  214. governmentids.append(userGroup.getUser_id() + ",");
  215. }
  216. Message messages = new Message();
  217. messages.setApply_id(activityId);
  218. messages.setTitle(projectDeclaration.getProject_name() + "准备申报");
  219. String projectName = projectDeclaration.getProject_name();
  220. String s = projectDeclaration.getApply_startdate();
  221. String e = projectDeclaration.getApply_enddate();
  222. try {
  223. SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
  224. Date date1 = sdf1.parse(s);
  225. Date date2 = sdf1.parse(e);
  226. SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
  227. s = sdf2.format(date1);
  228. e = sdf2.format(date2);
  229. } catch (ParseException e1) {
  230. e1.printStackTrace();
  231. }
  232. String message = projectName + "自" + s + "开始可以进行申报,申报截止日期为" + e;
  233. messages.setContent(message);
  234. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  235. if (!StringUtils.isEmpty(streetids)) {
  236. String[] streetArr = streetids.split(",");
  237. Set<String> set = new HashSet<>();
  238. for (int i = 0; i < streetArr.length; i++) {
  239. set.add(streetArr[i]);
  240. }
  241. String[] streetArrs = (String[]) set.toArray(new String[set.size()]);
  242. int[] streetArrInt = new int[streetArrs.length];
  243. for (int i = 0; i < streetArrs.length; i++) {
  244. streetArrInt[i] = Integer.parseInt(streetArrs[i]);
  245. }
  246. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.STREET);
  247. }
  248. if (!StringUtils.isEmpty(companyids)) {
  249. String[] companyArr = companyids.split(",");
  250. Set<String> set = new HashSet<>();
  251. for (int i = 0; i < companyArr.length; i++) {
  252. set.add(companyArr[i]);
  253. }
  254. String[] companyArrs = (String[]) set.toArray(new String[set.size()]);
  255. int[] companyArrInt = new int[companyArrs.length];
  256. for (int i = 0; i < companyArrs.length; i++) {
  257. companyArrInt[i] = Integer.parseInt(companyArrs[i]);
  258. }
  259. messageService.saveMessageAndPush(messages, companyArrInt, Constant.UserType.COMPANY);
  260. }
  261. if (!StringUtils.isEmpty(governmentids.toString())) {
  262. String[] governmentArr = governmentids.toString().split(",");
  263. Set<String> set = new HashSet<>();
  264. for (int i = 0; i < governmentArr.length; i++) {
  265. set.add(governmentArr[i]);
  266. }
  267. String[] governmentArrs = (String[]) set.toArray(new String[set.size()]);
  268. int[] governmentArrInt = new int[governmentArrs.length];
  269. for (int i = 0; i < governmentArrs.length; i++) {
  270. governmentArrInt[i] = Integer.parseInt(governmentArrs[i]);
  271. }
  272. messageService.saveMessageAndPush(messages, governmentArrInt, Constant.UserType.GOVERNMENT);
  273. }
  274. }
  275. return activityId;
  276. }
  277. public Integer update(ProjectDeclaration projectDeclaration) {
  278. String apply_date_range = projectDeclaration.getApply_date_range();
  279. /*if (apply_date_range != null && apply_date_range != "") {
  280. if (apply_date_range.contains(" 至 ")) {
  281. String[] dateRange = apply_date_range.split(" 至 ");
  282. if (dateRange[0] == null || dateRange[0] == "" || dateRange[0] == "null") {
  283. projectDeclaration.setApply_startdate("");
  284. } else {
  285. projectDeclaration.setApply_startdate(dateRange[0]);
  286. }
  287. if (dateRange[1] == null || dateRange[1] == "" || dateRange[1] == "null") {
  288. projectDeclaration.setApply_enddate("");
  289. } else {
  290. projectDeclaration.setApply_enddate(dateRange[1]);
  291. }
  292. } else {
  293. projectDeclaration.setApply_startdate("");
  294. projectDeclaration.setApply_enddate("");
  295. }
  296. } else {
  297. projectDeclaration.setApply_startdate("");
  298. projectDeclaration.setApply_enddate("");
  299. }*/
  300. this.updateSelective(projectDeclaration);
  301. Integer activityId = projectDeclaration.getId();
  302. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId());
  303. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId(), projectDeclaration.getFileDown().getFile_id());
  304. pushNotices(projectDeclaration);
  305. if (projectDeclaration.getStatus().equals(Constant.ProjectDeclarationStatus.RELEASE)) {
  306. //所有企业
  307. List<Company> companies = companyService.findCompanyList();
  308. String companyids = "";
  309. for (Company company : companies) {
  310. companyids += company.getId() + ",";
  311. }
  312. //所有街道
  313. List<Street> streets = streetService.findList();
  314. String streetids = "";
  315. for (Street street : streets) {
  316. streetids += street.getId() + ",";
  317. }
  318. //中心窗口
  319. StringBuffer governmentids = new StringBuffer("");
  320. Group group = groupService.findByName(Constant.XMSBCLSLZ, null);
  321. if (null == group) {
  322. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  323. }
  324. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  325. for (UserGroup userGroup : userGroups) {
  326. governmentids.append(userGroup.getUser_id() + ",");
  327. }
  328. //处室
  329. group = groupService.findByName(Constant.XMSBCLSHZ, null);
  330. if (null == group) {
  331. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  332. }
  333. userGroups = userGroupService.findByGroupId(group.getId());
  334. for (UserGroup userGroup : userGroups) {
  335. governmentids.append(userGroup.getUser_id() + ",");
  336. }
  337. //财政
  338. group = groupService.findByName(Constant.XMSBCZSHZ, null);
  339. if (null == group) {
  340. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  341. }
  342. userGroups = userGroupService.findByGroupId(group.getId());
  343. for (UserGroup userGroup : userGroups) {
  344. governmentids.append(userGroup.getUser_id() + ",");
  345. }
  346. Message messages = new Message();
  347. messages.setApply_id(activityId);
  348. messages.setTitle(projectDeclaration.getProject_name() + "准备申报");
  349. String projectName = projectDeclaration.getProject_name();
  350. String s = projectDeclaration.getApply_startdate();
  351. String e = projectDeclaration.getApply_enddate();
  352. try {
  353. SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
  354. Date date1 = sdf1.parse(s);
  355. Date date2 = sdf1.parse(e);
  356. SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
  357. s = sdf2.format(date1);
  358. e = sdf2.format(date2);
  359. } catch (ParseException e1) {
  360. e1.printStackTrace();
  361. }
  362. String message = projectName + "自" + s + "开始可以进行申报,申报截止日期为" + e;
  363. messages.setContent(message);
  364. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  365. if (!StringUtils.isEmpty(streetids)) {
  366. String[] streetArr = streetids.split(",");
  367. Set<String> set = new HashSet<>();
  368. for (int i = 0; i < streetArr.length; i++) {
  369. set.add(streetArr[i]);
  370. }
  371. String[] streetArrs = (String[]) set.toArray(new String[set.size()]);
  372. int[] streetArrInt = new int[streetArrs.length];
  373. for (int i = 0; i < streetArrs.length; i++) {
  374. streetArrInt[i] = Integer.parseInt(streetArrs[i]);
  375. }
  376. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.STREET);
  377. }
  378. if (!StringUtils.isEmpty(companyids)) {
  379. String[] companyArr = companyids.split(",");
  380. Set<String> set = new HashSet<>();
  381. for (int i = 0; i < companyArr.length; i++) {
  382. set.add(companyArr[i]);
  383. }
  384. String[] companyArrs = (String[]) set.toArray(new String[set.size()]);
  385. int[] companyArrInt = new int[companyArrs.length];
  386. for (int i = 0; i < companyArrs.length; i++) {
  387. companyArrInt[i] = Integer.parseInt(companyArrs[i]);
  388. }
  389. messageService.saveMessageAndPush(messages, companyArrInt, Constant.UserType.COMPANY);
  390. }
  391. if (!StringUtils.isEmpty(governmentids.toString())) {
  392. String[] governmentArr = governmentids.toString().split(",");
  393. Set<String> set = new HashSet<>();
  394. for (int i = 0; i < governmentArr.length; i++) {
  395. set.add(governmentArr[i]);
  396. }
  397. String[] governmentArrs = (String[]) set.toArray(new String[set.size()]);
  398. int[] governmentArrInt = new int[governmentArrs.length];
  399. for (int i = 0; i < governmentArrs.length; i++) {
  400. governmentArrInt[i] = Integer.parseInt(governmentArrs[i]);
  401. }
  402. messageService.saveMessageAndPush(messages, governmentArrInt, Constant.UserType.GOVERNMENT);
  403. }
  404. }
  405. return activityId;
  406. }
  407. public ProjectDeclaration selectById(String id) {
  408. ProjectDeclaration projectDeclaration = projectDeclarationDao.selectById(id);
  409. //发布单位
  410. if (StringUtils.isNotBlank(projectDeclaration.getRelease_departments())) {
  411. String[] deptIds = projectDeclaration.getRelease_departments().split(",");
  412. List<Integer> release_departmentsIds = new ArrayList<Integer>();
  413. String release_departmentsNames = "";
  414. for (int i = 0; i < deptIds.length; i++) {
  415. Department dept = departmentService.findById(Integer.valueOf(deptIds[i]));
  416. if (null != dept) {
  417. release_departmentsIds.add(Integer.valueOf(deptIds[i]));
  418. release_departmentsNames += dept.getName() + ",";
  419. }
  420. }
  421. projectDeclaration.setRelease_departmentsIds(release_departmentsIds);
  422. if (StringUtils.isNotBlank(release_departmentsNames)) {
  423. String names = release_departmentsNames.substring(0, release_departmentsNames.length() - 1);
  424. projectDeclaration.setRelease_departments_name(names);
  425. }
  426. }
  427. //责任单位
  428. if (null != projectDeclaration.getDepartment_id()) {
  429. Department dept = departmentService.findById(projectDeclaration.getDepartment_id());
  430. if (null != dept) {
  431. projectDeclaration.setDepartment_name(dept.getName());
  432. }
  433. }
  434. //项目大类
  435. String superType = projectDeclaration.getProject_super_type();
  436. if (StringUtils.isNotBlank(superType)) {
  437. DictionaryItem superTypeItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_APPLICATION_SUPER_TYPE, superType);
  438. if (null != superTypeItem) {
  439. projectDeclaration.setProject_super_type_name(superTypeItem.getName());
  440. }
  441. }
  442. //项目来源
  443. String source = projectDeclaration.getProject_source();
  444. if (StringUtils.isNotBlank(source)) {
  445. DictionaryItem sourceItem = dictionaryItemService.findByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, source);
  446. if (null != sourceItem) {
  447. projectDeclaration.setProject_source_name(sourceItem.getName());
  448. }
  449. }
  450. //文件
  451. List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.PROJECT_DECLARATION, projectDeclaration.getId(), null);
  452. if (null != attachments && attachments.size() > 0) {
  453. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  454. projectDeclaration.setFileDown(fileDown);
  455. }
  456. try {
  457. projectDeclaration = getPushNames(projectDeclaration);
  458. } catch (Exception e) {
  459. e.printStackTrace();
  460. }
  461. return projectDeclaration;
  462. }
  463. public void push(Integer id) {
  464. ProjectDeclaration projectDeclaration = projectDeclarationDao.selectById(id.toString());
  465. pushNotices(projectDeclaration);
  466. }
  467. @Transactional
  468. public void pushNotices(ProjectDeclaration projectDeclaration) {
  469. if (null != projectDeclaration.getNew_push_company_ids()) {
  470. try {
  471. updatePushDetails(projectDeclaration, projectDeclaration.getNew_push_street_ids(), projectDeclaration.getNew_push_build_ids(), projectDeclaration.getNew_push_company_ids());
  472. } catch (Exception e) {
  473. e.printStackTrace();
  474. }
  475. String company_ids = projectDeclaration.getNew_push_company_ids();
  476. projectDeclaration.setPush_company_ids(company_ids);
  477. }
  478. if (Objects.equals(projectDeclaration.getStatus(), "1") && projectDeclaration.getPush_company_ids() != null && !projectDeclaration.getPush_company_ids().isEmpty()) {
  479. Notices notice = new Notices();
  480. if (Objects.equals(projectDeclaration.getApp_notice(), "1")) {
  481. notice.setNotice_type("1");
  482. if (Objects.equals(projectDeclaration.getMes_notice(), "1")) {
  483. notice.setNotice_type("3");
  484. }
  485. } else {
  486. if (Objects.equals(projectDeclaration.getMes_notice(), "1")) {
  487. notice.setNotice_type("2");
  488. }
  489. }
  490. notice.setMessage_content("");
  491. notice.setRecorde_id(projectDeclaration.getId().toString());
  492. noticesService.insertAndGetId(notice);
  493. Integer noticesId = notice.getId();
  494. String companyIds = projectDeclaration.getPush_company_ids();
  495. String[] companyIdsArr = companyIds.split(",");
  496. List<NoticesAccept> ids = new ArrayList<NoticesAccept>();
  497. if (companyIdsArr.length > 0) {
  498. for (String id : companyIdsArr) {
  499. NoticesAccept noticesAccept = new NoticesAccept();
  500. noticesAccept.setNotice_id(noticesId);
  501. noticesAccept.setRead_statu(0);
  502. noticesAccept.setUser_type(Constant.UserType.COMPANY);
  503. noticesAccept.setRecorde_type(2);
  504. noticesAccept.setRecorde_id(projectDeclaration.getId());
  505. noticesAccept.setUser_id(Integer.parseInt(id));
  506. noticesAccept.setUser_type(3);
  507. noticesAcceptService.insertAndGetId(noticesAccept);
  508. }
  509. }
  510. }
  511. }
  512. //查询推送单位名称
  513. public ProjectDeclaration getPushNames(ProjectDeclaration projectDeclaration) throws Exception {
  514. String pushNames = "";
  515. if (StringUtils.isNotBlank(projectDeclaration.getPush_street_ids())) {
  516. List<String> streetNames = new ArrayList<String>();
  517. String[] streetIds = projectDeclaration.getPush_street_ids().split(",");
  518. for (int i = 0; i < streetIds.length; i++) {
  519. String name = streetService.getStreetName(Integer.valueOf(streetIds[i]));
  520. streetNames.add(name);
  521. }
  522. projectDeclaration.setPush_street_names(String.join(",", streetNames));
  523. pushNames += String.join(",", streetNames);
  524. }
  525. if (StringUtils.isNotBlank(projectDeclaration.getPush_build_ids())) {
  526. List<String> buildNames = new ArrayList<String>();
  527. String[] buildIds = projectDeclaration.getPush_build_ids().split(",");
  528. for (int i = 0; i < buildIds.length; i++) {
  529. String name = buildInfoService.getBuildName(Integer.valueOf(buildIds[i]));
  530. buildNames.add(name);
  531. }
  532. projectDeclaration.setPush_build_names(String.join(",", buildNames));
  533. pushNames += " ; " + String.join(",", buildNames);
  534. }
  535. if (StringUtils.isNotBlank(projectDeclaration.getPush_company_ids())) {
  536. List<String> companyNames = new ArrayList<String>();
  537. String[] companyIds = projectDeclaration.getPush_company_ids().split(",");
  538. for (int i = 0; i < companyIds.length; i++) {
  539. String name = companyService.getCompanyName(Integer.valueOf(companyIds[i]));
  540. companyNames.add(name);
  541. }
  542. projectDeclaration.setPush_company_names(String.join(",", companyNames));
  543. pushNames += " ; " + String.join(",", companyNames);
  544. }
  545. projectDeclaration.setPush_names(pushNames);
  546. return projectDeclaration;
  547. }
  548. /**
  549. * 更新通知推送单位
  550. */
  551. public Boolean updatePushDetails(ProjectDeclaration projectDeclaration, String street_ids, String build_ids, String company_ids) throws Exception {
  552. String alreadyPushStreets = projectDeclaration.getPush_street_ids() == null ? "" : projectDeclaration.getPush_build_ids();
  553. String alreadyPushBuilds = projectDeclaration.getPush_build_ids() == null ? "" : projectDeclaration.getPush_build_ids();
  554. String alreadyPushCompanys = projectDeclaration.getPush_company_ids() == null ? "" : projectDeclaration.getPush_company_ids();
  555. if (StringUtils.isNotBlank(street_ids)) {
  556. String[] idsArr = street_ids.split(",");
  557. if (idsArr.length > 0) {
  558. for (int i = 0; i < idsArr.length; i++) {
  559. if (!alreadyPushStreets.contains(idsArr[i])) {
  560. alreadyPushStreets += "," + idsArr[i];
  561. }
  562. }
  563. } else {
  564. alreadyPushStreets = street_ids;
  565. }
  566. }
  567. if (StringUtils.isNotBlank(build_ids)) {
  568. String[] idsArr = build_ids.split(",");
  569. if (idsArr.length > 0) {
  570. for (int i = 0; i < idsArr.length; i++) {
  571. if (!alreadyPushBuilds.contains(idsArr[i])) {
  572. alreadyPushBuilds += "," + idsArr[i];
  573. }
  574. }
  575. } else {
  576. alreadyPushBuilds = build_ids;
  577. }
  578. }
  579. if (StringUtils.isNotBlank(company_ids)) {
  580. String[] idsArr = company_ids.split(",");
  581. if (idsArr.length > 0) {
  582. for (int i = 0; i < idsArr.length; i++) {
  583. if (!alreadyPushCompanys.contains(idsArr[i])) {
  584. alreadyPushCompanys += "," + idsArr[i];
  585. }
  586. }
  587. } else {
  588. alreadyPushCompanys = company_ids;
  589. }
  590. }
  591. projectDeclaration.setPush_build_ids(alreadyPushBuilds.substring(0, alreadyPushBuilds.length()));
  592. projectDeclaration.setPush_build_ids(alreadyPushBuilds.substring(0, alreadyPushBuilds.length()));
  593. projectDeclaration.setPush_company_ids(alreadyPushCompanys.substring(0, alreadyPushCompanys.length()));
  594. return this.updateSelective(projectDeclaration) > 0;
  595. }
  596. //根据小组名称获取组内用户
  597. public String findUserIdByGroupName(String groupName) {
  598. Group group = groupService.findByName(groupName, null);
  599. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  600. StringBuffer sb = new StringBuffer("");
  601. for (UserGroup userGroup : userGroups) {
  602. sb.append(userGroup.getUser_id() + ",");
  603. }
  604. return sb.toString();
  605. }
  606. //根据用户获取所在部门
  607. public String findUserDepartment(String userIds) {
  608. int currentUserId = ShiroUtils.getUserId();
  609. String[] userIdArr = userIds.split(",");
  610. List<String> list = Arrays.asList(userIdArr);
  611. if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) {
  612. if (list.contains(String.valueOf(currentUserId))) {
  613. Integer departmentId = userService.findDepartmentIdByUserId(currentUserId);
  614. if (null != departmentId) {
  615. return departmentId.toString();
  616. }
  617. }
  618. }
  619. return null;
  620. }
  621. public void getProjectApproval(Integer id) {
  622. int currentUserId = ShiroUtils.getUserId();
  623. Example example = new Example(Project.class);
  624. Example.Criteria criteria = example.createCriteria();
  625. criteria.andEqualTo("id", id);
  626. List<Project> projectList = projectDao.selectByExample(example);
  627. if (!CollectionUtils.isEmpty(projectList)) {
  628. projectList.get(0).getDepartment_id();
  629. projectList.get(0).getDepartment_name();
  630. }
  631. //材料受理
  632. String sl = findUserIdByGroupName(Constant.XMSBCLSLZ);
  633. //材料审核
  634. String sh = findUserIdByGroupName(Constant.XMSBCLSHZ);
  635. }
  636. //获取项目申报id 待审批
  637. public List<String> getProjectIdsd() {
  638. /* boolean flag = false;*/
  639. int currentUserId = ShiroUtils.getUserId();
  640. /*Group group = groupService.findByName(Constant.XMSBFZR, null);
  641. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  642. for (UserGroup userGroup : userGroups) {
  643. if (Objects.equals(userGroup.getUser_id(), currentUserId)) {
  644. flag = true;
  645. }
  646. }*/
  647. List<Approval> approvalList = approvalDao.selectAllApprovalDistinct(Constant.DictionaryType.PROJECT_APPLICATION);
  648. Set<String> projectApplicationIds = new HashSet<String>();
  649. if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) {
  650. if (!CollectionUtils.isEmpty(approvalList)) {
  651. for (Approval approval : approvalList) {
  652. String nextCheckerIds = approval.getNextchecker();
  653. if (nextCheckerIds != null && nextCheckerIds != "") {
  654. String[] userIdArr = nextCheckerIds.split(",");
  655. List<String> list = Arrays.asList(userIdArr);
  656. if (list.contains(String.valueOf(currentUserId))) {
  657. projectApplicationIds.add(approval.getApply_id().toString());
  658. }
  659. }
  660. }
  661. }
  662. }
  663. /*if (flag) {
  664. Example example = new Example(ProjectApplication.class);
  665. Example.Criteria criteria = example.createCriteria();
  666. criteria.andEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTIFY);
  667. //criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.APPROVED);
  668. List<ProjectApplication> projectList = projectApplicationDao.selectByExample(example);
  669. for (ProjectApplication project : projectList) {
  670. projectApplicationIds.add(project.getId().toString());
  671. }
  672. }*/
  673. List<String> result = new ArrayList<>(projectApplicationIds);
  674. return result;
  675. }
  676. //获取项目申报id 已审批
  677. public List<String> getProjectIdsy() {
  678. int currentUserId = ShiroUtils.getUserId();
  679. List<Approval> approvalList = approvalDao.selectAllApproval(Constant.DictionaryType.PROJECT_APPLICATION);
  680. Set<String> projectApplicationIds = new HashSet<String>();
  681. if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) {
  682. if (!CollectionUtils.isEmpty(approvalList)) {
  683. for (Approval approval : approvalList) {
  684. String checkerIds = approval.getChecker() + "";
  685. if (checkerIds != null && checkerIds != "") {
  686. if (Objects.equals(checkerIds, String.valueOf(currentUserId))) {
  687. projectApplicationIds.add(approval.getApply_id().toString());
  688. }
  689. }
  690. }
  691. }
  692. }
  693. List<String> result = new ArrayList<>(projectApplicationIds);
  694. return result;
  695. }
  696. //获取项目申报id 待通知
  697. public List<String> getProjectIdsn() {
  698. /*int currentUserId = ShiroUtils.getUserId();
  699. List<Approval> approvalList = approvalDao.selectAllApprovalDistinct();
  700. Set<String> projectApplicationIds = new HashSet<String>();
  701. if (Objects.equals(ShiroUtils.getUserType(), Constant.UserType.GOVERNMENT)) {
  702. if (!CollectionUtils.isEmpty(approvalList)) {
  703. for (Approval approval : approvalList) {
  704. String checkerIds = approval.getChecker()+"";
  705. if (checkerIds != null && checkerIds != "") {
  706. String[] userIdArr = checkerIds.split(",");
  707. List<String> list = Arrays.asList(userIdArr);
  708. if (list.contains(String.valueOf(currentUserId))) {
  709. projectApplicationIds.add(approval.getApply_id().toString());
  710. }
  711. }
  712. }
  713. }
  714. }*/
  715. List<String> result = new ArrayList<>();
  716. Example example = new Example(ProjectApplication.class);
  717. Example.Criteria criteria = example.createCriteria();
  718. criteria.andEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTIFY);
  719. //criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.APPROVED);
  720. List<ProjectApplication> projectList = projectApplicationDao.selectByExample(example);
  721. for (ProjectApplication project : projectList) {
  722. result.add(project.getId().toString());
  723. }
  724. return result;
  725. }
  726. //获取项目申报id 查看所有
  727. public List<String> getProjectIdsc() {
  728. List<String> result = new ArrayList<>();
  729. Example example = new Example(ProjectApplication.class);
  730. Example.Criteria criteria = example.createCriteria();
  731. criteria.andEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTIFY);//待通知
  732. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.LOCAL_AUDIT); //属地初审
  733. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.CENTRE_AUDIT);//材料审核
  734. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);//处室(中心)审批
  735. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.FINANCE_AUDIT);//财政审批
  736. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.UPLOAD_REPORT);//待上传报告
  737. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.APPROVED);//通过
  738. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.REJECT_TO_COMPANY);//退回至企业
  739. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.REJECT_TO_DEPARTMENT);//退回至处室
  740. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.NOTAPPROVED);//不通过
  741. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.UPLOAD_CS);//待财政上传
  742. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.UPLOAD_CZ);//待处室上传
  743. criteria.orEqualTo("approve_status", Constant.ProjectApplicationStatus.COMMIT_FILE);//待中心窗口上传
  744. criteria.orEqualTo("del_flag", "0");//不显示删除的
  745. List<ProjectApplication> projectList = projectApplicationDao.selectByExample(example);
  746. for (ProjectApplication project : projectList) {
  747. result.add(project.getId().toString());
  748. }
  749. return result;
  750. }
  751. //根据用户组获取可查询到的项目
  752. public List<String> getProjectIdsByGroup() {
  753. List<ProjectApplication> projectLists = new ArrayList<>();
  754. Integer user_id = ShiroUtils.getUserId();
  755. Department department = departmentService.findById(ShiroUtils.getUserEntity().getDepartment_id());
  756. Integer departmentId = 21;//中心窗口
  757. if (!department.getParent_id().equals(departmentId)) departmentId = department.getId();
  758. Example example = new Example(Project.class);
  759. Example.Criteria criteria = example.createCriteria();
  760. criteria.andEqualTo("del_flag", "0");
  761. criteria.andEqualTo("department_id", departmentId);
  762. List<Project> projectList = projectDao.selectByExample(example);
  763. List<String> project_ids = new ArrayList<>();
  764. if (CollectionUtils.isEmpty(projectList)) return project_ids;
  765. for (Project project : projectList) {
  766. project_ids.add(project.getId() + "");
  767. }
  768. Group group;
  769. List<UserGroup> userGroups;
  770. List<String> apply_status_list = new ArrayList<>();
  771. if (ShiroUtils.getUserType() == Constant.UserType.STREET) {
  772. group = groupService.findByName(Constant.XMSBJDSLZ, null);
  773. if (null == group) {
  774. apply_status_list.add("");
  775. }
  776. userGroups = userGroupService.findByGroupId(group.getId());
  777. if (null == userGroups) {
  778. apply_status_list.add("");
  779. }
  780. for (UserGroup userGroup : userGroups) {
  781. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  782. apply_status_list.add(Constant.ProjectProvincesStatus.LOCAL_AUDIT);
  783. break;
  784. }
  785. }
  786. } else {
  787. //材料受理
  788. group = groupService.findByName(Constant.XMSBCLSLZ, null);
  789. userGroups = userGroupService.findByGroupId(group.getId());
  790. for (UserGroup userGroup : userGroups) {
  791. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  792. apply_status_list.add(Constant.ProjectApplicationStatus.CENTRE_AUDIT);
  793. apply_status_list.add(Constant.ProjectApplicationStatus.COMMIT_FILE);
  794. projectLists.addAll(projectApplicationDao.findByProjectIdAndApproveStatus(new ArrayList<>(), apply_status_list, null));
  795. break;
  796. }
  797. }
  798. //材料审核
  799. group = groupService.findByName(Constant.XMSBCLSHZ, null);
  800. userGroups = userGroupService.findByGroupId(group.getId());
  801. for (UserGroup userGroup : userGroups) {
  802. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  803. apply_status_list.add(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  804. apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_REPORT);
  805. apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_CZ);
  806. break;
  807. }
  808. }
  809. //项目申报财政审核组
  810. group = groupService.findByName(Constant.XMSBCZSHZ, null);
  811. userGroups = userGroupService.findByGroupId(group.getId());
  812. for (UserGroup userGroup : userGroups) {
  813. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  814. apply_status_list.add(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  815. apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_REPORT);
  816. apply_status_list.add(Constant.ProjectApplicationStatus.UPLOAD_CS);
  817. break;
  818. }
  819. }
  820. //项目申报负责人
  821. group = groupService.findByName(Constant.XMSBFZR, null);
  822. userGroups = userGroupService.findByGroupId(group.getId());
  823. for (UserGroup userGroup : userGroups) {
  824. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  825. apply_status_list.add(Constant.ProjectApplicationStatus.NOTIFY);
  826. projectLists.addAll(projectApplicationDao.findByProjectIdAndApproveStatus(new ArrayList<>(), apply_status_list, null));
  827. break;
  828. }
  829. }
  830. }
  831. if (apply_status_list.size() <= 0) {
  832. apply_status_list.add("");
  833. }
  834. projectLists.addAll(projectApplicationDao.findByProjectIdAndApproveStatus(project_ids, apply_status_list, null));
  835. List<String> result = new ArrayList<>();
  836. for (ProjectApplication project : projectLists) {
  837. result.add(project.getId().toString());
  838. }
  839. return result;
  840. }
  841. //待审核分页
  842. public PageInfo<ApplicationDto> findPage(Integer pageNum, Integer pageSize, ParamApplication paramApplication, String type) {
  843. paramApplication.setApproval_type(Constant.DictionaryType.PROJECT_APPLICATION);
  844. if (Objects.equals("1", type)) {
  845. //paramApplication.setProjectIds(getProjectIdsd()); //原逻辑
  846. paramApplication.setProjectIds(getProjectIdsByGroup());//新逻辑
  847. } else if (Objects.equals("2", type)) {
  848. paramApplication.setProjectIds(getProjectIdsy());
  849. } /*else if (Objects.equals("3", type)) {
  850. paramApplication.setProjectIds(getProjectIdsn());
  851. }*/ else if (Objects.equals("4", type)) {
  852. paramApplication.setProjectIds(getProjectIdsc());
  853. }
  854. String year = paramApplication.getProject_year();
  855. if (year != null && !year.equals("")) {
  856. paramApplication.setProject_year_date(year + "-01-01 00:00:00");
  857. }
  858. PageHelper.startPage(pageNum, pageSize);
  859. List<ApplicationDto> applicationDtoList = projectApplicationDao.findPage(paramApplication);
  860. for (ApplicationDto app : applicationDtoList) {
  861. if (null != app.getProject_type()) {
  862. ProjectType projectType = projectTypeService.findById(Integer.parseInt(app.getProject_type()));
  863. //String type_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPLICATION_TYPE, app.getProject_type());
  864. app.setProject_type(projectType.getType_name());
  865. }
  866. if (null != app.getApprove_status()) {
  867. String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPROVE_STATUS, app.getApprove_status());
  868. app.setStatedesc(status_name);
  869. }
  870. }
  871. return new PageInfo<>(applicationDtoList);
  872. }
  873. //待审核分页
  874. public List<ApplicationDto> findList(ParamApplication paramApplication, String type) {
  875. paramApplication.setApproval_type(Constant.DictionaryType.PROJECT_APPLICATION);
  876. if (Objects.equals("1", type)) {
  877. //paramApplication.setProjectIds(getProjectIdsd()); //原逻辑
  878. paramApplication.setProjectIds(getProjectIdsByGroup());//新逻辑
  879. } else if (Objects.equals("2", type)) {
  880. paramApplication.setProjectIds(getProjectIdsy());
  881. } /*else if (Objects.equals("3", type)) {
  882. paramApplication.setProjectIds(getProjectIdsn());
  883. }*/ else if (Objects.equals("4", type)) {
  884. paramApplication.setProjectIds(getProjectIdsc());
  885. }
  886. String year = paramApplication.getProject_year();
  887. if (year != null && !year.equals("")) {
  888. paramApplication.setProject_year_date(year + "-01-01 00:00:00");
  889. }
  890. List<ApplicationDto> applicationDtoList = projectApplicationDao.findPage(paramApplication);
  891. for (ApplicationDto app : applicationDtoList) {
  892. if (null != app.getProject_type()) {
  893. ProjectType projectType = projectTypeService.findById(Integer.parseInt(app.getProject_type()));
  894. //String type_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPLICATION_TYPE, app.getProject_type());
  895. app.setProject_type(projectType.getType_name());
  896. }
  897. if (null != app.getApprove_status()) {
  898. String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_APPROVE_STATUS, app.getApprove_status());
  899. app.setStatedesc(status_name);
  900. }
  901. }
  902. return applicationDtoList;
  903. }
  904. //通过
  905. public Boolean pass(Integer projectId, String comment) throws ClientException, InterruptedException {
  906. ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString());
  907. Project project = new Project();
  908. project.setId(projectApplication.getProject_id());
  909. project = projectDao.selectOne(project);
  910. //判断年份
  911. ProjectDeclaration declaration = findById(projectApplication.getDeclaration_id());
  912. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  913. int year = LocalDateTime.parse(declaration.getApply_startdate(), formatter).getYear();
  914. if (year == 2019) return refactorPass(projectId, comment);
  915. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION);
  916. Approval a = new Approval();
  917. a.setApply_id(projectId);
  918. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  919. if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) {
  920. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  921. a.setDepartment(departmentname);
  922. }
  923. a.setApproval_comment(comment);
  924. a.setChecker(ShiroUtils.getUserId());
  925. a.setOper_type(Constant.OperType.APPROVED);
  926. a.setDeal_time(DateUtil.getTimeString(new Date()));
  927. //短信所需参数
  928. Map<String, String> params = new HashMap<>();
  929. params.put("project_no", projectApplication.getApply_no());
  930. params.put("apply_name", Constant.ProjectType.PROJECT_APPLICATION);
  931. Company company = companyService.findById(projectApplication.getCompany_id());
  932. User companyAdmin = userService.findCompanyAdmin(company.getId());
  933. if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) {
  934. //材料审核通过,进如处室(中心)审批
  935. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT);
  936. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  937. Integer departmentid = declaration.getDepartment_id();
  938. Group group = groupService.findByName(Constant.XMSBCLSHZ, null);
  939. if (null == group) {
  940. throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  941. }
  942. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  943. List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString());
  944. StringBuffer sb = new StringBuffer("");
  945. // Company company = companyService.findById(projectApplication.getCompany_id());
  946. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  947. String projectName = projectDeclaration.getProject_name();
  948. Message messages = new Message();
  949. messages.setApply_id(projectId);
  950. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  951. messages.setTitle("提醒处室审核");
  952. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  953. for (UserGroup userGroup : userGroups) {
  954. for (User user : users) {
  955. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  956. sb.append(userGroup.getUser_id() + ",");
  957. //User u = userService.findById(userGroup.getUser_id());
  958. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  959. messages.setContent(message);
  960. int[] streetArrInt = new int[1];
  961. streetArrInt[0] = userGroup.getUser_id();
  962. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  963. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  964. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  965. //发送短信
  966. // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT;
  967. // AlibabaSMSUtil.sendSMSMessage(
  968. // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  969. }
  970. }
  971. }
  972. a.setNextchecker(sb.toString());
  973. if (null == sb || sb.length() == 0) {
  974. throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  975. }
  976. ProjectApplication pa = new ProjectApplication();
  977. pa.setId(projectId);
  978. pa.setApprove_status(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  979. projectApplicationDao.updateByPrimaryKeySelective(pa);
  980. approvalService.insertAndGetId(a);
  981. return true;
  982. } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) {
  983. //处室通过,进去中心窗口提交
  984. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  985. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE);
  986. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  987. String projectName = projectDeclaration.getProject_name();
  988. if (project.getIs_technical()) {
  989. //技改类发送通知
  990. Message messages1 = new Message();
  991. messages1.setApply_id(projectId);
  992. messages1.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  993. messages1.setTitle("提醒企业准备材料");
  994. String message = company.getCompany_name() + ",您好。您提交的单号为" + projectApplication.getApply_no() + "的区级工业经济扶持项目申请," + "审核流程已过半,请提前准备好申报的纸质材料,等待审核通过谢谢!";
  995. messages1.setContent(message);
  996. int[] streetArrInt = new int[1];
  997. streetArrInt[0] = projectApplication.getCompany_id();
  998. messageService.saveMessageAndPush(messages1, streetArrInt, Constant.UserType.COMPANY);
  999. //发送短信(提醒企业准备材料)
  1000. String tempCode = Constant.SMS_TemplateCode.REMINSD_COMPNAY_PREPARE_MATERIALS;
  1001. AlibabaSMSUtil.sendSMS(
  1002. companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1003. }
  1004. Message messages = new Message();
  1005. messages.setApply_id(projectId);
  1006. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1007. messages.setTitle("提醒中心补充材料");
  1008. Group group = groupService.findByName(Constant.XMSBCLSLZ, null);
  1009. if (null == group) {
  1010. throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1011. }
  1012. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1013. StringBuffer sb = new StringBuffer("");
  1014. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1015. for (UserGroup userGroup : userGroups) {
  1016. sb.append(userGroup.getUser_id() + ",");
  1017. User user = userService.findById(userGroup.getUser_id());
  1018. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”提交的“" + projectName + "项目”申请需要您补充材料。谢谢。";
  1019. messages.setContent(message);
  1020. int[] streetArrInt = new int[1];
  1021. streetArrInt[0] = userGroup.getUser_id();
  1022. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1023. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1024. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1025. //发送短信
  1026. // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT;
  1027. // AlibabaSMSUtil.sendSMSMessage(
  1028. // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1029. }
  1030. a.setNextchecker(sb.toString());
  1031. if (sb.length() == 0) {
  1032. throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1033. }
  1034. ProjectApplication pa = new ProjectApplication();
  1035. pa.setId(projectId);
  1036. pa.setApprove_status(Constant.ProjectApplicationStatus.COMMIT_FILE);
  1037. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1038. approvalService.insertAndGetId(a);
  1039. return true;
  1040. } else if (Objects.equals(Constant.ProjectApplicationStatus.COMMIT_FILE, approval.getAfter_approvalstatus())) {
  1041. //中心窗口提交完成 进入财政审批
  1042. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE);
  1043. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  1044. Integer departmentid = project.getDepartment_id();
  1045. Group group = groupService.findByName(Constant.XMSBCZSHZ, null);
  1046. if (null == group) {
  1047. throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  1048. }
  1049. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1050. List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString());
  1051. StringBuffer sb = new StringBuffer("");
  1052. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1053. String projectName = projectDeclaration.getProject_name();
  1054. Message messages = new Message();
  1055. messages.setApply_id(projectId);
  1056. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1057. messages.setTitle("提醒财政审核");
  1058. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1059. for (UserGroup userGroup : userGroups) {
  1060. for (User user : users) {
  1061. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1062. sb.append(userGroup.getUser_id() + ",");
  1063. //User user = userService.findById(userGroup.getUser_id());
  1064. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  1065. messages.setContent(message);
  1066. int[] streetArrInt = new int[1];
  1067. streetArrInt[0] = userGroup.getUser_id();
  1068. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1069. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1070. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1071. //发送短信
  1072. // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT;
  1073. // AlibabaSMSUtil.sendSMSMessage(
  1074. // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1075. }
  1076. }
  1077. }
  1078. a.setNextchecker(sb.toString());
  1079. if (sb.length() == 0) {
  1080. throw new BaseException("操作失败,项目申报材料受理组没有该项目责任单位的审核人员,请联系管理员配置");
  1081. }
  1082. ProjectApplication pa = new ProjectApplication();
  1083. pa.setId(projectId);
  1084. pa.setApprove_status(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  1085. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1086. approvalService.insertAndGetId(a);
  1087. return true;
  1088. } else if (Objects.equals(Constant.ProjectApplicationStatus.FINANCE_AUDIT, approval.getAfter_approvalstatus())) {
  1089. //财政审核通过
  1090. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  1091. ProjectApplication pa = new ProjectApplication();
  1092. pa.setId(projectId);
  1093. if (project.getIs_technical()) {
  1094. //技改类等待上传
  1095. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT);
  1096. pa.setApprove_status(Constant.ProjectApplicationStatus.UPLOAD_REPORT);
  1097. Integer departmentid = project.getDepartment_id();
  1098. Group group = groupService.findByName(Constant.XMSBCLSHZ, null);
  1099. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1100. List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString());
  1101. StringBuffer sb = new StringBuffer("");
  1102. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1103. String projectName = projectDeclaration.getProject_name();
  1104. Message messages = new Message();
  1105. messages.setApply_id(projectId);
  1106. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1107. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1108. for (UserGroup userGroup : userGroups) {
  1109. for (User user : users) {
  1110. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1111. sb.append(userGroup.getUser_id()).append(",");
  1112. User userss = userService.findById(userGroup.getUser_id());
  1113. messages.setTitle("提醒处室补充材料");
  1114. String message = userss.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”提交的“" + projectName + "项目”申请需要您补充材料。谢谢。";
  1115. messages.setContent(message);
  1116. int[] streetArrInt = new int[1];
  1117. streetArrInt[0] = userGroup.getUser_id();
  1118. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1119. waitToDoService.newTODO("项目申报上传材料", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1120. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1121. //发送短信(提醒处室补充材料)
  1122. // Map<String, String> paramMap = new HashMap<>();
  1123. // paramMap.put("company_name", company.getCompany_name());
  1124. // paramMap.put("project_name", projectName);
  1125. // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_REPORT;
  1126. // AlibabaSMSUtil.sendSMS(
  1127. // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(paramMap));
  1128. }
  1129. }
  1130. }
  1131. Group groups = groupService.findByName(Constant.XMSBCZSHZ, null);
  1132. if (null == group) {
  1133. throw new BaseException("操作失败,项目申报财政审核组或项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1134. }
  1135. List<UserGroup> userGroupss = userGroupService.findByGroupId(groups.getId());
  1136. for (UserGroup userGroup : userGroupss) {
  1137. sb.append(userGroup.getUser_id() + ",");
  1138. User user = userService.findById(userGroup.getUser_id());
  1139. messages.setTitle("提醒财政补充材料");
  1140. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”提交的“" + projectName + "项目”申请需要您补充材料。谢谢。";
  1141. messages.setContent(message);
  1142. int[] streetArrInt = new int[1];
  1143. streetArrInt[0] = userGroup.getUser_id();
  1144. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1145. waitToDoService.newTODO("项目申报上传材料", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1146. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1147. //发送短信(提醒财政补充材料)
  1148. // Map<String, String> paramMap = new HashMap<>();
  1149. // paramMap.put("company_name", company.getCompany_name());
  1150. // paramMap.put("project_name", projectName);
  1151. // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_REPORT;
  1152. // AlibabaSMSUtil.sendSMS(
  1153. // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1154. }
  1155. a.setNextchecker(sb.toString());
  1156. } else {
  1157. // Company company = companyService.findById(projectApplication.getCompany_id());
  1158. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1159. String projectName = projectDeclaration.getProject_name();
  1160. Message messages = new Message();
  1161. messages.setApply_id(projectId);
  1162. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1163. messages.setTitle("提醒中心负责人");
  1164. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.NOTIFY);
  1165. pa.setApprove_status(Constant.ProjectApplicationStatus.NOTIFY);
  1166. Group group = groupService.findByName(Constant.XMSBFZR, null);
  1167. if (null == group) {
  1168. throw new BaseException("操作失败,项目申报财政审核组或项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1169. }
  1170. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1171. StringBuffer sb = new StringBuffer("");
  1172. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1173. for (UserGroup userGroup : userGroups) {
  1174. sb.append(userGroup.getUser_id() + ",");
  1175. User user = userService.findById(userGroup.getUser_id());
  1176. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  1177. messages.setContent(message);
  1178. int[] streetArrInt = new int[1];
  1179. streetArrInt[0] = userGroup.getUser_id();
  1180. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1181. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1182. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1183. //发送短信
  1184. // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT;
  1185. // AlibabaSMSUtil.sendSMSMessage(
  1186. // user.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1187. }
  1188. a.setNextchecker(sb.toString());
  1189. if (null == sb || sb.length() == 0) {
  1190. throw new BaseException("操作失败,项目申报财政审核组或项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1191. }
  1192. }
  1193. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1194. approvalService.insertAndGetId(a);
  1195. //发送短信
  1196. // String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_FINANCIAL_PREARE_MATERIALS;
  1197. // AlibabaSMSUtil.sendSMS(
  1198. // companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1199. return true;
  1200. }
  1201. return false;
  1202. }
  1203. /**
  1204. * 2019审核流程
  1205. *
  1206. * @param projectId
  1207. * @param comment
  1208. */
  1209. private boolean refactorPass(Integer projectId, String comment) {
  1210. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION);
  1211. Approval a = new Approval();
  1212. a.setApply_id(projectId);
  1213. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1214. if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) {
  1215. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1216. a.setDepartment(departmentname);
  1217. }
  1218. a.setApproval_comment(comment);
  1219. a.setChecker(ShiroUtils.getUserId());
  1220. a.setOper_type(Constant.OperType.APPROVED);
  1221. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1222. ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString());
  1223. Project project = projectService.findById(projectApplication.getProject_id());
  1224. Integer responsibleUnit = project.getDepartment_id();
  1225. ProjectDeclaration declaration = findById(projectApplication.getDeclaration_id());
  1226. String projectName = declaration.getProject_name();
  1227. //短信所需参数
  1228. Map<String, String> params = new HashMap<>();
  1229. params.put("project_no", projectApplication.getApply_no());
  1230. Company company = companyService.findById(projectApplication.getCompany_id());
  1231. User companyAdmin = userService.findCompanyAdmin(company.getId());
  1232. if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) {
  1233. //材料审核通过,进如处室(中心)审批
  1234. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT);
  1235. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1236. Group group = groupService.findByName(Constant.XMSBCLSHZ, null);
  1237. if (null == group) {
  1238. throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1239. }
  1240. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1241. List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(responsibleUnit.toString());
  1242. StringBuffer sb = new StringBuffer("");
  1243. Message messages = new Message();
  1244. messages.setApply_id(projectId);
  1245. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1246. messages.setTitle("提醒处室审核");
  1247. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1248. for (UserGroup userGroup : userGroups) {
  1249. for (User user : users) {
  1250. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1251. sb.append(userGroup.getUser_id() + ",");
  1252. //User u = userService.findById(userGroup.getUser_id());
  1253. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  1254. messages.setContent(message);
  1255. int[] streetArrInt = new int[1];
  1256. streetArrInt[0] = userGroup.getUser_id();
  1257. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1258. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1259. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1260. }
  1261. }
  1262. }
  1263. a.setNextchecker(sb.toString());
  1264. if (null == sb || sb.length() == 0) {
  1265. throw new BaseException("操作失败,项目申报材料审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1266. }
  1267. ProjectApplication pa = new ProjectApplication();
  1268. pa.setId(projectId);
  1269. pa.setApprove_status(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1270. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1271. approvalService.insertAndGetId(a);
  1272. return true;
  1273. } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) {
  1274. //处室通过,审核结束
  1275. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1276. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.APPROVED);
  1277. ProjectApplication pa = new ProjectApplication();
  1278. pa.setId(projectId);
  1279. pa.setApprove_status(Constant.ProjectApplicationStatus.APPROVED);
  1280. pa.setApply_status(Constant.ProjectApplyStatus.APPROVED);
  1281. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1282. approvalService.insertAndGetId(a);
  1283. ExecutorService threadPool = new ThreadPoolExecutor(
  1284. 1,
  1285. 2,
  1286. 1L,
  1287. TimeUnit.SECONDS,
  1288. new LinkedBlockingDeque<>(),
  1289. Executors.defaultThreadFactory(),
  1290. new ThreadPoolExecutor.AbortPolicy());
  1291. try {
  1292. threadPool.execute(() -> {
  1293. Message messages = new Message();
  1294. messages.setApply_id(projectId);
  1295. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1296. messages.setTitle("项目申报审核通过");
  1297. String message = "您单号为 " + projectApplication.getApply_no() + " 的区级工业经济扶持项目申请,已审核通过," +
  1298. "请将纸质材料(需与审核通过的电子档一致)交与属地经济主管部门。";
  1299. messages.setContent(message);
  1300. int[] streetArrInt = new int[1];
  1301. streetArrInt[0] = companyAdmin.getId();
  1302. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1303. String tempCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_PREARE_MATERIALS;
  1304. try {
  1305. AlibabaSMSUtil.sendSMS(
  1306. companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1307. } catch (ClientException | InterruptedException e) {
  1308. e.printStackTrace();
  1309. }
  1310. });
  1311. } catch (Exception e) {
  1312. e.printStackTrace();
  1313. } finally {
  1314. threadPool.shutdown();
  1315. }
  1316. return true;
  1317. }
  1318. return false;
  1319. }
  1320. //退回
  1321. public boolean untread(Integer projectId, String comment) {
  1322. Boolean flag = false;
  1323. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION);
  1324. Approval a = new Approval();
  1325. a.setApply_id(projectId);
  1326. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1327. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1328. a.setDepartment(departmentname);
  1329. a.setApproval_comment(comment);
  1330. a.setChecker(ShiroUtils.getUserId());
  1331. a.setOper_type(Constant.OperType.REJECT);
  1332. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1333. ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString());
  1334. Project project = new Project();
  1335. project.setId(projectApplication.getProject_id());
  1336. project = projectDao.selectOne(project);
  1337. if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) {
  1338. //材料审核退回,退回至企业
  1339. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT);
  1340. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY);
  1341. a.setNextchecker(projectApplication.getCreate_by().toString());
  1342. ProjectApplication p = new ProjectApplication();
  1343. p.setId(projectId);
  1344. p.setApply_status(Constant.ProjectApplyStatus.REJECT);
  1345. p.setApprove_status(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY);
  1346. projectApplicationDao.updateByPrimaryKeySelective(p);
  1347. approvalService.insertAndGetId(a);
  1348. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1349. String projectName = projectDeclaration.getProject_name();
  1350. Company company = companyService.findById(projectApplication.getCompany_id());
  1351. Message messages = new Message();
  1352. messages.setApply_id(projectApplication.getId());
  1353. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1354. messages.setTitle("提醒企业");
  1355. String message = company.getCompany_name() + ",您好。您提交的" + projectName + "项目申报,请修改后重新提交,谢谢。退回原因:" + comment;
  1356. messages.setContent(message);
  1357. int[] streetArrInt = new int[1];
  1358. streetArrInt[0] = projectApplication.getCompany_id();
  1359. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  1360. List<User> users = userService.findUsersByCompanyId(projectApplication.getCompany_id());
  1361. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1362. for (User user : users) {
  1363. waitToDoService.newTODO("项目申报编辑", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  1364. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1365. }
  1366. flag = true;
  1367. } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) {
  1368. //处室(中心)审核退回,退回至企业
  1369. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1370. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY);
  1371. a.setNextchecker(projectApplication.getCreate_by().toString());
  1372. ProjectApplication p = new ProjectApplication();
  1373. p.setId(projectId);
  1374. p.setApply_status(Constant.ProjectApplyStatus.REJECT);
  1375. p.setApprove_status(Constant.ProjectApplicationStatus.REJECT_TO_COMPANY);
  1376. projectApplicationDao.updateByPrimaryKeySelective(p);
  1377. approvalService.insertAndGetId(a);
  1378. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1379. String projectName = projectDeclaration.getProject_name();
  1380. Company company = companyService.findById(projectApplication.getCompany_id());
  1381. Message messages = new Message();
  1382. messages.setApply_id(projectApplication.getId());
  1383. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1384. messages.setTitle("提醒企业");
  1385. String message = company.getCompany_name() + ",您好。您提交的" + projectName + "项目申报,请修改后重新提交,谢谢。退回原因:" + comment;
  1386. messages.setContent(message);
  1387. int[] streetArrInt = new int[1];
  1388. streetArrInt[0] = projectApplication.getCompany_id();
  1389. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  1390. List<User> users = userService.findUsersByCompanyId(projectApplication.getCompany_id());
  1391. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1392. for (User user : users) {
  1393. waitToDoService.newTODO("项目申报编辑", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  1394. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1395. }
  1396. flag = true;
  1397. } /*else if (Objects.equals(Constant.ProjectApplicationStatus.COMMIT_FILE, approval.getAfter_approvalstatus())) {
  1398. //中心窗口提交专家审核意见,退回中心(处室)
  1399. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE);
  1400. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1401. Integer departmentid = project.getDepartment_id();
  1402. Group group = groupService.findByName(Constant.XMSBCLSHZ, null);
  1403. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1404. List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString());
  1405. StringBuffer sb = new StringBuffer("");
  1406. for (UserGroup userGroup : userGroups) {
  1407. for (User user : users) {
  1408. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1409. sb.append(userGroup.getUser_id() + ",");
  1410. }
  1411. }
  1412. }
  1413. a.setNextchecker(sb.toString());
  1414. ProjectApplication p = new ProjectApplication();
  1415. p.setId(projectId);
  1416. //p.setApply_status(Constant.ProjectApplyStatus.REJECT);
  1417. p.setApprove_status(Constant.ProjectApplicationStatus.REJECT_TO_DEPARTMENT);
  1418. projectApplicationDao.updateByPrimaryKeySelective(p);
  1419. approvalService.insertAndGetId(a);
  1420. }*/ else if (Objects.equals(Constant.ProjectApplicationStatus.FINANCE_AUDIT, approval.getAfter_approvalstatus())) {
  1421. //财政审核退回,退回至处室
  1422. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  1423. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1424. Integer departmentid = project.getDepartment_id();
  1425. Group group = groupService.findByName(Constant.XMSBCLSHZ, null);
  1426. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1427. List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString());
  1428. StringBuffer sb = new StringBuffer("");
  1429. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1430. String projectName = projectDeclaration.getProject_name();
  1431. Company company = companyService.findById(projectApplication.getCompany_id());
  1432. Message messages = new Message();
  1433. messages.setApply_id(projectApplication.getId());
  1434. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1435. messages.setTitle("提醒企业");
  1436. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1437. for (UserGroup userGroup : userGroups) {
  1438. for (User user : users) {
  1439. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1440. sb.append(userGroup.getUser_id() + ",");
  1441. String message = company.getCompany_name() + ",您好。您提交的" + projectName + ",项目返回修改请复审。谢谢。退回原因:" + comment;
  1442. messages.setContent(message);
  1443. int[] streetArrInt = new int[1];
  1444. streetArrInt[0] = projectApplication.getCompany_id();
  1445. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1446. waitToDoService.newTODO("项目申报编辑", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  1447. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1448. }
  1449. }
  1450. }
  1451. a.setNextchecker(sb.toString());
  1452. ProjectApplication p = new ProjectApplication();
  1453. p.setId(projectId);
  1454. p.setApply_status(Constant.ProjectApplyStatus.REJECT);
  1455. p.setApprove_status(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1456. projectApplicationDao.updateByPrimaryKeySelective(p);
  1457. approvalService.insertAndGetId(a);
  1458. flag = true;
  1459. }
  1460. //发送短信给企业
  1461. Map<String, String> params = new HashMap<>();
  1462. params.put("project_no", projectApplication.getApply_no());
  1463. params.put("apply_name", Constant.ProjectType.PROJECT_APPLICATION);
  1464. String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_REJECT;
  1465. try {
  1466. User user = userService.findCompanyAdmin(projectApplication.getCompany_id());
  1467. AlibabaSMSUtil.sendSMS(
  1468. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1469. } catch (ClientException | InterruptedException e) {
  1470. e.printStackTrace();
  1471. }
  1472. return flag;
  1473. }
  1474. //不通过
  1475. public boolean reject(Integer projectId, String comment) {
  1476. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION);
  1477. Approval a = new Approval();
  1478. a.setApply_id(projectId);
  1479. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1480. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1481. a.setDepartment(departmentname);
  1482. a.setApproval_comment(comment);
  1483. a.setChecker(ShiroUtils.getUserId());
  1484. a.setOper_type(Constant.OperType.NOTAPPROVED);
  1485. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1486. ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString());
  1487. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.NOTAPPROVED);
  1488. a.setNextchecker(projectApplication.getCreate_by().toString());
  1489. ProjectApplication p = new ProjectApplication();
  1490. p.setId(projectId);
  1491. p.setApply_status(Constant.ProjectApplyStatus.NOTAPPROVED);
  1492. p.setApprove_status(Constant.ProjectApplicationStatus.NOTAPPROVED);
  1493. projectApplicationDao.updateByPrimaryKeySelective(p);
  1494. if (Objects.equals(Constant.ProjectApplicationStatus.CENTRE_AUDIT, approval.getAfter_approvalstatus())) {
  1495. //材料审核退回,退回至企业
  1496. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.CENTRE_AUDIT);
  1497. } else if (Objects.equals(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT, approval.getAfter_approvalstatus())) {
  1498. //处室(中心)审核退回,退回至企业
  1499. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.DEPARTMENT_AUDIT);
  1500. } else if (Objects.equals(Constant.ProjectApplicationStatus.FINANCE_AUDIT, approval.getAfter_approvalstatus())) {
  1501. //财政审核退回,退回至处室中心
  1502. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  1503. }
  1504. approvalService.insertAndGetId(a);
  1505. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1506. String projectName = projectDeclaration.getProject_name();
  1507. Company company = companyService.findById(projectApplication.getCompany_id());
  1508. Message messages = new Message();
  1509. messages.setApply_id(projectApplication.getId());
  1510. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1511. messages.setTitle("提醒企业");
  1512. String message = company.getCompany_name() + ",您好。您提交的" + projectName + "审核不通过,请知悉。";
  1513. messages.setContent(message);
  1514. int[] streetArrInt = new int[1];
  1515. streetArrInt[0] = projectApplication.getCompany_id();
  1516. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  1517. //发送短信给企业
  1518. Map<String, String> params = new HashMap<>();
  1519. params.put("project_no", projectApplication.getApply_no());
  1520. params.put("apply_name", Constant.ProjectType.PROJECT_APPLICATION);
  1521. String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_UNPASS;
  1522. try {
  1523. User user = userService.findCompanyAdmin(projectApplication.getCompany_id());
  1524. AlibabaSMSUtil.sendSMS(
  1525. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1526. } catch (ClientException | InterruptedException e) {
  1527. e.printStackTrace();
  1528. }
  1529. return true;
  1530. }
  1531. //通知
  1532. public boolean notify(Integer projectId, String payment) throws ClientException, InterruptedException {
  1533. Approval approval = approvalDao.getLatestApproval(projectId, Constant.DictionaryType.PROJECT_APPLICATION);
  1534. Approval a = new Approval();
  1535. a.setApply_id(projectId);
  1536. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1537. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1538. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1539. a.setDepartment(departmentname);
  1540. a.setChecker(ShiroUtils.getUserId());
  1541. a.setOper_type(Constant.OperType.APPROVED);
  1542. ProjectApplication projectApplication = projectApplicationDao.selectById(projectId.toString());
  1543. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.APPROVED);
  1544. //a.setNextchecker(projectApplication.getCreate_by().toString());
  1545. ProjectApplication p = new ProjectApplication();
  1546. p.setId(projectId);
  1547. p.setProject_payment(payment);
  1548. p.setApply_status(Constant.ProjectApplyStatus.APPROVED);
  1549. p.setApprove_status(Constant.ProjectApplicationStatus.APPROVED);
  1550. projectApplicationDao.updateByPrimaryKeySelective(p);
  1551. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.NOTIFY);
  1552. approvalService.insertAndGetId(a);
  1553. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1554. String projectName = projectDeclaration.getProject_name();
  1555. Message messages = new Message();
  1556. messages.setApply_id(projectId);
  1557. messages.setTitle("企业项目审批完成通知");
  1558. Company company = companyService.findById(projectApplication.getCompany_id());
  1559. messages.setContent(company.getCompany_name() + ",您好。您的" + projectName + "项目申请成功,发放" + payment + "万元人民币,请开收据,提交纸质材料。谢谢。");
  1560. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1561. int[] streetArrInt = new int[1];
  1562. streetArrInt[0] = projectApplication.getCompany_id();
  1563. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  1564. //发送短信
  1565. Map<String, String> params = new HashMap<>();
  1566. User companyAdmin = userService.findCompanyAdmin(company.getId());
  1567. String tempCode = Constant.SMS_TemplateCode.REMINSD_COMPNAY_PRINT_MATERIALS;
  1568. params.put("project_no", projectApplication.getApply_no());
  1569. params.put("apply_name", Constant.ProjectType.PROJECT_APPLICATION);
  1570. AlibabaSMSUtil.sendSMS(
  1571. companyAdmin.getPhone(), tempCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1572. return true;
  1573. }
  1574. //发送短信,通知审核
  1575. public Boolean sendProjectMessage(ProjectApplication projectApplication) throws ClientException {
  1576. String phone = "";
  1577. Map<String, String> params = new HashMap<>();
  1578. if (projectApplication != null) {
  1579. CompanyContact contact = companyContactService.findFirstByCompanyId(projectApplication.getCompany_id());
  1580. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.
  1581. findByApplyIdAndType(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1582. if (null != companyInfo && null != companyInfo.getContact_phone()) {
  1583. phone = companyInfo.getContact_phone();
  1584. } else if (null != contact) {
  1585. phone = contact.getPhone();
  1586. }
  1587. params.put("project_id", projectApplication.getApply_no());
  1588. String templatCode = Constant.SMS_TemplateCode.RPOJECT_APPLICATION_AUDIT;
  1589. if (StringUtils.isNotBlank(phone)) {
  1590. AlibabaSMSUtil.sendSMSMessage(phone, templatCode, Constant.SINGNAMW, JSONObject.toJSONString(params));
  1591. return true;
  1592. }
  1593. }
  1594. return false;
  1595. }
  1596. //发送短信
  1597. public Boolean sendProjectSMS(ProjectApplication projectApplication) throws ClientException, InterruptedException {
  1598. if (null != projectApplication) {
  1599. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1600. String status = projectApplication.getApply_status();
  1601. String statusName = "";
  1602. if (status.equals(Constant.ProjectApplyStatus.NOTAPPROVED)) {
  1603. statusName = Constant.OperType.NOTAPPROVED;
  1604. } else if (status.equals(Constant.ProjectApplyStatus.APPROVED)) {
  1605. statusName = Constant.OperType.APPROVED;
  1606. } else if (status.equals(Constant.ProjectApplyStatus.REJECT)) {
  1607. statusName = Constant.OperType.REJECT;
  1608. }
  1609. if (StringUtils.isNotBlank(statusName)) {
  1610. return sendProjectSMSToCompany(departmentname, projectApplication, statusName);
  1611. }
  1612. }
  1613. return false;
  1614. }
  1615. public Boolean sendProjectSMSToCompany(String departmentname, ProjectApplication projectApplication,
  1616. String status) throws ClientException, InterruptedException {
  1617. String phone = "";
  1618. CompanyContact contact = companyContactService.findFirstByCompanyId(projectApplication.getCompany_id());
  1619. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1620. if (null != companyInfo && null != companyInfo.getContact_phone()) {
  1621. phone = companyInfo.getContact_phone();
  1622. } else if (null != contact) {
  1623. phone = contact.getPhone();
  1624. }
  1625. if (StringUtils.isNotBlank(phone)) {
  1626. //${department_name}提醒您,您申请的${project_name}单据已审核 ${approve_status}。具体信息请登录PC端查看。感谢您的支持。
  1627. String project_name = projectApplication.getProject_name();
  1628. String templateParam = "{\"department_name\":\"" + departmentname + "\",\"project_name\":\"" + project_name + "\",\"approve_status\":\"" + status + "\"}";
  1629. AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.PROJECT_APPLICATION_NOTIFY, Constant.SINGNAMW, templateParam);
  1630. return true;
  1631. } else {
  1632. return false;
  1633. }
  1634. }
  1635. //部门上传数据
  1636. public void departmentUpload(ParamFile paramFile) {
  1637. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_CS, paramFile.getPid());
  1638. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_CS, paramFile.getPid(), paramFile.getFileDown().getFile_id());
  1639. ProjectMaterial projectMaterial = new ProjectMaterial();
  1640. projectMaterial.setApply_id(paramFile.getPid());
  1641. projectMaterial.setTemplate_id(paramFile.getFileDown().getFile_id());
  1642. projectMaterial.setMaterial_type(1);
  1643. Example example = new Example(ProjectMaterial.class);
  1644. Example.Criteria criteria = example.createCriteria();
  1645. criteria.andEqualTo("apply_id", paramFile.getPid());
  1646. criteria.andEqualTo("material_type", "1");
  1647. List<ProjectMaterial> list = projectMaterialDao.selectByExample(example);
  1648. if (CollectionUtils.isEmpty(list)) {
  1649. projectMaterialDaoService.saveMaterial(projectMaterial);
  1650. } else {
  1651. projectMaterial.setId(list.get(0).getId());
  1652. projectMaterialDaoService.updateMaterial(projectMaterial);
  1653. }
  1654. //判断两种文件是否全
  1655. validateUploadedFile(paramFile.getPid());
  1656. }
  1657. //财政上传数据
  1658. public void financeUpload(ParamFile paramFile) {
  1659. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_CZ, paramFile.getPid());
  1660. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_CZ, paramFile.getPid(), paramFile.getFileDown().getFile_id());
  1661. ProjectMaterial projectMaterial = new ProjectMaterial();
  1662. projectMaterial.setApply_id(paramFile.getPid());
  1663. projectMaterial.setTemplate_id(paramFile.getFileDown().getFile_id());
  1664. projectMaterial.setMaterial_type(2);
  1665. Example example = new Example(ProjectMaterial.class);
  1666. Example.Criteria criteria = example.createCriteria();
  1667. criteria.andEqualTo("apply_id", paramFile.getPid());
  1668. criteria.andEqualTo("material_type", "2");
  1669. List<ProjectMaterial> list = projectMaterialDao.selectByExample(example);
  1670. if (CollectionUtils.isEmpty(list)) {
  1671. projectMaterialDaoService.saveMaterial(projectMaterial);
  1672. } else {
  1673. projectMaterial.setId(list.get(0).getId());
  1674. projectMaterialDaoService.updateMaterial(projectMaterial);
  1675. }
  1676. //判断两种文件是否全
  1677. validateUploadedFile(paramFile.getPid());
  1678. }
  1679. //中心上传数据
  1680. public void centreUpload(ParamFile paramFile) {
  1681. attachmentDao.deleteByBusiness(Constant.Attachment.PROJECT_ZX, paramFile.getPid());
  1682. attachmentDao.updateAttachment(Constant.Attachment.PROJECT_ZX, paramFile.getPid(), paramFile.getFileDown().getFile_id());
  1683. ProjectMaterial projectMaterial = new ProjectMaterial();
  1684. projectMaterial.setApply_id(paramFile.getPid());
  1685. projectMaterial.setTemplate_id(paramFile.getFileDown().getFile_id());
  1686. projectMaterial.setMaterial_type(3);
  1687. Example example = new Example(ProjectMaterial.class);
  1688. Example.Criteria criteria = example.createCriteria();
  1689. criteria.andEqualTo("apply_id", paramFile.getPid());
  1690. criteria.andEqualTo("material_type", "3");
  1691. List<ProjectMaterial> list = projectMaterialDao.selectByExample(example);
  1692. if (CollectionUtils.isEmpty(list)) {
  1693. projectMaterialDaoService.saveMaterial(projectMaterial);
  1694. } else {
  1695. projectMaterial.setId(list.get(0).getId());
  1696. projectMaterialDaoService.updateMaterial(projectMaterial);
  1697. }
  1698. Approval a = new Approval();
  1699. a.setApply_id(paramFile.getPid());
  1700. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1701. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1702. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1703. a.setDepartment(departmentname);
  1704. a.setChecker(ShiroUtils.getUserId());
  1705. a.setOper_type(Constant.OperType.APPROVED);
  1706. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.COMMIT_FILE);
  1707. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  1708. Group group = groupService.findByName(Constant.XMSBCZSHZ, null);
  1709. if (null == group) {
  1710. throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1711. }
  1712. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1713. StringBuffer sb = new StringBuffer("");
  1714. ProjectApplication projectApplication = projectApplicationDao.selectById(paramFile.getPid().toString());
  1715. Company company = companyService.findById(projectApplication.getCompany_id());
  1716. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1717. String projectName = projectDeclaration.getProject_name();
  1718. Message messages = new Message();
  1719. messages.setApply_id(paramFile.getPid());
  1720. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1721. messages.setTitle("提醒财政审核");
  1722. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1723. for (UserGroup userGroup : userGroups) {
  1724. sb.append(userGroup.getUser_id() + ",");
  1725. User user = userService.findById(userGroup.getUser_id());
  1726. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  1727. messages.setContent(message);
  1728. int[] streetArrInt = new int[1];
  1729. streetArrInt[0] = userGroup.getUser_id();
  1730. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1731. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1732. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1733. }
  1734. a.setNextchecker(sb.toString());
  1735. if (null == sb || sb.length() == 0) {
  1736. throw new BaseException("操作失败,项目申报财政审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1737. }
  1738. approvalService.insertAndGetId(a);
  1739. ProjectApplication pa = new ProjectApplication();
  1740. pa.setId(paramFile.getPid());
  1741. pa.setApprove_status(Constant.ProjectApplicationStatus.FINANCE_AUDIT);
  1742. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1743. }
  1744. private void validateUploadedFile(Integer id) {
  1745. Example example1 = new Example(ProjectMaterial.class);
  1746. Example example2 = new Example(ProjectMaterial.class);
  1747. Example.Criteria criteria1 = example1.createCriteria();
  1748. Example.Criteria criteria2 = example2.createCriteria();
  1749. criteria1.andEqualTo("apply_id", id);
  1750. criteria1.andEqualTo("material_type", "1");
  1751. criteria2.andEqualTo("apply_id", id);
  1752. criteria2.andEqualTo("material_type", "2");
  1753. List<ProjectMaterial> list1 = projectMaterialDao.selectByExample(example1);
  1754. List<ProjectMaterial> list2 = projectMaterialDao.selectByExample(example2);
  1755. if (!CollectionUtils.isEmpty(list1) && !CollectionUtils.isEmpty(list2)) {
  1756. Approval a = new Approval();
  1757. a.setApply_id(id);
  1758. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1759. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1760. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1761. a.setDepartment(departmentname);
  1762. a.setChecker(ShiroUtils.getUserId());
  1763. a.setOper_type(Constant.OperType.APPROVED);
  1764. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT);
  1765. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.NOTIFY);
  1766. Group group = groupService.findByName(Constant.XMSBFZR, null);
  1767. if (null == group) {
  1768. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1769. }
  1770. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1771. StringBuffer sb = new StringBuffer("");
  1772. ProjectApplication projectApplication = projectApplicationDao.selectById(id.toString());
  1773. Company company = companyService.findById(projectApplication.getCompany_id());
  1774. ProjectDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  1775. String projectName = projectDeclaration.getProject_name();
  1776. Message messages = new Message();
  1777. messages.setApply_id(id);
  1778. messages.setBusiness_type(Constant.Message_Business_type.PROJECT_APPLY);
  1779. messages.setTitle("提醒中心负责人");
  1780. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1781. for (UserGroup userGroup : userGroups) {
  1782. sb.append(userGroup.getUser_id() + ",");
  1783. User user = userService.findById(userGroup.getUser_id());
  1784. String message = user.getUser_name() + ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  1785. messages.setContent(message);
  1786. int[] streetArrInt = new int[1];
  1787. streetArrInt[0] = userGroup.getUser_id();
  1788. messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1789. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1790. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1791. }
  1792. a.setNextchecker(sb.toString());
  1793. if (null == sb || sb.length() == 0) {
  1794. throw new BaseException("操作失败,项目申报审核组没有该项目责任单位的审核人员,请联系管理员配置");
  1795. }
  1796. approvalService.insertAndGetId(a);
  1797. ProjectApplication pa = new ProjectApplication();
  1798. pa.setId(id);
  1799. pa.setApprove_status(Constant.ProjectApplicationStatus.NOTIFY);
  1800. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1801. } else if (CollectionUtils.isEmpty(list1) && !CollectionUtils.isEmpty(list2)) {
  1802. Approval a = new Approval();
  1803. a.setApply_id(id);
  1804. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1805. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1806. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1807. a.setDepartment(departmentname);
  1808. a.setChecker(ShiroUtils.getUserId());
  1809. a.setOper_type(Constant.OperType.APPROVED);
  1810. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT);
  1811. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_CZ);
  1812. ProjectApplication projectApplication = projectApplicationDao.selectById(id.toString());
  1813. Project project = new Project();
  1814. project.setId(projectApplication.getProject_id());
  1815. project = projectDao.selectOne(project);
  1816. Integer departmentid = project.getDepartment_id();
  1817. Group group = groupService.findByName(Constant.XMSBCLSHZ, null);
  1818. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1819. List<User> users = userService.findUserBydepartmentIdWithoutApprovalLevel(departmentid.toString());
  1820. StringBuffer sb = new StringBuffer("");
  1821. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1822. for (UserGroup userGroup : userGroups) {
  1823. for (User user : users) {
  1824. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1825. sb.append(userGroup.getUser_id() + ",");
  1826. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1827. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1828. }
  1829. }
  1830. }
  1831. a.setNextchecker(sb.toString());
  1832. approvalService.insertAndGetId(a);
  1833. ProjectApplication pa = new ProjectApplication();
  1834. pa.setId(id);
  1835. pa.setApprove_status(Constant.ProjectApplicationStatus.UPLOAD_CZ);
  1836. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1837. } else if (!CollectionUtils.isEmpty(list1) && CollectionUtils.isEmpty(list2)) {
  1838. Approval a = new Approval();
  1839. a.setApply_id(id);
  1840. a.setDeal_time(DateUtil.getTimeString(new Date()));
  1841. a.setType(Constant.DictionaryType.PROJECT_APPLICATION);
  1842. ProjectApplication projectApplication = projectApplicationDao.selectById(id.toString());
  1843. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1844. a.setDepartment(departmentname);
  1845. a.setChecker(ShiroUtils.getUserId());
  1846. a.setOper_type(Constant.OperType.APPROVED);
  1847. a.setBefore_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_REPORT);
  1848. a.setAfter_approvalstatus(Constant.ProjectApplicationStatus.UPLOAD_CS);
  1849. StringBuffer sb = new StringBuffer("");
  1850. Group groups = groupService.findByName(Constant.XMSBCZSHZ, null);
  1851. List<UserGroup> userGroupss = userGroupService.findByGroupId(groups.getId());
  1852. waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_APPLICATION);
  1853. for (UserGroup userGroup : userGroupss) {
  1854. sb.append(userGroup.getUser_id() + ",");
  1855. waitToDoService.newTODO("项目申报审核", "/projectDeclaration/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1856. Constant.DictionaryType.PROJECT_APPLICATION, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1857. }
  1858. a.setNextchecker(sb.toString());
  1859. approvalService.insertAndGetId(a);
  1860. ProjectApplication pa = new ProjectApplication();
  1861. pa.setId(id);
  1862. pa.setApprove_status(Constant.ProjectApplicationStatus.UPLOAD_CS);
  1863. projectApplicationDao.updateByPrimaryKeySelective(pa);
  1864. }
  1865. }
  1866. public ModelMap getMaterial(Integer id, ModelMap modelMap) {
  1867. Example example = new Example(ProjectMaterial.class);
  1868. Example.Criteria criteria = example.createCriteria();
  1869. criteria.andEqualTo("apply_id", id);
  1870. criteria.andEqualTo("del_flag", 0);
  1871. List<ProjectMaterial> list = projectMaterialDao.selectByExample(example);
  1872. //modelMap.addAttribute("approveMaterials", list);
  1873. List<Attachment> attachments = attachmentDao.selectByIdAndBusinessId(Constant.Attachment.PROJECT_CS, id, null);
  1874. List<Attachment> attachments2 = attachmentDao.selectByIdAndBusinessId(Constant.Attachment.PROJECT_CZ, id, null);
  1875. List<Attachment> attachments3 = attachmentDao.selectByIdAndBusinessId(Constant.Attachment.PROJECT_ZX, id, null);
  1876. attachments.addAll(attachments2);
  1877. attachments.addAll(attachments3);
  1878. FileDown fd = new FileDown();
  1879. fd.setFile_name("");
  1880. fd.setDownload_uri("");
  1881. fd.setFile_url("");
  1882. fd.setFile_id(null);
  1883. modelMap.addAttribute("czMaterials", fd);
  1884. modelMap.addAttribute("csMaterials", fd);
  1885. modelMap.addAttribute("zxMaterials", fd);
  1886. for (ProjectMaterial projectMaterial : list) {
  1887. if (Objects.equals(1, projectMaterial.getMaterial_type())) {
  1888. for (Attachment attachment : attachments) {
  1889. if (Objects.equals(attachment.getId(), projectMaterial.getTemplate_id())) {
  1890. FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri());
  1891. modelMap.addAttribute("csMaterials", fileDown);
  1892. }
  1893. }
  1894. }
  1895. if (Objects.equals(2, projectMaterial.getMaterial_type())) {
  1896. for (Attachment attachment : attachments) {
  1897. if (Objects.equals(attachment.getId(), projectMaterial.getTemplate_id())) {
  1898. FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri());
  1899. modelMap.addAttribute("czMaterials", fileDown);
  1900. }
  1901. }
  1902. }
  1903. if (Objects.equals(3, projectMaterial.getMaterial_type())) {
  1904. for (Attachment attachment : attachments) {
  1905. if (Objects.equals(attachment.getId(), projectMaterial.getTemplate_id())) {
  1906. FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri());
  1907. modelMap.addAttribute("zxMaterials", fileDown);
  1908. }
  1909. }
  1910. }
  1911. }
  1912. return modelMap;
  1913. }
  1914. public boolean isFina() {
  1915. //Group group = groupService.findByName(Constant.XMSBCLSHZ, null);
  1916. Group group = groupService.findByName(Constant.XMSBCZSHZ, null);
  1917. if (group == null) {
  1918. return false;
  1919. }
  1920. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1921. //Department department = departmentService.findByName(Constant.QCZC, null);
  1922. //List<User> users = userService.findUserBydepartmentId(department.getId().toString());
  1923. StringBuffer sb = new StringBuffer("");
  1924. for (UserGroup userGroup : userGroups) {
  1925. //for (User user : users) {
  1926. //if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1927. if (String.valueOf(ShiroUtils.getUserId()).equals(String.valueOf(userGroup.getUser_id()))) {
  1928. return true;
  1929. }
  1930. //}
  1931. //}
  1932. }
  1933. return false;
  1934. }
  1935. public PageInfo<ProjectDeclaration> findByCompany(String projectName, Integer pageNum, Integer pagesize,
  1936. String startTime1, String startTime2, String endTime1, String endTime2) {
  1937. PageHelper.startPage(pageNum, pagesize);
  1938. FindRequest request = new FindRequest();
  1939. request.setUser_type(Constant.UserType.COMPANY);
  1940. request.setCompany_id(ShiroUtils.getCompanyId());
  1941. List<ProjectDeclaration> list = projectDeclarationDao.findByCondition(projectName, startTime1, startTime2, endTime1, endTime2, request, new ProjectDeclaration());
  1942. for (ProjectDeclaration projectDeclaration : list) {
  1943. if (Objects.equals(projectDeclaration.getStatus(), "0")) {
  1944. projectDeclaration.setStatus_name("待发布");
  1945. } else {
  1946. try {
  1947. String end = projectDeclaration.getApply_enddate();
  1948. if (end.length() <= 10) end += " 23:59:59";
  1949. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1950. Date endtime = sdf.parse(end);
  1951. Date now = new Date();
  1952. if (now.before(endtime)) {
  1953. projectDeclaration.setStatus_name("申请中");
  1954. projectDeclaration.setCanApply(true);
  1955. } else {
  1956. projectDeclaration.setStatus_name("失效");
  1957. projectDeclaration.setCanApply(false);
  1958. }
  1959. } catch (Exception e) {
  1960. projectDeclaration.setStatus_name("申请中");
  1961. }
  1962. }
  1963. }
  1964. return new PageInfo<ProjectDeclaration>(list);
  1965. }
  1966. public ModelMap getDictInfo(ModelMap modelMap) {
  1967. //项目大类
  1968. List<DictionaryItem> projectSuperTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_APPLICATION_SUPER_TYPE);
  1969. modelMap.put("projectSuperTypeList", projectSuperTypeList);
  1970. //项目来源
  1971. List<DictionaryItem> projectSourceList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SOURCE);
  1972. modelMap.put("projectSourceList", projectSourceList);
  1973. //责任单位
  1974. Department department = new Department();
  1975. department.setDel_flag(false);
  1976. department.setUser_type(ShiroUtils.getUserEntity().getUser_type());
  1977. department.setUser_type(Constant.UserType.GOVERNMENT);
  1978. modelMap.addAttribute("departmentList", departmentService.findListByWhere(department));
  1979. return modelMap;
  1980. }
  1981. //可以在线申报的项目
  1982. public PageInfo<ProjectDeclaration> findActive(String projectName, Integer pageNum, Integer pagesize,
  1983. String startTime1, String startTime2, String endTime1, String endTime2) {
  1984. PageHelper.startPage(pageNum, pagesize);
  1985. FindRequest request = new FindRequest();
  1986. request.setIsActive(true);
  1987. ProjectDeclaration decl = new ProjectDeclaration();
  1988. decl.setIs_online_application("1");
  1989. List<ProjectDeclaration> list = projectDeclarationDao.findByCondition(projectName, startTime1, startTime2, endTime1, endTime2, request, decl);
  1990. for (ProjectDeclaration projectDeclaration : list) {
  1991. if (Objects.equals(projectDeclaration.getStatus(), "0")) {
  1992. projectDeclaration.setStatus_name("待发布");
  1993. } else {
  1994. try {
  1995. String end = projectDeclaration.getApply_enddate();
  1996. if (end.length() <= 10) end += " 23:59:59";
  1997. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1998. Date endtime = sdf.parse(end);
  1999. Date now = new Date();
  2000. if (now.before(endtime)) {
  2001. projectDeclaration.setStatus_name("申请中");
  2002. projectDeclaration.setCanApply(true);
  2003. } else {
  2004. projectDeclaration.setStatus_name("失效");
  2005. projectDeclaration.setCanApply(false);
  2006. }
  2007. } catch (Exception e) {
  2008. projectDeclaration.setStatus_name("申请中");
  2009. }
  2010. }
  2011. }
  2012. return new PageInfo<ProjectDeclaration>(list);
  2013. }
  2014. public FindResponseProject findProejctsOnHome(FindRequest request) {
  2015. FindResponseProject response = new FindResponseProject();
  2016. PageHelper.startPage(request.getPage_no(), request.getPage_size());
  2017. List<ProjectDeclaration> contents;
  2018. //报表填报
  2019. if (request.getId() == 77) {
  2020. contents = projectFillingService.findUnionProjectsOnHome(request);
  2021. } else {//项目申报、省市申报
  2022. contents = projectDeclarationDao.findUnionProjectsOnHome(request);
  2023. }
  2024. if (contents.size() > 0) {
  2025. for (ProjectDeclaration project : contents) {
  2026. if (null != project.getProject_source()) {
  2027. String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, project.getProject_source());
  2028. project.setProject_source_name(sourceName);
  2029. }
  2030. }
  2031. }
  2032. PageInfo<ProjectDeclaration> pageInfo = new PageInfo<>(contents);
  2033. response.setProjects(contents);
  2034. response.setCounts((int) pageInfo.getTotal());
  2035. response.setPage_no(request.getPage_no());
  2036. return response;
  2037. }
  2038. PageInfo<OrderTrackingDto> findOrderTrackingPage(Integer pageNum, Integer pagesize, String businessType, String typeId, String number, String companyName, String startDate, String endDate) {
  2039. PageHelper.startPage(pageNum, pagesize);
  2040. List<OrderTrackingDto> list = projectApplicationDao.findOrderTrackingPage(businessType, typeId, number, companyName, startDate, endDate);
  2041. return new PageInfo<OrderTrackingDto>(list);
  2042. }
  2043. /**
  2044. * 功能描述:单据追踪导出
  2045. *
  2046. * @param:
  2047. * @return:
  2048. * @auther: huZhiHao
  2049. * @date: 2018/9/26 15:26
  2050. */
  2051. public void exportOrder(HttpServletResponse response, String businessType, String typeId, String number, String companyName, String startDate, String endDate) throws Exception {
  2052. List<OrderTrackingDto> list = projectApplicationDao.findOrderTrackingPage(businessType, typeId, number, companyName, startDate, endDate);
  2053. String fileName = "单据追踪.xlsx";
  2054. List<OrderExports> applyList = new ArrayList<>();
  2055. for (OrderTrackingDto orderTrackingDto : list) {
  2056. OrderExports orderExports = new OrderExports();
  2057. orderExports.setBusinessName(orderTrackingDto.getBusinessName());
  2058. orderExports.setTypeName(orderTrackingDto.getTypeName());
  2059. orderExports.setNumber(orderTrackingDto.getNumber());
  2060. orderExports.setCompanyName(orderTrackingDto.getCompanyName());
  2061. orderExports.setStatus(orderTrackingDto.getStatus());
  2062. applyList.add(orderExports);
  2063. }
  2064. new ExportExcel("单据追踪", OrderExports.class).setDataList(applyList).write(response, fileName).dispose();
  2065. }
  2066. /**
  2067. * 项目申报详情
  2068. *
  2069. * @param request
  2070. * @return
  2071. */
  2072. public PageInfo<ProjectDeclaration> findProjectList(FindRequest request) {
  2073. PageHelper.startPage(request.getPage_no(), request.getPage_size());
  2074. List<ProjectDeclaration> contents = projectDeclarationDao.findUnionProjectsOnHome(request);
  2075. return new PageInfo<>(contents);
  2076. }
  2077. public void importData(InputStream inputStream, Workbook wb) throws Exception {
  2078. Row row = null;
  2079. Cell cell = null;
  2080. Sheet sheet = (Sheet) wb.getSheetAt(0);
  2081. int tatalRows = sheet.getPhysicalNumberOfRows();
  2082. if (tatalRows == 2) {
  2083. throw new Exception("请添加数据");
  2084. }
  2085. String year = "";
  2086. String street = "";
  2087. String companyName = "";
  2088. String projectType = "";
  2089. String projectName = "";
  2090. String projectName_ = "";
  2091. List<ProjectApplicationImportDto> projectApplicationImportDtoList = new ArrayList<>();
  2092. //从3行读取数据
  2093. for (int r = 2; r < tatalRows; r++) {
  2094. //获取行数据
  2095. row = sheet.getRow(r);
  2096. cell = row.getCell(0);
  2097. year = getCellValue(cell, r, "年度") == "" ? year : getCellValue(cell, r, "年度");
  2098. cell = row.getCell(1);
  2099. street = getCellValue(cell, r, "属地") == "" ? street : getCellValue(cell, r, "属地");
  2100. cell = row.getCell(2);
  2101. companyName = getCellValue(cell, r, "企业名称");
  2102. cell = row.getCell(3);
  2103. projectType = getCellValue(cell, r, "项目大类");
  2104. cell = row.getCell(4);
  2105. projectName = getCellValue(cell, r, "项目小类");
  2106. cell = row.getCell(5);
  2107. projectName_ = getCellValue(cell, r, "申报项目名称");
  2108. if (companyName == "" || projectType == "" || projectName == "") {
  2109. continue;
  2110. }
  2111. ProjectApplicationImportDto projectApplicationImportDto = new ProjectApplicationImportDto();
  2112. projectApplicationImportDto.setProjectYear(year);
  2113. projectApplicationImportDto.setStreetName(street);
  2114. projectApplicationImportDto.setCompanyName(companyName);
  2115. projectApplicationImportDto.setSuperTypeName(projectType);
  2116. projectApplicationImportDto.setTypeName(projectName);
  2117. projectApplicationImportDto.setProjectName(projectName_);
  2118. projectApplicationImportDtoList.add(projectApplicationImportDto);
  2119. }
  2120. updateApplication(projectApplicationImportDtoList);
  2121. }
  2122. /**
  2123. * 获取单元格值
  2124. */
  2125. private static String getCellValue(Cell cell, int index, String thead) throws Exception {
  2126. String value = null;
  2127. if (cell != null) {
  2128. cell.setCellType(Cell.CELL_TYPE_STRING);
  2129. value = cell.getStringCellValue();
  2130. if (StringUtils.isNotBlank(value)) {
  2131. return value;
  2132. }
  2133. }
  2134. return value;
  2135. //throw new Exception("第"+(index+1)+"行"+thead+"不能为空");
  2136. }
  2137. private void updateApplication(List<ProjectApplicationImportDto> projectApplicationImportDtoList) {
  2138. // Example example = new Example(ProjectApplication.class);
  2139. // Example.Criteria criteria = example.createCriteria();
  2140. // criteria.andEqualTo("del_flag", 0);
  2141. // example.setOrderByClause("create_time desc");
  2142. // List<ProjectApplication> applys = projectApplicationService.selectByExample(example);
  2143. List<ProjectApplicationImportDto> projectApplicationList = projectApplicationService.importList();
  2144. for (ProjectApplicationImportDto projectApplication : projectApplicationList) {
  2145. for (ProjectApplicationImportDto projectApplicationImportDto : projectApplicationImportDtoList) {
  2146. if (
  2147. Objects.equals(projectApplicationImportDto.getProjectYear(), projectApplication.getProjectYear())
  2148. && Objects.equals(projectApplicationImportDto.getCompanyName(), projectApplication.getCompanyName())
  2149. && projectApplicationImportDto.getSuperTypeName().contains(projectApplication.getSuperTypeName())
  2150. && projectApplicationImportDto.getTypeName().contains(projectApplication.getTypeName())
  2151. ) {
  2152. ProjectApplication projectApp = new ProjectApplication();
  2153. projectApp.setId(Integer.valueOf(projectApplication.getId()));
  2154. projectApp.setPass("通过");
  2155. projectApplicationService.updateSelective(projectApp);
  2156. break;
  2157. }
  2158. }
  2159. }
  2160. }
  2161. }