AdminApiController.java 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249
  1. package com.goafanti.admin.controller;
  2. import java.text.ParseException;
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.Calendar;
  6. import java.util.Date;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.TreeMap;
  10. import java.util.UUID;
  11. import javax.annotation.Resource;
  12. import javax.servlet.http.HttpServletRequest;
  13. import javax.servlet.http.HttpServletResponse;
  14. import javax.validation.Valid;
  15. import org.springframework.beans.BeanUtils;
  16. import org.springframework.stereotype.Controller;
  17. import org.springframework.validation.BindingResult;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RequestMethod;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import com.goafanti.admin.bo.AdminDetail;
  22. import com.goafanti.admin.bo.InputAdmin;
  23. import com.goafanti.admin.service.AdminService;
  24. import com.goafanti.cognizance.bo.ActivityNumberBo;
  25. import com.goafanti.cognizance.bo.AnnualReportBo;
  26. import com.goafanti.cognizance.bo.CognizanceDetailBo;
  27. import com.goafanti.cognizance.bo.InputApplyCognizance;
  28. import com.goafanti.cognizance.bo.InputOrgActivity;
  29. import com.goafanti.cognizance.bo.InputOrgActivityCost;
  30. import com.goafanti.cognizance.bo.InputOrgAnnualReport;
  31. import com.goafanti.cognizance.bo.InputOrgCognizance;
  32. import com.goafanti.cognizance.bo.InputOrgFinance;
  33. import com.goafanti.cognizance.bo.InputOrgHonorDatum;
  34. import com.goafanti.cognizance.bo.InputOrgHumanResource;
  35. import com.goafanti.cognizance.bo.InputOrgIntellectualProperty;
  36. import com.goafanti.cognizance.bo.InputOrgRatepay;
  37. import com.goafanti.cognizance.bo.InputOrgStandard;
  38. import com.goafanti.cognizance.bo.InputOrgTechAchievement;
  39. import com.goafanti.cognizance.bo.InputOrgTechCenter;
  40. import com.goafanti.cognizance.bo.InputOrgTechCenterDetail;
  41. import com.goafanti.cognizance.bo.InputOrgTechProduct;
  42. import com.goafanti.cognizance.service.OrgActivityCostService;
  43. import com.goafanti.cognizance.service.OrgActivityService;
  44. import com.goafanti.cognizance.service.OrgAnnualReportService;
  45. import com.goafanti.cognizance.service.OrgCognizanceLogService;
  46. import com.goafanti.cognizance.service.OrgCognizanceService;
  47. import com.goafanti.cognizance.service.OrgFinanceService;
  48. import com.goafanti.cognizance.service.OrgHonorDatumService;
  49. import com.goafanti.cognizance.service.OrgIntellectualPropertyService;
  50. import com.goafanti.cognizance.service.OrgRatepayService;
  51. import com.goafanti.cognizance.service.OrgStandardService;
  52. import com.goafanti.cognizance.service.OrgTechAchievementService;
  53. import com.goafanti.cognizance.service.OrgTechCenterDetailService;
  54. import com.goafanti.cognizance.service.OrgTechCenterService;
  55. import com.goafanti.cognizance.service.OrgTechProductService;
  56. import com.goafanti.common.bo.Result;
  57. import com.goafanti.common.constant.AFTConstants;
  58. import com.goafanti.common.constant.ErrorConstants;
  59. import com.goafanti.common.controller.CertifyApiController;
  60. import com.goafanti.common.enums.AdminFields;
  61. import com.goafanti.common.enums.AttachmentType;
  62. import com.goafanti.common.enums.CognizanceApplyFields;
  63. import com.goafanti.common.enums.OrgActivityFields;
  64. import com.goafanti.common.enums.OrgAnnualReportFields;
  65. import com.goafanti.common.enums.OrgCognizanceFields;
  66. import com.goafanti.common.enums.OrgCognizanceStatus;
  67. import com.goafanti.common.enums.OrgFinanceFields;
  68. import com.goafanti.common.enums.OrgHonorDatumFields;
  69. import com.goafanti.common.enums.OrgHumanResourceFields;
  70. import com.goafanti.common.enums.OrgIntellectualPropertyFields;
  71. import com.goafanti.common.enums.OrgRatepayFields;
  72. import com.goafanti.common.enums.OrgStandardFields;
  73. import com.goafanti.common.enums.OrgTechAchievementFields;
  74. import com.goafanti.common.enums.OrgTechCenterDetailFields;
  75. import com.goafanti.common.enums.OrgTechCenterFields;
  76. import com.goafanti.common.enums.OrgTechProductFields;
  77. import com.goafanti.common.enums.OrganizationIdentityFields;
  78. import com.goafanti.common.enums.UserAbilityFields;
  79. import com.goafanti.common.enums.UserIdentityFields;
  80. import com.goafanti.common.model.Admin;
  81. import com.goafanti.common.model.OrgActivity;
  82. import com.goafanti.common.model.OrgActivityCost;
  83. import com.goafanti.common.model.OrgAnnualReport;
  84. import com.goafanti.common.model.OrgCognizance;
  85. import com.goafanti.common.model.OrgCognizanceLog;
  86. import com.goafanti.common.model.OrgFinance;
  87. import com.goafanti.common.model.OrgHonorDatum;
  88. import com.goafanti.common.model.OrgHumanResource;
  89. import com.goafanti.common.model.OrgIntellectualProperty;
  90. import com.goafanti.common.model.OrgRatepay;
  91. import com.goafanti.common.model.OrgStandard;
  92. import com.goafanti.common.model.OrgTechAchievement;
  93. import com.goafanti.common.model.OrgTechCenter;
  94. import com.goafanti.common.model.OrgTechCenterDetail;
  95. import com.goafanti.common.model.OrgTechProduct;
  96. import com.goafanti.common.model.OrganizationIdentity;
  97. import com.goafanti.common.model.User;
  98. import com.goafanti.common.model.UserAbility;
  99. import com.goafanti.common.model.UserIdentity;
  100. import com.goafanti.common.utils.DateUtils;
  101. import com.goafanti.common.utils.PasswordUtil;
  102. import com.goafanti.common.utils.StringUtils;
  103. import com.goafanti.core.mybatis.page.Pagination;
  104. import com.goafanti.core.shiro.token.TokenManager;
  105. import com.goafanti.user.bo.InputOrganizationIdentity;
  106. import com.goafanti.user.bo.InputUserAbility;
  107. import com.goafanti.user.bo.InputUserIdentity;
  108. import com.goafanti.user.bo.OrgListBo;
  109. import com.goafanti.user.bo.UserListBo;
  110. import com.goafanti.user.service.OrgHumanResourceService;
  111. import com.goafanti.user.service.OrganizationIdentityService;
  112. import com.goafanti.user.service.UserAbilityService;
  113. import com.goafanti.user.service.UserIdentityService;
  114. import com.goafanti.user.service.UserService;
  115. @Controller
  116. @RequestMapping(value = "/api/admin")
  117. public class AdminApiController extends CertifyApiController {
  118. @Resource
  119. private UserService userService;
  120. @Resource
  121. private UserIdentityService userIdentityService;
  122. @Resource
  123. private OrganizationIdentityService organizationIdentityService;
  124. @Resource
  125. private OrgHumanResourceService orgHumanResourceService;
  126. @Resource
  127. private OrgStandardService orgStandardService;
  128. @Resource
  129. private OrgIntellectualPropertyService orgIntellectualPropertyService;
  130. @Resource
  131. private OrgTechProductService orgTechProductService;
  132. @Resource
  133. private OrgRatepayService orgRatepayService;
  134. @Resource
  135. private OrgFinanceService orgFinanceService;
  136. @Resource
  137. private OrgActivityService orgActivityService;
  138. @Resource
  139. private OrgActivityCostService orgActivityCostService;
  140. @Resource
  141. private OrgTechAchievementService orgTechAchievementService;
  142. @Resource
  143. private OrgHonorDatumService orgHonorDatumService;
  144. @Resource
  145. private OrgTechCenterService orgTechCenterService;
  146. @Resource
  147. private OrgCognizanceService orgCognizanceService;
  148. @Resource
  149. private OrgCognizanceLogService orgCognizanceLogService;
  150. @Resource
  151. private UserAbilityService userAbilityService;
  152. @Resource
  153. private OrgAnnualReportService orgAnnualReportService;
  154. @Resource(name = "passwordUtil")
  155. private PasswordUtil passwordUtil;
  156. @Resource
  157. private AdminService adminService;
  158. @Resource
  159. private OrgTechCenterDetailService orgTechCenterDetailService;
  160. /**
  161. * 管理员修改本人信息
  162. * @param admin
  163. * @param bindingResult
  164. * @return
  165. */
  166. @RequestMapping(value = "/updateAdminInfo", method = RequestMethod.POST)
  167. public Result updateAdminInfo(@Valid InputAdmin admin, String pwd, BindingResult bindingResult){
  168. Result res = new Result();
  169. if (!checkAdminLogin(res)) {
  170. return res;
  171. }
  172. if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  173. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "超级管理员"));
  174. return res;
  175. }
  176. if (bindingResult.hasErrors()) {
  177. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  178. AdminFields.getFieldDesc(bindingResult.getFieldError().getField())));
  179. return res;
  180. }
  181. if (StringUtils.isBlank(admin.getId())){
  182. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
  183. return res;
  184. }
  185. if (StringUtils.isBlank(admin.getMobile())) {
  186. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "登录帐号为空", "登录帐号"));
  187. return res;
  188. }
  189. if (StringUtils.isBlank(admin.getName())) {
  190. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名为空", "用户名"));
  191. return res;
  192. }
  193. Admin a = adminService.selectByMobile(admin.getMobile().trim());
  194. if (!TokenManager.getAdminId().equals(a.getId())) {
  195. res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
  196. return res;
  197. }
  198. Admin ad = new Admin();
  199. BeanUtils.copyProperties(admin, ad);
  200. Admin aa = adminService.selectByPrimaryKey(TokenManager.getAdminId());
  201. ad.setMobile(ad.getMobile().trim());
  202. ad.setCreateTime(aa.getCreateTime());
  203. if (!StringUtils.isBlank(ad.getPassword())){
  204. if (StringUtils.isBlank(pwd)){
  205. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "原密码"));
  206. return res;
  207. }
  208. if (!aa.getPassword().equals(passwordUtil.getEncryptPwd(pwd, aa.getCreateTime()))) {
  209. res.getError().add(buildError(ErrorConstants.PWD_NOT_MATCH_ERROR,"","原密码"));
  210. return res;
  211. }
  212. } else {
  213. ad.setPassword(aa.getPassword());
  214. }
  215. ad.setPassword(passwordUtil.getEncryptPwd(ad));
  216. res.setData(adminService.updateByPrimaryKey(ad));
  217. return res;
  218. }
  219. /**
  220. * 管理员本人信息详情
  221. * @param id
  222. * @return
  223. */
  224. @RequestMapping(value = "/adminInfo", method = RequestMethod.GET)
  225. public Result adminInfo(){
  226. Result res = new Result();
  227. if (!checkAdminLogin(res)) {
  228. return res;
  229. }
  230. if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  231. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "超级管理员"));
  232. return res;
  233. }
  234. res.setData(adminService.selectByPrimaryKey(TokenManager.getAdminId()));
  235. return res;
  236. }
  237. /**
  238. * 管理员列表
  239. *
  240. * @param province
  241. * @param number
  242. * @param mobile
  243. * @param name
  244. * @param pageNo
  245. * @param pageSize
  246. * @return
  247. */
  248. @RequestMapping(value = "/adminList", method = RequestMethod.GET)
  249. public Result adminList(String province, Integer number, String mobile, String name, String pageNo,
  250. String pageSize) {
  251. Result res = new Result();
  252. if (!checkAdminLogin(res)) {
  253. return res;
  254. }
  255. Integer pNo = 1;
  256. Integer pSize = 10;
  257. if (StringUtils.isNumeric(pageSize)) {
  258. pSize = Integer.parseInt(pageSize);
  259. }
  260. if (StringUtils.isNumeric(pageNo)) {
  261. pNo = Integer.parseInt(pageNo);
  262. }
  263. res.setData(adminService.listAdmin(province, number, mobile, name, pNo, pSize));
  264. return res;
  265. }
  266. /**
  267. * 新增管理员
  268. *
  269. * @param admin
  270. * @param bindingResult
  271. * @return
  272. */
  273. @RequestMapping(value = "/insertAdmin", method = RequestMethod.POST)
  274. public Result insertAdmin(@Valid InputAdmin admin, BindingResult bindingResult) {
  275. Result res = new Result();
  276. if (bindingResult.hasErrors()) {
  277. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  278. AdminFields.getFieldDesc(bindingResult.getFieldError().getField())));
  279. return res;
  280. }
  281. if (!checkAdminLogin(res)) {
  282. return res;
  283. }
  284. if (StringUtils.isBlank(admin.getMobile())) {
  285. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "登录帐号为空", "登录帐号"));
  286. return res;
  287. }
  288. if (StringUtils.isBlank(admin.getName())) {
  289. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名为空", "用户名"));
  290. return res;
  291. }
  292. Admin a = adminService.selectByMobile(admin.getMobile().trim());
  293. if (null != a) {
  294. res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
  295. return res;
  296. }
  297. Calendar now = Calendar.getInstance();
  298. now.set(Calendar.MILLISECOND, 0);
  299. Admin ad = new Admin();
  300. BeanUtils.copyProperties(admin, ad);
  301. ad.setId(UUID.randomUUID().toString());
  302. ad.setCreateTime(now.getTime());
  303. if (StringUtils.isBlank(ad.getPassword())){
  304. ad.setPassword("123456");
  305. }
  306. ad.setPassword(passwordUtil.getEncryptPwd(ad));
  307. adminService.insert(ad);
  308. return res;
  309. }
  310. /**
  311. * 管理员详情
  312. * @param id
  313. * @return
  314. */
  315. @RequestMapping(value = "/adminDetail", method = RequestMethod.GET)
  316. public Result adminDetail(String id){
  317. Result res = new Result();
  318. if (StringUtils.isBlank(id)){
  319. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
  320. return res;
  321. }
  322. AdminDetail ad = adminService.selectAdminDetail(id);
  323. res.setData(ad);
  324. return res;
  325. }
  326. /**
  327. * 修改管理员信息
  328. *
  329. * @param admin
  330. * @param bindingResult
  331. * @return
  332. */
  333. @RequestMapping(value = "/updateAdmin", method = RequestMethod.POST)
  334. public Result updateAdmin(@RequestParam(value = "roles[]", required = false) String[] roleIds,
  335. @Valid InputAdmin admin, BindingResult bindingResult) {
  336. Result res = new Result();
  337. if (bindingResult.hasErrors()) {
  338. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  339. AdminFields.getFieldDesc(bindingResult.getFieldError().getField())));
  340. return res;
  341. }
  342. if (!checkAdminLogin(res)) {
  343. return res;
  344. }
  345. if (null == admin.getId()) {
  346. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
  347. return res;
  348. }
  349. if (null == admin.getMobile()) {
  350. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "登录帐号为空", "登录帐号"));
  351. return res;
  352. }
  353. if (null == admin.getName()) {
  354. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名为空", "用户名"));
  355. return res;
  356. }
  357. Admin aa = adminService.selectByMobile(admin.getMobile().trim());
  358. if (!admin.getId().equals(aa.getId()) ){
  359. res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
  360. return res;
  361. }
  362. Admin a = adminService.selectByPrimaryKey(admin.getId());
  363. if (null == a){
  364. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
  365. return res;
  366. }
  367. Admin ad = new Admin();
  368. BeanUtils.copyProperties(admin, ad);
  369. List<String> roles = new ArrayList<String>();
  370. for (String role : roleIds){
  371. roles.add(role);
  372. }
  373. res.setData(adminService.updateByPrimaryKeySelective(ad, roles));
  374. return res;
  375. }
  376. /**
  377. * 重置管理员密码
  378. * @param id
  379. * @return
  380. */
  381. @RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
  382. public Result resetPwd(String id) {
  383. Result res = new Result();
  384. if (!checkAdminLogin(res)) {
  385. return res;
  386. }
  387. if (StringUtils.isBlank(id)) {
  388. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
  389. return res;
  390. }
  391. Admin admin = adminService.selectByPrimaryKey(id);
  392. if (null == admin){
  393. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户id"));
  394. return res;
  395. }
  396. Admin a = new Admin();
  397. a.setId(admin.getId());
  398. a.setCreateTime(admin.getCreateTime());
  399. a.setPassword("123456");
  400. a.setPassword(passwordUtil.getEncryptPwd(a));
  401. res.setData(adminService.updateByPrimaryKey(a));
  402. return res;
  403. }
  404. /**
  405. * 个人用户列表
  406. *
  407. * @param mobile
  408. * @param email
  409. * @param createTime
  410. * @param number
  411. * @param auditStatus
  412. * @param pageNo
  413. * @param pageSize
  414. * @return
  415. * @throws ParseException
  416. */
  417. @RequestMapping(value = "/userList", method = RequestMethod.POST)
  418. public Result userList(String mobile, String email,
  419. @RequestParam(name = "createTime[]", required = false) String[] createTime, Integer number,
  420. String aftUsername, Integer auditStatus, String pageNo, String pageSize) throws ParseException {
  421. Result res = new Result();
  422. if (!checkAdminLogin(res)) {
  423. return res;
  424. }
  425. Integer pNo = 1;
  426. Integer pSize = 10;
  427. if (StringUtils.isNumeric(pageSize)) {
  428. pSize = Integer.parseInt(pageSize);
  429. }
  430. if (StringUtils.isNumeric(pageNo)) {
  431. pNo = Integer.parseInt(pageNo);
  432. }
  433. res.setData(getUserList(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize));
  434. return res;
  435. }
  436. /**
  437. * 新增用户
  438. *
  439. * @param mobile
  440. * @param type
  441. * @param unitName
  442. * @return
  443. */
  444. @RequestMapping(value = "/addNewUser", method = RequestMethod.POST)
  445. public Result addNewUser(String mobile, Integer type, String unitName) {
  446. Result res = new Result();
  447. if (!checkAdminLogin(res)) {
  448. return res;
  449. }
  450. if (StringUtils.isBlank(mobile)) {
  451. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "mobile", "mobile"));
  452. return res;
  453. }
  454. if (null == type) {
  455. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "type", "type"));
  456. return res;
  457. }
  458. User user = userService.selectByMobieAndType(mobile.trim(), type);
  459. if (null != user) {
  460. res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
  461. return res;
  462. }
  463. User u = new User();
  464. u.setId(UUID.randomUUID().toString());
  465. u.setMobile(mobile.trim());
  466. u.setPassword(mobile.trim());
  467. u.setType(type);
  468. Calendar now = Calendar.getInstance();
  469. now.set(Calendar.MILLISECOND, 0);
  470. u.setCreateTime(now.getTime());
  471. u.setPassword(passwordUtil.getEncryptPwd(u));
  472. u.setLvl(0);
  473. u.setAid(TokenManager.getAdminId());
  474. userService.insertRegister(u, "", unitName);
  475. return res;
  476. }
  477. /**
  478. * 个人用户信息明细
  479. *
  480. * @param uid
  481. * @return
  482. */
  483. @RequestMapping(value = "/userDetail", method = RequestMethod.POST)
  484. public Result userDetail(String uid) {
  485. Result res = new Result();
  486. if (!checkAdminLogin(res)) {
  487. return res;
  488. }
  489. if (StringUtils.isBlank(uid)) {
  490. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  491. return res;
  492. }
  493. res.setData(userIdentityService.selectUserIdentityByUserId(uid));
  494. return res;
  495. }
  496. /**
  497. * 修改个人用户信息
  498. *
  499. * @return
  500. * @throws ParseException
  501. */
  502. @RequestMapping(value = "updateUserDetail", method = RequestMethod.POST)
  503. public Result updateUserDetail(@Valid InputUserIdentity userIdentity, BindingResult bindingResult,
  504. String paymentDateFormattedDate) {
  505. Result res = new Result();
  506. if (bindingResult.hasErrors()) {
  507. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  508. UserIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
  509. return res;
  510. }
  511. if (!checkAdminLogin(res)) {
  512. return res;
  513. }
  514. if (null == userIdentity.getUid()) {
  515. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  516. return res;
  517. }
  518. if (!StringUtils.isBlank(paymentDateFormattedDate)) {
  519. try {
  520. userIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, AFTConstants.YYYYMMDD));
  521. } catch (ParseException e) {
  522. }
  523. }
  524. UserIdentity ui = new UserIdentity();
  525. BeanUtils.copyProperties(userIdentity, ui);
  526. if (StringUtils.isBlank(ui.getId())) {
  527. ui.setId(UUID.randomUUID().toString());
  528. ui.setAuditStatus(null == userIdentity.getAuditStatus() ? 0 : userIdentity.getAuditStatus());
  529. ui.setProcess(null == userIdentity.getProcess() ? 0 : userIdentity.getProcess());
  530. res.setData(userIdentityService.insert(ui));
  531. } else {
  532. res.setData(userIdentityService.updateUserDetail(ui));
  533. }
  534. return res;
  535. }
  536. /**
  537. * 团体用户列表
  538. *
  539. * @param mobile
  540. * @param email
  541. * @param createTime
  542. * @param number
  543. * @param auditStatus
  544. * @param pageNo
  545. * @param pageSize
  546. * @return
  547. * @throws ParseException
  548. */
  549. @RequestMapping(value = "/orgList", method = RequestMethod.POST)
  550. public Result orgList(String uid, String mobile, String email,
  551. @RequestParam(name = "createTime[]", required = false) String[] createTime, Integer number, String unitName,
  552. Integer auditStatus, String pageNo, String pageSize) throws ParseException {
  553. Result res = new Result();
  554. if (!checkAdminLogin(res)) {
  555. return res;
  556. }
  557. Integer pNo = 1;
  558. Integer pSize = 10;
  559. if (StringUtils.isNumeric(pageSize)) {
  560. pSize = Integer.parseInt(pageSize);
  561. }
  562. if (StringUtils.isNumeric(pageNo)) {
  563. pNo = Integer.parseInt(pageNo);
  564. }
  565. res.setData(getOrgList(uid, mobile, email, createTime, number, unitName, auditStatus, pNo, pSize));
  566. return res;
  567. }
  568. /**
  569. * 团体用户明细
  570. *
  571. * @param uid
  572. * @return
  573. */
  574. @RequestMapping(value = "/orgDetail", method = RequestMethod.POST)
  575. public Result orgDetail(String uid) {
  576. Result res = new Result();
  577. if (!checkAdminLogin(res)) {
  578. return res;
  579. }
  580. if (StringUtils.isBlank(uid)) {
  581. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  582. return res;
  583. }
  584. res.setData(organizationIdentityService.selectOrgIdentityByUserId(uid));
  585. return res;
  586. }
  587. /**
  588. * 修改团体用户信息
  589. *
  590. * @param orgIdentity
  591. * @return
  592. * @throws ParseException
  593. */
  594. @RequestMapping(value = "/updateOrgDetail", method = RequestMethod.POST)
  595. public Result updateOrgDetail(@Valid InputOrganizationIdentity orgIdentity, BindingResult bindingResult,
  596. String paymentDateFormattedDate) {
  597. Result res = new Result();
  598. if (bindingResult.hasErrors()) {
  599. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  600. OrganizationIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
  601. return res;
  602. }
  603. if (!checkAdminLogin(res)) {
  604. return res;
  605. }
  606. if (null == orgIdentity.getUid()) {
  607. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  608. return res;
  609. }
  610. if (!StringUtils.isBlank(paymentDateFormattedDate)) {
  611. try {
  612. orgIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, AFTConstants.YYYYMMDD));
  613. } catch (ParseException e) {
  614. }
  615. }
  616. OrganizationIdentity oi = new OrganizationIdentity();
  617. BeanUtils.copyProperties(orgIdentity, oi);
  618. if (StringUtils.isBlank(oi.getId())) {
  619. oi.setId(UUID.randomUUID().toString());
  620. oi.setIdentityType(null == oi.getIdentityType() ? 0 : oi.getIdentityType());
  621. oi.setAuditStatus(null == oi.getAuditStatus() ? 0 : oi.getAuditStatus());
  622. oi.setProcess(null == oi.getProcess() ? 0 : oi.getProcess());
  623. oi.setListed(null == oi.getListed() ? 0 : oi.getListed());
  624. oi.setListedType(null == oi.getListedType() ? 0 : oi.getListedType());
  625. res.setData(organizationIdentityService.insert(oi));
  626. } else {
  627. res.setData(organizationIdentityService.updateOrgDetail(oi));
  628. }
  629. return res;
  630. }
  631. /**
  632. * 团体用户人力资源情况列表
  633. *
  634. * @param uid
  635. * 用户ID
  636. * @return
  637. */
  638. @RequestMapping(value = "/orgHumanResource", method = RequestMethod.POST)
  639. public Result orgHumanResource(Integer year, String pageNo, String pageSize, String uid) {
  640. Result res = new Result();
  641. if (!checkAdminLogin(res)) {
  642. return res;
  643. }
  644. if (StringUtils.isBlank(uid)) {
  645. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  646. return res;
  647. }
  648. if (!checkCertify(res, uid).getError().isEmpty()) {
  649. return res;
  650. }
  651. Integer pNo = 1;
  652. Integer pSize = 10;
  653. if (StringUtils.isNumeric(pageSize)) {
  654. pSize = Integer.parseInt(pageSize);
  655. }
  656. if (StringUtils.isNumeric(pageNo)) {
  657. pNo = Integer.parseInt(pageNo);
  658. }
  659. res.setData(orgHumanResourceService.listOrgHumanResource(year, pNo, pSize, uid));
  660. return res;
  661. }
  662. /**
  663. * 新增及修改团体用户人力资源情况
  664. *
  665. * @param orgHumanResource
  666. * @return
  667. */
  668. @RequestMapping(value = "/updateOrgHumanResource", method = RequestMethod.POST)
  669. public Result updateOrgHumanResource(@Valid InputOrgHumanResource orgHumanResource, BindingResult bindingResult) {
  670. Result res = new Result();
  671. if (bindingResult.hasErrors()) {
  672. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  673. OrgHumanResourceFields.getFieldDesc(bindingResult.getFieldError().getField())));
  674. return res;
  675. }
  676. if (!checkAdminLogin(res)) {
  677. return res;
  678. }
  679. if (StringUtils.isBlank(orgHumanResource.getUid())) {
  680. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  681. return res;
  682. }
  683. if (null == orgHumanResource.getYear()) {
  684. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到年份", "年份"));
  685. return res;
  686. }
  687. if (!checkCertify(res, orgHumanResource.getUid()).getError().isEmpty()) {
  688. return res;
  689. }
  690. OrgHumanResource ohr = new OrgHumanResource();
  691. BeanUtils.copyProperties(orgHumanResource, ohr);
  692. if (StringUtils.isBlank(ohr.getId())) {
  693. if (null != orgHumanResourceService.selectOrgHumanResourceByUidAndYear(ohr.getYear(), ohr.getUid())) {
  694. res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度人力资源情况已录入!"));
  695. return res;
  696. }
  697. ohr.setId(UUID.randomUUID().toString());
  698. ohr.setDeletedSign(0);
  699. orgHumanResourceService.insert(ohr);
  700. } else {
  701. orgHumanResourceService.updateByPrimaryKeySelective(ohr);
  702. }
  703. return res;
  704. }
  705. /**
  706. * 企业花名册上传
  707. *
  708. * @param req
  709. * @param sign
  710. * @param uid
  711. * @return
  712. */
  713. @RequestMapping(value = "/uploadRoster", method = RequestMethod.POST)
  714. public Result uploadRoster(HttpServletRequest req, String sign, String uid, String year) {
  715. Result res = new Result();
  716. if (!checkAdminLogin(res)) {
  717. return res;
  718. }
  719. if (StringUtils.isBlank(year)) {
  720. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示年份"));
  721. return res;
  722. }
  723. User curUser = userService.selectByPrimaryKey(uid);
  724. if (!checkCertify(res, curUser)) {
  725. return res;
  726. }
  727. AttachmentType attachmentType = AttachmentType.getField(sign);
  728. if (attachmentType == AttachmentType.ROSTER) {
  729. sign = sign + "_" + year;
  730. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  731. } else {
  732. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  733. }
  734. return res;
  735. }
  736. /**
  737. * 企业社保情况表上传
  738. *
  739. * @param req
  740. * @param sign
  741. * @param uid
  742. * @return
  743. */
  744. @RequestMapping(value = "/uploadSocialSecurity", method = RequestMethod.POST)
  745. public Result uploadSocialSecurity(HttpServletRequest req, String sign, String uid, String year) {
  746. Result res = new Result();
  747. if (!checkAdminLogin(res)) {
  748. return res;
  749. }
  750. if (StringUtils.isBlank(year)) {
  751. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示年份"));
  752. return res;
  753. }
  754. User curUser = userService.selectByPrimaryKey(uid);
  755. if (!checkCertify(res, curUser)) {
  756. return res;
  757. }
  758. AttachmentType attachmentType = AttachmentType.getField(sign);
  759. if (attachmentType == AttachmentType.SOCIAL_SECURITY) {
  760. sign = sign + "_" + year;
  761. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  762. } else {
  763. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  764. }
  765. return res;
  766. }
  767. /**
  768. * 企业花名册及社保情况表下载
  769. *
  770. * @param response
  771. * @param sign
  772. * @param id
  773. * @return
  774. */
  775. @RequestMapping(value = "/downloadHumanResource", method = RequestMethod.GET)
  776. public Result downloadHumanResource(HttpServletResponse response, String sign, String id) {
  777. Result res = new Result();
  778. if (!checkAdminLogin(res)) {
  779. return res;
  780. }
  781. if (StringUtils.isEmpty(id)) {
  782. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业人员情况id"));
  783. return res;
  784. }
  785. OrgHumanResource ohr = orgHumanResourceService.selectByPrimaryKey(id);
  786. if (ohr == null) {
  787. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业人员情况id"));
  788. return res;
  789. }
  790. AttachmentType attachmentType = AttachmentType.getField(sign);
  791. if (attachmentType == AttachmentType.ROSTER) {
  792. downloadFile(response, ohr.getRosterDownloadFileName(), ohr.getRosterUrl());
  793. } else if (attachmentType == AttachmentType.SOCIAL_SECURITY) {
  794. downloadFile(response, ohr.getSocialSecurityDownloadFileName(), ohr.getSocialSecurityUrl());
  795. } else {
  796. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  797. }
  798. return res;
  799. }
  800. /**
  801. * 企业参与国家标准或行业标准制定情况明细列表
  802. *
  803. * @param uid
  804. * 用户id
  805. * @return
  806. */
  807. @RequestMapping(value = "/standard", method = RequestMethod.POST)
  808. public Result standard(String uid, String standardName, String standardNumber, Integer standardLevel,
  809. Integer participateWay, String pageNo, String pageSize) {
  810. Result res = new Result();
  811. if (!checkAdminLogin(res)) {
  812. return res;
  813. }
  814. if (StringUtils.isBlank(uid)) {
  815. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  816. return res;
  817. }
  818. if (!checkCertify(res, uid).getError().isEmpty()) {
  819. return res;
  820. }
  821. Integer pNo = 1;
  822. Integer pSize = 10;
  823. if (StringUtils.isNumeric(pageSize)) {
  824. pSize = Integer.parseInt(pageSize);
  825. }
  826. if (StringUtils.isNumeric(pageNo)) {
  827. pNo = Integer.parseInt(pageNo);
  828. }
  829. res.setData(orgStandardService.listOrgStandard(standardName, standardNumber, standardLevel, participateWay, pNo,
  830. pSize, uid));
  831. return res;
  832. }
  833. /**
  834. * 企业参与国家标准或行业标准制定情况明细新增及修改
  835. *
  836. * @param orgStandard
  837. * @return
  838. */
  839. @RequestMapping(value = "/developStandard", method = RequestMethod.POST)
  840. public Result developStandard(@Valid InputOrgStandard orgStandard, BindingResult bindingResult) {
  841. Result res = new Result();
  842. if (bindingResult.hasErrors()) {
  843. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  844. OrgStandardFields.getFieldDesc(bindingResult.getFieldError().getField())));
  845. return res;
  846. }
  847. if (!checkAdminLogin(res)) {
  848. return res;
  849. }
  850. if (StringUtils.isBlank(orgStandard.getUid())) {
  851. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  852. return res;
  853. }
  854. if (!checkCertify(res, orgStandard.getUid()).getError().isEmpty()) {
  855. return res;
  856. }
  857. OrgStandard os = new OrgStandard();
  858. BeanUtils.copyProperties(orgStandard, os);
  859. if (StringUtils.isBlank(os.getId())) {
  860. os.setId(UUID.randomUUID().toString());
  861. os.setDeletedSign(0);
  862. Calendar now = Calendar.getInstance();
  863. now.set(Calendar.MILLISECOND, 0);
  864. os.setCreateTime(now.getTime());
  865. orgStandardService.insert(os);
  866. } else {
  867. orgStandardService.updateByPrimaryKeySelective(os);
  868. }
  869. res.setData(orgStandard);
  870. return res;
  871. }
  872. /**
  873. * 删除选中标准制定情况记录
  874. *
  875. * @param id
  876. * 记录id
  877. * @return
  878. */
  879. @RequestMapping(value = "/deleteStandard", method = RequestMethod.POST)
  880. public Result deleteStandard(@RequestParam(name = "ids[]", required = false) String[] ids) {
  881. Result res = new Result();
  882. if (!checkAdminLogin(res)) {
  883. return res;
  884. }
  885. if (ids == null || ids.length < 1) {
  886. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  887. } else {
  888. res.setData(orgStandardService.deleteByPrimaryKey(Arrays.asList(ids)));
  889. }
  890. return res;
  891. }
  892. /**
  893. * 知识产权列表
  894. *
  895. * @param pageNo
  896. * @param pageSize
  897. * @return
  898. */
  899. @RequestMapping(value = "/intellectualList", method = RequestMethod.POST)
  900. public Result intellectualList(String pageNo, String pageSize, String uid) {
  901. Result res = new Result();
  902. if (!checkAdminLogin(res)) {
  903. return res;
  904. }
  905. if (StringUtils.isBlank(uid)) {
  906. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  907. return res;
  908. }
  909. if (!checkCertify(res, uid).getError().isEmpty()) {
  910. return res;
  911. }
  912. Integer pNo = 1;
  913. Integer pSize = 10;
  914. if (StringUtils.isNumeric(pageSize)) {
  915. pSize = Integer.parseInt(pageSize);
  916. }
  917. if (StringUtils.isNumeric(pageNo)) {
  918. pNo = Integer.parseInt(pageNo);
  919. }
  920. res.setData(orgIntellectualPropertyService.listIntellectual(pNo, pSize, uid));
  921. return res;
  922. }
  923. /**
  924. * 知识产权信息新增及修改
  925. *
  926. * @return
  927. * @throws ParseException
  928. */
  929. @RequestMapping(value = "/intellectual", method = RequestMethod.POST)
  930. public Result intellectual(@Valid InputOrgIntellectualProperty orgIntellectualProperty, BindingResult bindingResult,
  931. String authorizationDateFormattedDate) {
  932. Result res = new Result();
  933. if (bindingResult.hasErrors()) {
  934. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  935. OrgIntellectualPropertyFields.getFieldDesc(bindingResult.getFieldError().getField())));
  936. return res;
  937. }
  938. if (!checkAdminLogin(res)) {
  939. return res;
  940. }
  941. if (StringUtils.isBlank(orgIntellectualProperty.getUid())) {
  942. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  943. return res;
  944. }
  945. if (!checkCertify(res, orgIntellectualProperty.getUid()).getError().isEmpty()) {
  946. return res;
  947. }
  948. if (!StringUtils.isBlank(authorizationDateFormattedDate)) {
  949. try {
  950. orgIntellectualProperty.setAuthorizationDate(
  951. DateUtils.parseDate(authorizationDateFormattedDate, AFTConstants.YYYYMMDD));
  952. } catch (ParseException e) {
  953. }
  954. }
  955. OrgIntellectualProperty oip = new OrgIntellectualProperty();
  956. BeanUtils.copyProperties(orgIntellectualProperty, oip);
  957. if (StringUtils.isBlank(oip.getId())) {
  958. oip.setId(UUID.randomUUID().toString());
  959. oip.setEvaluationCategory((oip.getCatagory() >= 2 && oip.getCatagory() <= 4) ? 1 : 0);
  960. oip.setDeletedSign(0);
  961. res.setData(orgIntellectualPropertyService.insert(oip));
  962. } else {
  963. oip.setEvaluationCategory(orgIntellectualProperty.getCatagory() <= 2 ? 1 : 0);
  964. res.setData(orgIntellectualPropertyService.updateByPrimaryKeySelective(oip));
  965. }
  966. return res;
  967. }
  968. /**
  969. * 知识产权证书上传
  970. *
  971. * @param req
  972. * @param sign
  973. * @param uid
  974. * @return
  975. */
  976. @RequestMapping(value = "/uploadPropertyRight", method = RequestMethod.POST)
  977. public Result uploadPropertyRight(HttpServletRequest req, String sign, String uid) {
  978. Result res = new Result();
  979. if (!checkAdminLogin(res)) {
  980. return res;
  981. }
  982. User curUser = userService.selectByPrimaryKey(uid);
  983. if (!checkCertify(res, curUser)) {
  984. return res;
  985. }
  986. AttachmentType attachmentType = AttachmentType.getField(sign);
  987. if (attachmentType == AttachmentType.PROPERTY_RIGHT) {
  988. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  989. } else {
  990. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  991. }
  992. return res;
  993. }
  994. /**
  995. * 知识产权证书下载
  996. *
  997. * @param response
  998. * @param sign
  999. * @param id
  1000. * @return
  1001. */
  1002. @RequestMapping(value = "/downloadPropertyRight", method = RequestMethod.GET)
  1003. public Result downloadPropertyRight(HttpServletResponse response, String sign, String id) {
  1004. Result res = new Result();
  1005. if (!checkAdminLogin(res)) {
  1006. return res;
  1007. }
  1008. if (StringUtils.isEmpty(id)) {
  1009. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "知识产权id"));
  1010. return res;
  1011. }
  1012. OrgIntellectualProperty olp = orgIntellectualPropertyService.selectByPrimaryKey(id);
  1013. if (olp == null) {
  1014. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "知识产权id"));
  1015. return res;
  1016. }
  1017. AttachmentType attachmentType = AttachmentType.getField(sign);
  1018. if (attachmentType == AttachmentType.PROPERTY_RIGHT) {
  1019. downloadFile(response, olp.getPropertyRightDownloadFileName(), olp.getPropertyRightUrl());
  1020. } else {
  1021. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1022. }
  1023. return res;
  1024. }
  1025. /**
  1026. * 删除知识产权记录
  1027. *
  1028. * @param id
  1029. * @return
  1030. */
  1031. @RequestMapping(value = "/deleteIntellectual", method = RequestMethod.POST)
  1032. public Result deleteIntellectual(@RequestParam(name = "ids[]", required = false) String[] ids) {
  1033. Result res = new Result();
  1034. if (!checkAdminLogin(res)) {
  1035. return res;
  1036. }
  1037. if (ids == null || ids.length < 1) {
  1038. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  1039. } else {
  1040. res.setData(orgIntellectualPropertyService.deleteByPrimaryKey(Arrays.asList(ids)));
  1041. }
  1042. return res;
  1043. }
  1044. /**
  1045. * 上年度高新技术产品(服务)情况列表
  1046. *
  1047. * @param pageNo
  1048. * @param pageSize
  1049. * @return
  1050. */
  1051. @RequestMapping(value = "/techProductList", method = RequestMethod.POST)
  1052. public Result techProductList(String pageNo, String pageSize, String uid) {
  1053. Result res = new Result();
  1054. if (!checkAdminLogin(res)) {
  1055. return res;
  1056. }
  1057. if (StringUtils.isBlank(uid)) {
  1058. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1059. return res;
  1060. }
  1061. if (!checkCertify(res, uid).getError().isEmpty()) {
  1062. return res;
  1063. }
  1064. Integer pNo = 1;
  1065. Integer pSize = 10;
  1066. if (StringUtils.isNumeric(pageSize)) {
  1067. pSize = Integer.parseInt(pageSize);
  1068. }
  1069. if (StringUtils.isNumeric(pageNo)) {
  1070. pNo = Integer.parseInt(pageNo);
  1071. }
  1072. res.setData(orgTechProductService.listTechProduct(pNo, pSize, uid));
  1073. return res;
  1074. }
  1075. /**
  1076. * 上年度高新技术产品(服务)情况(新增+修改)
  1077. *
  1078. * @param orgTechProduct
  1079. * @return
  1080. */
  1081. @RequestMapping(value = "/techProduct", method = RequestMethod.POST)
  1082. public Result techProduct(@Valid InputOrgTechProduct orgTechProduct, BindingResult bindingResult) {
  1083. Result res = new Result();
  1084. if (bindingResult.hasErrors()) {
  1085. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  1086. OrgTechProductFields.getFieldDesc(bindingResult.getFieldError().getField())));
  1087. return res;
  1088. }
  1089. if (!checkAdminLogin(res)) {
  1090. return res;
  1091. }
  1092. if (StringUtils.isBlank(orgTechProduct.getUid())) {
  1093. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1094. return res;
  1095. }
  1096. if (!checkCertify(res, orgTechProduct.getUid()).getError().isEmpty()) {
  1097. return res;
  1098. }
  1099. OrgTechProduct otp = new OrgTechProduct();
  1100. BeanUtils.copyProperties(orgTechProduct, otp);
  1101. if (StringUtils.isBlank(otp.getId())) {
  1102. otp.setId(UUID.randomUUID().toString());
  1103. otp.setDeletedSign(0);
  1104. Calendar now = Calendar.getInstance();
  1105. now.set(Calendar.MILLISECOND, 0);
  1106. otp.setCreateTime(now.getTime());
  1107. otp.setYear(Calendar.getInstance().get(Calendar.YEAR) - 1);
  1108. orgTechProductService.insert(otp);
  1109. } else {
  1110. orgTechProductService.updateByPrimaryKeySelective(otp);
  1111. }
  1112. res.setData(orgTechProduct);
  1113. return res;
  1114. }
  1115. /**
  1116. * 高新技术产品台帐上传
  1117. *
  1118. * @param req
  1119. * @param sign
  1120. * @param uid
  1121. * @return
  1122. */
  1123. @RequestMapping(value = "/uploadTecProduct", method = RequestMethod.POST)
  1124. public Result uploadTecProduct(HttpServletRequest req, String sign, String uid) {
  1125. Result res = new Result();
  1126. if (!checkAdminLogin(res)) {
  1127. return res;
  1128. }
  1129. User curUser = userService.selectByPrimaryKey(uid);
  1130. if (!checkCertify(res, curUser)) {
  1131. return res;
  1132. }
  1133. AttachmentType attachmentType = AttachmentType.getField(sign);
  1134. if (attachmentType == AttachmentType.TECH_PRODUCT) {
  1135. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  1136. } else {
  1137. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1138. }
  1139. return res;
  1140. }
  1141. /**
  1142. * 高新技术产品台帐下载
  1143. *
  1144. * @param response
  1145. * @param sign
  1146. * @param id
  1147. * @return
  1148. */
  1149. @RequestMapping(value = "/downloadTecProduct", method = RequestMethod.GET)
  1150. public Result downloadTecProduct(HttpServletResponse response, String sign, String id) {
  1151. Result res = new Result();
  1152. if (!checkAdminLogin(res)) {
  1153. return res;
  1154. }
  1155. if (StringUtils.isEmpty(id)) {
  1156. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "高新技术产品id"));
  1157. return res;
  1158. }
  1159. OrgTechProduct otp = orgTechProductService.selectByPrimaryKey(id);
  1160. if (otp == null) {
  1161. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "高新技术产品id"));
  1162. return res;
  1163. }
  1164. AttachmentType attachmentType = AttachmentType.getField(sign);
  1165. if (attachmentType == AttachmentType.TECH_PRODUCT) {
  1166. downloadFile(response, otp.getAccountDownloadFileName(), otp.getAccountUrl());
  1167. } else {
  1168. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1169. }
  1170. return res;
  1171. }
  1172. /**
  1173. * 删除选中上年度高新技术产品(服务)情况记录
  1174. *
  1175. * @param ids
  1176. * @return
  1177. */
  1178. @RequestMapping(value = "/deleteTechProduct", method = RequestMethod.POST)
  1179. public Result deleteTechProduct(@RequestParam(name = "ids[]", required = false) String[] ids) {
  1180. Result res = new Result();
  1181. if (!checkAdminLogin(res)) {
  1182. return res;
  1183. }
  1184. if (ids == null || ids.length < 1) {
  1185. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  1186. } else {
  1187. res.setData(orgTechProductService.deleteByPrimaryKey(Arrays.asList(ids)));
  1188. }
  1189. return res;
  1190. }
  1191. /**
  1192. * 企业研究开发活动情况表入口
  1193. *
  1194. * @param activityNumber
  1195. * @param activityName
  1196. * @param startDate
  1197. * @param endDate
  1198. * @param pageNo
  1199. * @param pageSize
  1200. * @return
  1201. * @throws ParseException
  1202. */
  1203. @RequestMapping(value = "/activityList", method = RequestMethod.POST)
  1204. public Result activityList(String activityNumber, String activityName, String startDateFormattedDate,
  1205. String endDateFormattedDate, String pageNo, String pageSize, String uid) throws ParseException {
  1206. Result res = new Result();
  1207. if (!checkAdminLogin(res)) {
  1208. return res;
  1209. }
  1210. if (StringUtils.isBlank(uid)) {
  1211. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1212. }
  1213. if (!checkCertify(res, uid).getError().isEmpty()) {
  1214. return res;
  1215. }
  1216. Integer pNo = 1;
  1217. Integer pSize = 10;
  1218. if (StringUtils.isNumeric(pageSize)) {
  1219. pSize = Integer.parseInt(pageSize);
  1220. }
  1221. if (StringUtils.isNumeric(pageNo)) {
  1222. pNo = Integer.parseInt(pageNo);
  1223. }
  1224. res.setData(orgActivityService.listOrgActivity(activityNumber, activityName, startDateFormattedDate,
  1225. endDateFormattedDate, pNo, pSize, uid));
  1226. return res;
  1227. }
  1228. /**
  1229. * 企业研究开发活动情况新增、修改
  1230. *
  1231. * @param orgActivity
  1232. * @return
  1233. * @throws ParseException
  1234. */
  1235. @RequestMapping(value = "/activity", method = RequestMethod.POST)
  1236. public Result activity(@Valid InputOrgActivity orgActivity, BindingResult bindingResult,
  1237. String startDateFormattedDate, String endDateFormattedDate) {
  1238. Result res = new Result();
  1239. if (bindingResult.hasErrors()) {
  1240. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  1241. OrgActivityFields.getFieldDesc(bindingResult.getFieldError().getField())));
  1242. return res;
  1243. }
  1244. if (!checkAdminLogin(res)) {
  1245. return res;
  1246. }
  1247. if (StringUtils.isBlank(orgActivity.getUid())) {
  1248. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1249. return res;
  1250. }
  1251. if (!checkCertify(res, orgActivity.getUid()).getError().isEmpty()) {
  1252. return res;
  1253. }
  1254. if (!StringUtils.isBlank(startDateFormattedDate)) {
  1255. try {
  1256. orgActivity.setStartDate(DateUtils.parseDate(startDateFormattedDate, AFTConstants.YYYYMMDD));
  1257. } catch (ParseException e) {
  1258. }
  1259. }
  1260. if (StringUtils.isBlank(endDateFormattedDate)) {
  1261. try {
  1262. orgActivity.setEndDate(DateUtils.parseDate(endDateFormattedDate, AFTConstants.YYYYMMDD));
  1263. } catch (ParseException e) {
  1264. }
  1265. }
  1266. OrgActivity oa = new OrgActivity();
  1267. BeanUtils.copyProperties(orgActivity, oa);
  1268. oa.setDeletedSign(0);
  1269. if (StringUtils.isBlank(oa.getId())) {
  1270. oa.setId(UUID.randomUUID().toString());
  1271. orgActivityService.insert(oa);
  1272. } else {
  1273. orgActivityService.updateOrgActivity(oa);
  1274. }
  1275. res.setData(orgActivity);
  1276. return res;
  1277. }
  1278. /**
  1279. * 研发活动立项证明材料上传
  1280. *
  1281. * @param req
  1282. * @param sign
  1283. * @param uid
  1284. * @return
  1285. */
  1286. @RequestMapping(value = "/uploadProof", method = RequestMethod.POST)
  1287. public Result uploadProof(HttpServletRequest req, String sign, String uid) {
  1288. Result res = new Result();
  1289. if (!checkAdminLogin(res)) {
  1290. return res;
  1291. }
  1292. User curUser = userService.selectByPrimaryKey(uid);
  1293. if (!checkCertify(res, curUser)) {
  1294. return res;
  1295. }
  1296. AttachmentType attachmentType = AttachmentType.getField(sign);
  1297. if (attachmentType == AttachmentType.PROOF) {
  1298. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  1299. } else {
  1300. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1301. }
  1302. return res;
  1303. }
  1304. /**
  1305. * 研发活动立项证明材料下载
  1306. *
  1307. * @param response
  1308. * @param sign
  1309. * @param id
  1310. * @return
  1311. */
  1312. @RequestMapping(value = "/downloadProof", method = RequestMethod.GET)
  1313. public Result downloadProof(HttpServletResponse response, String sign, String id) {
  1314. Result res = new Result();
  1315. if (!checkAdminLogin(res)) {
  1316. return res;
  1317. }
  1318. if (StringUtils.isEmpty(id)) {
  1319. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "研发活动id"));
  1320. return res;
  1321. }
  1322. OrgActivity oa = orgActivityService.selectOrgActivityByPrimaryKey(id);
  1323. if (oa == null) {
  1324. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "研发活动id"));
  1325. return res;
  1326. }
  1327. AttachmentType attachmentType = AttachmentType.getField(sign);
  1328. if (attachmentType == AttachmentType.PROOF) {
  1329. downloadFile(response, oa.getProofDownloadFileName(), oa.getProofUrl());
  1330. } else {
  1331. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1332. }
  1333. return res;
  1334. }
  1335. /**
  1336. * 删除企业研究开发活动情况
  1337. *
  1338. * @param ids
  1339. * @return
  1340. */
  1341. @RequestMapping(value = "/deleteActivity", method = RequestMethod.POST)
  1342. public Result deleteActivity(@RequestParam(name = "ids[]", required = false) String[] ids) {
  1343. Result res = new Result();
  1344. if (!checkAdminLogin(res)) {
  1345. return res;
  1346. }
  1347. if (ids == null || ids.length < 1) {
  1348. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  1349. } else {
  1350. res.setData(orgActivityService.deleteByPrimaryKey(Arrays.asList(ids)));
  1351. orgActivityCostService.deleteByAid(Arrays.asList(ids));
  1352. }
  1353. return res;
  1354. }
  1355. /**
  1356. * 企业年度研究开发费用结构明细表列表
  1357. *
  1358. * @return
  1359. * @throws ParseException
  1360. */
  1361. @RequestMapping(value = "/activityCostList", method = RequestMethod.POST)
  1362. public Result activityCostList(String activityNumber, String startDateFormattedDate, String endDateFormattedDate,
  1363. String pageNo, String pageSize, String uid) throws ParseException {
  1364. Result res = new Result();
  1365. if (!checkAdminLogin(res)) {
  1366. return res;
  1367. }
  1368. if (StringUtils.isBlank(uid)) {
  1369. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1370. return res;
  1371. }
  1372. if (!checkCertify(res, uid).getError().isEmpty()) {
  1373. return res;
  1374. }
  1375. Integer pNo = 1;
  1376. Integer pSize = 10;
  1377. if (StringUtils.isNumeric(pageSize)) {
  1378. pSize = Integer.parseInt(pageSize);
  1379. }
  1380. if (StringUtils.isNumeric(pageNo)) {
  1381. pNo = Integer.parseInt(pageNo);
  1382. }
  1383. res.setData(orgActivityCostService.listOrgActivityCost(activityNumber, startDateFormattedDate,
  1384. endDateFormattedDate, pNo, pSize, uid));
  1385. return res;
  1386. }
  1387. /**
  1388. * 企业年度研究开发费用结构明细表(新增+修改)
  1389. *
  1390. * @return
  1391. * @throws ParseException
  1392. */
  1393. @RequestMapping(value = "/activityCost", method = RequestMethod.POST)
  1394. public Result activityCost(@Valid InputOrgActivityCost orgActivityCost, BindingResult bindingResult,
  1395. String signDateFormattedDate) {
  1396. Result res = new Result();
  1397. if (bindingResult.hasErrors()) {
  1398. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  1399. OrgActivityFields.getFieldDesc(bindingResult.getFieldError().getField())));
  1400. return res;
  1401. }
  1402. if (!checkAdminLogin(res)) {
  1403. return res;
  1404. }
  1405. if (StringUtils.isBlank(orgActivityCost.getUid())) {
  1406. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1407. return res;
  1408. }
  1409. if (!checkCertify(res, orgActivityCost.getUid()).getError().isEmpty()) {
  1410. return res;
  1411. }
  1412. if (StringUtils.isBlank(signDateFormattedDate)) {
  1413. try {
  1414. orgActivityCost.setSignDate(DateUtils.parseDate(signDateFormattedDate, AFTConstants.YYYYMMDD));
  1415. } catch (ParseException e) {
  1416. }
  1417. }
  1418. OrgActivityCost oac = new OrgActivityCost();
  1419. BeanUtils.copyProperties(orgActivityCost, oac);
  1420. if (StringUtils.isBlank(oac.getId())) {
  1421. if (null != orgActivityCostService.selectOrgActivityCostByUidAndAid(oac.getAid(), oac.getUid())) {
  1422. res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "该研究项目费用详情已录入!"));
  1423. return res;
  1424. }
  1425. OrgActivity ac = orgActivityService.selectOrgActivityByPrimaryKey(oac.getAid());
  1426. oac.setStartDate(null == ac.getStartDate() ? null : ac.getStartDate());
  1427. oac.setEndDate(null == ac.getEndDate() ? null : ac.getEndDate());
  1428. oac.setId(UUID.randomUUID().toString());
  1429. oac.setDeletedSign(0);
  1430. orgActivityCostService.insert(oac);
  1431. } else {
  1432. orgActivityCostService.updateByPrimaryKeySelective(oac);
  1433. }
  1434. return res;
  1435. }
  1436. /**
  1437. * 研发活动费用台帐上传
  1438. *
  1439. * @param req
  1440. * @param sign
  1441. * @param uid
  1442. * @return
  1443. */
  1444. @RequestMapping(value = "/uploadActivityCost", method = RequestMethod.POST)
  1445. public Result uploadActivityCost(HttpServletRequest req, String sign, String uid) {
  1446. Result res = new Result();
  1447. if (!checkAdminLogin(res)) {
  1448. return res;
  1449. }
  1450. User curUser = userService.selectByPrimaryKey(uid);
  1451. if (!checkCertify(res, curUser)) {
  1452. return res;
  1453. }
  1454. AttachmentType attachmentType = AttachmentType.getField(sign);
  1455. if (attachmentType == AttachmentType.ACTIVITY_COST_ACCOUNT) {
  1456. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  1457. } else {
  1458. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1459. }
  1460. return res;
  1461. }
  1462. /**
  1463. * 研发活动费用台帐下载
  1464. *
  1465. * @param response
  1466. * @param sign
  1467. * @param id
  1468. * @return
  1469. */
  1470. @RequestMapping(value = "/downloadActivityCost", method = RequestMethod.GET)
  1471. public Result downloadActivityCost(HttpServletResponse response, String sign, String id) {
  1472. Result res = new Result();
  1473. if (!checkAdminLogin(res)) {
  1474. return res;
  1475. }
  1476. if (StringUtils.isEmpty(id)) {
  1477. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", " 研发活动费用id"));
  1478. return res;
  1479. }
  1480. OrgActivityCost oac = orgActivityCostService.selectByPrimaryKey(id);
  1481. if (oac == null) {
  1482. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", " 研发活动费用id"));
  1483. return res;
  1484. }
  1485. AttachmentType attachmentType = AttachmentType.getField(sign);
  1486. if (attachmentType == AttachmentType.ACTIVITY_COST_ACCOUNT) {
  1487. downloadFile(response, oac.getAccountDownloadFileName(), oac.getAccountUrl());
  1488. } else {
  1489. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1490. }
  1491. return res;
  1492. }
  1493. /**
  1494. * 删除企业年度研究开发费用结构明细表
  1495. *
  1496. * @param ids
  1497. * @return
  1498. */
  1499. @RequestMapping(value = "/deleteActivityCost", method = RequestMethod.POST)
  1500. public Result deleteActivityCost(@RequestParam(name = "ids[]", required = false) String[] ids) {
  1501. Result res = new Result();
  1502. if (!checkAdminLogin(res)) {
  1503. return res;
  1504. }
  1505. if (ids == null || ids.length < 1) {
  1506. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  1507. } else {
  1508. res.setData(orgActivityCostService.batchDeleteByPrimaryKey(Arrays.asList(ids)));
  1509. }
  1510. return res;
  1511. }
  1512. /**
  1513. * 获取当前用户已录入项目标号列表
  1514. *
  1515. * @param uid
  1516. * @return
  1517. */
  1518. @RequestMapping(value = "/activityNumber", method = RequestMethod.POST)
  1519. public Result listActivityNumber(String uid) {
  1520. Result res = new Result();
  1521. if (!checkAdminLogin(res)) {
  1522. return res;
  1523. }
  1524. if (StringUtils.isBlank(uid)) {
  1525. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1526. return res;
  1527. }
  1528. List<ActivityNumberBo> activityNumberBo = orgActivityService.selectOrgActivityNumberBoByUid(uid);
  1529. res.setData(activityNumberBo);
  1530. return res;
  1531. }
  1532. /**
  1533. * 企业纳税申报信息列表
  1534. *
  1535. * @return
  1536. */
  1537. @RequestMapping(value = "/ratepay", method = RequestMethod.POST)
  1538. public Result ratepay(Integer year, String pageNo, String pageSize, String uid) {
  1539. Result res = new Result();
  1540. if (!checkAdminLogin(res)) {
  1541. return res;
  1542. }
  1543. if (StringUtils.isBlank(uid)) {
  1544. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1545. return res;
  1546. }
  1547. if (!checkCertify(res, uid).getError().isEmpty()) {
  1548. return res;
  1549. }
  1550. Integer pNo = 1;
  1551. Integer pSize = 10;
  1552. if (StringUtils.isNumeric(pageSize)) {
  1553. pSize = Integer.parseInt(pageSize);
  1554. }
  1555. if (StringUtils.isNumeric(pageNo)) {
  1556. pNo = Integer.parseInt(pageNo);
  1557. }
  1558. res.setData(orgRatepayService.listOrgRatepay(year, pNo, pSize, uid));
  1559. return res;
  1560. }
  1561. /**
  1562. * 企业纳税申报信息录入+修改
  1563. */
  1564. @RequestMapping(value = "/disposeRatepay", method = RequestMethod.POST)
  1565. public Result disposeRatepay(@Valid InputOrgRatepay orgRatepay, BindingResult bindingResult) {
  1566. Result res = new Result();
  1567. if (bindingResult.hasErrors()) {
  1568. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  1569. OrgRatepayFields.getFieldDesc(bindingResult.getFieldError().getField())));
  1570. return res;
  1571. }
  1572. if (!checkAdminLogin(res)) {
  1573. return res;
  1574. }
  1575. if (StringUtils.isBlank(orgRatepay.getUid())) {
  1576. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1577. return res;
  1578. }
  1579. if (null == orgRatepay.getYear()) {
  1580. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到年份", "年份"));
  1581. return res;
  1582. }
  1583. if (!checkCertify(res, orgRatepay.getUid()).getError().isEmpty()) {
  1584. return res;
  1585. }
  1586. OrgRatepay rate = new OrgRatepay();
  1587. BeanUtils.copyProperties(orgRatepay, rate);
  1588. if (StringUtils.isBlank(rate.getId())) {
  1589. if (null == orgRatepayService.selectRatepayByUidAndYear(rate.getUid(), rate.getYear())) {
  1590. rate.setId(UUID.randomUUID().toString());
  1591. rate.setDeletedSign(0);
  1592. orgRatepayService.insert(rate);
  1593. } else {
  1594. res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度纳税申报表已录入!"));
  1595. return res;
  1596. }
  1597. } else {
  1598. orgRatepayService.updateByPrimaryKeySelective(rate);
  1599. }
  1600. return res;
  1601. }
  1602. /**
  1603. * 企业纳税申报表上传
  1604. *
  1605. * @param req
  1606. * @param sign
  1607. * @param uid
  1608. * @return
  1609. */
  1610. @RequestMapping(value = "/uploadRatepay", method = RequestMethod.POST)
  1611. public Result uploadRatepay(HttpServletRequest req, String sign, String uid, String year) {
  1612. Result res = new Result();
  1613. if (!checkAdminLogin(res)) {
  1614. return res;
  1615. }
  1616. User curUser = userService.selectByPrimaryKey(uid);
  1617. if (!checkCertify(res, curUser)) {
  1618. return res;
  1619. }
  1620. if (StringUtils.isBlank(year)) {
  1621. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示年份"));
  1622. return res;
  1623. }
  1624. AttachmentType attachmentType = AttachmentType.getField(sign);
  1625. if (attachmentType == AttachmentType.RATEPAY) {
  1626. sign = sign + "_" + year;
  1627. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  1628. } else {
  1629. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1630. }
  1631. return res;
  1632. }
  1633. /**
  1634. * 企业纳税申报表下载
  1635. *
  1636. * @param response
  1637. * @param sign
  1638. * @param id
  1639. * @return
  1640. */
  1641. @RequestMapping(value = "/downloadRatepay", method = RequestMethod.GET)
  1642. public Result downloadRatepay(HttpServletResponse response, String sign, String id) {
  1643. Result res = new Result();
  1644. if (!checkAdminLogin(res)) {
  1645. return res;
  1646. }
  1647. if (StringUtils.isEmpty(id)) {
  1648. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业纳税申报id"));
  1649. return res;
  1650. }
  1651. OrgRatepay ratepay = orgRatepayService.selectByPrimaryKey(id);
  1652. if (ratepay == null) {
  1653. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业纳税申报id"));
  1654. return res;
  1655. }
  1656. AttachmentType attachmentType = AttachmentType.getField(sign);
  1657. if (attachmentType == AttachmentType.RATEPAY) {
  1658. downloadFile(response, ratepay.getTaxReturnDownloadFileName(), ratepay.getTaxReturnUrl());
  1659. } else {
  1660. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1661. }
  1662. return res;
  1663. }
  1664. /**
  1665. * 刪除企业纳税申报信息
  1666. *
  1667. * @param ids
  1668. * @return
  1669. */
  1670. @RequestMapping(value = "/deleteRatepay", method = RequestMethod.POST)
  1671. public Result deleteRatepay(@RequestParam(name = "ids[]", required = false) String[] ids) {
  1672. Result res = new Result();
  1673. if (!checkAdminLogin(res)) {
  1674. return res;
  1675. }
  1676. if (ids == null || ids.length < 1) {
  1677. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  1678. } else {
  1679. res.setData(orgRatepayService.deleteByPrimaryKey(Arrays.asList(ids)));
  1680. }
  1681. return res;
  1682. }
  1683. /**
  1684. * 财务报表信息列表
  1685. *
  1686. * @return
  1687. */
  1688. @RequestMapping(value = "/finance", method = RequestMethod.POST)
  1689. public Result finance(Integer year, String pageNo, String pageSize, String uid) {
  1690. Result res = new Result();
  1691. if (!checkAdminLogin(res)) {
  1692. return res;
  1693. }
  1694. if (StringUtils.isBlank(uid)) {
  1695. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1696. return res;
  1697. }
  1698. if (!checkCertify(res, uid).getError().isEmpty()) {
  1699. return res;
  1700. }
  1701. Integer pNo = 1;
  1702. Integer pSize = 10;
  1703. if (StringUtils.isNumeric(pageSize)) {
  1704. pSize = Integer.parseInt(pageSize);
  1705. }
  1706. if (StringUtils.isNumeric(pageNo)) {
  1707. pNo = Integer.parseInt(pageNo);
  1708. }
  1709. res.setData(orgFinanceService.listFinance(year, pNo, pSize, uid));
  1710. return res;
  1711. }
  1712. /**
  1713. * 财务报表录入+修改
  1714. *
  1715. * @param orgFinance
  1716. * @return
  1717. */
  1718. @RequestMapping(value = "/disposeFinance", method = RequestMethod.POST)
  1719. public Result disposeFinance(@Valid InputOrgFinance orgFinance, BindingResult bindingResult) {
  1720. Result res = new Result();
  1721. if (bindingResult.hasErrors()) {
  1722. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  1723. OrgFinanceFields.getFieldDesc(bindingResult.getFieldError().getField())));
  1724. return res;
  1725. }
  1726. if (!checkAdminLogin(res)) {
  1727. return res;
  1728. }
  1729. if (StringUtils.isBlank(orgFinance.getUid())) {
  1730. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1731. return res;
  1732. }
  1733. if (null == orgFinance.getYear()) {
  1734. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到年份", "年份"));
  1735. return res;
  1736. }
  1737. if (!checkCertify(res, orgFinance.getUid()).getError().isEmpty()) {
  1738. return res;
  1739. }
  1740. OrgFinance of = new OrgFinance();
  1741. BeanUtils.copyProperties(orgFinance, of);
  1742. if (StringUtils.isBlank(of.getId())) {
  1743. if (null == orgFinanceService.selectFinanceByUidAndYear(of.getUid(), of.getYear())) {
  1744. of.setId(UUID.randomUUID().toString());
  1745. of.setDeletedSign(0);
  1746. orgFinanceService.insert(of);
  1747. } else {
  1748. res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度财务报表已录入!"));
  1749. return res;
  1750. }
  1751. } else {
  1752. orgFinanceService.updateByPrimaryKeySelective(of);
  1753. }
  1754. return res;
  1755. }
  1756. /**
  1757. * 企业财务报表上传
  1758. *
  1759. * @param req
  1760. * @param sign
  1761. * @param uid
  1762. * @return
  1763. */
  1764. @RequestMapping(value = "/uploadFinance", method = RequestMethod.POST)
  1765. public Result uploadFinance(HttpServletRequest req, String sign, String uid, String year) {
  1766. Result res = new Result();
  1767. if (!checkAdminLogin(res)) {
  1768. return res;
  1769. }
  1770. if (StringUtils.isBlank(year)) {
  1771. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示年份"));
  1772. return res;
  1773. }
  1774. User curUser = userService.selectByPrimaryKey(uid);
  1775. if (!checkCertify(res, curUser)) {
  1776. return res;
  1777. }
  1778. AttachmentType attachmentType = AttachmentType.getField(sign);
  1779. if (attachmentType == AttachmentType.FINANCE) {
  1780. sign = sign + "_" + year;
  1781. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  1782. } else {
  1783. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1784. }
  1785. return res;
  1786. }
  1787. /**
  1788. * 企业财务报表下载
  1789. *
  1790. * @param response
  1791. * @param sign
  1792. * @param id
  1793. * @return
  1794. */
  1795. @RequestMapping(value = "/downloadFinance", method = RequestMethod.GET)
  1796. public Result downloadFinance(HttpServletResponse response, String sign, String id) {
  1797. Result res = new Result();
  1798. if (!checkAdminLogin(res)) {
  1799. return res;
  1800. }
  1801. if (StringUtils.isEmpty(id)) {
  1802. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业财务报表id"));
  1803. return res;
  1804. }
  1805. OrgFinance of = orgFinanceService.selectByPrimaryKey(id);
  1806. if (of == null) {
  1807. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业财务报表id"));
  1808. return res;
  1809. }
  1810. AttachmentType attachmentType = AttachmentType.getField(sign);
  1811. if (attachmentType == AttachmentType.FINANCE) {
  1812. downloadFile(response, of.getFinanceDownloadFileName(), of.getFinanceUrl());
  1813. } else {
  1814. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1815. }
  1816. return res;
  1817. }
  1818. /**
  1819. * 删除财务报表
  1820. *
  1821. * @param ids
  1822. * @return
  1823. */
  1824. @RequestMapping(value = "/deleteFinance", method = RequestMethod.POST)
  1825. public Result deleteFinance(@RequestParam(name = "ids[]", required = false) String[] ids) {
  1826. Result res = new Result();
  1827. if (!checkAdminLogin(res)) {
  1828. return res;
  1829. }
  1830. if (ids == null || ids.length < 1) {
  1831. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  1832. } else {
  1833. res.setData(orgFinanceService.deleteByPrimaryKey(Arrays.asList(ids)));
  1834. }
  1835. return res;
  1836. }
  1837. /**
  1838. * 科技成果转化情况列表入口
  1839. *
  1840. * @param pageNo
  1841. * @param pageSize
  1842. * @return
  1843. */
  1844. @RequestMapping(value = "/achievementList", method = RequestMethod.POST)
  1845. public Result achievementList(String pageNo, String pageSize, String uid) {
  1846. Result res = new Result();
  1847. if (!checkAdminLogin(res)) {
  1848. return res;
  1849. }
  1850. if (StringUtils.isBlank(uid)) {
  1851. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1852. return res;
  1853. }
  1854. if (!checkCertify(res, uid).getError().isEmpty()) {
  1855. return res;
  1856. }
  1857. Integer pNo = 1;
  1858. Integer pSize = 10;
  1859. if (StringUtils.isNumeric(pageSize)) {
  1860. pSize = Integer.parseInt(pageSize);
  1861. }
  1862. if (StringUtils.isNumeric(pageNo)) {
  1863. pNo = Integer.parseInt(pageNo);
  1864. }
  1865. res.setData(orgTechAchievementService.listOrgTechAchievement(pNo, pSize, uid));
  1866. return res;
  1867. }
  1868. /**
  1869. * 科技成果转化情况新增+修改
  1870. *
  1871. * @param achievement
  1872. * @return
  1873. * @throws ParseException
  1874. */
  1875. @RequestMapping(value = "/disposeAchievement", method = RequestMethod.POST)
  1876. public Result disposeAchievement(@Valid InputOrgTechAchievement achievement, BindingResult bindingResult) {
  1877. Result res = new Result();
  1878. if (bindingResult.hasErrors()) {
  1879. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  1880. OrgTechAchievementFields.getFieldDesc(bindingResult.getFieldError().getField())));
  1881. return res;
  1882. }
  1883. if (!checkAdminLogin(res)) {
  1884. return res;
  1885. }
  1886. if (StringUtils.isBlank(achievement.getUid())) {
  1887. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1888. return res;
  1889. }
  1890. if (!checkCertify(res, achievement.getUid()).getError().isEmpty()) {
  1891. return res;
  1892. }
  1893. OrgTechAchievement ota = new OrgTechAchievement();
  1894. BeanUtils.copyProperties(achievement, ota);
  1895. if (StringUtils.isBlank(ota.getId())) {
  1896. ota.setId(UUID.randomUUID().toString());
  1897. ota.setDeletedSign(0);
  1898. orgTechAchievementService.insert(ota);
  1899. } else {
  1900. orgTechAchievementService.updateByPrimaryKeySelective(ota);
  1901. }
  1902. return res;
  1903. }
  1904. /**
  1905. * 科技成果附件上传
  1906. *
  1907. * @param req
  1908. * @param sign
  1909. * @param uid
  1910. * @return
  1911. */
  1912. @RequestMapping(value = "/uploadAchievement", method = RequestMethod.POST)
  1913. public Result uploadAchievement(HttpServletRequest req, String sign, String uid) {
  1914. Result res = new Result();
  1915. if (!checkAdminLogin(res)) {
  1916. return res;
  1917. }
  1918. User curUser = userService.selectByPrimaryKey(uid);
  1919. if (!checkCertify(res, curUser)) {
  1920. return res;
  1921. }
  1922. AttachmentType attachmentType = AttachmentType.getField(sign);
  1923. if (attachmentType == AttachmentType.ACHIEVEMENT) {
  1924. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  1925. } else {
  1926. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1927. }
  1928. return res;
  1929. }
  1930. /**
  1931. * 科技成果附件下载
  1932. *
  1933. * @param response
  1934. * @param sign
  1935. * @param id
  1936. * @return
  1937. */
  1938. @RequestMapping(value = "/downloadAchievement", method = RequestMethod.GET)
  1939. public Result downloadAchievement(HttpServletResponse response, String sign, String id) {
  1940. Result res = new Result();
  1941. if (!checkAdminLogin(res)) {
  1942. return res;
  1943. }
  1944. if (StringUtils.isEmpty(id)) {
  1945. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "科技成果id"));
  1946. return res;
  1947. }
  1948. OrgTechAchievement ota = orgTechAchievementService.selectByPrimaryKey(id);
  1949. if (ota == null) {
  1950. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "科技成果id"));
  1951. return res;
  1952. }
  1953. AttachmentType attachmentType = AttachmentType.getField(sign);
  1954. if (attachmentType == AttachmentType.ACHIEVEMENT) {
  1955. downloadFile(response, ota.getEnclosureDownloadFileName(), ota.getEnclosureUrl());
  1956. } else {
  1957. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1958. }
  1959. return res;
  1960. }
  1961. /**
  1962. * 删除科技成果转化情况
  1963. *
  1964. * @param ids
  1965. * @return
  1966. */
  1967. @RequestMapping(value = "/deleteAchievement", method = RequestMethod.POST)
  1968. public Result deleteAchievement(@RequestParam(name = "ids[]", required = false) String[] ids) {
  1969. Result res = new Result();
  1970. if (!checkAdminLogin(res)) {
  1971. return res;
  1972. }
  1973. if (ids == null || ids.length < 1) {
  1974. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  1975. } else {
  1976. res.setData(orgTechAchievementService.deleteByPrimaryKey(Arrays.asList(ids)));
  1977. }
  1978. return res;
  1979. }
  1980. /**
  1981. * 企业荣誉及其他证明材料列表入口
  1982. *
  1983. * @return
  1984. */
  1985. @RequestMapping(value = "/honorList", method = RequestMethod.POST)
  1986. public Result honorList(String pageNo, String pageSize, String uid) {
  1987. Result res = new Result();
  1988. if (!checkAdminLogin(res)) {
  1989. return res;
  1990. }
  1991. if (StringUtils.isBlank(uid)) {
  1992. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  1993. return res;
  1994. }
  1995. if (!checkCertify(res, uid).getError().isEmpty()) {
  1996. return res;
  1997. }
  1998. Integer pNo = 1;
  1999. Integer pSize = 10;
  2000. if (StringUtils.isNumeric(pageSize)) {
  2001. pSize = Integer.parseInt(pageSize);
  2002. }
  2003. if (StringUtils.isNumeric(pageNo)) {
  2004. pNo = Integer.parseInt(pageNo);
  2005. }
  2006. res.setData(orgHonorDatumService.listOrgHonorDatum(pNo, pSize, uid));
  2007. return res;
  2008. }
  2009. /**
  2010. * 企业荣誉及其他证明材料新增+修改
  2011. *
  2012. * @param achievement
  2013. * @return
  2014. * @throws ParseException
  2015. */
  2016. @RequestMapping(value = "/disposeHonor", method = RequestMethod.POST)
  2017. public Result disposeHonor(@Valid InputOrgHonorDatum honor, BindingResult bindingResult,
  2018. String issuingTimeFormattedDate) {
  2019. Result res = new Result();
  2020. if (bindingResult.hasErrors()) {
  2021. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  2022. OrgHonorDatumFields.getFieldDesc(bindingResult.getFieldError().getField())));
  2023. return res;
  2024. }
  2025. if (!checkAdminLogin(res)) {
  2026. return res;
  2027. }
  2028. if (StringUtils.isBlank(honor.getUid())) {
  2029. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2030. return res;
  2031. }
  2032. if (!checkCertify(res, honor.getUid()).getError().isEmpty()) {
  2033. return res;
  2034. }
  2035. if (!StringUtils.isBlank(issuingTimeFormattedDate)) {
  2036. try {
  2037. honor.setIssuingTime(DateUtils.parseDate(issuingTimeFormattedDate, AFTConstants.YYYYMMDD));
  2038. } catch (ParseException e) {
  2039. }
  2040. }
  2041. OrgHonorDatum ohd = new OrgHonorDatum();
  2042. BeanUtils.copyProperties(honor, ohd);
  2043. if (StringUtils.isBlank(ohd.getId())) {
  2044. ohd.setId(UUID.randomUUID().toString());
  2045. ohd.setDeletedSign(0);
  2046. orgHonorDatumService.insert(ohd);
  2047. } else {
  2048. orgHonorDatumService.updateByPrimaryKeySelective(ohd);
  2049. }
  2050. return res;
  2051. }
  2052. /**
  2053. * 荣誉及其他证明材料上传
  2054. *
  2055. * @param req
  2056. * @param sign
  2057. * @param uid
  2058. * @return
  2059. */
  2060. @RequestMapping(value = "/uploadHonor", method = RequestMethod.POST)
  2061. public Result uploadHonor(HttpServletRequest req, String sign, String uid) {
  2062. Result res = new Result();
  2063. if (!checkAdminLogin(res)) {
  2064. return res;
  2065. }
  2066. User curUser = userService.selectByPrimaryKey(uid);
  2067. if (!checkCertify(res, curUser)) {
  2068. return res;
  2069. }
  2070. AttachmentType attachmentType = AttachmentType.getField(sign);
  2071. if (attachmentType == AttachmentType.HONOR) {
  2072. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  2073. } else {
  2074. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  2075. }
  2076. return res;
  2077. }
  2078. /**
  2079. * 荣誉及其他证明材料下载
  2080. *
  2081. * @param response
  2082. * @param sign
  2083. * @param id
  2084. * @return
  2085. */
  2086. @RequestMapping(value = "/downloadHonor", method = RequestMethod.GET)
  2087. public Result downloadHonor(HttpServletResponse response, String sign, String id) {
  2088. Result res = new Result();
  2089. if (!checkAdminLogin(res)) {
  2090. return res;
  2091. }
  2092. if (StringUtils.isEmpty(id)) {
  2093. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "荣誉及其他证明材料id"));
  2094. return res;
  2095. }
  2096. OrgHonorDatum ohd = orgHonorDatumService.selectByPrimaryKey(id);
  2097. if (ohd == null) {
  2098. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "荣誉及其他证明材料id"));
  2099. return res;
  2100. }
  2101. AttachmentType attachmentType = AttachmentType.getField(sign);
  2102. if (attachmentType == AttachmentType.HONOR) {
  2103. downloadFile(response, ohd.getEnclosureDownloadFileName(), ohd.getEnclosureUrl());
  2104. } else {
  2105. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  2106. }
  2107. return res;
  2108. }
  2109. /**
  2110. * 删除企业荣誉及其他证明材料
  2111. *
  2112. * @param ids
  2113. * @return
  2114. */
  2115. @RequestMapping(value = "/deleteHonor", method = RequestMethod.POST)
  2116. public Result deleteHonor(@RequestParam(name = "ids[]", required = false) String[] ids) {
  2117. Result res = new Result();
  2118. if (!checkAdminLogin(res)) {
  2119. return res;
  2120. }
  2121. if (ids == null || ids.length < 1) {
  2122. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  2123. } else {
  2124. res.setData(orgHonorDatumService.deleteByPrimaryKey(Arrays.asList(ids)));
  2125. }
  2126. return res;
  2127. }
  2128. /**
  2129. * 技术中心入口
  2130. *
  2131. * @return
  2132. */
  2133. @RequestMapping(value = "/center", method = RequestMethod.POST)
  2134. public Result center(String uid) {
  2135. Result res = new Result();
  2136. if (!checkAdminLogin(res)) {
  2137. return res;
  2138. }
  2139. if (StringUtils.isBlank(uid)) {
  2140. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2141. return res;
  2142. }
  2143. if (!checkCertify(res, uid).getError().isEmpty()) {
  2144. return res;
  2145. }
  2146. res.setData(orgTechCenterService.selectOrgTechCenterByUid(uid));
  2147. return res;
  2148. }
  2149. /**
  2150. * 技术中心新增+修改
  2151. *
  2152. * @return
  2153. * @throws ParseException
  2154. */
  2155. @RequestMapping(value = "/disposeCenter", method = RequestMethod.POST)
  2156. public Result disposeCenter(@Valid InputOrgTechCenter orgTechCenter, BindingResult bindingResult,
  2157. String foundingTimeFormattedDate) {
  2158. Result res = new Result();
  2159. if (bindingResult.hasErrors()) {
  2160. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  2161. OrgTechCenterFields.getFieldDesc(bindingResult.getFieldError().getField())));
  2162. return res;
  2163. }
  2164. if (!checkAdminLogin(res)) {
  2165. return res;
  2166. }
  2167. if (StringUtils.isBlank(orgTechCenter.getUid())) {
  2168. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2169. return res;
  2170. }
  2171. if (!checkCertify(res, orgTechCenter.getUid()).getError().isEmpty()) {
  2172. return res;
  2173. }
  2174. if (!StringUtils.isBlank(foundingTimeFormattedDate)) {
  2175. try {
  2176. orgTechCenter.setFoundingTime(DateUtils.parseDate(foundingTimeFormattedDate, AFTConstants.YYYYMMDD));
  2177. } catch (ParseException e) {
  2178. }
  2179. }
  2180. OrgTechCenter otc = new OrgTechCenter();
  2181. BeanUtils.copyProperties(orgTechCenter, otc);
  2182. if (StringUtils.isBlank(otc.getId())) {
  2183. otc.setId(UUID.randomUUID().toString());
  2184. otc.setDeletedSign(0);
  2185. orgTechCenterService.insert(otc);
  2186. } else {
  2187. orgTechCenterService.updateByPrimaryKeySelective(otc);
  2188. }
  2189. return res;
  2190. }
  2191. /**
  2192. * 研发部门制度上传
  2193. *
  2194. * @param req
  2195. * @param sign
  2196. * @param uid
  2197. * @return
  2198. */
  2199. @RequestMapping(value = "/uploadInstitution", method = RequestMethod.POST)
  2200. public Result uploadInstitution(HttpServletRequest req, String sign, String uid) {
  2201. Result res = new Result();
  2202. if (!checkAdminLogin(res)) {
  2203. return res;
  2204. }
  2205. User curUser = userService.selectByPrimaryKey(uid);
  2206. if (!checkCertify(res, curUser)) {
  2207. return res;
  2208. }
  2209. AttachmentType attachmentType = AttachmentType.getField(sign);
  2210. if (attachmentType == AttachmentType.INSTITUTION) {
  2211. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  2212. } else {
  2213. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  2214. }
  2215. return res;
  2216. }
  2217. /**
  2218. * 研发部门制度下载
  2219. *
  2220. * @param response
  2221. * @param sign
  2222. * @param id
  2223. * @return
  2224. */
  2225. @RequestMapping(value = "/downloadInstitution", method = RequestMethod.GET)
  2226. public Result downloadInstitution(HttpServletResponse response, String sign, String id) {
  2227. Result res = new Result();
  2228. if (!checkAdminLogin(res)) {
  2229. return res;
  2230. }
  2231. if (StringUtils.isEmpty(id)) {
  2232. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "研发部门id"));
  2233. return res;
  2234. }
  2235. OrgTechCenter otc = orgTechCenterService.selectByPrimaryKey(id);
  2236. if (otc == null) {
  2237. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "研发部门id"));
  2238. return res;
  2239. }
  2240. AttachmentType attachmentType = AttachmentType.getField(sign);
  2241. if (attachmentType == AttachmentType.INSTITUTION) {
  2242. downloadFile(response, otc.getSystemDownloadFileName(), otc.getSystemUrl());
  2243. } else {
  2244. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  2245. }
  2246. return res;
  2247. }
  2248. /**
  2249. * 技术中心明细入口
  2250. *
  2251. * @return
  2252. */
  2253. @RequestMapping(value = "/centerDetail", method = RequestMethod.GET)
  2254. public Result centerDetail(String pageNo, String pageSize, String cid) {
  2255. Result res = new Result();
  2256. if (!checkAdminLogin(res)) {
  2257. return res;
  2258. }
  2259. if (StringUtils.isBlank(cid)) {
  2260. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "技术中心ID"));
  2261. return res;
  2262. }
  2263. Integer pNo = 1;
  2264. Integer pSize = 10;
  2265. if (StringUtils.isNumeric(pageSize)) {
  2266. pSize = Integer.parseInt(pageSize);
  2267. }
  2268. if (StringUtils.isNumeric(pageNo)) {
  2269. pNo = Integer.parseInt(pageNo);
  2270. }
  2271. res.setData(orgTechCenterDetailService.listOrgTechCenterDetail(pNo, pSize, cid));
  2272. return res;
  2273. }
  2274. /**
  2275. * 技术中心明细新增+修改(管理+用户)
  2276. *
  2277. * @param orgTechCenterDetail
  2278. * @param projectTimeFormattedDate
  2279. * @param termTimeFormattedDate
  2280. * @return
  2281. * @throws ParseException
  2282. */
  2283. @RequestMapping(value = "/disposeCenterDetail", method = RequestMethod.POST)
  2284. public Result disposeCenterDetail(@Valid InputOrgTechCenterDetail orgTechCenterDetail, BindingResult bindingResult,
  2285. String projectTimeFormattedDate, String termTimeFormattedDate) {
  2286. Result res = new Result();
  2287. if (bindingResult.hasErrors()) {
  2288. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  2289. OrgTechCenterDetailFields.getFieldDesc(bindingResult.getFieldError().getField())));
  2290. return res;
  2291. }
  2292. if (!checkAdminLogin(res)) {
  2293. return res;
  2294. }
  2295. if (!StringUtils.isBlank(projectTimeFormattedDate)) {
  2296. try {
  2297. orgTechCenterDetail
  2298. .setProjectTime(DateUtils.parseDate(projectTimeFormattedDate, AFTConstants.YYYYMMDD));
  2299. } catch (ParseException e) {
  2300. }
  2301. }
  2302. if (!StringUtils.isBlank(termTimeFormattedDate)) {
  2303. try {
  2304. orgTechCenterDetail.setTermTime(DateUtils.parseDate(termTimeFormattedDate, AFTConstants.YYYYMMDD));
  2305. } catch (ParseException e) {
  2306. }
  2307. }
  2308. OrgTechCenterDetail otcd = new OrgTechCenterDetail();
  2309. BeanUtils.copyProperties(orgTechCenterDetail, otcd);
  2310. if (StringUtils.isBlank(otcd.getId())) {
  2311. otcd.setId(UUID.randomUUID().toString());
  2312. otcd.setDeletedSign(0);
  2313. orgTechCenterDetailService.insert(otcd);
  2314. } else {
  2315. orgTechCenterDetailService.updateByPrimaryKeySelective(otcd);
  2316. }
  2317. return res;
  2318. }
  2319. /**
  2320. * 产学研技术中心协议上传
  2321. *
  2322. * @param req
  2323. * @param sign
  2324. * @param uid
  2325. * @return
  2326. */
  2327. @RequestMapping(value = "/uploadProtocol", method = RequestMethod.POST)
  2328. public Result uploadProtocol(HttpServletRequest req, String sign, String uid) {
  2329. Result res = new Result();
  2330. if (!checkAdminLogin(res)) {
  2331. return res;
  2332. }
  2333. if (null == uid) {
  2334. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户ID"));
  2335. return res;
  2336. }
  2337. User curUser = userService.selectByPrimaryKey(uid);
  2338. if (!checkCertify(res, curUser)) {
  2339. return res;
  2340. }
  2341. AttachmentType attachmentType = AttachmentType.getField(sign);
  2342. if (attachmentType == AttachmentType.PROTOCOL) {
  2343. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  2344. } else {
  2345. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  2346. }
  2347. return res;
  2348. }
  2349. /**
  2350. * 产学研技术中心协议下载
  2351. *
  2352. * @param response
  2353. * @param sign
  2354. * @param id
  2355. * @return
  2356. */
  2357. @RequestMapping(value = "/downloadProtocol", method = RequestMethod.GET)
  2358. public Result downloadProtocol(HttpServletResponse response, String sign, String id) {
  2359. Result res = new Result();
  2360. if (!checkAdminLogin(res)) {
  2361. return res;
  2362. }
  2363. if (StringUtils.isEmpty(id)) {
  2364. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "产学研技术中心id"));
  2365. return res;
  2366. }
  2367. OrgTechCenterDetail otcd = orgTechCenterDetailService.selectByPrimaryKey(id);
  2368. if (otcd == null) {
  2369. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "产学研技术中心id"));
  2370. return res;
  2371. }
  2372. AttachmentType attachmentType = AttachmentType.getField(sign);
  2373. if (attachmentType == AttachmentType.PROTOCOL) {
  2374. downloadFile(response, otcd.getProtocolDownloadFileName(), otcd.getProtocolUrl());
  2375. } else {
  2376. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  2377. }
  2378. return res;
  2379. }
  2380. /**
  2381. * 删除技术中心明细
  2382. *
  2383. * @param ids
  2384. * @return
  2385. */
  2386. @RequestMapping(value = "/deleteOrgTechCenterDetail", method = RequestMethod.POST)
  2387. public Result deleteOrgTechCenterDetail(@RequestParam(name = "ids[]", required = false) String[] ids) {
  2388. Result res = new Result();
  2389. if (!checkAdminLogin(res)) {
  2390. return res;
  2391. }
  2392. if (ids == null || ids.length < 1) {
  2393. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  2394. } else {
  2395. res.setData(orgTechCenterDetailService.deleteByPrimaryKey(Arrays.asList(ids)));
  2396. }
  2397. return res;
  2398. }
  2399. /**
  2400. * 获取公司联系人
  2401. *
  2402. * @return
  2403. */
  2404. @RequestMapping(value = "/getContacts", method = RequestMethod.GET)
  2405. public Result getContacts(String uid) {
  2406. Result res = new Result();
  2407. if (!checkAdminLogin(res)) {
  2408. return res;
  2409. }
  2410. if (StringUtils.isBlank(uid)) {
  2411. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2412. return res;
  2413. }
  2414. res.setData(organizationIdentityService.selectContactsByUserId(uid));
  2415. return res;
  2416. }
  2417. /**
  2418. * 高企认定列表
  2419. *
  2420. * @param locationProvince
  2421. * @param unitName
  2422. * @return
  2423. */
  2424. @RequestMapping(value = "/listCognizance", method = RequestMethod.POST)
  2425. public Result listCognizance(String uid, String unitName, String locationProvince, String pageNo, String pageSize) {
  2426. Result res = new Result();
  2427. if (!checkAdminLogin(res)) {
  2428. return res;
  2429. }
  2430. Integer pNo = 1;
  2431. Integer pSize = 10;
  2432. if (StringUtils.isNumeric(pageSize)) {
  2433. pSize = Integer.parseInt(pageSize);
  2434. }
  2435. if (StringUtils.isNumeric(pageNo)) {
  2436. pNo = Integer.parseInt(pageNo);
  2437. }
  2438. res.setData(orgCognizanceService.listCognizance(uid, unitName, locationProvince, pNo, pSize));
  2439. return res;
  2440. }
  2441. /**
  2442. * 申请高企认定
  2443. *
  2444. * @return
  2445. */
  2446. @RequestMapping(value = "/applyCognizance", method = RequestMethod.POST)
  2447. public Result applyCognizance(@Valid InputApplyCognizance cog, BindingResult bindingResult) {
  2448. Result res = new Result();
  2449. if (bindingResult.hasErrors()) {
  2450. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  2451. CognizanceApplyFields.getFieldDesc(bindingResult.getFieldError().getField())));
  2452. return res;
  2453. }
  2454. if (!checkAdminLogin(res)) {
  2455. return res;
  2456. }
  2457. if (StringUtils.isBlank(cog.getUid())) {
  2458. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2459. return res;
  2460. }
  2461. if (null == cog.getYear()) {
  2462. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "年份"));
  2463. return res;
  2464. }
  2465. if (!checkCertify(res, cog.getUid()).getError().isEmpty()) {
  2466. return res;
  2467. }
  2468. if (null != orgCognizanceService.selectCognizanceByUidAndYear(cog.getYear(), cog.getUid())) {
  2469. res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度高企认定已申请!"));
  2470. return res;
  2471. }
  2472. User u = userService.selectByPrimaryKey(cog.getUid());
  2473. String aid = null;
  2474. if (!StringUtils.isBlank(u.getAid())) {
  2475. aid = u.getAid();
  2476. }
  2477. OrgCognizance oc = new OrgCognizance();
  2478. BeanUtils.copyProperties(cog, oc);
  2479. orgCognizanceService.insertCognizance(oc, aid);
  2480. return res;
  2481. }
  2482. /**
  2483. * 高企认定详情入口
  2484. *
  2485. * @param uid
  2486. * @param cid
  2487. * @return
  2488. */
  2489. @RequestMapping(value = "/cognizanceDetail", method = RequestMethod.POST)
  2490. public Result cognizanceDetail(String uid, String cid, Integer year) {
  2491. Result res = new Result();
  2492. if (!checkAdminLogin(res)) {
  2493. return res;
  2494. }
  2495. if (StringUtils.isBlank(uid)) {
  2496. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2497. return res;
  2498. }
  2499. if (StringUtils.isBlank(cid)) {
  2500. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "高企ID"));
  2501. return res;
  2502. }
  2503. if (null == year) {
  2504. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "年份"));
  2505. return res;
  2506. }
  2507. if (!checkCertify(res, uid).getError().isEmpty()) {
  2508. return res;
  2509. }
  2510. res.setData(handleCognizanceDetail(uid, cid, year));
  2511. return res;
  2512. }
  2513. /**
  2514. * 高企认定流转状态下拉
  2515. * @return
  2516. */
  2517. @RequestMapping(value = "/cognizanceStatus", method = RequestMethod.GET)
  2518. public Result cognizanceStatus(){
  2519. Result res = new Result();
  2520. if (!checkAdminLogin(res)) {
  2521. return res;
  2522. }
  2523. res.setData(disposeCognizanceStatus());
  2524. return res;
  2525. }
  2526. /**
  2527. * 高企认定流转状态
  2528. *
  2529. * @param cid
  2530. * @return
  2531. */
  2532. @RequestMapping(value = "/cognizanceLog", method = RequestMethod.POST)
  2533. public Result cognizanceLog(String cid) {
  2534. Result res = new Result();
  2535. if (!checkAdminLogin(res)) {
  2536. return res;
  2537. }
  2538. if (StringUtils.isBlank(cid)) {
  2539. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "高企ID"));
  2540. return res;
  2541. }
  2542. res.setData(orgCognizanceLogService.selectOrgCognizanceLogByCid(cid));
  2543. return res;
  2544. }
  2545. /**
  2546. * 保存高企认定详情
  2547. *
  2548. * @throws ParseException
  2549. */
  2550. @RequestMapping(value = "/disposeCognizanceDetail", method = RequestMethod.POST)
  2551. public Result disposeCognizanceDetail(@Valid InputOrgCognizance cog, BindingResult bindingResult,
  2552. String recordTimeFormattedDate) {
  2553. Result res = new Result();
  2554. if (bindingResult.hasErrors()) {
  2555. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  2556. OrgCognizanceFields.getFieldDesc(bindingResult.getFieldError().getField())));
  2557. return res;
  2558. }
  2559. if (!checkAdminLogin(res)) {
  2560. return res;
  2561. }
  2562. if (StringUtils.isBlank(cog.getUid())) {
  2563. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2564. return res;
  2565. }
  2566. if (!checkCertify(res, cog.getUid()).getError().isEmpty()) {
  2567. return res;
  2568. }
  2569. Date recordTime = null;
  2570. if (!StringUtils.isBlank(recordTimeFormattedDate)) {
  2571. try {
  2572. recordTime = DateUtils.parseDate(recordTimeFormattedDate, AFTConstants.YYYYMMDD);
  2573. } catch (ParseException e) {
  2574. }
  2575. }
  2576. OrgCognizance oc = new OrgCognizance();
  2577. OrgCognizanceLog ocl = new OrgCognizanceLog();
  2578. BeanUtils.copyProperties(cog, oc);
  2579. BeanUtils.copyProperties(cog, ocl);
  2580. orgCognizanceService.updateCognizance(oc, ocl, recordTime, TokenManager.getAdminId());
  2581. return res;
  2582. }
  2583. /**
  2584. * 刪除高企认定
  2585. *
  2586. * @param ids
  2587. * @return
  2588. */
  2589. @RequestMapping(value = "/deleteCognizance", method = RequestMethod.POST)
  2590. public Result deleteCognizance(@RequestParam(name = "ids[]", required = false) String[] ids) {
  2591. Result res = new Result();
  2592. if (!checkAdminLogin(res)) {
  2593. return res;
  2594. }
  2595. if (ids == null || ids.length < 1) {
  2596. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  2597. } else {
  2598. res.setData(orgCognizanceService.deleteByPrimaryKey(Arrays.asList(ids)));
  2599. }
  2600. return res;
  2601. }
  2602. /**
  2603. * 企业创新能力入口
  2604. *
  2605. * @param uid
  2606. * @return
  2607. */
  2608. @RequestMapping(value = "/able", method = RequestMethod.POST)
  2609. public Result able(String uid) {
  2610. Result res = new Result();
  2611. if (!checkAdminLogin(res)) {
  2612. return res;
  2613. }
  2614. if (StringUtils.isBlank(uid)) {
  2615. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2616. return res;
  2617. }
  2618. res.setData(userAbilityService.selectUserAbilityByUserId(uid));
  2619. return res;
  2620. }
  2621. /**
  2622. * 企业创新能力新增+保存
  2623. *
  2624. * @param u
  2625. * @return
  2626. */
  2627. @RequestMapping(value = "/disposeAble", method = RequestMethod.POST)
  2628. public Result disposeAble(@Valid InputUserAbility u, BindingResult bindingResult) {
  2629. Result res = new Result();
  2630. if (bindingResult.hasErrors()) {
  2631. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  2632. UserAbilityFields.getFieldDesc(bindingResult.getFieldError().getField())));
  2633. return res;
  2634. }
  2635. if (StringUtils.isBlank(u.getUid())) {
  2636. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2637. return res;
  2638. }
  2639. UserAbility user = new UserAbility();
  2640. BeanUtils.copyProperties(u, user);
  2641. if (StringUtils.isBlank(user.getId())) {
  2642. user.setId(UUID.randomUUID().toString());
  2643. userAbilityService.insert(user);
  2644. } else {
  2645. userAbilityService.updateByPrimaryKeySelective(user);
  2646. }
  2647. return res;
  2648. }
  2649. /**
  2650. * 年报列表
  2651. *
  2652. * @return
  2653. */
  2654. @RequestMapping(value = "/annualReport", method = RequestMethod.POST)
  2655. public Result annualReport(String uid, Integer year, Integer state, String pageSize, String pageNo) {
  2656. Result res = new Result();
  2657. res = checkCertify(res, uid);
  2658. if (res.getError().isEmpty()) {
  2659. Integer pNo = 1;
  2660. Integer pSize = 10;
  2661. if (StringUtils.isNumeric(pageSize)) {
  2662. pSize = Integer.parseInt(pageSize);
  2663. }
  2664. if (StringUtils.isNumeric(pageNo)) {
  2665. pNo = Integer.parseInt(pageNo);
  2666. }
  2667. res.setData(orgAnnualReportService.listOrgAnnualReport(year, state, pNo, pSize, uid));
  2668. }
  2669. return res;
  2670. }
  2671. /**
  2672. * 企业年报详情
  2673. *
  2674. * @param uid
  2675. * @param year
  2676. * @return
  2677. */
  2678. @RequestMapping(value = "/annualReportDetail", method = RequestMethod.POST)
  2679. public Result annualReportDetail(String uid, Integer year) {
  2680. Result res = new Result();
  2681. if (StringUtils.isBlank(uid)) {
  2682. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2683. return res;
  2684. }
  2685. if (null == year) {
  2686. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "年份"));
  2687. return res;
  2688. }
  2689. if (!checkCertify(res, uid).getError().isEmpty()) {
  2690. return res;
  2691. }
  2692. res.setData(handleAnnualReport(uid, year));
  2693. return res;
  2694. }
  2695. /**
  2696. * 高企年报新增+修改
  2697. *
  2698. * @param orgAnnualReport
  2699. * @return
  2700. */
  2701. @RequestMapping(value = "/disposeAnnualReport", method = RequestMethod.POST)
  2702. public Result disposeAnnualReport(@Valid InputOrgAnnualReport orgAnnualReport, BindingResult bindingResult) {
  2703. Result res = new Result();
  2704. if (bindingResult.hasErrors()) {
  2705. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  2706. OrgAnnualReportFields.getFieldDesc(bindingResult.getFieldError().getField())));
  2707. return res;
  2708. }
  2709. if (StringUtils.isBlank(orgAnnualReport.getUid())) {
  2710. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2711. return res;
  2712. }
  2713. if (!checkCertify(res, orgAnnualReport.getUid()).getError().isEmpty()) {
  2714. res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
  2715. return res;
  2716. }
  2717. OrgAnnualReport oar = new OrgAnnualReport();
  2718. BeanUtils.copyProperties(orgAnnualReport, oar);
  2719. if (StringUtils.isBlank(oar.getId())) {
  2720. if (null != orgAnnualReportService.selectAnnualReportByYearAndUid(oar.getYear(), oar.getUid())) {
  2721. res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年企业年报已录入!"));
  2722. return res;
  2723. } else {
  2724. oar.setId(UUID.randomUUID().toString());
  2725. Calendar now = Calendar.getInstance();
  2726. now.set(Calendar.MILLISECOND, 0);
  2727. oar.setCreateTime(now.getTime());
  2728. oar.setLastUpdateTime(oar.getCreateTime());
  2729. oar.setDeletedSign(0);
  2730. orgAnnualReportService.insert(oar);
  2731. }
  2732. } else {
  2733. Calendar now = Calendar.getInstance();
  2734. now.set(Calendar.MILLISECOND, 0);
  2735. oar.setLastUpdateTime(now.getTime());
  2736. orgAnnualReportService.updateByPrimaryKeySelective(oar);
  2737. }
  2738. return res;
  2739. }
  2740. /**
  2741. * 删除企业年报记录
  2742. *
  2743. * @param ids
  2744. * @return
  2745. */
  2746. @RequestMapping(value = "/deleteAnnualReport", method = RequestMethod.POST)
  2747. public Result deleteAnnualReport(@RequestParam(name = "ids[]", required = false) String[] ids) {
  2748. Result res = new Result();
  2749. if (!checkAdminLogin(res)) {
  2750. return res;
  2751. }
  2752. if (ids == null || ids.length < 1) {
  2753. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  2754. } else {
  2755. res.setData(orgAnnualReportService.deleteByPrimaryKey(Arrays.asList(ids)));
  2756. }
  2757. return res;
  2758. }
  2759. /**
  2760. * 高企培育列表
  2761. *
  2762. * @param pageNo
  2763. * @param pageSize
  2764. * @return
  2765. */
  2766. @RequestMapping(value = "/cultivate", method = RequestMethod.POST)
  2767. public Result cultivationList(String uid, String province, String unitName, String pageNo, String pageSize) {
  2768. Result res = new Result();
  2769. Integer pNo = 1;
  2770. Integer pSize = 10;
  2771. if (StringUtils.isNumeric(pageSize)) {
  2772. pSize = Integer.parseInt(pageSize);
  2773. }
  2774. if (StringUtils.isNumeric(pageNo)) {
  2775. pNo = Integer.parseInt(pageNo);
  2776. }
  2777. res.setData(orgCognizanceService.listCultivation(uid, province, unitName, pNo, pSize));
  2778. return res;
  2779. }
  2780. /**
  2781. * 高企相关材料上传
  2782. *
  2783. * @param req
  2784. * @param sign
  2785. * @param uid
  2786. * @return
  2787. */
  2788. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  2789. public Result cognizanceFile(HttpServletRequest req, String sign, String uid) {
  2790. Result res = new Result();
  2791. if (!checkUserLogin(res)) {
  2792. return res;
  2793. }
  2794. if (StringUtils.isBlank(uid)) {
  2795. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  2796. return res;
  2797. }
  2798. res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
  2799. return res;
  2800. }
  2801. /**
  2802. *
  2803. * @return
  2804. */
  2805. // 判断用户是否通过认证
  2806. private Result checkCertify(Result res, String uid) {
  2807. OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(uid);
  2808. if (null == o || 5 != o.getAuditStatus()) {
  2809. res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
  2810. }
  2811. return res;
  2812. }
  2813. // org团体列表
  2814. private Pagination<OrgListBo> getOrgList(String uid, String mobile, String email, String[] createTime,
  2815. Integer number, String unitName, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException {
  2816. return userService.listOrg(uid, mobile, email, createTime, number, unitName, auditStatus, pNo, pSize);
  2817. }
  2818. // user个人列表
  2819. private Pagination<UserListBo> getUserList(String mobile, String email, String[] createTime, Integer number,
  2820. String aftUsername, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException {
  2821. return userService.listUser(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize);
  2822. }
  2823. // 高企详情
  2824. private CognizanceDetailBo handleCognizanceDetail(String uid, String cid, Integer year) {
  2825. return orgCognizanceService.selectCognizanceDetailBo(uid, cid, year);
  2826. }
  2827. // 年报
  2828. private AnnualReportBo handleAnnualReport(String uid, Integer year) {
  2829. return orgAnnualReportService.selectAnnualReportBo(uid, year);
  2830. }
  2831. private Map<String, String> disposeCognizanceStatus() {
  2832. Map<String, String> status = new TreeMap<String, String>();
  2833. if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  2834. for (OrgCognizanceStatus p : OrgCognizanceStatus.values()){
  2835. status.put(p.getCode().toString(), p.getDesc());
  2836. status.remove(OrgCognizanceStatus.OTHER.getCode().toString());
  2837. }
  2838. } else {
  2839. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.CREATE.getCode())){
  2840. status.put(OrgCognizanceStatus.CREATE.getCode().toString(), OrgCognizanceStatus.CREATE.getDesc());
  2841. }
  2842. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.SIGN.getCode())){
  2843. status.put(OrgCognizanceStatus.SIGN.getCode().toString(), OrgCognizanceStatus.SIGN.getDesc());
  2844. }
  2845. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.DELIVERD.getCode())){
  2846. status.put(OrgCognizanceStatus.DELIVERD.getCode().toString(), OrgCognizanceStatus.DELIVERD.getDesc());
  2847. }
  2848. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.CIRCULATION.getCode())){
  2849. status.put(OrgCognizanceStatus.CIRCULATION.getCode().toString(), OrgCognizanceStatus.CIRCULATION.getDesc());
  2850. }
  2851. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.PREPARE.getCode())){
  2852. status.put(OrgCognizanceStatus.PREPARE.getCode().toString(), OrgCognizanceStatus.PREPARE.getDesc());
  2853. }
  2854. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.SUBMIT.getCode())){
  2855. status.put(OrgCognizanceStatus.SUBMIT.getCode().toString(), OrgCognizanceStatus.SUBMIT.getDesc());
  2856. }
  2857. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.ACCEPT.getCode())){
  2858. status.put(OrgCognizanceStatus.ACCEPT.getCode().toString(), OrgCognizanceStatus.ACCEPT.getDesc());
  2859. }
  2860. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.APPRVOVED.getCode())){
  2861. status.put(OrgCognizanceStatus.APPRVOVED.getCode().toString(), OrgCognizanceStatus.APPRVOVED.getDesc());
  2862. }
  2863. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.REJECT.getCode())){
  2864. status.put(OrgCognizanceStatus.REJECT.getCode().toString(), OrgCognizanceStatus.REJECT.getDesc());
  2865. }
  2866. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.ISSUING.getCode())){
  2867. status.put(OrgCognizanceStatus.ISSUING.getCode().toString(), OrgCognizanceStatus.ISSUING.getDesc());
  2868. }
  2869. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.EXPIRED.getCode())){
  2870. status.put(OrgCognizanceStatus.EXPIRED.getCode().toString(), OrgCognizanceStatus.EXPIRED.getDesc());
  2871. }
  2872. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.FOSTER.getCode())){
  2873. status.put(OrgCognizanceStatus.FOSTER.getCode().toString(), OrgCognizanceStatus.FOSTER.getDesc());
  2874. }
  2875. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.SETTLEMENT.getCode())){
  2876. status.put(OrgCognizanceStatus.SETTLEMENT.getCode().toString(), OrgCognizanceStatus.SETTLEMENT.getDesc());
  2877. }
  2878. if (TokenManager.hasPermission("CognizanceStatus" + OrgCognizanceStatus.CALLBACK.getCode())){
  2879. status.put(OrgCognizanceStatus.CALLBACK.getCode().toString(), OrgCognizanceStatus.CALLBACK.getDesc());
  2880. }
  2881. }
  2882. return status;
  2883. }
  2884. }