IndustrialLandSupplyDetailService.java 224 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921
  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 com.xiaoleilu.hutool.util.StrUtil;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.apache.poi.xwpf.usermodel.XWPFDocument;
  9. import org.springframework.beans.BeanUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.stereotype.Service;
  13. import org.springframework.transaction.annotation.Transactional;
  14. import org.springframework.util.CollectionUtils;
  15. import platform.common.Constant;
  16. import platform.common.base.service.BaseService;
  17. import platform.common.base.service.DictionaryItemService;
  18. import platform.common.exception.BaseException;
  19. import platform.common.util.*;
  20. import platform.common.util.word.ExportWord;
  21. import platform.modules.company.dto.LandSupplyApprovalDto;
  22. import platform.modules.company.entity.ProjectApplication;
  23. import platform.modules.government.dao.IndustrialLandSupplyDetailDao;
  24. import platform.modules.government.dto.DepartmentDto;
  25. import platform.modules.government.dto.IndustrialLandSupplyDto;
  26. import platform.modules.government.dto.IndustrialLandSupplyParam;
  27. import platform.modules.government.entity.*;
  28. import platform.modules.sys.entity.*;
  29. import platform.modules.sys.service.*;
  30. import tk.mybatis.mapper.entity.Example;
  31. import javax.annotation.Resource;
  32. import javax.servlet.http.HttpServletResponse;
  33. import java.io.File;
  34. import java.io.IOException;
  35. import java.io.UnsupportedEncodingException;
  36. import java.net.URLEncoder;
  37. import java.text.ParseException;
  38. import java.util.*;
  39. import java.util.stream.Collectors;
  40. /**
  41. * 功能描述: 产业供地详情
  42. *
  43. * @Author: huZhiHao
  44. * @Date: 2020/3/5
  45. **/
  46. @Service
  47. public class IndustrialLandSupplyDetailService extends BaseService<IndustrialLandSupplyDetail> {
  48. @Resource
  49. private IndustrialLandSupplyDetailDao industrialLandSupplyDetailDao;
  50. @Autowired
  51. private IndustrialLandSupplyConsultationService industrialLandSupplyConsultationService;
  52. @Autowired
  53. private IndustrialLandSupplyDistributionService industrialLandSupplyDistributionService;
  54. @Autowired
  55. private IndustrialLandSupplyConfigService industrialLandSupplyConfigService;
  56. @Autowired
  57. private ApprovalService approvalService;
  58. @Autowired
  59. private AttachmentService attachmentService;
  60. @Autowired
  61. private UserService userService;
  62. @Autowired
  63. private GroupService groupService;
  64. @Autowired
  65. private UserGroupService userGroupService;
  66. @Autowired
  67. private DepartmentService departmentService;
  68. @Autowired
  69. private DictionaryItemService dictionaryItemService;
  70. @Autowired
  71. private SysConfigService sysConfigService;
  72. private static String FEEDBACK_TIME = "1";
  73. private static String SUMMARY_TIME = "2";
  74. private static String DISTRIBUTE_TIME = "3";
  75. private static String JOINT_TRIAL_TIME = "4";
  76. private static String CONSULTATION_MESSAGE = "请反馈明确意见";
  77. @Value("${repositoryPath}")
  78. public String repositoryPath;
  79. final private String attachmentType = "annex_template";
  80. /**
  81. * @Author: huZhiHao
  82. * @Description: 分页查询
  83. * @Date: 2020/3/6
  84. * @Params: [pageNum, pagesize, title, location, status, stage]
  85. * @Return: com.github.pagehelper.PageInfo<platform.modules.government.entity.IndustrialLandSupplyDetail>
  86. **/
  87. @Transactional
  88. public PageInfo<IndustrialLandSupplyDto> findPage(Integer pageNum, Integer pageSize, IndustrialLandSupplyParam param, String type) throws ParseException {
  89. param.setApproval_type(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  90. //是否是待处理页面
  91. boolean flag = true;
  92. if (Objects.equals("1", type)) {
  93. //待处理
  94. flag = true;
  95. param.setApplyIds(getProjectIdsByGroup());
  96. } else if (Objects.equals("2", type)) {
  97. //已处理
  98. flag = false;
  99. param.setApplyIds(getProjectIdsy());
  100. } else if (Objects.equals("3", type)) {
  101. //查看所有
  102. flag = false;
  103. param.setApplyIds(getProjectIdsc());
  104. }
  105. PageHelper.startPage(pageNum, pageSize);
  106. List<IndustrialLandSupplyDto> list = industrialLandSupplyDetailDao.findPage(param);
  107. for (IndustrialLandSupplyDto entity : list) {
  108. if (null != entity.getApprove_status()) {
  109. String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY_APPROVE_STATUS, entity.getApprove_status());
  110. entity.setApprove_status_desc(status_name);
  111. getPendingDepartment(entity);
  112. if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK, entity.getApprove_status())
  113. || Objects.equals("a", entity.getApprove_status())) {
  114. //咨询待反馈剩余时间
  115. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  116. IndustrialLandSupplyConsultation landSupplyConsultation = new IndustrialLandSupplyConsultation();
  117. landSupplyConsultation.setIndustrial_land_supply_id(entity.getId());
  118. Department department = departmentService.findRootById(ShiroUtils.getUserEntity().getDepartment_id());
  119. landSupplyConsultation.setDepartment_id(department.getId() + "");
  120. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(landSupplyConsultation);
  121. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  122. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = industrialLandSupplyConsultationList.get(industrialLandSupplyConsultationList.size() - 1);
  123. // entity.setRemain_time(DateUtil.getTimeDiffStr(industrialLandSupplyConsultation.getConsultation_time(), days));
  124. String dealTime = null;
  125. if (!flag) {
  126. Approval approval = new Approval();
  127. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  128. approval.setApply_id(Integer.parseInt(entity.getId()));
  129. approval.setCreate_by(ShiroUtils.getUserId());
  130. List<Approval> approvals = approvalService.findListByWhere(approval);
  131. if (!CollectionUtils.isEmpty(approvals)) {
  132. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  133. try {
  134. if (entity.getUpdate_time() == null) {
  135. entity.setUpdate_time("1970-01-01 00:00:00");
  136. }
  137. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  138. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  139. if (d2.before(d1)) {
  140. dealTime = null;
  141. }
  142. } catch (ParseException e) {
  143. e.printStackTrace();
  144. }
  145. }
  146. }
  147. entity.setRemain_time(DateUtil.getTimeDiff(
  148. industrialLandSupplyConsultation.getConsultation_time(),
  149. dealTime,
  150. days,
  151. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  152. ));
  153. }
  154. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY, entity.getApprove_status())) {
  155. //咨询待汇总剩余时间
  156. Approval approval = new Approval();
  157. approval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  158. approval.setApply_id(Integer.parseInt(entity.getId()));
  159. List<Approval> approvalList = approvalService.findListByWhere(approval);
  160. if (!CollectionUtils.isEmpty(approvalList)) {
  161. Approval approve = approvalList.get(approvalList.size() - 1);
  162. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(SUMMARY_TIME));
  163. // entity.setRemain_time(DateUtil.getTimeDiffStr(approve.getCreate_time(), days));
  164. String dealTime = null;
  165. if (!flag) {
  166. approval = new Approval();
  167. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  168. approval.setApply_id(Integer.parseInt(entity.getId()));
  169. List<Approval> approvals = approvalService.findListByWhere(approval);
  170. if (!CollectionUtils.isEmpty(approvals)) {
  171. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  172. try {
  173. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  174. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  175. if (d2.before(d1)) {
  176. dealTime = null;
  177. }
  178. } catch (ParseException e) {
  179. e.printStackTrace();
  180. }
  181. }
  182. }
  183. entity.setRemain_time(DateUtil.getTimeDiff(
  184. approve.getCreate_time(),
  185. dealTime,
  186. days,
  187. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  188. ));
  189. }
  190. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK, entity.getApprove_status())
  191. || Objects.equals("a", entity.getApprove_status())) {
  192. //分发待反馈剩余时间
  193. /*int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(DISTRIBUTE_TIME));
  194. IndustrialLandSupplyDistribution landSupplyDistribution = new IndustrialLandSupplyDistribution();
  195. landSupplyDistribution.setIndustrial_land_supply_id(entity.getId());
  196. Department department = departmentService.findRootById(ShiroUtils.getUserEntity().getDepartment_id());
  197. landSupplyDistribution.setDepartment_id(department.getId() + "");
  198. List<IndustrialLandSupplyDistribution> industrialLandSupplylandSupplyDistributionList = industrialLandSupplyDistributionService.findListByWhere(landSupplyDistribution);
  199. if (!CollectionUtils.isEmpty(industrialLandSupplylandSupplyDistributionList)) {
  200. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = industrialLandSupplylandSupplyDistributionList.get(industrialLandSupplylandSupplyDistributionList.size() - 1);
  201. // entity.setRemain_time(DateUtil.getTimeDiffStr(industrialLandSupplyDistribution.getDistribute_time(), days));
  202. String dealTime = null;
  203. if (!flag) {
  204. Approval approval = new Approval();
  205. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  206. approval.setApply_id(Integer.parseInt(entity.getId()));
  207. approval.setCreate_by(ShiroUtils.getUserId());
  208. List<Approval> approvals = approvalService.findListByWhere(approval);
  209. if (!CollectionUtils.isEmpty(approvals)) {
  210. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  211. try {
  212. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  213. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  214. if (d2.before(d1)) {
  215. dealTime = null;
  216. }
  217. } catch (ParseException e) {
  218. e.printStackTrace();
  219. }
  220. }
  221. }
  222. entity.setRemain_time(DateUtil.getTimeDiff(
  223. industrialLandSupplyDistribution.getDistribute_time(),
  224. dealTime,
  225. days,
  226. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  227. ));
  228. }*/
  229. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY, entity.getApprove_status())) {
  230. //会审审批剩余时间
  231. Approval approval = new Approval();
  232. approval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY);
  233. approval.setApply_id(Integer.parseInt(entity.getId()));
  234. List<Approval> approvalList = approvalService.findListByWhere(approval);
  235. if (!CollectionUtils.isEmpty(approvalList)) {
  236. Approval approve = approvalList.get(approvalList.size() - 1);
  237. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(JOINT_TRIAL_TIME));
  238. // entity.setRemain_time(DateUtil.getTimeDiffStr(approve.getCreate_time(), days));
  239. String dealTime = null;
  240. if (!flag) {
  241. approval = new Approval();
  242. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  243. approval.setApply_id(Integer.parseInt(entity.getId()));
  244. List<Approval> approvals = approvalService.findListByWhere(approval);
  245. if (!CollectionUtils.isEmpty(approvals)) {
  246. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  247. try {
  248. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  249. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  250. if (d2.before(d1)) {
  251. dealTime = null;
  252. }
  253. } catch (ParseException e) {
  254. e.printStackTrace();
  255. }
  256. }
  257. }
  258. entity.setRemain_time(DateUtil.getTimeDiff(
  259. approve.getCreate_time(),
  260. dealTime,
  261. days,
  262. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  263. ));
  264. }
  265. }
  266. }
  267. if (null != entity.getProcess_stage()) {
  268. String process_stage_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY_APPROVE_STAGE, entity.getProcess_stage());
  269. entity.setProcess_stage_desc(process_stage_name);
  270. }
  271. List<Attachment> attachmentList = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_GS, Integer.valueOf(entity.getId()), null);
  272. if (null != entity.getGs_feedback() || !CollectionUtils.isEmpty(attachmentList)) {
  273. entity.setGs_feedback("0");
  274. }
  275. }
  276. return new PageInfo<IndustrialLandSupplyDto>(list);
  277. }
  278. /**
  279. * @Author: huZhiHao
  280. * @Description: 获取待咨询部门
  281. * @Date: 2020/3/11
  282. * @Params: [entity]
  283. * @Return: void
  284. **/
  285. private void getPendingDepartment(IndustrialLandSupplyDto entity) {
  286. if (Objects.equals(Constant.UserType.GOVERNMENT, ShiroUtils.getUserType())) {
  287. String id = entity.getId();
  288. String approveStatus = entity.getApprove_status();
  289. User user = ShiroUtils.getUserEntity();
  290. if (Objects.equals(approveStatus, Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK)) {
  291. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  292. industrialLandSupplyConsultation.setIndustrial_land_supply_id(id);
  293. //industrialLandSupplyConsultation.setDepartment_id(user.getDepartment_id() + "");
  294. Department department = departmentService.findRootById(user.getDepartment_id());
  295. industrialLandSupplyConsultation.setDepartment_id(department.getId() + "");
  296. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  297. boolean sumbitToSummary = false;
  298. for (IndustrialLandSupplyConsultation landSupplyConsultation : industrialLandSupplyConsultationList) {
  299. //是否所有咨询都已回答
  300. if (CommonUtils.isNull(landSupplyConsultation.getFeedback()) || CommonUtils.isNull(landSupplyConsultation.getUpdate_by())) {
  301. sumbitToSummary = false;
  302. break;
  303. } else {
  304. sumbitToSummary = true;
  305. }
  306. }
  307. //接受咨询的举办 负责的状态
  308. Group group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_2, null);
  309. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  310. for (UserGroup userGroup : userGroups) {
  311. if (Objects.equals(userGroup.getUser_id(), user.getId())) {
  312. //Department department = departmentService.selectById(user.getDepartment_id());
  313. department = departmentService.findRootById(user.getDepartment_id());
  314. if (sumbitToSummary) {
  315. entity.setApprove_status_desc(department.getName() + "已反馈");
  316. entity.setApprove_status("a");
  317. } else {
  318. entity.setApprove_status_desc(department.getName() + "待反馈");
  319. }
  320. break;
  321. }
  322. }
  323. } else if (Objects.equals(approveStatus, Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK)) {
  324. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = new IndustrialLandSupplyDistribution();
  325. industrialLandSupplyDistribution.setIndustrial_land_supply_id(id);
  326. //industrialLandSupplyDistribution.setDepartment_id(user.getDepartment_id() + "");
  327. Department department = departmentService.findRootById(user.getDepartment_id());
  328. industrialLandSupplyDistribution.setDepartment_id(department.getId() + "");
  329. List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = industrialLandSupplyDistributionService.findListByWhere(industrialLandSupplyDistribution);
  330. boolean sumbitToSummary = false;
  331. for (IndustrialLandSupplyDistribution landSupplyDistribution : industrialLandSupplyDistributionList) {
  332. //是否所有咨询都已回答
  333. if (CommonUtils.isNull(landSupplyDistribution.getFeedback()) || CommonUtils.isNull(landSupplyDistribution.getUpdate_by())) {
  334. sumbitToSummary = false;
  335. break;
  336. } else {
  337. sumbitToSummary = true;
  338. }
  339. }
  340. //接受分发的举办 负责的状态
  341. Group group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_5, null);
  342. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  343. for (UserGroup userGroup : userGroups) {
  344. if (Objects.equals(userGroup.getUser_id(), user.getId())) {
  345. //Department department = departmentService.selectById(user.getDepartment_id());
  346. department = departmentService.findRootById(user.getDepartment_id());
  347. if (sumbitToSummary) {
  348. entity.setApprove_status_desc(department.getName() + "已反馈");
  349. entity.setApprove_status("a");
  350. } else {
  351. entity.setApprove_status_desc(department.getName() + "待反馈");
  352. }
  353. break;
  354. }
  355. }
  356. }
  357. }
  358. }
  359. /**
  360. * @Author: huZhiHao
  361. * @Description: 查询详情
  362. * @Date: 2020/3/11
  363. * @Params: [id]
  364. * @Return: platform.modules.government.entity.IndustrialLandSupplyDetail
  365. **/
  366. @Transactional
  367. public IndustrialLandSupplyDetail selectById(String id) throws ParseException {
  368. IndustrialLandSupplyDetail entity = industrialLandSupplyDetailDao.selectById(id);
  369. //文件
  370. List<Attachment> attachments = null;
  371. //基本信息附件
  372. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, entity.getId(), null);
  373. if (null != attachments && attachments.size() > 0) {
  374. List<FileDown> fileList = new ArrayList<>();
  375. for (Attachment attachment : attachments) {
  376. FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri());
  377. fileList.add(fileDown);
  378. }
  379. entity.setFileList(fileList);
  380. }
  381. //补充附件
  382. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_COMMERCE_SUPPLEMENT, entity.getId(), null);
  383. if (null != attachments && attachments.size() > 0) {
  384. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  385. entity.setSupplement_file(fileDown);
  386. }
  387. //汇总附件
  388. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_SUMMARY, entity.getId(), null);
  389. if (null != attachments && attachments.size() > 0) {
  390. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  391. entity.setConsultation_summary_file(fileDown);
  392. }
  393. //商务局分管领导附件
  394. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_COMMERCE_LEADER, entity.getId(), null);
  395. if (null != attachments && attachments.size() > 0) {
  396. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  397. entity.setCommerce_leader_pre_approve_file(fileDown);
  398. }
  399. //管委会分管领导附件
  400. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_MANAGEMENT_COMMITTEE_LEADER, entity.getId(), null);
  401. if (null != attachments && attachments.size() > 0) {
  402. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  403. entity.setCommittee_leader_pre_approve_file(fileDown);
  404. }
  405. //分发汇总附件
  406. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_SUMMARY, entity.getId(), null);
  407. if (null != attachments && attachments.size() > 0) {
  408. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  409. entity.setDistribution_summary_file(fileDown);
  410. }
  411. //专题会审附件
  412. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_JOINT_TRIAL, entity.getId(), null);
  413. if (null != attachments && attachments.size() > 0) {
  414. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  415. entity.setJoint_trial_file(fileDown);
  416. }
  417. //供地审批附件
  418. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_APPROVE, entity.getId(), null);
  419. if (null != attachments && attachments.size() > 0) {
  420. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  421. entity.setLand_supply_file(fileDown);
  422. }
  423. //最终信息附件
  424. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_FINAL, entity.getId(), null);
  425. if (null != attachments && attachments.size() > 0) {
  426. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  427. entity.setFinal_file(fileDown);
  428. }
  429. //行政反馈附件
  430. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_GS, entity.getId(), null);
  431. if (null != attachments && attachments.size() > 0) {
  432. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  433. entity.setGs_feedback_file(fileDown);
  434. }
  435. //会签附件
  436. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_MANAGEMENT_COMMITTEE_LEADER_COUNTERSIGN, entity.getId(), null);
  437. if (null != attachments && attachments.size() > 0) {
  438. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  439. entity.setCountersign_file(fileDown);
  440. }
  441. //状态详情
  442. if (null != entity.getApprove_status()) {
  443. String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY_APPROVE_STATUS, entity.getApprove_status());
  444. entity.setApprove_status_desc(status_name);
  445. }
  446. if (null != entity.getProcess_stage()) {
  447. String process_stage_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY_APPROVE_STAGE, entity.getProcess_stage());
  448. entity.setProcess_stage_desc(process_stage_name);
  449. }
  450. User user = userService.getUser(entity.getCreate_by());
  451. if (CommonUtils.isNotNull(user) && Constant.UserType.STREET.equals(user.getUser_type())) {
  452. if (CommonUtils.isNotNull(user.getDepartment_name()) && Objects.equals(user.getDepartment_name(), "招商中心")) {
  453. entity.setResource(user.getDepartment_name());
  454. } else {
  455. entity.setResource(user.getStreet_name());
  456. }
  457. } else if (CommonUtils.isNotNull(user) && Constant.UserType.GOVERNMENT.equals(user.getUser_type())) {
  458. entity.setResource(user.getDepartment_name());
  459. }
  460. //咨询列表
  461. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  462. industrialLandSupplyConsultation.setIndustrial_land_supply_id(id);
  463. industrialLandSupplyConsultation.setDel_flag(false);
  464. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  465. for (IndustrialLandSupplyConsultation landSupplyConsultation : industrialLandSupplyConsultationList) {
  466. /* if (Objects.equals(landSupplyConsultation.getConsultation(), CONSULTATION_MESSAGE)) {
  467. landSupplyConsultation.setIsDefault(true);
  468. } else */
  469. if (landSupplyConsultation.getIsDefault() == null) {
  470. landSupplyConsultation.setIsDefault(false);
  471. }
  472. //文件
  473. List<Attachment> feedbackAttachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_FEEDBACK, landSupplyConsultation.getId(), null);
  474. if (null != feedbackAttachments && feedbackAttachments.size() > 0) {
  475. FileDown fileDown = new FileDown(feedbackAttachments.get(0).getId(), feedbackAttachments.get(0).getFile_name(), feedbackAttachments.get(0).getFile_url(), feedbackAttachments.get(0).getDownload_uri());
  476. landSupplyConsultation.setFileDown(fileDown);
  477. }
  478. if (CommonUtils.isNull(landSupplyConsultation.getFeedback())) {
  479. landSupplyConsultation.setCanWithdraw(true);
  480. } else {
  481. landSupplyConsultation.setCanWithdraw(false);
  482. }
  483. Department department = departmentService.selectById(Integer.valueOf(landSupplyConsultation.getDepartment_id()));
  484. if (department != null) {
  485. landSupplyConsultation.setDepartment_name(department.getName());
  486. }
  487. //是否同意
  488. if (landSupplyConsultation.getIsAgree() != null) {
  489. String feedback = landSupplyConsultation.getFeedback();
  490. String str = "";
  491. if (landSupplyConsultation.getIsAgree()) {
  492. str = "同意。";
  493. } else {
  494. str = "不同意。";
  495. }
  496. landSupplyConsultation.setFeedback(str + feedback);
  497. }
  498. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  499. // landSupplyConsultation.setRemain_time(DateUtil.getTimeDiffStr(landSupplyConsultation.getConsultation_time(), days));
  500. String dealTime = null;
  501. Approval approval = new Approval();
  502. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  503. approval.setApply_id(Integer.parseInt(id));
  504. List<Approval> approvals = approvalService.findListByWhere(approval);
  505. if (!CollectionUtils.isEmpty(approvals)) {
  506. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  507. try {
  508. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time() == null ? "1970-01-01 00:00:00" : entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  509. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  510. if (d2.before(d1)) {
  511. dealTime = null;
  512. }
  513. } catch (ParseException e) {
  514. e.printStackTrace();
  515. }
  516. }
  517. // landSupplyConsultation.setRemain_time(DateUtil.getTimeDiff(landSupplyConsultation.getCreate_time(), dealTime, days));
  518. landSupplyConsultation.setRemain_time(DateUtil.getTimeDiff(
  519. landSupplyConsultation.getCreate_time(),
  520. landSupplyConsultation.getUpdate_time(),
  521. days,
  522. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  523. ));
  524. }
  525. entity.setConsultationList(industrialLandSupplyConsultationList);
  526. //分发列表
  527. // IndustrialLandSupplyDistribution industrialLandSupplyDistribution = new IndustrialLandSupplyDistribution();
  528. // industrialLandSupplyDistribution.setIndustrial_land_supply_id(id);
  529. // industrialLandSupplyDistribution.setDel_flag(false);
  530. // List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = industrialLandSupplyDistributionService.findListByWhere(industrialLandSupplyDistribution);
  531. Example example = new Example(IndustrialLandSupplyDistribution.class);
  532. Example.Criteria criteria = example.createCriteria();
  533. criteria.andEqualTo("industrial_land_supply_id", id);
  534. criteria.andEqualTo("del_flag", 0);
  535. //倒序
  536. example.orderBy("department_id").asc();
  537. List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = industrialLandSupplyDistributionService.selectByExample(example);
  538. for (IndustrialLandSupplyDistribution landSupplyDistribution : industrialLandSupplyDistributionList) {
  539. List<Attachment> attachmentList = null;
  540. //分发文件
  541. attachmentList = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE, landSupplyDistribution.getId(), null);
  542. if (null != attachmentList && attachmentList.size() > 0) {
  543. FileDown fileDown = new FileDown(attachmentList.get(0).getId(), attachmentList.get(0).getFile_name(), attachmentList.get(0).getFile_url(), attachmentList.get(0).getDownload_uri());
  544. landSupplyDistribution.setDistribution_file(fileDown);
  545. }
  546. //分发反馈文件
  547. attachmentList = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_FEEDBACK, landSupplyDistribution.getId(), null);
  548. if (null != attachmentList && attachmentList.size() > 0) {
  549. FileDown fileDown = new FileDown(attachmentList.get(0).getId(), attachmentList.get(0).getFile_name(), attachmentList.get(0).getFile_url(), attachmentList.get(0).getDownload_uri());
  550. landSupplyDistribution.setFeedback_file(fileDown);
  551. }
  552. if (Objects.equals(landSupplyDistribution.getDepartment_id(), "0")) {
  553. landSupplyDistribution.setDepartment_name("所有部门可见");
  554. } else {
  555. Department department = departmentService.selectById(Integer.valueOf(landSupplyDistribution.getDepartment_id()));
  556. if (department != null) {
  557. landSupplyDistribution.setDepartment_name(department.getName());
  558. }
  559. }
  560. //分发反馈剩余时间
  561. /*if (!Objects.equals(landSupplyDistribution.getDepartment_id(), "0")) {
  562. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(DISTRIBUTE_TIME));
  563. // landSupplyDistribution.setRemain_time(DateUtil.getTimeDiffStr(landSupplyDistribution.getDistribute_time(), days));
  564. String dealTime = null;
  565. Approval approval = new Approval();
  566. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  567. approval.setApply_id(Integer.parseInt(id));
  568. List<Approval> approvals = approvalService.findListByWhere(approval);
  569. if (!CollectionUtils.isEmpty(approvals)) {
  570. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  571. try {
  572. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  573. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  574. if (d2.before(d1)) {
  575. dealTime = null;
  576. }
  577. } catch (ParseException e) {
  578. e.printStackTrace();
  579. }
  580. }
  581. // landSupplyDistribution.setRemain_time(DateUtil.getTimeDiff(landSupplyDistribution.getCreate_time(), dealTime, days));
  582. landSupplyDistribution.setRemain_time(DateUtil.getTimeDiff(
  583. landSupplyDistribution.getCreate_time(),
  584. landSupplyDistribution.getUpdate_time(),
  585. days,
  586. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  587. ));
  588. }*/
  589. }
  590. entity.setDistributionList(industrialLandSupplyDistributionList);
  591. //汇总剩余时间
  592. //获取最后一次进入待汇总的时间作为节点
  593. Approval approval = new Approval();
  594. approval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  595. approval.setApply_id(Integer.parseInt(id));
  596. List<Approval> approvalList = approvalService.findListByWhere(approval);
  597. if (!CollectionUtils.isEmpty(approvalList)) {
  598. Approval approve = approvalList.get(approvalList.size() - 1);
  599. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(SUMMARY_TIME));
  600. // entity.setSummary_remain_time(DateUtil.getTimeDiffStr(approve.getCreate_time(), days));
  601. String dealTime = null;
  602. approval = new Approval();
  603. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  604. approval.setApply_id(Integer.parseInt(id));
  605. approval.setCreate_by(ShiroUtils.getUserId());
  606. List<Approval> approvals = approvalService.findListByWhere(approval);
  607. if (!CollectionUtils.isEmpty(approvals)) {
  608. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  609. try {
  610. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  611. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  612. if (d2.before(d1)) {
  613. dealTime = null;
  614. }
  615. } catch (ParseException e) {
  616. e.printStackTrace();
  617. }
  618. }
  619. entity.setSummary_remain_time(DateUtil.getTimeDiff(
  620. approve.getCreate_time(),
  621. dealTime,
  622. days,
  623. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  624. ));
  625. }
  626. //会审剩余时间
  627. approval = new Approval();
  628. approval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY);
  629. approval.setApply_id(Integer.parseInt(id));
  630. approvalList = approvalService.findListByWhere(approval);
  631. if (!CollectionUtils.isEmpty(approvalList)) {
  632. Approval approve = approvalList.get(approvalList.size() - 1);
  633. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(JOINT_TRIAL_TIME));
  634. // entity.setJoint_trial_remain_time(DateUtil.getTimeDiffStr(approve.getCreate_time(), days));
  635. String dealTime = null;
  636. approval = new Approval();
  637. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  638. approval.setApply_id(Integer.parseInt(id));
  639. List<Approval> approvals = approvalService.findListByWhere(approval);
  640. if (!CollectionUtils.isEmpty(approvals)) {
  641. dealTime = approvals.get(approvals.size() - 1).getCreate_time();
  642. try {
  643. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  644. Date d2 = DateUtil.parseTimeStringToDate(dealTime, "yyyy-MM-dd hh:mm:ss");
  645. if (d2.before(d1)) {
  646. dealTime = null;
  647. }
  648. } catch (ParseException e) {
  649. e.printStackTrace();
  650. }
  651. }
  652. entity.setSummary_remain_time(DateUtil.getTimeDiff(
  653. approve.getCreate_time(),
  654. dealTime,
  655. days,
  656. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  657. ));
  658. }
  659. List<DepartmentDto> consulDepartmentList = new ArrayList<>();
  660. List<Department> departmentList = consulDepartmentList();
  661. if (!CollectionUtils.isEmpty(departmentList)) {
  662. for (Department department : departmentList) {
  663. DepartmentDto departmentDto = new DepartmentDto();
  664. BeanUtils.copyProperties(department, departmentDto);
  665. departmentDto.setIsDefault(false);
  666. for (IndustrialLandSupplyConsultation landSupplyConsultation : industrialLandSupplyConsultationList) {
  667. if (Objects.equals(departmentDto.getId() + "", landSupplyConsultation.getDepartment_id())
  668. && landSupplyConsultation.getIsDefault()) {
  669. departmentDto.setIsDefault(true);
  670. break;
  671. }
  672. }
  673. consulDepartmentList.add(departmentDto);
  674. }
  675. }
  676. entity.setConsulDepartmentList(consulDepartmentList);
  677. //获取商务和商务分管领导审批意见
  678. // Group group = null;
  679. // List<Approval> approvals = null;
  680. // group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_1, null);
  681. // List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  682. //目前都只有一个人
  683. // if (!CollectionUtils.isEmpty(userGroups)) {
  684. //
  685. // Example example = new Example(Approval.class);
  686. // Example.Criteria criteria = example.createCriteria();
  687. // criteria.andEqualTo("apply_id", id);
  688. // criteria.andEqualTo("type", Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  689. // criteria.andEqualTo("after_approvalstatus", Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  690. // criteria.andEqualTo("checker", userGroups.get(0).getUser_id());
  691. // example.orderBy("create_time").desc();
  692. // approvals = approvalService.selectByExample(example);
  693. // if (!CollectionUtils.isEmpty(approvals)) {
  694. // Approval approval = approvals.get(0);
  695. // approval.getOper_type();
  696. // approval.getApproval_comment();
  697. // }
  698. // }
  699. return entity;
  700. }
  701. public IndustrialLandSupplyDetail selectByIdWithDepartment(String id) throws ParseException {
  702. IndustrialLandSupplyDetail entity = industrialLandSupplyDetailDao.selectById(id);
  703. //文件
  704. List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, entity.getId(), null);
  705. if (null != attachments && attachments.size() > 0) {
  706. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  707. entity.setFileDown(fileDown);
  708. }
  709. //补充附件
  710. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_COMMERCE_SUPPLEMENT, entity.getId(), null);
  711. if (null != attachments && attachments.size() > 0) {
  712. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  713. entity.setSupplement_file(fileDown);
  714. }
  715. if (null != entity.getApprove_status()) {
  716. String status_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY_APPROVE_STATUS, entity.getApprove_status());
  717. entity.setApprove_status_desc(status_name);
  718. }
  719. if (null != entity.getProcess_stage()) {
  720. String process_stage_name = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY_APPROVE_STAGE, entity.getProcess_stage());
  721. entity.setProcess_stage_desc(process_stage_name);
  722. }
  723. User user = userService.getUser(entity.getCreate_by());
  724. if (CommonUtils.isNotNull(user) && Constant.UserType.STREET.equals(user.getUser_type())) {
  725. entity.setResource(user.getStreet_name());
  726. } else if (CommonUtils.isNotNull(user) && Constant.UserType.GOVERNMENT.equals(user.getUser_type())) {
  727. entity.setResource(user.getDepartment_name());
  728. }
  729. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  730. industrialLandSupplyConsultation.setIndustrial_land_supply_id(id);
  731. //industrialLandSupplyConsultation.setDepartment_id(ShiroUtils.getUserEntity().getDepartment_id() + "");
  732. Department department = departmentService.findRootById(ShiroUtils.getUserEntity().getDepartment_id());
  733. industrialLandSupplyConsultation.setDepartment_id(department.getId() + "");
  734. industrialLandSupplyConsultation.setDel_flag(false);
  735. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  736. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  737. for (IndustrialLandSupplyConsultation landSupplyConsultation : industrialLandSupplyConsultationList) {
  738. //文件
  739. List<Attachment> feedbackAttachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_FEEDBACK, landSupplyConsultation.getId(), null);
  740. if (null != feedbackAttachments && feedbackAttachments.size() > 0) {
  741. FileDown fileDown = new FileDown(feedbackAttachments.get(0).getId(), feedbackAttachments.get(0).getFile_name(), feedbackAttachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  742. landSupplyConsultation.setFileDown(fileDown);
  743. }
  744. Department depart = departmentService.selectById(Integer.valueOf(landSupplyConsultation.getDepartment_id()));
  745. landSupplyConsultation.setDepartment_name(depart.getName());
  746. //是否同意
  747. if (landSupplyConsultation.getIsAgree() != null) {
  748. String feedback = landSupplyConsultation.getFeedback();
  749. String str = "";
  750. if (landSupplyConsultation.getIsAgree()) {
  751. str = "同意。";
  752. } else {
  753. str = "不同意。";
  754. }
  755. landSupplyConsultation.setFeedback(str + feedback);
  756. }
  757. //剩余时间
  758. landSupplyConsultation.setRemain_time(DateUtil.getTimeDiff(
  759. landSupplyConsultation.getCreate_time(),
  760. landSupplyConsultation.getUpdate_time(),
  761. days,
  762. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  763. ));
  764. }
  765. entity.setConsultationList(industrialLandSupplyConsultationList);
  766. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = new IndustrialLandSupplyDistribution();
  767. industrialLandSupplyDistribution.setIndustrial_land_supply_id(id);
  768. //industrialLandSupplyDistribution.setDepartment_id(ShiroUtils.getUserEntity().getDepartment_id() + "");
  769. industrialLandSupplyDistribution.setDepartment_id(department.getId() + "");
  770. industrialLandSupplyDistribution.setDel_flag(false);
  771. List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = industrialLandSupplyDistributionService.findListByWhere(industrialLandSupplyDistribution);
  772. days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(DISTRIBUTE_TIME));
  773. for (IndustrialLandSupplyDistribution landSupplyDistribution : industrialLandSupplyDistributionList) {
  774. //文件
  775. List<Attachment> attachmentList = null;
  776. //分发文件
  777. attachmentList = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE, landSupplyDistribution.getId(), null);
  778. if (null != attachmentList && attachmentList.size() > 0) {
  779. FileDown fileDown = new FileDown(attachmentList.get(0).getId(), attachmentList.get(0).getFile_name(), attachmentList.get(0).getFile_url(), attachmentList.get(0).getDownload_uri());
  780. landSupplyDistribution.setDistribution_file(fileDown);
  781. }
  782. //分发反馈文件
  783. attachmentList = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_FEEDBACK, landSupplyDistribution.getId(), null);
  784. if (null != attachmentList && attachmentList.size() > 0) {
  785. FileDown fileDown = new FileDown(attachmentList.get(0).getId(), attachmentList.get(0).getFile_name(), attachmentList.get(0).getFile_url(), attachmentList.get(0).getDownload_uri());
  786. landSupplyDistribution.setFeedback_file(fileDown);
  787. }
  788. Department depart = departmentService.selectById(Integer.valueOf(landSupplyDistribution.getDepartment_id()));
  789. landSupplyDistribution.setDepartment_name(depart.getName());
  790. //剩余时间
  791. /*landSupplyDistribution.setRemain_time(DateUtil.getTimeDiff(
  792. landSupplyDistribution.getCreate_time(),
  793. landSupplyDistribution.getUpdate_time(),
  794. days,
  795. sysConfigService.getValueByKey("year_" + DateUtil.getCurrentDateString("yyyy"))
  796. ));*/
  797. }
  798. entity.setDistributionList(industrialLandSupplyDistributionList);
  799. return entity;
  800. }
  801. /**
  802. * @Author: huZhiHao
  803. * @Description: 根据用户组获取可查询到的项目
  804. * @Date: 2020/3/7
  805. * @Params: []
  806. * @Return: java.util.List<java.lang.String>
  807. **/
  808. @Transactional
  809. public List<String> getProjectIdsByGroup() {
  810. List<IndustrialLandSupplyDetail> list = new ArrayList<>();
  811. Integer user_id = ShiroUtils.getUserId();
  812. Group group = null;
  813. List<UserGroup> userGroups = null;
  814. List<String> apply_status_list = new ArrayList<>();
  815. boolean industriallandsupply_2_flag = false;
  816. boolean industriallandsupply_5_flag = false;
  817. boolean industriallandsupply_6_flag = false;
  818. //街道人员 负责的状态
  819. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  820. apply_status_list.add(Constant.LandSupplyApproveStatus.PLATE_PENDING_SUBMIT);
  821. apply_status_list.add(Constant.LandSupplyApproveStatus.PLATE_WITHDRAW);
  822. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_RETURN);
  823. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  824. //商务局受理员 负责的状态
  825. group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_1, null);
  826. userGroups = userGroupService.findByGroupId(group.getId());
  827. for (UserGroup userGroup : userGroups) {
  828. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  829. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  830. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  831. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  832. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  833. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_RETURN);
  834. apply_status_list.add(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_RETURN);
  835. break;
  836. }
  837. }
  838. //接受咨询的举办 负责的状态
  839. group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_2, null);
  840. userGroups = userGroupService.findByGroupId(group.getId());
  841. for (UserGroup userGroup : userGroups) {
  842. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  843. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  844. industriallandsupply_2_flag = true;
  845. break;
  846. }
  847. }
  848. //商务局分管领导 负责的状态
  849. group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_3, null);
  850. userGroups = userGroupService.findByGroupId(group.getId());
  851. for (UserGroup userGroup : userGroups) {
  852. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  853. apply_status_list.add(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  854. break;
  855. }
  856. }
  857. //管委会分管领导 负责的状态
  858. group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_4, null);
  859. userGroups = userGroupService.findByGroupId(group.getId());
  860. for (UserGroup userGroup : userGroups) {
  861. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  862. apply_status_list.add(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  863. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  864. break;
  865. }
  866. }
  867. //项目供地 待分发局办
  868. group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_5, null);
  869. userGroups = userGroupService.findByGroupId(group.getId());
  870. for (UserGroup userGroup : userGroups) {
  871. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  872. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  873. industriallandsupply_5_flag = true;
  874. break;
  875. }
  876. }
  877. //项目供地 行政局反馈
  878. group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_6, null);
  879. userGroups = userGroupService.findByGroupId(group.getId());
  880. for (UserGroup userGroup : userGroups) {
  881. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  882. apply_status_list.add(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE);
  883. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  884. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  885. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS);
  886. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_REJECT);
  887. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY);
  888. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_RETURN);
  889. industriallandsupply_6_flag = true;
  890. break;
  891. }
  892. }
  893. //项目供地 资源规划局
  894. group = groupService.findByName(Constant.INDUSTRIALLANDSUPPLY_7, null);
  895. userGroups = userGroupService.findByGroupId(group.getId());
  896. for (UserGroup userGroup : userGroups) {
  897. if (Objects.equals(userGroup.getUser_id(), user_id)) {
  898. apply_status_list.add(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE);
  899. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY);
  900. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS);
  901. apply_status_list.add(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_RETURN);
  902. break;
  903. }
  904. }
  905. //todo 后续角色的待审批状态在此添加
  906. }
  907. if (apply_status_list.size() <= 0) {
  908. apply_status_list.add("");
  909. }
  910. list.addAll(industrialLandSupplyDetailDao.findByProjectIdAndApproveStatus(apply_status_list));
  911. List<Approval> consulApprovalList = new ArrayList<>();
  912. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = new ArrayList<>();
  913. List<Approval> distApprovalList = new ArrayList<>();
  914. List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = new ArrayList<>();
  915. if (industriallandsupply_2_flag) {
  916. Approval approval = new Approval();
  917. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  918. approval.setChecker(user_id);
  919. consulApprovalList = approvalService.findListByWhere(approval);
  920. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  921. //industrialLandSupplyConsultation.setDepartment_id(ShiroUtils.getUserEntity().getDepartment_id() + "");
  922. Department department = departmentService.findRootById(ShiroUtils.getUserEntity().getDepartment_id());
  923. industrialLandSupplyConsultation.setDepartment_id(department.getId() + "");
  924. industrialLandSupplyConsultation.setDel_flag(false);
  925. industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  926. }
  927. if (industriallandsupply_5_flag) {
  928. Approval approval = new Approval();
  929. approval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  930. approval.setChecker(user_id);
  931. distApprovalList = approvalService.findListByWhere(approval);
  932. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = new IndustrialLandSupplyDistribution();
  933. //industrialLandSupplyDistribution.setDepartment_id(ShiroUtils.getUserEntity().getDepartment_id() + "");
  934. Department department = departmentService.findRootById(ShiroUtils.getUserEntity().getDepartment_id());
  935. industrialLandSupplyDistribution.setDepartment_id(department.getId() + "");
  936. industrialLandSupplyDistribution.setDel_flag(false);
  937. industrialLandSupplyDistributionList = industrialLandSupplyDistributionService.findListByWhere(industrialLandSupplyDistribution);
  938. }
  939. List<String> result = new ArrayList<>();
  940. for (IndustrialLandSupplyDetail entity : list) {
  941. if (
  942. Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK, entity.getApprove_status())
  943. || Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK, entity.getApprove_status())
  944. ) {
  945. if (industriallandsupply_2_flag || industriallandsupply_5_flag) {
  946. //是否被问
  947. boolean consulFlag = false;
  948. for (IndustrialLandSupplyConsultation industrialLandSupplyConsultation : industrialLandSupplyConsultationList) {
  949. if (Objects.equals(entity.getId() + "", industrialLandSupplyConsultation.getIndustrial_land_supply_id())) {
  950. consulFlag = true;
  951. break;
  952. }
  953. }
  954. //是否回答
  955. boolean consulApproveFlag = false;
  956. for (Approval approval : consulApprovalList) {
  957. if (Objects.equals(entity.getId(), approval.getApply_id())) {
  958. try {
  959. if (entity.getUpdate_time() == null) {
  960. entity.setUpdate_time("1970-01-01 00:00:00");
  961. }
  962. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  963. Date d2 = DateUtil.parseTimeStringToDate(approval.getCreate_time(), "yyyy-MM-dd hh:mm:ss");
  964. if (d1.before(d2)) {
  965. consulApproveFlag = true;
  966. break;
  967. }
  968. } catch (ParseException e) {
  969. e.printStackTrace();
  970. }
  971. }
  972. }
  973. //是否被问
  974. boolean distFlag = false;
  975. for (IndustrialLandSupplyDistribution industrialLandSupplyDistribution : industrialLandSupplyDistributionList) {
  976. if (Objects.equals(entity.getId() + "", industrialLandSupplyDistribution.getIndustrial_land_supply_id())) {
  977. distFlag = true;
  978. break;
  979. }
  980. }
  981. //是否回答
  982. boolean distApproveFlag = false;
  983. for (Approval approval : distApprovalList) {
  984. if (Objects.equals(entity.getId(), approval.getApply_id())) {
  985. try {
  986. Date d1 = DateUtil.parseTimeStringToDate(entity.getUpdate_time(), "yyyy-MM-dd hh:mm:ss");
  987. Date d2 = DateUtil.parseTimeStringToDate(approval.getCreate_time(), "yyyy-MM-dd hh:mm:ss");
  988. if (d1.before(d2)) {
  989. distApproveFlag = true;
  990. break;
  991. }
  992. } catch (ParseException e) {
  993. e.printStackTrace();
  994. }
  995. }
  996. }
  997. if ((consulFlag && !consulApproveFlag) || (distFlag && !distApproveFlag)) {
  998. result.add(entity.getId().toString());
  999. }
  1000. } else {
  1001. result.add(entity.getId().toString());
  1002. }
  1003. } else if (industriallandsupply_6_flag) {
  1004. List<Attachment> attachmentList = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_GS, entity.getId(), null);
  1005. if (CommonUtils.isNull(entity.getGs_feedback()) && CollectionUtils.isEmpty(attachmentList)) {
  1006. result.add(entity.getId().toString());
  1007. }
  1008. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS, entity.getApprove_status())) {
  1009. if (CommonUtils.isNull(entity.getFinal_result())) {
  1010. result.add(entity.getId().toString());
  1011. }
  1012. } else {
  1013. result.add(entity.getId().toString());
  1014. }
  1015. }
  1016. return result;
  1017. }
  1018. /**
  1019. * @Author: huZhiHao
  1020. * @Description: 获取id 已处理
  1021. * @Date: 2020/3/7
  1022. * @Params: []
  1023. * @Return: java.util.List<java.lang.String>
  1024. **/
  1025. @Transactional
  1026. public List<String> getProjectIdsy() {
  1027. int currentUserId = ShiroUtils.getUserId();
  1028. List<Approval> approvalList = approvalService.selectAllApproval(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  1029. Set<String> applyIds = new HashSet<String>();
  1030. if (!CollectionUtils.isEmpty(approvalList)) {
  1031. for (Approval approval : approvalList) {
  1032. String checkerIds = approval.getChecker() + "";
  1033. if (checkerIds != null && checkerIds != "") {
  1034. if (Objects.equals(checkerIds, String.valueOf(currentUserId))) {
  1035. applyIds.add(approval.getApply_id().toString());
  1036. }
  1037. }
  1038. }
  1039. }
  1040. List<String> result = new ArrayList<>(applyIds);
  1041. return result;
  1042. }
  1043. /**
  1044. * @Author: huZhiHao
  1045. * @Description: 获取id 查看所有
  1046. * @Date: 2020/3/7
  1047. * @Params: []
  1048. * @Return: java.util.List<java.lang.String>
  1049. **/
  1050. @Transactional
  1051. public List<String> getProjectIdsc() {
  1052. //根据当前登录人所在街道 查出该街道所有人员的id 将此id列表作为create_by筛选条件
  1053. List<String> result = new ArrayList<>();
  1054. Example example = new Example(IndustrialLandSupplyDetail.class);
  1055. Example.Criteria criteria = example.createCriteria();
  1056. criteria.orEqualTo("del_flag", "0");//不显示删除的
  1057. // List<String> streetUserIds = new ArrayList<>();
  1058. // if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  1059. // List<User> userList = userService.findUsersByStreetId(ShiroUtils.getStreetId());
  1060. // for (User user : userList) {
  1061. // streetUserIds.add(user.getId() + "");
  1062. // }
  1063. // criteria.andIn("create_by", streetUserIds);
  1064. // }
  1065. List<IndustrialLandSupplyDetail> list = industrialLandSupplyDetailDao.selectByExample(example);
  1066. for (IndustrialLandSupplyDetail entity : list) {
  1067. result.add(entity.getId().toString());
  1068. }
  1069. return result;
  1070. }
  1071. /**
  1072. * @Author: huZhiHao
  1073. * @Description: 保存
  1074. * @Date: 2020/3/7
  1075. * @Params: [apply, status]
  1076. * @Return: void
  1077. **/
  1078. @Transactional
  1079. public void save(IndustrialLandSupplyDetail apply, String status) {
  1080. Integer userType = ShiroUtils.getUserType();
  1081. if (Objects.equals(status, Constant.PublishStatus.DRAFT)) {
  1082. if (Constant.UserType.STREET.equals(userType)) {
  1083. apply.setApprove_status(Constant.LandSupplyApproveStatus.PLATE_PENDING_SUBMIT);
  1084. } else if (Constant.UserType.GOVERNMENT.equals(userType)) {
  1085. apply.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  1086. }
  1087. } else if (Objects.equals(status, Constant.PublishStatus.RELEASE)) {
  1088. if (Constant.UserType.STREET.equals(userType)) {
  1089. apply.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1090. } else if (Constant.UserType.GOVERNMENT.equals(userType)) {
  1091. apply.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1092. }
  1093. }
  1094. apply.setNo(GenerateNoUtil.generateIndustrialLandSupplyNo());
  1095. //如果是发布,更新时间
  1096. String dateTime = DateUtil.getTimeString(new Date());
  1097. if (Constant.PublishStatus.RELEASE.equals(status)) {
  1098. apply.setAccept_date(dateTime);
  1099. }
  1100. this.insertAndGetId(apply);
  1101. //保存材料
  1102. // if (null != apply.getFileDown() && null != apply.getFileDown().getFile_id()) {
  1103. // attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, apply.getId(), apply.getFileDown().getFile_id());
  1104. // }
  1105. if (!CollectionUtils.isEmpty(apply.getFileList())) {
  1106. for (FileDown fileDown : apply.getFileList()) {
  1107. if (null != fileDown && null != fileDown.getFile_id()) {
  1108. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, apply.getId(), fileDown.getFile_id());
  1109. }
  1110. }
  1111. }
  1112. //保存默认咨询列表
  1113. List<String> defaultList = apply.getDefaultList();
  1114. if (!CollectionUtils.isEmpty(defaultList)) {
  1115. for (String departmentId : defaultList) {
  1116. if (departmentId != null && departmentId != "") {
  1117. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1118. industrialLandSupplyConsultation.setIsDefault(true);
  1119. industrialLandSupplyConsultation.setIndustrial_land_supply_id(apply.getId() + "");
  1120. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  1121. industrialLandSupplyConsultation.setDepartment_id(departmentId);
  1122. industrialLandSupplyConsultation.setConsultation(CONSULTATION_MESSAGE);
  1123. industrialLandSupplyConsultationService.save(industrialLandSupplyConsultation);
  1124. }
  1125. }
  1126. }
  1127. //保存咨询列表
  1128. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = apply.getConsultationList();
  1129. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  1130. Iterator<IndustrialLandSupplyConsultation> it = industrialLandSupplyConsultationList.iterator();
  1131. while (it.hasNext()) {
  1132. if (CommonUtils.isNull(it.next().getConsultation())) {
  1133. it.remove();
  1134. }
  1135. }
  1136. for (IndustrialLandSupplyConsultation industrialLandSupplyConsultation : industrialLandSupplyConsultationList) {
  1137. industrialLandSupplyConsultation.setIsDefault(false);
  1138. industrialLandSupplyConsultation.setIndustrial_land_supply_id(apply.getId() + "");
  1139. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  1140. }
  1141. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  1142. industrialLandSupplyConsultationService.saveList(industrialLandSupplyConsultationList);
  1143. }
  1144. }
  1145. //如果是发布,进提交流程
  1146. if (Constant.PublishStatus.RELEASE.equals(status)) {
  1147. //直接提交申请,添加流程信息
  1148. pass(apply.getId(), null);
  1149. }
  1150. }
  1151. /**
  1152. * @Author: huZhiHao
  1153. * @Description: 修改
  1154. * @Date: 2020/3/7
  1155. * @Params: [apply, status]
  1156. * @Return: void
  1157. **/
  1158. @Transactional
  1159. public Integer update(IndustrialLandSupplyDetail apply, String status) {
  1160. Integer userType = ShiroUtils.getUserType();
  1161. if (Objects.equals(status, Constant.PublishStatus.DRAFT)) {
  1162. if (Constant.UserType.STREET.equals(userType)) {
  1163. apply.setApprove_status(Constant.LandSupplyApproveStatus.PLATE_PENDING_SUBMIT);
  1164. } else if (Constant.UserType.GOVERNMENT.equals(userType)) {
  1165. apply.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  1166. }
  1167. } else if (Objects.equals(status, Constant.PublishStatus.RELEASE)) {
  1168. if (Constant.UserType.STREET.equals(userType)) {
  1169. apply.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1170. } else if (Constant.UserType.GOVERNMENT.equals(userType)) {
  1171. apply.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1172. }
  1173. }
  1174. //如果是发布,更新时间
  1175. if (Constant.PublishStatus.RELEASE.equals(status)) {
  1176. apply.setAccept_date(DateUtil.getTimeString(new Date()));
  1177. }
  1178. this.updateSelective(apply);
  1179. Integer id = apply.getId();
  1180. //保存材料
  1181. // if (null != apply.getFileDown() && null != apply.getFileDown().getFile_id()) {
  1182. // attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, apply.getId());
  1183. // attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, apply.getId(), apply.getFileDown().getFile_id());
  1184. // }
  1185. if (!CollectionUtils.isEmpty(apply.getFileList())) {
  1186. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, apply.getId());
  1187. for (FileDown fileDown : apply.getFileList()) {
  1188. if (null != fileDown && null != fileDown.getFile_id()) {
  1189. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY, apply.getId(), fileDown.getFile_id());
  1190. }
  1191. }
  1192. }
  1193. //保存咨询列表
  1194. String dateTime = DateUtil.getTimeString(new Date());
  1195. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = apply.getConsultationList();
  1196. List<String> defaultList = apply.getDefaultList();
  1197. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList) && !CollectionUtils.isEmpty(defaultList)) {
  1198. //过滤空的
  1199. Iterator<IndustrialLandSupplyConsultation> it = industrialLandSupplyConsultationList.iterator();
  1200. while (it.hasNext()) {
  1201. if (CommonUtils.isNull(it.next().getConsultation())) {
  1202. it.remove();
  1203. }
  1204. }
  1205. for (IndustrialLandSupplyConsultation industrialLandSupplyConsultation : industrialLandSupplyConsultationList) {
  1206. industrialLandSupplyConsultation.setIsDefault(false);
  1207. industrialLandSupplyConsultation.setIndustrial_land_supply_id(apply.getId() + "");
  1208. if (industrialLandSupplyConsultation.getId() != null) {
  1209. IndustrialLandSupplyConsultation industrialLandSupplyConsultation1 = industrialLandSupplyConsultationService.findById(industrialLandSupplyConsultation.getId());
  1210. //如果问的问题没变则保留id等信息 不然作为新的处理
  1211. if (Objects.equals(industrialLandSupplyConsultation1.getConsultation(), industrialLandSupplyConsultation.getConsultation())) {
  1212. BeanUtils.copyProperties(industrialLandSupplyConsultation1, industrialLandSupplyConsultation);
  1213. }
  1214. }
  1215. if (CommonUtils.isNull(industrialLandSupplyConsultation.getConsultation_time())) {
  1216. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  1217. }
  1218. }
  1219. IndustrialLandSupplyConsultation query = new IndustrialLandSupplyConsultation();
  1220. query.setIndustrial_land_supply_id(apply.getId() + "");
  1221. industrialLandSupplyConsultationService.deleteByWhere(query);
  1222. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  1223. industrialLandSupplyConsultationService.saveList(industrialLandSupplyConsultationList);
  1224. }
  1225. //保存默认咨询列表
  1226. if (!CollectionUtils.isEmpty(defaultList)) {
  1227. for (String departmentId : defaultList) {
  1228. if (departmentId != null && departmentId != "") {
  1229. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1230. industrialLandSupplyConsultation.setIsDefault(true);
  1231. industrialLandSupplyConsultation.setIndustrial_land_supply_id(apply.getId() + "");
  1232. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  1233. industrialLandSupplyConsultation.setDepartment_id(departmentId);
  1234. industrialLandSupplyConsultation.setConsultation(CONSULTATION_MESSAGE);
  1235. industrialLandSupplyConsultationService.save(industrialLandSupplyConsultation);
  1236. }
  1237. }
  1238. }
  1239. }
  1240. //如果是发布,进提交流程
  1241. if (Constant.PublishStatus.RELEASE.equals(status)) {
  1242. //直接提交申请,添加流程信息
  1243. pass(apply.getId(), null);
  1244. }
  1245. return id;
  1246. }
  1247. /**
  1248. * @Author: huZhiHao
  1249. * @Description: 通过
  1250. * @Date: 2020/3/7
  1251. * @Params: [applyId, comment]
  1252. * @Return: java.lang.Boolean
  1253. **/
  1254. @Transactional
  1255. public Boolean pass(Integer applyId, String comment) {
  1256. Approval approval = approvalService.getLatestApproval(applyId, Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  1257. Approval newApproval = new Approval();
  1258. newApproval.setApply_id(applyId);
  1259. newApproval.setType(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  1260. if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) {
  1261. if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) {
  1262. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  1263. newApproval.setDepartment(departmentname);
  1264. }
  1265. } else if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  1266. newApproval.setDepartment(ShiroUtils.getUserEntity().getStreet_name());
  1267. }
  1268. newApproval.setApproval_comment(comment);
  1269. newApproval.setChecker(ShiroUtils.getUserId());
  1270. newApproval.setOper_type(Constant.OperType.APPROVED);
  1271. newApproval.setDeal_time(DateUtil.getTimeString(new Date()));
  1272. //短信参数
  1273. Map<String, String> params = new HashMap<>();
  1274. IndustrialLandSupplyDetail detail = null;
  1275. try {
  1276. detail = this.selectById(applyId + "");
  1277. } catch (ParseException e) {
  1278. e.printStackTrace();
  1279. }
  1280. params.put("title", detail.getTitle());
  1281. params.put("no", detail.getNo());
  1282. String templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY;
  1283. if (CommonUtils.isNull(approval)) {
  1284. //待属地提交 --》待商务局受理员审核 或 待咨询反馈
  1285. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1286. industrialLandSupplyConsultation.setIndustrial_land_supply_id(applyId + "");
  1287. industrialLandSupplyConsultation.setDel_flag(false);
  1288. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  1289. boolean sumbitToLeader = false;
  1290. if (CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  1291. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1292. sumbitToLeader = true;
  1293. }
  1294. Group group = null;
  1295. newApproval.setOper_type(Constant.OperType.SUBMIT);
  1296. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1297. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.PLATE_PENDING_SUBMIT);
  1298. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1299. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  1300. if (null == group) {
  1301. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1302. }
  1303. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1304. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  1305. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1306. if (!sumbitToLeader) {
  1307. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1308. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  1309. if (null == group) {
  1310. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1311. }
  1312. } else {
  1313. //newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1314. //临时跳过商务领导审核
  1315. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1316. //group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_3);
  1317. //临时跳过商务领导审核
  1318. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  1319. if (null == group) {
  1320. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1321. //临时跳过商务领导审核
  1322. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1323. }
  1324. }
  1325. }
  1326. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1327. List<User> users = userService.findListByWhere(new User());
  1328. StringBuffer sb = new StringBuffer("");
  1329. // platform.modules.build.entity.Company company = companyService.findById(projectApplication.getCompany_id());
  1330. // String projectName = projectProvincesDeclaration.getProject_name();
  1331. // Message messages = new Message();
  1332. // messages.setApply_id(projectId);
  1333. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  1334. // messages.setTitle("提醒中心审核");
  1335. // waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  1336. for (UserGroup userGroup : userGroups) {
  1337. for (User user : users) {
  1338. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1339. if (newApproval.getAfter_approvalstatus().equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK)) {
  1340. List<IndustrialLandSupplyConsultation> ids = detail.getConsultationList();
  1341. for (IndustrialLandSupplyConsultation ilsc : ids) {
  1342. if (Objects.equals(user.getDepartment_id() + "", ilsc.getDepartment_id())) {
  1343. sb.append(userGroup.getUser_id() + ",");
  1344. if (Objects.equals(ilsc.getConsultation(), CONSULTATION_MESSAGE)) {
  1345. }
  1346. //发送短信
  1347. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_CONSUL;
  1348. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  1349. params.put("days", days + "");
  1350. try {
  1351. AlibabaSMSUtil.sendSMS(
  1352. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1353. );
  1354. } catch (Exception e) {
  1355. e.printStackTrace();
  1356. }
  1357. break;
  1358. }
  1359. }
  1360. } else {
  1361. sb.append(userGroup.getUser_id() + ",");
  1362. //发送短信
  1363. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_COMMERE;
  1364. try {
  1365. AlibabaSMSUtil.sendSMS(
  1366. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1367. );
  1368. } catch (Exception e) {
  1369. e.printStackTrace();
  1370. }
  1371. }
  1372. // String message = user.getUser_name() +0 ",您好。“" + company.getCompany_name() + "企业”的“" + projectName + "项目”申请需要您审核。谢谢。";
  1373. // messages.setContent(message);
  1374. // int[] streetArrInt = new int[1];
  1375. // streetArrInt[0] = userGroup.getUser_id();
  1376. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.GOVERNMENT);
  1377. // waitToDoService.newTODO("区级智能制造审核", "/government/projectIntelligent/approve/" + projectApplication.getId(), Constant.WaitToDo_OperType.AUDIT, projectApplication.getId(),
  1378. // Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), userGroup.getUser_id().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  1379. }
  1380. }
  1381. }
  1382. newApproval.setNextchecker(sb.toString());
  1383. if (sb.length() == 0) {
  1384. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1385. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1386. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1387. if (!sumbitToLeader) {
  1388. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1389. } else {
  1390. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1391. //临时跳过商务领导审核
  1392. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1393. }
  1394. }
  1395. }
  1396. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1397. entity.setId(applyId);
  1398. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1399. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1400. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1401. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1402. if (!sumbitToLeader) {
  1403. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1404. } else {
  1405. //entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1406. //临时跳过商务领导审核
  1407. entity.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1408. }
  1409. }
  1410. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  1411. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1412. approvalService.insertAndGetId(newApproval);
  1413. return true;
  1414. } else if (Objects.equals(Constant.LandSupplyApproveStatus.PLATE_WITHDRAW, approval.getAfter_approvalstatus())) {
  1415. //属地撤回 --》待商务局受理员审核 或 待咨询反馈
  1416. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1417. industrialLandSupplyConsultation.setIndustrial_land_supply_id(applyId + "");
  1418. industrialLandSupplyConsultation.setDel_flag(false);
  1419. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  1420. boolean sumbitToLeader = false;
  1421. if (CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  1422. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1423. sumbitToLeader = true;
  1424. }
  1425. Group group = null;
  1426. newApproval.setOper_type(Constant.OperType.SUBMIT);
  1427. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1428. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.PLATE_WITHDRAW);
  1429. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1430. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  1431. if (null == group) {
  1432. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1433. }
  1434. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1435. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  1436. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1437. if (!sumbitToLeader) {
  1438. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1439. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  1440. if (null == group) {
  1441. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1442. }
  1443. } else {
  1444. //newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1445. //临时跳过商务领导审核
  1446. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1447. //group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_3);
  1448. //临时跳过商务领导审核
  1449. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  1450. if (null == group) {
  1451. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1452. //临时跳过商务领导审核
  1453. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1454. }
  1455. }
  1456. }
  1457. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1458. List<User> users = userService.findListByWhere(new User());
  1459. StringBuffer sb = new StringBuffer("");
  1460. for (UserGroup userGroup : userGroups) {
  1461. for (User user : users) {
  1462. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1463. if (newApproval.getAfter_approvalstatus().equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK)) {
  1464. List<IndustrialLandSupplyConsultation> ids = detail.getConsultationList();
  1465. for (IndustrialLandSupplyConsultation ilsc : ids) {
  1466. if (Objects.equals(user.getDepartment_id() + "", ilsc.getDepartment_id())) {
  1467. sb.append(userGroup.getUser_id() + ",");
  1468. //发送短信
  1469. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_CONSUL;
  1470. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  1471. params.put("days", days + "");
  1472. try {
  1473. AlibabaSMSUtil.sendSMS(
  1474. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1475. );
  1476. } catch (Exception e) {
  1477. e.printStackTrace();
  1478. }
  1479. break;
  1480. }
  1481. }
  1482. } else {
  1483. sb.append(userGroup.getUser_id() + ",");
  1484. //发送短信
  1485. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_COMMERE;
  1486. try {
  1487. AlibabaSMSUtil.sendSMS(
  1488. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1489. );
  1490. } catch (Exception e) {
  1491. e.printStackTrace();
  1492. }
  1493. }
  1494. }
  1495. }
  1496. }
  1497. newApproval.setNextchecker(sb.toString());
  1498. if (sb.length() == 0) {
  1499. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1500. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1501. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1502. if (!sumbitToLeader) {
  1503. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1504. } else {
  1505. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1506. //临时跳过商务领导审核
  1507. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1508. }
  1509. }
  1510. }
  1511. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1512. entity.setId(applyId);
  1513. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1514. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1515. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1516. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1517. if (!sumbitToLeader) {
  1518. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1519. } else {
  1520. //entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1521. //临时跳过商务领导审核
  1522. entity.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1523. }
  1524. }
  1525. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  1526. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1527. approvalService.insertAndGetId(newApproval);
  1528. return true;
  1529. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT, approval.getAfter_approvalstatus())) {
  1530. //商务局受理员待提交--》待商务局受理员审核 或 待咨询反馈
  1531. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1532. industrialLandSupplyConsultation.setIndustrial_land_supply_id(applyId + "");
  1533. industrialLandSupplyConsultation.setDel_flag(false);
  1534. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  1535. boolean sumbitToLeader = false;
  1536. if (CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  1537. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1538. sumbitToLeader = true;
  1539. }
  1540. Group group = null;
  1541. newApproval.setOper_type(Constant.OperType.SUBMIT);
  1542. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1543. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  1544. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1545. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  1546. if (null == group) {
  1547. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1548. }
  1549. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1550. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  1551. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1552. if (!sumbitToLeader) {
  1553. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1554. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  1555. if (null == group) {
  1556. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1557. }
  1558. } else {
  1559. //newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1560. //临时跳过商务领导审核
  1561. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1562. //group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_3);
  1563. //临时跳过商务领导审核
  1564. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  1565. if (null == group) {
  1566. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1567. //临时跳过商务领导审核
  1568. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1569. }
  1570. }
  1571. }
  1572. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1573. List<User> users = userService.findListByWhere(new User());
  1574. StringBuffer sb = new StringBuffer("");
  1575. for (UserGroup userGroup : userGroups) {
  1576. for (User user : users) {
  1577. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1578. if (newApproval.getAfter_approvalstatus().equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK)) {
  1579. List<IndustrialLandSupplyConsultation> ids = detail.getConsultationList();
  1580. for (IndustrialLandSupplyConsultation ilsc : ids) {
  1581. if (Objects.equals(user.getDepartment_id() + "", ilsc.getDepartment_id())) {
  1582. sb.append(userGroup.getUser_id() + ",");
  1583. //发送短信
  1584. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_CONSUL;
  1585. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  1586. params.put("days", days + "");
  1587. try {
  1588. AlibabaSMSUtil.sendSMS(
  1589. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1590. );
  1591. } catch (Exception e) {
  1592. e.printStackTrace();
  1593. }
  1594. break;
  1595. }
  1596. }
  1597. } else {
  1598. sb.append(userGroup.getUser_id() + ",");
  1599. //发送短信
  1600. try {
  1601. AlibabaSMSUtil.sendSMS(
  1602. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1603. );
  1604. } catch (Exception e) {
  1605. e.printStackTrace();
  1606. }
  1607. }
  1608. }
  1609. }
  1610. }
  1611. newApproval.setNextchecker(sb.toString());
  1612. if (sb.length() == 0) {
  1613. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1614. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1615. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1616. if (!sumbitToLeader) {
  1617. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1618. } else {
  1619. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1620. //临时跳过商务领导审核
  1621. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1622. }
  1623. }
  1624. }
  1625. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1626. entity.setId(applyId);
  1627. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  1628. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1629. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  1630. //如果提交了咨询信息进入待反馈 未提交直接进入商务局分管领导审核
  1631. if (!sumbitToLeader) {
  1632. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1633. } else {
  1634. //entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1635. //临时跳过商务领导审核
  1636. entity.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1637. }
  1638. }
  1639. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  1640. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1641. approvalService.insertAndGetId(newApproval);
  1642. return true;
  1643. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  1644. //待商务局受理员审核 --》 待咨询反馈 或 管委会领导审核
  1645. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1646. industrialLandSupplyConsultation.setIndustrial_land_supply_id(applyId + "");
  1647. industrialLandSupplyConsultation.setDel_flag(false);
  1648. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  1649. boolean sumbitToLeader = false;
  1650. if (CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  1651. sumbitToLeader = true;
  1652. }
  1653. Group group = null;
  1654. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1655. if (sumbitToLeader) {
  1656. newApproval.setOper_type(Constant.OperType.SUBMIT);
  1657. //newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1658. //临时跳过商务领导审核
  1659. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1660. //group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_3);
  1661. //临时跳过商务领导审核
  1662. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  1663. if (null == group) {
  1664. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1665. //临时跳过商务领导审核
  1666. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1667. }
  1668. } else {
  1669. newApproval.setOper_type(Constant.OperType.DISTRIBUTE);
  1670. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1671. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  1672. if (null == group) {
  1673. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1674. }
  1675. }
  1676. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1677. List<User> users = userService.findListByWhere(new User());
  1678. StringBuffer sb = new StringBuffer("");
  1679. for (UserGroup userGroup : userGroups) {
  1680. for (User user : users) {
  1681. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1682. if (newApproval.getAfter_approvalstatus().equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK)) {
  1683. List<IndustrialLandSupplyConsultation> ids = detail.getConsultationList();
  1684. for (IndustrialLandSupplyConsultation ilsc : ids) {
  1685. if (Objects.equals(user.getDepartment_id() + "", ilsc.getDepartment_id())) {
  1686. sb.append(userGroup.getUser_id() + ",");
  1687. //发送短信
  1688. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_CONSUL;
  1689. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  1690. params.put("days", days + "");
  1691. try {
  1692. AlibabaSMSUtil.sendSMS(
  1693. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1694. );
  1695. } catch (Exception e) {
  1696. e.printStackTrace();
  1697. }
  1698. break;
  1699. }
  1700. }
  1701. } else {
  1702. sb.append(userGroup.getUser_id() + ",");
  1703. //发送短信
  1704. try {
  1705. AlibabaSMSUtil.sendSMS(
  1706. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1707. );
  1708. } catch (Exception e) {
  1709. e.printStackTrace();
  1710. }
  1711. }
  1712. }
  1713. }
  1714. }
  1715. newApproval.setNextchecker(sb.toString());
  1716. if (sumbitToLeader) {
  1717. if (sb.length() == 0) {
  1718. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1719. //临时跳过商务领导审核
  1720. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1721. }
  1722. } else {
  1723. if (sb.length() == 0) {
  1724. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1725. }
  1726. }
  1727. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1728. entity.setId(applyId);
  1729. if (sumbitToLeader) {
  1730. //entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1731. //临时跳过商务领导审核
  1732. entity.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1733. } else {
  1734. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1735. }
  1736. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  1737. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1738. approvalService.insertAndGetId(newApproval);
  1739. return true;
  1740. } else if (Objects.equals(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_RETURN, approval.getAfter_approvalstatus())) {
  1741. //预审退回 --》 待咨询反馈 或 咨询汇总
  1742. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1743. industrialLandSupplyConsultation.setIndustrial_land_supply_id(applyId + "");
  1744. industrialLandSupplyConsultation.setDel_flag(false);
  1745. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  1746. boolean sumbitToSummary = true;
  1747. for (IndustrialLandSupplyConsultation landSupplyConsultation : industrialLandSupplyConsultationList) {
  1748. //如果所有咨询都已回答 进入待汇总
  1749. if (CommonUtils.isNull(landSupplyConsultation.getFeedback()) || CommonUtils.isNull(landSupplyConsultation.getUpdate_by())) {
  1750. sumbitToSummary = false;
  1751. break;
  1752. } else {
  1753. sumbitToSummary = true;
  1754. }
  1755. }
  1756. Group group = null;
  1757. newApproval.setOper_type(Constant.OperType.SUBMIT);
  1758. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_RETURN);
  1759. if (sumbitToSummary) {
  1760. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  1761. } else {
  1762. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1763. }
  1764. if (sumbitToSummary) {
  1765. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  1766. } else {
  1767. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  1768. }
  1769. if (null == group) {
  1770. if (sumbitToSummary) {
  1771. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1772. } else {
  1773. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1774. }
  1775. }
  1776. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1777. List<User> users = userService.findListByWhere(new User());
  1778. StringBuffer sb = new StringBuffer("");
  1779. for (UserGroup userGroup : userGroups) {
  1780. for (User user : users) {
  1781. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1782. sb.append(userGroup.getUser_id() + ",");
  1783. //发送短信
  1784. if (sumbitToSummary) {
  1785. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_COMMERCE_SUMMARY;
  1786. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(SUMMARY_TIME));
  1787. params.put("days", days + "");
  1788. } else {
  1789. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_CONSUL;
  1790. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  1791. params.put("days", days + "");
  1792. }
  1793. try {
  1794. AlibabaSMSUtil.sendSMS(
  1795. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1796. );
  1797. } catch (Exception e) {
  1798. e.printStackTrace();
  1799. }
  1800. }
  1801. }
  1802. }
  1803. newApproval.setNextchecker(sb.toString());
  1804. if (sb.length() == 0) {
  1805. if (sumbitToSummary) {
  1806. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1807. } else {
  1808. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1809. }
  1810. }
  1811. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1812. entity.setId(applyId);
  1813. if (sumbitToSummary) {
  1814. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  1815. } else {
  1816. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1817. }
  1818. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  1819. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1820. approvalService.insertAndGetId(newApproval);
  1821. return true;
  1822. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK, approval.getAfter_approvalstatus())) {
  1823. //待咨询反馈 --》 待咨询汇总
  1824. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  1825. industrialLandSupplyConsultation.setIndustrial_land_supply_id(applyId + "");
  1826. industrialLandSupplyConsultation.setDel_flag(false);
  1827. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  1828. boolean sumbitToSummary = true;
  1829. for (IndustrialLandSupplyConsultation landSupplyConsultation : industrialLandSupplyConsultationList) {
  1830. //如果所有咨询都已回答 进入待汇总
  1831. if (/*CommonUtils.isNull(landSupplyConsultation.getFeedback()) || */CommonUtils.isNull(landSupplyConsultation.getUpdate_by())) {
  1832. sumbitToSummary = false;
  1833. break;
  1834. } else {
  1835. sumbitToSummary = true;
  1836. }
  1837. }
  1838. Group group = null;
  1839. newApproval.setOper_type(Constant.OperType.SUBMIT);
  1840. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1841. if (sumbitToSummary) {
  1842. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  1843. } else {
  1844. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1845. }
  1846. if (sumbitToSummary) {
  1847. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  1848. } else {
  1849. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  1850. }
  1851. if (null == group) {
  1852. if (sumbitToSummary) {
  1853. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1854. } else {
  1855. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1856. }
  1857. }
  1858. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1859. List<User> users = userService.findListByWhere(new User());
  1860. StringBuffer sb = new StringBuffer("");
  1861. for (UserGroup userGroup : userGroups) {
  1862. for (User user : users) {
  1863. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1864. sb.append(userGroup.getUser_id() + ",");
  1865. //发送短信
  1866. if (sumbitToSummary) {
  1867. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_COMMERCE_SUMMARY;
  1868. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(SUMMARY_TIME));
  1869. params.put("days", days + "");
  1870. try {
  1871. AlibabaSMSUtil.sendSMS(
  1872. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1873. );
  1874. } catch (Exception e) {
  1875. e.printStackTrace();
  1876. }
  1877. }
  1878. }
  1879. }
  1880. }
  1881. newApproval.setNextchecker(sb.toString());
  1882. if (sb.length() == 0) {
  1883. if (sumbitToSummary) {
  1884. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1885. } else {
  1886. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  1887. }
  1888. }
  1889. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1890. entity.setId(applyId);
  1891. if (sumbitToSummary) {
  1892. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  1893. } else {
  1894. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  1895. }
  1896. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  1897. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1898. approvalService.insertAndGetId(newApproval);
  1899. return true;
  1900. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY, approval.getAfter_approvalstatus())) {
  1901. //待咨询汇总 --》 待商务局分管领导审批
  1902. Group group = null;
  1903. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  1904. //newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1905. //临时跳过商务领导审核
  1906. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1907. //group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_3);
  1908. //临时跳过商务领导审核
  1909. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  1910. if (null == group) {
  1911. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1912. //临时跳过商务领导审核
  1913. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1914. }
  1915. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1916. List<User> users = userService.findListByWhere(new User());
  1917. StringBuffer sb = new StringBuffer("");
  1918. for (UserGroup userGroup : userGroups) {
  1919. for (User user : users) {
  1920. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1921. sb.append(userGroup.getUser_id() + ",");
  1922. //发送短信
  1923. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_COMMITTEE_LEADER;
  1924. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(SUMMARY_TIME));
  1925. params.put("days", days + "");
  1926. try {
  1927. AlibabaSMSUtil.sendSMS(
  1928. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1929. );
  1930. } catch (Exception e) {
  1931. e.printStackTrace();
  1932. }
  1933. }
  1934. }
  1935. }
  1936. newApproval.setNextchecker(sb.toString());
  1937. if (sb.length() == 0) {
  1938. //throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_3 + "没有该项目责任单位的人员,请联系管理员配置");
  1939. //临时跳过商务领导审核
  1940. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1941. }
  1942. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1943. entity.setId(applyId);
  1944. //entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1945. //临时跳过商务领导审核
  1946. entity.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1947. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  1948. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1949. approvalService.insertAndGetId(newApproval);
  1950. return true;
  1951. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  1952. //待商务局分管领导审批 --》 待管委会分管领导审批
  1953. Group group = null;
  1954. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  1955. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1956. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  1957. if (null == group) {
  1958. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1959. }
  1960. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  1961. List<User> users = userService.findListByWhere(new User());
  1962. StringBuffer sb = new StringBuffer("");
  1963. for (UserGroup userGroup : userGroups) {
  1964. for (User user : users) {
  1965. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  1966. sb.append(userGroup.getUser_id() + ",");
  1967. //发送短信
  1968. try {
  1969. AlibabaSMSUtil.sendSMS(
  1970. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  1971. );
  1972. } catch (Exception e) {
  1973. e.printStackTrace();
  1974. }
  1975. }
  1976. }
  1977. }
  1978. newApproval.setNextchecker(sb.toString());
  1979. if (sb.length() == 0) {
  1980. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  1981. }
  1982. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  1983. entity.setId(applyId);
  1984. entity.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  1985. entity.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  1986. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  1987. approvalService.insertAndGetId(newApproval);
  1988. return true;
  1989. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_RETURN, approval.getAfter_approvalstatus())) {
  1990. //商务局受理员退回--》待商务局受理员审核
  1991. Group group = null;
  1992. newApproval.setOper_type(Constant.OperType.SUBMIT);
  1993. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_RETURN);
  1994. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  1995. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  1996. if (null == group) {
  1997. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  1998. }
  1999. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2000. List<User> users = userService.findListByWhere(new User());
  2001. StringBuffer sb = new StringBuffer("");
  2002. for (UserGroup userGroup : userGroups) {
  2003. for (User user : users) {
  2004. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2005. sb.append(userGroup.getUser_id() + ",");
  2006. //发送短信
  2007. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_COMMERE;
  2008. try {
  2009. AlibabaSMSUtil.sendSMS(
  2010. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2011. );
  2012. } catch (Exception e) {
  2013. e.printStackTrace();
  2014. }
  2015. }
  2016. }
  2017. }
  2018. newApproval.setNextchecker(sb.toString());
  2019. if (sb.length() == 0) {
  2020. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  2021. }
  2022. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2023. entity.setId(applyId);
  2024. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  2025. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  2026. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2027. approvalService.insertAndGetId(newApproval);
  2028. return true;
  2029. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_RETURN, approval.getAfter_approvalstatus())) {
  2030. //商务局分管领导退回 --》待商务局商务局分管领导审核
  2031. Group group = null;
  2032. newApproval.setOper_type(Constant.OperType.SUBMIT);
  2033. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_RETURN);
  2034. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  2035. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  2036. if (null == group) {
  2037. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  2038. }
  2039. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2040. List<User> users = userService.findListByWhere(new User());
  2041. StringBuffer sb = new StringBuffer("");
  2042. for (UserGroup userGroup : userGroups) {
  2043. for (User user : users) {
  2044. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2045. sb.append(userGroup.getUser_id() + ",");
  2046. //发送短信
  2047. try {
  2048. AlibabaSMSUtil.sendSMS(
  2049. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2050. );
  2051. } catch (Exception e) {
  2052. e.printStackTrace();
  2053. }
  2054. }
  2055. }
  2056. }
  2057. newApproval.setNextchecker(sb.toString());
  2058. if (sb.length() == 0) {
  2059. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  2060. }
  2061. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2062. entity.setId(applyId);
  2063. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  2064. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  2065. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2066. approvalService.insertAndGetId(newApproval);
  2067. return true;
  2068. } else if (Objects.equals(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  2069. // 分管领导审核通过 --》 预审通过待分发
  2070. Group group = null;
  2071. newApproval.setOper_type(Constant.OperType.APPROVED);
  2072. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  2073. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE);
  2074. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_7);
  2075. if (null == group) {
  2076. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2077. }
  2078. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2079. List<User> users = userService.findListByWhere(new User());
  2080. StringBuffer sb = new StringBuffer("");
  2081. for (UserGroup userGroup : userGroups) {
  2082. for (User user : users) {
  2083. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2084. sb.append(userGroup.getUser_id() + ",");
  2085. //发送短信
  2086. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_ZIGUI;
  2087. try {
  2088. AlibabaSMSUtil.sendSMS(
  2089. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2090. );
  2091. } catch (Exception e) {
  2092. e.printStackTrace();
  2093. }
  2094. }
  2095. }
  2096. }
  2097. newApproval.setNextchecker(sb.toString());
  2098. if (sb.length() == 0) {
  2099. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2100. }
  2101. //短信给行政审批局
  2102. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_6);
  2103. userGroups = userGroupService.findByGroupId(group.getId());
  2104. for (UserGroup userGroup : userGroups) {
  2105. for (User user : users) {
  2106. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2107. //发送短信
  2108. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_XINGZHENG;
  2109. try {
  2110. AlibabaSMSUtil.sendSMS(
  2111. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2112. );
  2113. } catch (Exception e) {
  2114. e.printStackTrace();
  2115. }
  2116. }
  2117. }
  2118. }
  2119. //如果是政府业务员提交的 只给商务业务员发
  2120. Integer createId = detail.getCreate_by();
  2121. User creater = userService.getUser(createId);
  2122. if (!Objects.equals(creater.getUser_type(), Constant.UserType.GOVERNMENT)) {
  2123. //如果不是政府账号创建 说明是街道提交 则给提交人也发短信
  2124. //发送短信
  2125. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_YS;
  2126. try {
  2127. AlibabaSMSUtil.sendSMS(
  2128. creater.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2129. );
  2130. } catch (Exception e) {
  2131. e.printStackTrace();
  2132. }
  2133. }
  2134. //短信给商务受理员
  2135. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  2136. userGroups = userGroupService.findByGroupId(group.getId());
  2137. for (UserGroup userGroup : userGroups) {
  2138. for (User user : users) {
  2139. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2140. //发送短信
  2141. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_YS;
  2142. try {
  2143. AlibabaSMSUtil.sendSMS(
  2144. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2145. );
  2146. } catch (Exception e) {
  2147. e.printStackTrace();
  2148. }
  2149. }
  2150. }
  2151. }
  2152. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2153. entity.setId(applyId);
  2154. entity.setApprove_status(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE);
  2155. entity.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2156. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2157. approvalService.insertAndGetId(newApproval);
  2158. // sendToLeader(params);
  2159. return true;
  2160. } else if (
  2161. Objects.equals(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE, approval.getAfter_approvalstatus())
  2162. || Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_RETURN, approval.getAfter_approvalstatus())
  2163. ) {
  2164. // 预审通过待分发 --》 分发待反馈
  2165. Group group = null;
  2166. newApproval.setOper_type(Constant.OperType.DISTRIBUTE);
  2167. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE);
  2168. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  2169. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_5);
  2170. if (null == group) {
  2171. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_5 + "没有该项目责任单位的人员,请联系管理员配置");
  2172. }
  2173. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2174. List<User> users = userService.findListByWhere(new User());
  2175. StringBuffer sb = new StringBuffer("");
  2176. for (UserGroup userGroup : userGroups) {
  2177. for (User user : users) {
  2178. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2179. if (newApproval.getAfter_approvalstatus().equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK)) {
  2180. List<IndustrialLandSupplyDistribution> ids = detail.getDistributionList();
  2181. for (IndustrialLandSupplyDistribution ilsc : ids) {
  2182. if (Objects.equals(ilsc.getDepartment_id(), "0") ||
  2183. Objects.equals(user.getDepartment_id() + "", ilsc.getDepartment_id())) {
  2184. if (!sb.toString().contains(userGroup.getUser_id() + "")) {
  2185. sb.append(userGroup.getUser_id() + ",");
  2186. //发送短信
  2187. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE;
  2188. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(DISTRIBUTE_TIME));
  2189. params.put("days", days + "");
  2190. try {
  2191. AlibabaSMSUtil.sendSMS(
  2192. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2193. );
  2194. } catch (Exception e) {
  2195. e.printStackTrace();
  2196. }
  2197. }
  2198. break;
  2199. }
  2200. }
  2201. } else {
  2202. sb.append(userGroup.getUser_id() + ",");
  2203. //发送短信
  2204. try {
  2205. AlibabaSMSUtil.sendSMS(
  2206. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2207. );
  2208. } catch (Exception e) {
  2209. e.printStackTrace();
  2210. }
  2211. }
  2212. }
  2213. }
  2214. }
  2215. newApproval.setNextchecker(sb.toString());
  2216. if (sb.length() == 0) {
  2217. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_5 + "没有该项目责任单位的人员,请联系管理员配置");
  2218. }
  2219. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2220. entity.setId(applyId);
  2221. entity.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  2222. entity.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2223. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2224. approvalService.insertAndGetId(newApproval);
  2225. return true;
  2226. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK, approval.getAfter_approvalstatus())) {
  2227. //分发待反馈 --》 待分发汇总
  2228. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = new IndustrialLandSupplyDistribution();
  2229. industrialLandSupplyDistribution.setIndustrial_land_supply_id(applyId + "");
  2230. industrialLandSupplyDistribution.setDel_flag(false);
  2231. List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = industrialLandSupplyDistributionService.findListByWhere(industrialLandSupplyDistribution);
  2232. boolean sumbitToSummary = true;
  2233. for (IndustrialLandSupplyDistribution landSupplyDistribution : industrialLandSupplyDistributionList) {
  2234. //如果所有咨询都已回答 进入待汇总
  2235. if (!Objects.equals(landSupplyDistribution.getDepartment_id(), "0")) {
  2236. if (CommonUtils.isNull(landSupplyDistribution.getUpdate_by())) {
  2237. sumbitToSummary = false;
  2238. break;
  2239. } else {
  2240. sumbitToSummary = true;
  2241. }
  2242. }
  2243. }
  2244. Group group = null;
  2245. newApproval.setOper_type(Constant.OperType.SUBMIT);
  2246. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  2247. if (sumbitToSummary) {
  2248. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY);
  2249. } else {
  2250. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  2251. }
  2252. if (sumbitToSummary) {
  2253. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_7);
  2254. } else {
  2255. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_5);
  2256. }
  2257. if (null == group) {
  2258. if (sumbitToSummary) {
  2259. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2260. } else {
  2261. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_5 + "没有该项目责任单位的人员,请联系管理员配置");
  2262. }
  2263. }
  2264. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2265. List<User> users = userService.findListByWhere(new User());
  2266. StringBuffer sb = new StringBuffer("");
  2267. for (UserGroup userGroup : userGroups) {
  2268. for (User user : users) {
  2269. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2270. sb.append(userGroup.getUser_id() + ",");
  2271. //发送短信
  2272. if (sumbitToSummary) {
  2273. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_SUMMARY;
  2274. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  2275. params.put("days", days + "");
  2276. try {
  2277. AlibabaSMSUtil.sendSMS(
  2278. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2279. );
  2280. } catch (Exception e) {
  2281. e.printStackTrace();
  2282. }
  2283. }
  2284. }
  2285. }
  2286. }
  2287. newApproval.setNextchecker(sb.toString());
  2288. if (sb.length() == 0) {
  2289. if (sumbitToSummary) {
  2290. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2291. } else {
  2292. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_5 + "没有该项目责任单位的人员,请联系管理员配置");
  2293. }
  2294. }
  2295. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2296. entity.setId(applyId);
  2297. if (sumbitToSummary) {
  2298. entity.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY);
  2299. } else {
  2300. entity.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_FEEDBACK);
  2301. }
  2302. entity.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2303. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2304. approvalService.insertAndGetId(newApproval);
  2305. return true;
  2306. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY, approval.getAfter_approvalstatus())) {
  2307. //待分发汇总 --》 待供地审批
  2308. Group group = null;
  2309. newApproval.setOper_type(Constant.OperType.SUBMIT);
  2310. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_PENDIND_SUMMARY);
  2311. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  2312. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  2313. if (null == group) {
  2314. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  2315. }
  2316. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2317. List<User> users = userService.findListByWhere(new User());
  2318. StringBuffer sb = new StringBuffer("");
  2319. for (UserGroup userGroup : userGroups) {
  2320. for (User user : users) {
  2321. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2322. sb.append(userGroup.getUser_id() + ",");
  2323. //发送短信
  2324. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_LEADER_HANDLE;
  2325. try {
  2326. AlibabaSMSUtil.sendSMS(
  2327. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2328. );
  2329. } catch (Exception e) {
  2330. e.printStackTrace();
  2331. }
  2332. }
  2333. }
  2334. }
  2335. newApproval.setNextchecker(sb.toString());
  2336. if (sb.length() == 0) {
  2337. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_4 + "没有该项目责任单位的人员,请联系管理员配置");
  2338. }
  2339. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2340. entity.setId(applyId);
  2341. entity.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  2342. entity.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2343. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2344. approvalService.insertAndGetId(newApproval);
  2345. return true;
  2346. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE, approval.getAfter_approvalstatus())) {
  2347. //待供地审批 --》 待供地审批通过
  2348. Group group = null;
  2349. newApproval.setOper_type(Constant.OperType.SUBMIT);
  2350. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  2351. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS);
  2352. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_7);
  2353. if (null == group) {
  2354. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2355. }
  2356. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2357. List<User> users = userService.findListByWhere(new User());
  2358. StringBuffer sb = new StringBuffer("");
  2359. for (UserGroup userGroup : userGroups) {
  2360. for (User user : users) {
  2361. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2362. sb.append(userGroup.getUser_id() + ",");
  2363. //发送短信
  2364. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_GD;
  2365. try {
  2366. AlibabaSMSUtil.sendSMS(
  2367. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2368. );
  2369. } catch (Exception e) {
  2370. e.printStackTrace();
  2371. }
  2372. }
  2373. }
  2374. }
  2375. newApproval.setNextchecker(sb.toString());
  2376. if (sb.length() == 0) {
  2377. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2378. }
  2379. //如果是政府业务员提交的 只给商务业务员发
  2380. Integer createId = detail.getCreate_by();
  2381. User creater = userService.getUser(createId);
  2382. if (!Objects.equals(creater.getUser_type(), Constant.UserType.GOVERNMENT)) {
  2383. //如果不是政府账号创建 说明是街道提交 则给提交人也发短信
  2384. //发送短信
  2385. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_GD;
  2386. try {
  2387. AlibabaSMSUtil.sendSMS(
  2388. creater.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2389. );
  2390. } catch (Exception e) {
  2391. e.printStackTrace();
  2392. }
  2393. }
  2394. //短信给商务受理员
  2395. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  2396. userGroups = userGroupService.findByGroupId(group.getId());
  2397. for (UserGroup userGroup : userGroups) {
  2398. for (User user : users) {
  2399. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2400. //发送短信
  2401. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_GD;
  2402. try {
  2403. AlibabaSMSUtil.sendSMS(
  2404. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2405. );
  2406. } catch (Exception e) {
  2407. e.printStackTrace();
  2408. }
  2409. }
  2410. }
  2411. }
  2412. //短信给经发
  2413. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_8);
  2414. userGroups = userGroupService.findByGroupId(group.getId());
  2415. for (UserGroup userGroup : userGroups) {
  2416. for (User user : users) {
  2417. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2418. //发送短信
  2419. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_GD;
  2420. try {
  2421. AlibabaSMSUtil.sendSMS(
  2422. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2423. );
  2424. } catch (Exception e) {
  2425. e.printStackTrace();
  2426. }
  2427. }
  2428. }
  2429. }
  2430. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2431. entity.setId(applyId);
  2432. entity.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS);
  2433. entity.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2434. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2435. approvalService.insertAndGetId(newApproval);
  2436. return true;
  2437. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS, approval.getAfter_approvalstatus())) {
  2438. //待供地审批通过 --》 最终信息 待供地审批通过
  2439. Group group = null;
  2440. newApproval.setOper_type(Constant.OperType.FINAL);
  2441. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS);
  2442. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS);
  2443. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_7);
  2444. if (null == group) {
  2445. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2446. }
  2447. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2448. List<User> users = userService.findListByWhere(new User());
  2449. StringBuffer sb = new StringBuffer("");
  2450. for (UserGroup userGroup : userGroups) {
  2451. for (User user : users) {
  2452. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2453. sb.append(userGroup.getUser_id() + ",");
  2454. //发送短信
  2455. // try {
  2456. // AlibabaSMSUtil.sendSMS(
  2457. // user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2458. // );
  2459. // } catch (ClientException e) {
  2460. // e.printStackTrace();
  2461. // }
  2462. }
  2463. }
  2464. }
  2465. newApproval.setNextchecker(sb.toString());
  2466. if (sb.length() == 0) {
  2467. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2468. }
  2469. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  2470. entity.setId(applyId);
  2471. entity.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PASS);
  2472. entity.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2473. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  2474. approvalService.insertAndGetId(newApproval);
  2475. return true;
  2476. }
  2477. return false;
  2478. }
  2479. /**
  2480. * @Author: huZhiHao
  2481. * @Description: 退回
  2482. * @Date: 2020/3/9
  2483. * @Params: [applyId, comment]
  2484. * @Return: boolean
  2485. **/
  2486. @Transactional
  2487. public boolean untread(Integer applyId, String comment) {
  2488. Approval approval = approvalService.getLatestApproval(applyId, Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  2489. Approval newApproval = new Approval();
  2490. newApproval.setApply_id(applyId);
  2491. newApproval.setType(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  2492. if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) {
  2493. if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) {
  2494. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  2495. newApproval.setDepartment(departmentname);
  2496. }
  2497. } else if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  2498. newApproval.setDepartment(ShiroUtils.getUserEntity().getStreet_name());
  2499. }
  2500. newApproval.setApproval_comment(comment);
  2501. newApproval.setChecker(ShiroUtils.getUserId());
  2502. newApproval.setOper_type(Constant.OperType.REJECT);
  2503. newApproval.setDeal_time(DateUtil.getTimeString(new Date()));
  2504. IndustrialLandSupplyDetail entity = industrialLandSupplyDetailDao.selectById(applyId + "");
  2505. // User companyAdmin = userService.findCompanyAdmin(projectApplication.getCompany_id());
  2506. // Message messages = new Message();
  2507. // messages.setApply_id(projectApplication.getId());
  2508. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  2509. // messages.setTitle("提醒企业");
  2510. // String message = "您有单号为" + projectApplication.getApply_no() + "的" +
  2511. // Constant.ProjectType.PROJECT_INTELLIGENT + ",经审核被退回,要求修改,详情请登录平台查看。退回原因:" + comment;
  2512. // messages.setContent(message);
  2513. // int[] streetArrInt = new int[1];
  2514. // streetArrInt[0] = projectApplication.getCompany_id();
  2515. // Map<String, String> params = new HashMap<>();
  2516. // params.put("project_no", projectApplication.getApply_no());
  2517. // params.put("apply_name", Constant.ProjectType.PROJECT_INTELLIGENT);
  2518. // String templateCode = Constant.SMS_TemplateCode.RPOJECT_MATTERS_REJECT;
  2519. //短信参数
  2520. Map<String, String> params = new HashMap<>();
  2521. IndustrialLandSupplyDetail detail = this.findById(applyId);
  2522. params.put("title", detail.getTitle());
  2523. params.put("no", detail.getNo());
  2524. params.put("reason", comment);
  2525. String templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY;
  2526. if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  2527. //商务局业务办理员退回 --》 街道板块
  2528. newApproval.setOper_type(Constant.OperType.REJECT);
  2529. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  2530. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_RETURN);
  2531. newApproval.setNextchecker(entity.getCreate_by().toString());
  2532. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2533. p.setId(applyId);
  2534. p.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_RETURN);
  2535. p.setProcess_stage(null);
  2536. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2537. approvalService.insertAndGetId(newApproval);
  2538. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  2539. // waitToDoService.completeAllTODO(projectApplication.getId(), Constant.DictionaryType.PROJECT_INTELLIGENT);
  2540. // waitToDoService.newTODO("智能制造编辑", "/projectIntelligent/edit/" + projectApplication.getId(), Constant.WaitToDo_OperType.EDIT, projectApplication.getId(),
  2541. // Constant.DictionaryType.PROJECT_INTELLIGENT, projectApplication.getApply_no(), companyAdmin.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
  2542. //发送短信
  2543. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_UNTREAD;
  2544. try {
  2545. AlibabaSMSUtil.sendSMS(
  2546. userService.getUser(entity.getCreate_by()).getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2547. );
  2548. } catch (Exception e) {
  2549. e.printStackTrace();
  2550. }
  2551. return true;
  2552. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  2553. //商务局领导退回 --》 商务局业务员
  2554. Group group = null;
  2555. newApproval.setOper_type(Constant.OperType.REJECT);
  2556. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  2557. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_RETURN);
  2558. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  2559. if (null == group) {
  2560. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  2561. }
  2562. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2563. List<User> users = userService.findListByWhere(new User());
  2564. StringBuffer sb = new StringBuffer("");
  2565. for (UserGroup userGroup : userGroups) {
  2566. for (User user : users) {
  2567. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2568. sb.append(userGroup.getUser_id() + ",");
  2569. //发送短信
  2570. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_UNTREAD;
  2571. try {
  2572. AlibabaSMSUtil.sendSMS(
  2573. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2574. );
  2575. } catch (Exception e) {
  2576. e.printStackTrace();
  2577. }
  2578. }
  2579. }
  2580. }
  2581. newApproval.setNextchecker(sb.toString());
  2582. if (sb.length() == 0) {
  2583. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  2584. }
  2585. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2586. p.setId(applyId);
  2587. p.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_RETURN);
  2588. p.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  2589. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2590. approvalService.insertAndGetId(newApproval);
  2591. return true;
  2592. } else if (Objects.equals(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  2593. //管委会领导退回 --》 商务局业务员
  2594. Group group = null;
  2595. newApproval.setOper_type(Constant.OperType.REJECT);
  2596. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE);
  2597. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_RETURN);
  2598. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  2599. if (null == group) {
  2600. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  2601. }
  2602. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2603. List<User> users = userService.findListByWhere(new User());
  2604. StringBuffer sb = new StringBuffer("");
  2605. for (UserGroup userGroup : userGroups) {
  2606. for (User user : users) {
  2607. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2608. sb.append(userGroup.getUser_id() + ",");
  2609. //发送短信
  2610. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_UNTREAD;
  2611. try {
  2612. AlibabaSMSUtil.sendSMS(
  2613. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2614. );
  2615. } catch (Exception e) {
  2616. e.printStackTrace();
  2617. }
  2618. }
  2619. }
  2620. }
  2621. newApproval.setNextchecker(sb.toString());
  2622. if (sb.length() == 0) {
  2623. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  2624. }
  2625. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2626. p.setId(applyId);
  2627. p.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_RETURN);
  2628. p.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  2629. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2630. approvalService.insertAndGetId(newApproval);
  2631. return true;
  2632. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE, approval.getAfter_approvalstatus())) {
  2633. //供地领导退回 --》 资源规划局务员
  2634. Group group = null;
  2635. newApproval.setOper_type(Constant.OperType.REJECT);
  2636. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  2637. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_RETURN);
  2638. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_7);
  2639. if (null == group) {
  2640. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_7 + "没有该项目责任单位的人员,请联系管理员配置");
  2641. }
  2642. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2643. List<User> users = userService.findListByWhere(new User());
  2644. StringBuffer sb = new StringBuffer("");
  2645. for (UserGroup userGroup : userGroups) {
  2646. for (User user : users) {
  2647. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2648. sb.append(userGroup.getUser_id() + ",");
  2649. //发送短信
  2650. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_UNTREAD;
  2651. try {
  2652. AlibabaSMSUtil.sendSMS(
  2653. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2654. );
  2655. } catch (Exception e) {
  2656. e.printStackTrace();
  2657. }
  2658. }
  2659. }
  2660. }
  2661. newApproval.setNextchecker(sb.toString());
  2662. if (sb.length() == 0) {
  2663. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_5 + "没有该项目责任单位的人员,请联系管理员配置");
  2664. }
  2665. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2666. p.setId(applyId);
  2667. p.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_RETURN);
  2668. p.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2669. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2670. approvalService.insertAndGetId(newApproval);
  2671. return true;
  2672. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_RETURN, approval.getAfter_approvalstatus())) {
  2673. //供地审批退回 --》 预审通过待分发
  2674. Group group = null;
  2675. newApproval.setOper_type(Constant.OperType.REJECT);
  2676. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_RETURN);
  2677. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE);
  2678. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_5);
  2679. if (null == group) {
  2680. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_5 + "没有该项目责任单位的人员,请联系管理员配置");
  2681. }
  2682. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2683. List<User> users = userService.findListByWhere(new User());
  2684. StringBuffer sb = new StringBuffer("");
  2685. for (UserGroup userGroup : userGroups) {
  2686. for (User user : users) {
  2687. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2688. sb.append(userGroup.getUser_id() + ",");
  2689. //发送短信
  2690. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_UNTREAD;
  2691. try {
  2692. AlibabaSMSUtil.sendSMS(
  2693. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2694. );
  2695. } catch (Exception e) {
  2696. e.printStackTrace();
  2697. }
  2698. }
  2699. }
  2700. }
  2701. newApproval.setNextchecker(sb.toString());
  2702. if (sb.length() == 0) {
  2703. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_5 + "没有该项目责任单位的人员,请联系管理员配置");
  2704. }
  2705. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2706. p.setId(applyId);
  2707. p.setApprove_status(Constant.LandSupplyApproveStatus.PRE_APPROVE_PENDIND_DISTRIBUTE);
  2708. p.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2709. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2710. approvalService.insertAndGetId(newApproval);
  2711. return true;
  2712. }
  2713. return false;
  2714. }
  2715. /**
  2716. * @Author: huZhiHao
  2717. * @Description: 拒绝
  2718. * @Date: 2020/3/9
  2719. * @Params: [applyId, comment]
  2720. * @Return: boolean
  2721. **/
  2722. @Transactional
  2723. public boolean refuse(Integer applyId, String comment) {
  2724. Approval approval = approvalService.getLatestApproval(applyId, Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  2725. Approval newApproval = new Approval();
  2726. newApproval.setApply_id(applyId);
  2727. newApproval.setType(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  2728. if (ShiroUtils.getUserType().equals(Constant.UserType.GOVERNMENT)) {
  2729. if (null != userService.getUser(ShiroUtils.getUserId()).getDepartment_id()) {
  2730. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  2731. newApproval.setDepartment(departmentname);
  2732. }
  2733. } else if (ShiroUtils.getUserType().equals(Constant.UserType.STREET)) {
  2734. newApproval.setDepartment(ShiroUtils.getUserEntity().getStreet_name());
  2735. }
  2736. newApproval.setApproval_comment(comment);
  2737. newApproval.setChecker(ShiroUtils.getUserId());
  2738. newApproval.setOper_type(Constant.OperType.NOTAPPROVED);
  2739. newApproval.setDeal_time(DateUtil.getTimeString(new Date()));
  2740. IndustrialLandSupplyDetail entity = industrialLandSupplyDetailDao.selectById(applyId + "");
  2741. //短信参数
  2742. Map<String, String> params = new HashMap<>();
  2743. IndustrialLandSupplyDetail detail = this.findById(applyId);
  2744. params.put("title", detail.getTitle());
  2745. params.put("no", detail.getNo());
  2746. String templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY;
  2747. if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  2748. //商务局分管领导拒绝
  2749. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  2750. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_REJECT);
  2751. newApproval.setNextchecker(entity.getCreate_by().toString());
  2752. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2753. p.setId(applyId);
  2754. p.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_REJECT);
  2755. p.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  2756. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2757. approvalService.insertAndGetId(newApproval);
  2758. // ProjectIntelligentDeclaration projectDeclaration = this.findById(projectApplication.getDeclaration_id());
  2759. // String projectName = projectDeclaration.getProject_name();
  2760. // Company company = companyService.findById(projectApplication.getCompany_id());
  2761. // Message messages = new Message();
  2762. // messages.setApply_id(projectApplication.getId());
  2763. // messages.setBusiness_type(Constant.Message_Business_type.PROJECT_INTELLIGENT_APPLY);
  2764. // messages.setTitle("提醒企业");
  2765. // String message = company.getCompany_name() + ",您好。您提交的" + projectName + "审核不通过,请知悉。不通过原因:" + comment;
  2766. // messages.setContent(message);
  2767. // int[] streetArrInt = new int[1];
  2768. // streetArrInt[0] = projectApplication.getCompany_id();
  2769. // messageService.saveMessageAndPush(messages, streetArrInt, Constant.UserType.COMPANY);
  2770. //发送短信
  2771. // try {
  2772. // AlibabaSMSUtil.sendSMS(
  2773. // userService.getUser(entity.getCreate_by()).getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2774. // );
  2775. // } catch (ClientException e) {
  2776. // e.printStackTrace();
  2777. // }
  2778. return true;
  2779. } else if (Objects.equals(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  2780. //管委会分管领导拒绝
  2781. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_PENDING_HANDLE);
  2782. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_LEADER_REJECT);
  2783. newApproval.setNextchecker(entity.getCreate_by().toString());
  2784. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2785. p.setId(applyId);
  2786. p.setApprove_status(Constant.LandSupplyApproveStatus.MANAGEMENT_COMMITTEE_LEADER_REJECT);
  2787. p.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  2788. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2789. approvalService.insertAndGetId(newApproval);
  2790. //发送短信
  2791. // try {
  2792. // AlibabaSMSUtil.sendSMS(
  2793. // userService.getUser(entity.getCreate_by()).getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2794. // );
  2795. // } catch (ClientException e) {
  2796. // e.printStackTrace();
  2797. // }
  2798. return true;
  2799. } else if (Objects.equals(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE, approval.getAfter_approvalstatus())) {
  2800. //供地分管领导拒绝
  2801. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_PENDIND_HANDLE);
  2802. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_REJECT);
  2803. newApproval.setNextchecker(entity.getCreate_by().toString());
  2804. IndustrialLandSupplyDetail p = new IndustrialLandSupplyDetail();
  2805. p.setId(applyId);
  2806. p.setApprove_status(Constant.LandSupplyApproveStatus.LAND_SUPPLY_LEADER_REJECT);
  2807. p.setProcess_stage(Constant.LandSupplyApproveStage.SUPPLY);
  2808. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(p);
  2809. approvalService.insertAndGetId(newApproval);
  2810. //发送短信
  2811. // try {
  2812. // AlibabaSMSUtil.sendSMS(
  2813. // userService.getUser(entity.getCreate_by()).getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  2814. // );
  2815. // } catch (ClientException e) {
  2816. // e.printStackTrace();
  2817. // }
  2818. return true;
  2819. }
  2820. return false;
  2821. }
  2822. /**
  2823. * @Author: huZhiHao
  2824. * @Description: 是否可以新增
  2825. * @Date: 2020/3/9
  2826. * @Params: []
  2827. * @Return: java.lang.Boolean
  2828. **/
  2829. @Transactional
  2830. public Boolean canAdd() {
  2831. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  2832. return true;
  2833. } else if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  2834. Group group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  2835. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2836. for (UserGroup userGroup : userGroups) {
  2837. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2838. return true;
  2839. }
  2840. }
  2841. }
  2842. return false;
  2843. }
  2844. /**
  2845. * @Author: huZhiHao
  2846. * @Description: 是否可以咨询
  2847. * @Date: 2020/3/9
  2848. * @Params: []
  2849. * @Return: java.lang.Boolean
  2850. **/
  2851. @Transactional
  2852. public Boolean canAsk() {
  2853. if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  2854. Group group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  2855. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2856. for (UserGroup userGroup : userGroups) {
  2857. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2858. return true;
  2859. }
  2860. }
  2861. }
  2862. return false;
  2863. }
  2864. public String detailType() {
  2865. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  2866. return "0";
  2867. }
  2868. return "1";
  2869. }
  2870. /**
  2871. * @Author: huZhiHao
  2872. * @Description: 用户所在组
  2873. * @Date: 2020/3/9
  2874. * @Params: []
  2875. * @Return: java.lang.String
  2876. **/
  2877. @Transactional
  2878. public String userGroupType() {
  2879. String str = "";
  2880. if (Constant.UserType.STREET.equals(ShiroUtils.getUserType())) {
  2881. str += "0,";
  2882. }
  2883. if (Constant.UserType.GOVERNMENT.equals(ShiroUtils.getUserType())) {
  2884. Group group = null;
  2885. List<UserGroup> userGroups = null;
  2886. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  2887. userGroups = userGroupService.findByGroupId(group.getId());
  2888. for (UserGroup userGroup : userGroups) {
  2889. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2890. str += "1,";
  2891. }
  2892. }
  2893. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  2894. userGroups = userGroupService.findByGroupId(group.getId());
  2895. for (UserGroup userGroup : userGroups) {
  2896. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2897. str += "2,";
  2898. }
  2899. }
  2900. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_3);
  2901. userGroups = userGroupService.findByGroupId(group.getId());
  2902. for (UserGroup userGroup : userGroups) {
  2903. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2904. str += "3,";
  2905. }
  2906. }
  2907. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_4);
  2908. userGroups = userGroupService.findByGroupId(group.getId());
  2909. for (UserGroup userGroup : userGroups) {
  2910. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2911. str += "4,";
  2912. }
  2913. }
  2914. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_5);
  2915. userGroups = userGroupService.findByGroupId(group.getId());
  2916. for (UserGroup userGroup : userGroups) {
  2917. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2918. str += "5,";
  2919. }
  2920. }
  2921. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_6);
  2922. userGroups = userGroupService.findByGroupId(group.getId());
  2923. for (UserGroup userGroup : userGroups) {
  2924. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2925. str += "6,";
  2926. }
  2927. }
  2928. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_7);
  2929. userGroups = userGroupService.findByGroupId(group.getId());
  2930. for (UserGroup userGroup : userGroups) {
  2931. if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2932. str += "7,";
  2933. }
  2934. }
  2935. // group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_8);
  2936. // userGroups = userGroupService.findByGroupId(group.getId());
  2937. // for (UserGroup userGroup : userGroups) {
  2938. // if (Objects.equals(userGroup.getUser_id(), ShiroUtils.getUserId())) {
  2939. // str += "8,";
  2940. // }
  2941. // }
  2942. }
  2943. return str;
  2944. }
  2945. /**
  2946. * @Author: huZhiHao
  2947. * @Description: 部门
  2948. * @Date: 2020/3/9
  2949. * @Params: []
  2950. * @Return: java.util.List<platform.modules.sys.entity.Department>
  2951. **/
  2952. @Transactional
  2953. public List<Department> consulDepartmentList() {
  2954. List<Department> list = new ArrayList<>();
  2955. Group group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  2956. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2957. List<User> users = userService.findListByWhere(new User());
  2958. StringBuffer sb = new StringBuffer("");
  2959. for (UserGroup userGroup : userGroups) {
  2960. for (User user : users) {
  2961. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2962. //list.add(departmentService.selectById(user.getDepartment_id()));
  2963. //获取根目录部门
  2964. list.add(departmentService.findRootById(user.getDepartment_id()));
  2965. }
  2966. }
  2967. }
  2968. List<Department> myList = list.stream().distinct().collect(Collectors.toList());
  2969. return myList;
  2970. }
  2971. /**
  2972. * @Author: huZhiHao
  2973. * @Description: 分发部门
  2974. * @Date: 2020/3/9
  2975. * @Params: []
  2976. * @Return: java.util.List<platform.modules.sys.entity.Department>
  2977. **/
  2978. @Transactional
  2979. public List<Department> distDepartmentList() {
  2980. List<Department> list = new ArrayList<>();
  2981. Group group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_5);
  2982. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  2983. List<User> users = userService.findListByWhere(new User());
  2984. StringBuffer sb = new StringBuffer("");
  2985. for (UserGroup userGroup : userGroups) {
  2986. for (User user : users) {
  2987. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  2988. //list.add(departmentService.selectById(user.getDepartment_id()));
  2989. //获取根目录部门
  2990. list.add(departmentService.findRootById(user.getDepartment_id()));
  2991. }
  2992. }
  2993. }
  2994. List<Department> myList = list.stream().distinct().collect(Collectors.toList());
  2995. return myList;
  2996. }
  2997. /**
  2998. * @Author: huZhiHao
  2999. * @Description: 保存反馈
  3000. * @Date: 2020/3/10
  3001. * @Params: [industrialLandSupplyConsultationList]
  3002. * @Return: void
  3003. **/
  3004. @Transactional
  3005. public void saveFeedback(List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList) {
  3006. String dateTime = DateUtil.getTimeString(new Date());
  3007. for (IndustrialLandSupplyConsultation industrialLandSupplyConsultation : industrialLandSupplyConsultationList) {
  3008. industrialLandSupplyConsultation.setFeedback_time(dateTime);
  3009. industrialLandSupplyConsultationService.updateSelective(industrialLandSupplyConsultation);
  3010. //保存材料
  3011. if (null != industrialLandSupplyConsultation.getFileDown() && null != industrialLandSupplyConsultation.getFileDown().getFile_id()) {
  3012. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_FEEDBACK, industrialLandSupplyConsultation.getId());
  3013. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_FEEDBACK, industrialLandSupplyConsultation.getId(), industrialLandSupplyConsultation.getFileDown().getFile_id());
  3014. }
  3015. }
  3016. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = industrialLandSupplyConsultationService.findById(industrialLandSupplyConsultationList.get(0).getId());
  3017. this.pass(Integer.valueOf(industrialLandSupplyConsultation.getIndustrial_land_supply_id()), null);
  3018. }
  3019. /**
  3020. * @Author: huZhiHao
  3021. * @Description: 保存反馈
  3022. * @Date: 2020/3/10
  3023. * @Params: [industrialLandSupplyConsultationList]
  3024. * @Return: void
  3025. **/
  3026. @Transactional
  3027. public void saveFeedbackAppend(IndustrialLandSupplyDetail apply) {
  3028. //保存咨询列表
  3029. String dateTime = DateUtil.getTimeString(new Date());
  3030. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = apply.getConsultationList();
  3031. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  3032. Iterator<IndustrialLandSupplyConsultation> it = industrialLandSupplyConsultationList.iterator();
  3033. while (it.hasNext()) {
  3034. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = it.next();
  3035. if (CommonUtils.isNull(industrialLandSupplyConsultation.getConsultation()) || CommonUtils.isNotNull(industrialLandSupplyConsultation.getId())) {
  3036. it.remove();
  3037. }
  3038. }
  3039. for (IndustrialLandSupplyConsultation industrialLandSupplyConsultation : industrialLandSupplyConsultationList) {
  3040. industrialLandSupplyConsultation.setIndustrial_land_supply_id(apply.getId() + "");
  3041. industrialLandSupplyConsultation.setIsDefault(false);
  3042. if (CommonUtils.isNull(industrialLandSupplyConsultation.getConsultation_time())) {
  3043. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  3044. }
  3045. }
  3046. //短信参数
  3047. Map<String, String> params = new HashMap<>();
  3048. IndustrialLandSupplyDetail detail = null;
  3049. try {
  3050. detail = this.selectById(apply.getId() + "");
  3051. } catch (ParseException e) {
  3052. e.printStackTrace();
  3053. }
  3054. params.put("title", detail.getTitle());
  3055. params.put("no", detail.getNo());
  3056. String templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY;
  3057. Group group = null;
  3058. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_2);
  3059. if (null == group) {
  3060. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_2 + "没有该项目责任单位的人员,请联系管理员配置");
  3061. }
  3062. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  3063. List<User> users = userService.findListByWhere(new User());
  3064. StringBuffer sb = new StringBuffer("");
  3065. for (UserGroup userGroup : userGroups) {
  3066. for (User user : users) {
  3067. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  3068. List<IndustrialLandSupplyConsultation> ids = industrialLandSupplyConsultationList;
  3069. for (IndustrialLandSupplyConsultation ilsc : ids) {
  3070. if (Objects.equals(user.getDepartment_id() + "", ilsc.getDepartment_id())) {
  3071. sb.append(userGroup.getUser_id() + ",");
  3072. //发送短信
  3073. templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_CONSUL;
  3074. int days = Integer.parseInt(industrialLandSupplyConfigService.getValueByType(FEEDBACK_TIME));
  3075. params.put("days", days + "");
  3076. try {
  3077. AlibabaSMSUtil.sendSMS(
  3078. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  3079. );
  3080. } catch (Exception e) {
  3081. e.printStackTrace();
  3082. }
  3083. break;
  3084. }
  3085. }
  3086. }
  3087. }
  3088. }
  3089. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  3090. industrialLandSupplyConsultationService.saveList(industrialLandSupplyConsultationList);
  3091. }
  3092. //保存默认咨询列表
  3093. List<String> defaultList = apply.getDefaultList();
  3094. if (!CollectionUtils.isEmpty(defaultList)) {
  3095. IndustrialLandSupplyConsultation query = new IndustrialLandSupplyConsultation();
  3096. query.setIndustrial_land_supply_id(apply.getId() + "");
  3097. query.setDel_flag(false);
  3098. List<IndustrialLandSupplyConsultation> oldList = industrialLandSupplyConsultationService.findListByWhere(query);
  3099. for (String departmentId : defaultList) {
  3100. if (departmentId != null) {
  3101. boolean flag = true;
  3102. for (IndustrialLandSupplyConsultation industrialLandSupplyConsultation : oldList) {
  3103. if (industrialLandSupplyConsultation.getIsDefault() &&
  3104. Objects.equals(industrialLandSupplyConsultation.getDepartment_id(), departmentId)) {
  3105. flag = false;
  3106. }
  3107. }
  3108. if (flag) {
  3109. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  3110. industrialLandSupplyConsultation.setIsDefault(true);
  3111. industrialLandSupplyConsultation.setIndustrial_land_supply_id(apply.getId() + "");
  3112. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  3113. industrialLandSupplyConsultation.setDepartment_id(departmentId);
  3114. industrialLandSupplyConsultation.setConsultation(CONSULTATION_MESSAGE);
  3115. industrialLandSupplyConsultationService.save(industrialLandSupplyConsultation);
  3116. }
  3117. }
  3118. }
  3119. }
  3120. }
  3121. }
  3122. /**
  3123. * @Author: huZhiHao
  3124. * @Description: 保存汇总
  3125. * @Date: 2020/3/10
  3126. * @Params: [industrialLandSupplyDetail]
  3127. * @Return: void
  3128. **/
  3129. @Transactional
  3130. public void saveSummary(IndustrialLandSupplyDetail industrialLandSupplyDetail) {
  3131. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  3132. entity.setId(industrialLandSupplyDetail.getId());
  3133. entity.setConsultation_summary(industrialLandSupplyDetail.getConsultation_summary());
  3134. entity.setConsultation_summary_text(industrialLandSupplyDetail.getConsultation_summary_text());
  3135. this.updateSelective(entity);
  3136. //保存材料
  3137. if (null != industrialLandSupplyDetail.getFileDown() && null != industrialLandSupplyDetail.getFileDown().getFile_id()) {
  3138. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_SUMMARY, industrialLandSupplyDetail.getId());
  3139. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_SUMMARY, industrialLandSupplyDetail.getId(), industrialLandSupplyDetail.getFileDown().getFile_id());
  3140. }
  3141. this.pass(industrialLandSupplyDetail.getId(), null);
  3142. }
  3143. /**
  3144. * @Author: huZhiHao
  3145. * @Description: 撤回咨询
  3146. * @Date: 2020/3/7
  3147. * @Params: [applyId, comment]
  3148. * @Return: java.lang.Boolean
  3149. **/
  3150. @Transactional
  3151. public Boolean withDrawConsul(String id) {
  3152. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = industrialLandSupplyConsultationService.findById(Integer.valueOf(id));
  3153. industrialLandSupplyConsultation.setDel_flag(true);
  3154. industrialLandSupplyConsultationService.updateSelective(industrialLandSupplyConsultation);
  3155. return this.withdraw(Integer.valueOf(industrialLandSupplyConsultation.getIndustrial_land_supply_id()), null);
  3156. }
  3157. /**
  3158. * @Author: huZhiHao
  3159. * @Description: 撤回申请
  3160. * @Date: 2020/3/7
  3161. * @Params: [applyId, comment]
  3162. * @Return: java.lang.Boolean
  3163. **/
  3164. @Transactional
  3165. public void withdrawApply(String id) {
  3166. // IndustrialLandSupplyDetail industrialLandSupplyDetail = this.selectById(id);
  3167. // industrialLandSupplyDetail.setApprove_status(Constant.LandSupplyApproveStatus.PLATE_WITHDRAW);
  3168. // industrialLandSupplyDetail.setProcess_stage("");
  3169. // industrialLandSupplyDetail.setAccept_date("");
  3170. // this.updateSelective(industrialLandSupplyDetail);
  3171. // Approval approval = new Approval();
  3172. // approval.setApply_id(Integer.valueOf(id));
  3173. // approvalService.deleteByWhere(approval);
  3174. withdraw(Integer.valueOf(id), null);
  3175. }
  3176. /**
  3177. * @Author: huZhiHao
  3178. * @Description: 撤回
  3179. * @Date: 2020/3/7
  3180. * @Params: [applyId, comment]
  3181. * @Return: java.lang.Boolean
  3182. **/
  3183. @Transactional
  3184. public Boolean withdraw(Integer applyId, String comment) {
  3185. Approval approval = approvalService.getLatestApproval(applyId, Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  3186. Approval newApproval = new Approval();
  3187. newApproval.setApply_id(applyId);
  3188. newApproval.setType(Constant.DictionaryType.INDUSTRIAL_LAND_SUPPLY);
  3189. String departmentname = departmentService.selectById(userService.getUser(ShiroUtils.getUserId()).getDepartment_id()).getName();
  3190. newApproval.setDepartment(departmentname);
  3191. newApproval.setApproval_comment(comment);
  3192. newApproval.setChecker(ShiroUtils.getUserId());
  3193. newApproval.setOper_type(Constant.OperType.WITHDRAW);
  3194. newApproval.setDeal_time(DateUtil.getTimeString(new Date()));
  3195. if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK, approval.getAfter_approvalstatus())) {
  3196. //待咨询反馈 --》 待咨询汇总
  3197. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  3198. industrialLandSupplyConsultation.setIndustrial_land_supply_id(applyId + "");
  3199. industrialLandSupplyConsultation.setDel_flag(false);
  3200. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = industrialLandSupplyConsultationService.findListByWhere(industrialLandSupplyConsultation);
  3201. boolean sumbitToSummary = true;
  3202. boolean backToSubmit = false;
  3203. //如果剩下的没有反馈了 退回到待提交
  3204. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  3205. for (IndustrialLandSupplyConsultation landSupplyConsultation : industrialLandSupplyConsultationList) {
  3206. //如果剩下的都是已反馈的咨询 则进入汇总
  3207. if (CommonUtils.isNull(landSupplyConsultation.getFeedback()) || CommonUtils.isNull(landSupplyConsultation.getUpdate_by())) {
  3208. sumbitToSummary = false;
  3209. break;
  3210. } else {
  3211. sumbitToSummary = true;
  3212. }
  3213. }
  3214. } else {
  3215. backToSubmit = true;
  3216. }
  3217. if (sumbitToSummary || backToSubmit) {
  3218. Group group = null;
  3219. newApproval.setOper_type(Constant.OperType.SUBMIT);
  3220. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_FEEDBACK);
  3221. if (backToSubmit) {
  3222. IndustrialLandSupplyDetail industrialLandSupplyDetail = this.findById(applyId);
  3223. if (industrialLandSupplyDetail != null && industrialLandSupplyDetail.getCreate_by() != null) {
  3224. User user = userService.getUser(industrialLandSupplyDetail.getCreate_by());
  3225. if (Objects.equals(Constant.UserType.STREET, user.getUser_type())) {
  3226. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  3227. } else {
  3228. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUBMIT);
  3229. }
  3230. }
  3231. } else if (sumbitToSummary) {
  3232. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  3233. }
  3234. group = groupService.findByNameOnly(Constant.INDUSTRIALLANDSUPPLY_1);
  3235. if (null == group) {
  3236. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  3237. }
  3238. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  3239. List<User> users = userService.findListByWhere(new User());
  3240. StringBuffer sb = new StringBuffer("");
  3241. for (UserGroup userGroup : userGroups) {
  3242. for (User user : users) {
  3243. if (Objects.equals(user.getId(), userGroup.getUser_id())) {
  3244. sb.append(userGroup.getUser_id() + ",");
  3245. }
  3246. }
  3247. }
  3248. newApproval.setNextchecker(sb.toString());
  3249. if (sb.length() == 0) {
  3250. throw new BaseException("操作失败," + Constant.INDUSTRIALLANDSUPPLY_1 + "没有该项目责任单位的人员,请联系管理员配置");
  3251. }
  3252. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  3253. entity.setId(applyId);
  3254. if (backToSubmit) {
  3255. entity.setApprove_status(newApproval.getAfter_approvalstatus());
  3256. } else if (sumbitToSummary) {
  3257. entity.setApprove_status(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_SUMMARY);
  3258. }
  3259. entity.setProcess_stage(Constant.LandSupplyApproveStage.PRE_AUDIT);
  3260. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  3261. approvalService.insertAndGetId(newApproval);
  3262. return true;
  3263. }
  3264. } else if (Objects.equals(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE, approval.getAfter_approvalstatus())) {
  3265. //待商务业务员处理 --》 已撤回
  3266. newApproval.setBefore_approvalstatus(Constant.LandSupplyApproveStatus.COMMERCE_PENDING_HANDLE);
  3267. newApproval.setAfter_approvalstatus(Constant.LandSupplyApproveStatus.PLATE_WITHDRAW);
  3268. newApproval.setNextchecker(ShiroUtils.getUserId() + "");
  3269. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  3270. entity.setId(applyId);
  3271. entity.setApprove_status(Constant.LandSupplyApproveStatus.PLATE_WITHDRAW);
  3272. entity.setProcess_stage("");
  3273. industrialLandSupplyDetailDao.updateByPrimaryKeySelective(entity);
  3274. approvalService.insertAndGetId(newApproval);
  3275. return true;
  3276. }
  3277. return false;
  3278. }
  3279. @Transactional
  3280. public Integer commerceApprove(IndustrialLandSupplyDetail apply) {
  3281. Integer id = apply.getId();
  3282. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  3283. entity.setId(id);
  3284. entity.setSupplement(apply.getSupplement());
  3285. this.updateSelective(entity);
  3286. //保存材料
  3287. if (null != apply.getFileDown() && null != apply.getFileDown().getFile_id()) {
  3288. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_COMMERCE_SUPPLEMENT, id);
  3289. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_COMMERCE_SUPPLEMENT, id, apply.getFileDown().getFile_id());
  3290. }
  3291. //保存咨询列表
  3292. String dateTime = DateUtil.getTimeString(new Date());
  3293. List<IndustrialLandSupplyConsultation> industrialLandSupplyConsultationList = apply.getConsultationList();
  3294. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  3295. Iterator<IndustrialLandSupplyConsultation> it = industrialLandSupplyConsultationList.iterator();
  3296. while (it.hasNext()) {
  3297. if (CommonUtils.isNull(it.next().getConsultation())) {
  3298. it.remove();
  3299. }
  3300. }
  3301. for (IndustrialLandSupplyConsultation industrialLandSupplyConsultation : industrialLandSupplyConsultationList) {
  3302. industrialLandSupplyConsultation.setIsDefault(false);
  3303. industrialLandSupplyConsultation.setIndustrial_land_supply_id(id + "");
  3304. if (industrialLandSupplyConsultation.getId() != null) {
  3305. IndustrialLandSupplyConsultation industrialLandSupplyConsultation1 = industrialLandSupplyConsultationService.findById(industrialLandSupplyConsultation.getId());
  3306. //如果问的问题没变则保留id等信息 不然作为新的处理
  3307. if (Objects.equals(industrialLandSupplyConsultation1.getConsultation(), industrialLandSupplyConsultation.getConsultation())) {
  3308. BeanUtils.copyProperties(industrialLandSupplyConsultation1, industrialLandSupplyConsultation);
  3309. }
  3310. }
  3311. if (CommonUtils.isNull(industrialLandSupplyConsultation.getConsultation_time())) {
  3312. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  3313. }
  3314. }
  3315. IndustrialLandSupplyConsultation query = new IndustrialLandSupplyConsultation();
  3316. query.setIndustrial_land_supply_id(id + "");
  3317. industrialLandSupplyConsultationService.deleteByWhere(query);
  3318. if (!CollectionUtils.isEmpty(industrialLandSupplyConsultationList)) {
  3319. industrialLandSupplyConsultationService.saveList(industrialLandSupplyConsultationList);
  3320. }
  3321. }
  3322. //保存默认咨询列表
  3323. List<String> defaultList = apply.getDefaultList();
  3324. if (!CollectionUtils.isEmpty(defaultList)) {
  3325. for (String departmentId : defaultList) {
  3326. if (departmentId != null && departmentId != "") {
  3327. IndustrialLandSupplyConsultation industrialLandSupplyConsultation = new IndustrialLandSupplyConsultation();
  3328. industrialLandSupplyConsultation.setIsDefault(true);
  3329. industrialLandSupplyConsultation.setIndustrial_land_supply_id(apply.getId() + "");
  3330. industrialLandSupplyConsultation.setConsultation_time(dateTime);
  3331. industrialLandSupplyConsultation.setDepartment_id(departmentId);
  3332. industrialLandSupplyConsultation.setConsultation(CONSULTATION_MESSAGE);
  3333. industrialLandSupplyConsultationService.save(industrialLandSupplyConsultation);
  3334. }
  3335. }
  3336. }
  3337. //直接提交申请,添加流程信息
  3338. pass(id, null);
  3339. return id;
  3340. }
  3341. /**
  3342. * @Author: huZhiHao
  3343. * @Description: 保存
  3344. * @Date: 2020/3/7
  3345. * @Params: [apply, status]
  3346. * @Return: void
  3347. **/
  3348. @Transactional
  3349. public void updateAttachment(LandSupplyApprovalDto approval) {
  3350. IndustrialLandSupplyDetail industrialLandSupplyDetail = new IndustrialLandSupplyDetail();
  3351. industrialLandSupplyDetail.setId(approval.getApply_id());
  3352. //保存材料
  3353. if (Objects.equals(approval.getType(), "1")) {
  3354. //商务领导审核附件
  3355. if (null != approval.getFileDown() && null != approval.getFileDown().getFile_id()) {
  3356. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_COMMERCE_LEADER, approval.getApply_id(), approval.getFileDown().getFile_id());
  3357. }
  3358. industrialLandSupplyDetail.setCommerce_leader_pre_approve_comment(approval.getApproval_comment());
  3359. if (approval.getStatus().equals(Constant.ApproveButtonStatus.APPROVED)) {
  3360. //通过
  3361. industrialLandSupplyDetail.setCommerce_leader_pre_approve_operate("通过");
  3362. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.REJECT)) {
  3363. //退回
  3364. industrialLandSupplyDetail.setCommerce_leader_pre_approve_operate("退回");
  3365. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.NOTAPPROVED)) {
  3366. //不通过
  3367. industrialLandSupplyDetail.setCommerce_leader_pre_approve_operate("不通过");
  3368. }
  3369. } else if (Objects.equals(approval.getType(), "2")) {
  3370. //管委会领导审核附件
  3371. if (null != approval.getFileDown() && null != approval.getFileDown().getFile_id()) {
  3372. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_MANAGEMENT_COMMITTEE_LEADER, approval.getApply_id(), approval.getFileDown().getFile_id());
  3373. }
  3374. if (null != approval.getCountersign_file() && null != approval.getCountersign_file().getFile_id()) {
  3375. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_MANAGEMENT_COMMITTEE_LEADER_COUNTERSIGN, approval.getApply_id(), approval.getCountersign_file().getFile_id());
  3376. }
  3377. industrialLandSupplyDetail.setCommittee_leader_pre_approve_comment(approval.getApproval_comment());
  3378. industrialLandSupplyDetail.setCountersign_comment(approval.getCountersign_comment());
  3379. if (approval.getStatus().equals(Constant.ApproveButtonStatus.APPROVED)) {
  3380. //通过
  3381. industrialLandSupplyDetail.setCommittee_leader_pre_approve_operate("通过");
  3382. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.REJECT)) {
  3383. //退回
  3384. industrialLandSupplyDetail.setCommittee_leader_pre_approve_operate("退回");
  3385. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.NOTAPPROVED)) {
  3386. //不通过
  3387. industrialLandSupplyDetail.setCommittee_leader_pre_approve_operate("不通过");
  3388. }
  3389. } else if (Objects.equals(approval.getType(), "3")) {
  3390. //管委会领导审核附件
  3391. if (null != approval.getFileDown() && null != approval.getFileDown().getFile_id()) {
  3392. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_APPROVE, approval.getApply_id(), approval.getFileDown().getFile_id());
  3393. }
  3394. industrialLandSupplyDetail.setLand_supply_comment(approval.getApproval_comment());
  3395. if (approval.getStatus().equals(Constant.ApproveButtonStatus.APPROVED)) {
  3396. //通过
  3397. industrialLandSupplyDetail.setLand_supply_result("通过");
  3398. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.REJECT)) {
  3399. //退回
  3400. industrialLandSupplyDetail.setLand_supply_result("退回");
  3401. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.NOTAPPROVED)) {
  3402. //不通过
  3403. industrialLandSupplyDetail.setLand_supply_result("不通过");
  3404. }
  3405. } else if (Objects.equals(approval.getType(), "4")) {
  3406. //管委会领导审核附件
  3407. if (null != approval.getFileDown() && null != approval.getFileDown().getFile_id()) {
  3408. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_FINAL, approval.getApply_id(), approval.getFileDown().getFile_id());
  3409. }
  3410. industrialLandSupplyDetail.setFinal_comment(approval.getApproval_comment());
  3411. if (approval.getStatus().equals(Constant.ApproveButtonStatus.APPROVED)) {
  3412. //通过
  3413. industrialLandSupplyDetail.setFinal_result("通过");
  3414. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.REJECT)) {
  3415. //退回
  3416. industrialLandSupplyDetail.setFinal_result("退回");
  3417. } else if (approval.getStatus().equals(Constant.ApproveButtonStatus.NOTAPPROVED)) {
  3418. //不通过
  3419. industrialLandSupplyDetail.setFinal_result("不通过");
  3420. }
  3421. }
  3422. this.updateSelective(industrialLandSupplyDetail);
  3423. }
  3424. @Transactional
  3425. public Integer distribute(IndustrialLandSupplyDetail apply) {
  3426. Integer id = apply.getId();
  3427. String dateTime = DateUtil.getTimeString(new Date());
  3428. List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = apply.getDistributionList();
  3429. Iterator<IndustrialLandSupplyDistribution> it = industrialLandSupplyDistributionList.iterator();
  3430. while (it.hasNext()) {
  3431. if (CommonUtils.isNull(it.next().getDistribution_file().getFile_id())) {
  3432. it.remove();
  3433. }
  3434. }
  3435. IndustrialLandSupplyDetail industrialLandSupplyDetail = new IndustrialLandSupplyDetail();
  3436. industrialLandSupplyDetail.setId(id);
  3437. industrialLandSupplyDetail.setDescription_of_submitted(apply.getDescription_of_submitted());
  3438. this.updateSelective(industrialLandSupplyDetail);
  3439. //获取所有待分发的部门
  3440. List<Department> departmentIds = this.distDepartmentList();
  3441. //如果分发时有资料说明 但是没附件
  3442. if (
  3443. CommonUtils.isNotNull(apply.getDescription_of_submitted())
  3444. && CollectionUtils.isEmpty(industrialLandSupplyDistributionList)
  3445. ) {
  3446. for (Department department : departmentIds) {
  3447. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = new IndustrialLandSupplyDistribution();
  3448. industrialLandSupplyDistribution.setDepartment_id(department.getId() + "");
  3449. industrialLandSupplyDistribution.setIndustrial_land_supply_id(id + "");
  3450. industrialLandSupplyDistribution.setContent(apply.getDescription_of_submitted_text());
  3451. if (CommonUtils.isNull(industrialLandSupplyDistribution.getDistribute_time())) {
  3452. industrialLandSupplyDistribution.setDistribute_time(dateTime);
  3453. }
  3454. industrialLandSupplyDistributionService.saveSelective(industrialLandSupplyDistribution);
  3455. }
  3456. }
  3457. //如果分发时有资料说明 有附件
  3458. if (
  3459. CommonUtils.isNotNull(apply.getDescription_of_submitted())
  3460. && !CollectionUtils.isEmpty(industrialLandSupplyDistributionList)
  3461. ) {
  3462. for (IndustrialLandSupplyDistribution industrialLandSupplyDistribution : industrialLandSupplyDistributionList) {
  3463. //注释了 现在只把department=0的这个公共文件给所有部门看
  3464. /* industrialLandSupplyDistribution.setIndustrial_land_supply_id(id + "");
  3465. if (CommonUtils.isNull(industrialLandSupplyDistribution.getDistribute_time())) {
  3466. industrialLandSupplyDistribution.setDistribute_time(dateTime);
  3467. }
  3468. industrialLandSupplyDistributionService.saveSelective(industrialLandSupplyDistribution);
  3469. //保存材料
  3470. if (null != industrialLandSupplyDistribution.getDistribution_file() && null != industrialLandSupplyDistribution.getDistribution_file().getFile_id()) {
  3471. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE, industrialLandSupplyDistribution.getId());
  3472. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE, industrialLandSupplyDistribution.getId(), industrialLandSupplyDistribution.getDistribution_file().getFile_id());
  3473. }*/
  3474. if (Objects.equals("0", industrialLandSupplyDistribution.getDepartment_id())) {
  3475. Integer fileId = null;
  3476. if (null != industrialLandSupplyDistribution.getDistribution_file() && null != industrialLandSupplyDistribution.getDistribution_file().getFile_id()) {
  3477. fileId = industrialLandSupplyDistribution.getDistribution_file().getFile_id();
  3478. }
  3479. Attachment attachment = attachmentService.findById(fileId);
  3480. for (Department department : departmentIds) {
  3481. industrialLandSupplyDistribution.setId(null);
  3482. industrialLandSupplyDistribution.setDepartment_id(department.getId() + "");
  3483. industrialLandSupplyDistribution.setIndustrial_land_supply_id(id + "");
  3484. industrialLandSupplyDistribution.setContent(apply.getDescription_of_submitted_text());
  3485. if (CommonUtils.isNull(industrialLandSupplyDistribution.getDistribute_time())) {
  3486. industrialLandSupplyDistribution.setDistribute_time(dateTime);
  3487. }
  3488. industrialLandSupplyDistributionService.saveSelective(industrialLandSupplyDistribution);
  3489. attachment.setId(null);
  3490. attachment.setBusiness_type(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE);
  3491. attachment.setBusiness_id(industrialLandSupplyDistribution.getId());
  3492. attachmentService.saveSelective(attachment);
  3493. }
  3494. }
  3495. }
  3496. }
  3497. //直接提交申请,添加流程信息
  3498. pass(id, null);
  3499. return id;
  3500. }
  3501. public List<FileDown> getAllDepartmentFile(String id) {
  3502. List<FileDown> fileDownList = new ArrayList<>();
  3503. List<Attachment> attachments = new ArrayList<>();
  3504. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = new IndustrialLandSupplyDistribution();
  3505. industrialLandSupplyDistribution.setIndustrial_land_supply_id(id);
  3506. industrialLandSupplyDistribution.setDepartment_id("0");
  3507. industrialLandSupplyDistribution.setDel_flag(false);
  3508. List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList = industrialLandSupplyDistributionService.findListByWhere(industrialLandSupplyDistribution);
  3509. if (!CollectionUtils.isEmpty(industrialLandSupplyDistributionList)) {
  3510. for (IndustrialLandSupplyDistribution landSupplyDistribution : industrialLandSupplyDistributionList) {
  3511. attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE, landSupplyDistribution.getId(), null);
  3512. if (null != attachments && attachments.size() > 0) {
  3513. FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
  3514. fileDownList.add(fileDown);
  3515. }
  3516. }
  3517. return fileDownList;
  3518. }
  3519. return fileDownList;
  3520. }
  3521. @Transactional
  3522. public void distributeFeedback(List<IndustrialLandSupplyDistribution> industrialLandSupplyDistributionList) {
  3523. for (IndustrialLandSupplyDistribution industrialLandSupplyDistribution : industrialLandSupplyDistributionList) {
  3524. industrialLandSupplyDistributionService.updateSelective(industrialLandSupplyDistribution);
  3525. FileDown file = industrialLandSupplyDistribution.getFeedback_file();
  3526. //保存材料
  3527. if (null != file && null != file.getFile_id()) {
  3528. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_FEEDBACK, industrialLandSupplyDistribution.getId());
  3529. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_FEEDBACK, industrialLandSupplyDistribution.getId(), file.getFile_id());
  3530. }
  3531. }
  3532. IndustrialLandSupplyDistribution industrialLandSupplyDistribution = industrialLandSupplyDistributionService.findById(industrialLandSupplyDistributionList.get(0).getId());
  3533. this.pass(Integer.valueOf(industrialLandSupplyDistribution.getIndustrial_land_supply_id()), null);
  3534. }
  3535. @Transactional
  3536. public void distributeSummary(IndustrialLandSupplyDetail industrialLandSupplyDetail) {
  3537. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  3538. entity.setId(industrialLandSupplyDetail.getId());
  3539. entity.setJoint_trial(industrialLandSupplyDetail.getJoint_trial());
  3540. if (industrialLandSupplyDetail.getJoint_trial()) {
  3541. entity.setJoint_trial_comment(industrialLandSupplyDetail.getJoint_trial_comment());
  3542. entity.setJoint_trial_result(industrialLandSupplyDetail.getJoint_trial_result());
  3543. }
  3544. entity.setDistribution_summary(industrialLandSupplyDetail.getDistribution_summary());
  3545. this.updateSelective(entity);
  3546. //保存材料
  3547. if (null != industrialLandSupplyDetail.getDistribution_summary_file() && null != industrialLandSupplyDetail.getDistribution_summary_file().getFile_id()) {
  3548. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_SUMMARY, industrialLandSupplyDetail.getId());
  3549. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_DISTRIBUTE_SUMMARY, industrialLandSupplyDetail.getId(), industrialLandSupplyDetail.getDistribution_summary_file().getFile_id());
  3550. }
  3551. if (industrialLandSupplyDetail.getJoint_trial()) {
  3552. if (null != industrialLandSupplyDetail.getJoint_trial_file() && null != industrialLandSupplyDetail.getJoint_trial_file().getFile_id()) {
  3553. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_JOINT_TRIAL, industrialLandSupplyDetail.getId());
  3554. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_JOINT_TRIAL, industrialLandSupplyDetail.getId(), industrialLandSupplyDetail.getJoint_trial_file().getFile_id());
  3555. }
  3556. }
  3557. this.pass(industrialLandSupplyDetail.getId(), null);
  3558. }
  3559. @Transactional
  3560. public void gsFeedback(IndustrialLandSupplyDetail industrialLandSupplyDetail) {
  3561. IndustrialLandSupplyDetail entity = new IndustrialLandSupplyDetail();
  3562. entity.setId(industrialLandSupplyDetail.getId());
  3563. entity.setGs_feedback(industrialLandSupplyDetail.getGs_feedback());
  3564. this.updateSelective(entity);
  3565. //保存材料
  3566. if (null != industrialLandSupplyDetail.getFileDown() && null != industrialLandSupplyDetail.getFileDown().getFile_id()) {
  3567. attachmentService.deleteByBusiness(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_GS, industrialLandSupplyDetail.getId());
  3568. attachmentService.updateAttachment(Constant.Attachment.INDUSTRIAL_LAND_SUPPLY_GS, industrialLandSupplyDetail.getId(), industrialLandSupplyDetail.getFileDown().getFile_id());
  3569. }
  3570. // this.pass(industrialLandSupplyDetail.getId(), null);
  3571. }
  3572. public void sendToLeader(Map<String, String> params) {
  3573. String ids = userService.getUserIdsByUserTypeAndRole(0, "产业供地领导", null);
  3574. String[] idArr = ids.split(",");
  3575. for (String id : idArr) {
  3576. //发送短信
  3577. try {
  3578. String templateCode = Constant.SMS_TemplateCode.INDUSTRIAL_LAND_SUPPLY_LEADER;
  3579. User user = userService.getUser(Integer.parseInt(id));
  3580. AlibabaSMSUtil.sendSMS(
  3581. user.getPhone(), templateCode, Constant.SINGNAMW, JSONObject.toJSONString(params)
  3582. );
  3583. } catch (Exception e) {
  3584. e.printStackTrace();
  3585. }
  3586. }
  3587. }
  3588. public void exportCountersignWord(int id, HttpServletResponse response) throws IOException {
  3589. IndustrialLandSupplyDetail entity = this.findById(id);
  3590. ExportWord ew = new ExportWord();
  3591. XWPFDocument document = ew.createXWPFDocument(6, 2);
  3592. List<List<Object>> list = new ArrayList<List<Object>>();
  3593. String title = entity.getTitle();
  3594. String content = entity.getContent_text();
  3595. String location = entity.getLocation();
  3596. String consultationSummary = entity.getConsultation_summary_text();
  3597. List<Object> tempList = new ArrayList<Object>();
  3598. tempList.add("项目标题");
  3599. tempList.add(title == null ? "" : title);
  3600. list.add(tempList);
  3601. tempList = new ArrayList<Object>();
  3602. tempList.add("项目内容");
  3603. tempList.add(content == null ? "" : content);
  3604. list.add(tempList);
  3605. tempList = new ArrayList<Object>();
  3606. tempList.add("用地信息");
  3607. tempList.add(location == null ? "" : location);
  3608. list.add(tempList);
  3609. tempList = new ArrayList<Object>();
  3610. tempList.add("部门意见\r" +
  3611. "(商务汇总意见)");
  3612. tempList.add(consultationSummary == null ? "" : consultationSummary);
  3613. list.add(tempList);
  3614. tempList = new ArrayList<Object>();
  3615. tempList.add("领导批示和会签意见");
  3616. tempList.add("");
  3617. list.add(tempList);
  3618. tempList = new ArrayList<Object>();
  3619. tempList.add("日期");
  3620. String time = DateUtil.getCurrentDateString("yyyy-MM-yy");
  3621. tempList.add(time);
  3622. list.add(tempList);
  3623. Map<String, Object> dataList = new HashMap<String, Object>();
  3624. dataList.put("TITLE", "苏州国家高新区产业用地预审办文单");
  3625. dataList.put("TABLEDATA", list);
  3626. response.reset();
  3627. response.setContentType("application/octet-stream; charset=utf-8");
  3628. response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("苏州国家高新区产业用地预审办文单" + "-" + time + ".docx", "UTF-8"));
  3629. ew.exportCheckWord(dataList, document, response);
  3630. }
  3631. public void exportCountersignWord2(int id, HttpServletResponse response) throws Exception {
  3632. IndustrialLandSupplyDetail entity = this.findById(id);
  3633. generateWord(entity, response);
  3634. }
  3635. private void generateWord(IndustrialLandSupplyDetail entity, HttpServletResponse response) throws Exception {
  3636. String time = DateUtil.getTimeString(new Date()).split(" ")[0];
  3637. final String name = "苏州国家高新区产业用地预审办文单" + "-" + time + ".docx";
  3638. // String templateUrl = repositoryPath + "/docs/annex_template/annex4.docx";
  3639. String templateUrl = "template/苏州高新区产业用地预审办文单.docx";
  3640. //文件数据库存储路径
  3641. // String outputUrl = getFilePath(name, "docs") + ".docx";
  3642. String title = entity.getTitle();
  3643. String content = entity.getContent_text();
  3644. String location = entity.getLocation();
  3645. String consultationSummary = entity.getConsultation_summary_text();
  3646. Map<String, String> dataMap = new HashMap<>();
  3647. dataMap.put("title", title == null ? "" : title);
  3648. dataMap.put("content", content == null ? "" : content);
  3649. dataMap.put("location", location == null ? "" : location);
  3650. dataMap.put("consultationSummary", consultationSummary == null ? "" : consultationSummary);
  3651. dataMap.put("time", time);
  3652. response.reset();
  3653. response.setContentType("application/octet-stream; charset=utf-8");
  3654. response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("苏州国家高新区产业用地预审办文单" + "-" + time + ".docx", "UTF-8"));
  3655. changWord(templateUrl, response, dataMap);
  3656. }
  3657. public String getFilePath(String sourceFileName, String typeFolder) {
  3658. String baseFolder = repositoryPath + File.separator + typeFolder;
  3659. Date nowDate = new Date();
  3660. // yyyy/MM/dd
  3661. String fileFolder = baseFolder + File.separator + com.xiaoleilu.hutool.date.DateUtil.format(nowDate, "yyyy")
  3662. + File.separator + com.xiaoleilu.hutool.date.DateUtil.format(nowDate, "MM") + File.separator
  3663. + com.xiaoleilu.hutool.date.DateUtil.format(nowDate, "dd");
  3664. File file = new File(fileFolder);
  3665. if (!file.isDirectory()) {
  3666. // 如果目录不存在,则创建目录
  3667. file.mkdirs();
  3668. }
  3669. // 生成新的文件名
  3670. String fileName = com.xiaoleilu.hutool.date.DateUtil.format(nowDate, "yyyyMMddHHmmss") + sourceFileName;
  3671. return fileFolder + File.separator + fileName;
  3672. }
  3673. private void changWord(String annexOneTempUrl, HttpServletResponse response, Map<String, String> dataMap) {
  3674. BokeWordUtils.changWord(annexOneTempUrl, response, dataMap, null);
  3675. }
  3676. }