AdminApiController.java 106 KB

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