AdminApiController.java 107 KB

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