AdminApiController.java 106 KB

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