IndustrialLandSupplyDetailService.java 199 KB

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