package com.goafanti.admin.controller; import java.io.IOException; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.UUID; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import com.goafanti.admin.service.AftFileService; import com.goafanti.common.bo.Result; import com.goafanti.common.constant.ErrorConstants; import com.goafanti.common.controller.BaseApiController; import com.goafanti.common.model.AftFile; import com.goafanti.common.model.OrgActivity; import com.goafanti.common.model.OrgActivityCost; import com.goafanti.common.model.OrgAnnualReport; import com.goafanti.common.model.OrgCognizance; import com.goafanti.common.model.OrgCognizanceLog; import com.goafanti.common.model.OrgFinance; import com.goafanti.common.model.OrgHonorDatum; import com.goafanti.common.model.OrgHumanResource; import com.goafanti.common.model.OrgIntellectualProperty; import com.goafanti.common.model.OrgRatepay; import com.goafanti.common.model.OrgStandard; import com.goafanti.common.model.OrgTechAchievement; import com.goafanti.common.model.OrgTechCenter; import com.goafanti.common.model.OrgTechProduct; import com.goafanti.common.model.OrganizationIdentity; import com.goafanti.common.model.User; import com.goafanti.common.model.UserAbility; import com.goafanti.common.model.UserIdentity; import com.goafanti.common.utils.DateUtils; import com.goafanti.common.utils.LoggerUtils; import com.goafanti.common.utils.PasswordUtil; import com.goafanti.common.utils.StringUtils; import com.goafanti.core.mybatis.page.Pagination; import com.goafanti.core.shiro.token.TokenManager; import com.goafanti.techservice.cognizance.bo.ActivityNumberBo; import com.goafanti.techservice.cognizance.bo.AnnualReportBo; import com.goafanti.techservice.cognizance.bo.CognizanceDetailBo; import com.goafanti.techservice.cognizance.service.OrgActivityCostService; import com.goafanti.techservice.cognizance.service.OrgActivityService; import com.goafanti.techservice.cognizance.service.OrgAnnualReportService; import com.goafanti.techservice.cognizance.service.OrgCognizanceLogService; import com.goafanti.techservice.cognizance.service.OrgCognizanceService; import com.goafanti.techservice.cognizance.service.OrgFinanceService; import com.goafanti.techservice.cognizance.service.OrgHonorDatumService; import com.goafanti.techservice.cognizance.service.OrgIntellectualPropertyService; import com.goafanti.techservice.cognizance.service.OrgRatepayService; import com.goafanti.techservice.cognizance.service.OrgStandardService; import com.goafanti.techservice.cognizance.service.OrgTechAchievementService; import com.goafanti.techservice.cognizance.service.OrgTechCenterService; import com.goafanti.techservice.cognizance.service.OrgTechProductService; import com.goafanti.techservice.patent.service.AdminService; import com.goafanti.user.bo.OrgListBo; import com.goafanti.user.bo.UserListBo; import com.goafanti.user.service.OrgHumanResourceService; import com.goafanti.user.service.OrganizationIdentityService; import com.goafanti.user.service.UserAbilityService; import com.goafanti.user.service.UserIdentityService; import com.goafanti.user.service.UserService; @Controller @RequestMapping(value = "/api/admin") public class AdminApiController extends BaseApiController { @Resource private UserService userService; @Resource private UserIdentityService userIdentityService; @Resource private OrganizationIdentityService organizationIdentityService; @Resource private OrgHumanResourceService orgHumanResourceService; @Resource private OrgStandardService orgStandardService; @Resource private OrgIntellectualPropertyService orgIntellectualPropertyService; @Resource private OrgTechProductService orgTechProductService; @Resource private OrgRatepayService orgRatepayService; @Resource private OrgFinanceService orgFinanceService; @Resource private OrgActivityService orgActivityService; @Resource private OrgActivityCostService orgActivityCostService; @Resource private OrgTechAchievementService orgTechAchievementService; @Resource private OrgHonorDatumService orgHonorDatumService; @Resource private OrgTechCenterService orgTechCenterService; @Resource private OrgCognizanceService orgCognizanceService; @Resource private OrgCognizanceLogService orgCognizanceLogService; @Resource private UserAbilityService userAbilityService; @Resource private OrgAnnualReportService orgAnnualReportService; @Resource private AftFileService aftFileService; @Resource(name = "passwordUtil") private PasswordUtil passwordUtil; @Resource private AdminService adminService; /** * 新增用户 * * @param mobile * @param type * @param unitName * @return */ @RequestMapping(value = "/addNewUser", method = RequestMethod.POST) public Result addNewUser(String mobile, Integer type, String unitName) { Result res = new Result(); User user = userService.selectByMobieAndType(mobile, type); if (null != user) { res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!")); return res; } User u = new User(); u.setId(UUID.randomUUID().toString()); u.setMobile(mobile); u.setPassword(mobile); u.setType(type); Calendar now = Calendar.getInstance(); now.set(Calendar.MILLISECOND, 0); u.setCreateTime(now.getTime()); u.setPassword(passwordUtil.getEncryptPwd(u)); u.setLvl(0); u.setAid(TokenManager.getAdminId()); userService.insertRegister(u, "", unitName); return res; } /** * 个人用户列表 * * @param mobile * @param email * @param createTime * @param number * @param auditStatus * @param pageNo * @param pageSize * @return * @throws ParseException */ @RequestMapping(value = "/userList", method = RequestMethod.POST) public Result userList(String mobile, String email, @RequestParam(name = "createTime[]", required = false) String[] createTime, Integer number, String aftUsername, Integer auditStatus, String pageNo, String pageSize) throws ParseException { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getUserList(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize)); return res; } /** * 个人用户信息明细 * * @param uid * @return */ @RequestMapping(value = "/userDetail", method = RequestMethod.POST) public Result userDetail(String uid) { Result res = new Result(); res.setData(userIdentityService.selectUserIdentityByUserId(uid)); return res; } /** * 修改个人用户信息 * * @return * @throws ParseException */ @RequestMapping(value = "updateUserDetail", method = RequestMethod.POST) public Result updateUserDetail(UserIdentity userIdentity, String paymentDateFormattedDate) throws ParseException { Result res = new Result(); if (!StringUtils.isBlank(paymentDateFormattedDate)) { userIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, "yyyy-MM-dd")); } res.setData(userIdentityService.updateByPrimaryKeySelective(userIdentity)); return res; } /** * 团体用户列表 * * @param mobile * @param email * @param createTime * @param number * @param auditStatus * @param pageNo * @param pageSize * @return * @throws ParseException */ @RequestMapping(value = "/orgList", method = RequestMethod.POST) public Result orgList(String mobile, String email, @RequestParam(name = "createTime[]", required = false) String[] createTime, Integer number, String aftUsername, Integer auditStatus, String pageNo, String pageSize) throws ParseException { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getOrgList(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize)); return res; } /** * 团体用户明细 * * @param uid * @return */ @RequestMapping(value = "/orgDetail", method = RequestMethod.POST) public Result orgDetail(String uid) { Result res = new Result(); res.setData(organizationIdentityService.selectOrgIdentityByUserId(uid)); return res; } /** * 修改团体用户信息 * * @param orgIdentity * @return * @throws ParseException */ @RequestMapping(value = "/updateOrgDetail", method = RequestMethod.POST) public Result updateOrgDetail(OrganizationIdentity orgIdentity, String paymentDateFormattedDate) throws ParseException { Result res = new Result(); if (!StringUtils.isBlank(paymentDateFormattedDate)) { orgIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, "yyyy-MM-dd")); } res.setData(organizationIdentityService.updateByPrimaryKeySelective(orgIdentity)); return res; } /** * 团体用户人力资源情况入口 * * @param uid * 用户ID * @return */ @RequestMapping(value = "/orgHumanResource", method = RequestMethod.POST) public Result orgHumanResource(Integer year, String pageNo, String pageSize, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgHumanResourceService.listOrgHumanResource(year, pNo, pSize, uid)); } return res; } /** * 修改团体用户人力资源情况 * * @param orgHumanResource * @return */ @RequestMapping(value = "/updateOrgHumanResource", method = RequestMethod.POST) public Result updateOrgHumanResource(OrgHumanResource orgHumanResource) { Result res = new Result(); if (null == orgHumanResource.getId()) { if (null != orgHumanResourceService.selectOrgHumanResourceByUidAndYear(orgHumanResource.getYear(), orgHumanResource.getUid())){ res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度人力资源情况已录入!")); return res; } orgHumanResource.setId(UUID.randomUUID().toString()); orgHumanResource.setDeletedSign(0); orgHumanResourceService.insert(orgHumanResource); } else { orgHumanResourceService.updateByPrimaryKeySelective(orgHumanResource); } return res; } /** * 企业参与国家标准或行业标准制定情况明细入口 * * @param uid * 用户id * @return */ @RequestMapping(value = "/standard", method = RequestMethod.POST) public Result standard(String uid, String standardName, String standardNumber, Integer standardLevel, Integer participateWay, String pageNo, String pageSize) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgStandardService.listOrgStandard(standardName, standardNumber, standardLevel, participateWay, pNo, pSize, uid)); } return res; } /** * 企业参与国家标准或行业标准制定情况明细修改保存 * * @param orgStandard * @return */ @RequestMapping(value = "/developStandard", method = RequestMethod.POST) public Result developStandard(OrgStandard orgStandard) { Result res = new Result(); if (StringUtils.isBlank(orgStandard.getId())) { orgStandard.setId(UUID.randomUUID().toString()); orgStandard.setDeletedSign(0); Calendar now = Calendar.getInstance(); now.set(Calendar.MILLISECOND, 0); orgStandard.setCreateTime(now.getTime()); orgStandardService.insert(orgStandard); } else { orgStandardService.updateByPrimaryKeySelective(orgStandard); } res.setData(orgStandard); return res; } /** * 管理端录入+修改知识产权信息 * * @return * @throws ParseException */ @RequestMapping(value = "/intellectual", method = RequestMethod.POST) public Result intellectual(OrgIntellectualProperty orgIntellectualProperty, String authorizationDateFormattedDate, String uid) throws ParseException { Result res = new Result(); if (!StringUtils.isBlank(authorizationDateFormattedDate)) { orgIntellectualProperty .setAuthorizationDate(DateUtils.parseDate(authorizationDateFormattedDate, "yyyy-MM-dd")); } if (null == orgIntellectualProperty.getId()) { orgIntellectualProperty.setId(UUID.randomUUID().toString()); orgIntellectualProperty.setUid(uid); orgIntellectualProperty.setEvaluationCategory( (orgIntellectualProperty.getCatagory() >= 2 && orgIntellectualProperty.getCatagory() <= 4) ? 1 : 0); orgIntellectualProperty.setDeletedSign(0); res.setData(orgIntellectualPropertyService.insert(orgIntellectualProperty)); } else { orgIntellectualProperty.setEvaluationCategory(orgIntellectualProperty.getCatagory() <= 2 ? 1 : 0); res.setData(orgIntellectualPropertyService.updateByPrimaryKeySelective(orgIntellectualProperty)); } return res; } /** * 知识产权列表 * * @param pageNo * @param pageSize * @return */ @RequestMapping(value = "/intellectualList", method = RequestMethod.POST) public Result intellectualList(String pageNo, String pageSize, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgIntellectualPropertyService.listIntellectual(pNo, pSize, uid)); } return res; } /** * 上年度高新技术产品(服务)情况列表 * * @param pageNo * @param pageSize * @return */ @RequestMapping(value = "/techProductList", method = RequestMethod.POST) public Result techProductList(String pageNo, String pageSize, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgTechProductService.listTechProduct(pNo, pSize, uid)); } return res; } /** * 企业研究开发活动情况表入口 * * @param activityNumber * @param activityName * @param startDate * @param endDate * @param pageNo * @param pageSize * @return * @throws ParseException */ @RequestMapping(value = "/activityList", method = RequestMethod.POST) public Result activityList(String activityNumber, String activityName, String startDateFormattedDate, String endDateFormattedDate, String pageNo, String pageSize, String uid) throws ParseException { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgActivityService.listOrgActivity(activityNumber, activityName, startDateFormattedDate, endDateFormattedDate, pNo, pSize, uid)); } return res; } /** * 企业研究开发活动情况新增、修改 * * @param orgActivity * @return * @throws ParseException */ @RequestMapping(value = "/activity", method = RequestMethod.POST) public Result activity(OrgActivity orgActivity, String startDateFormattedDate, String endDateFormattedDate) throws ParseException { Result res = new Result(); orgActivity.setDeletedSign(0); if (!StringUtils.isBlank(startDateFormattedDate)) { orgActivity.setStartDate(DateUtils.parseDate(startDateFormattedDate, "yyyy-MM-dd")); } if (StringUtils.isBlank(endDateFormattedDate)) { orgActivity.setEndDate(DateUtils.parseDate(endDateFormattedDate, "yyyy-MM-dd")); } if (StringUtils.isBlank(orgActivity.getId())) { orgActivity.setId(UUID.randomUUID().toString()); orgActivity.setUid(TokenManager.getUserId()); orgActivityService.insert(orgActivity); } else { orgActivityService.updateByPrimaryKeySelective(orgActivity); Boolean flag = false; OrgActivityCost cost = orgActivityCostService.selectOrgActivityCostByAid(orgActivity.getId()); if (null != cost) { if (!StringUtils.isBlank(orgActivity.getActivityNumber())) { cost.setActivityNumber(orgActivity.getActivityNumber()); flag = true; } if (null == orgActivity.getStartDate()) { cost.setStartDate(orgActivity.getStartDate()); flag = true; } if (null == orgActivity.getEndDate()) { cost.setEndDate(orgActivity.getEndDate()); flag = true; } } if (flag) { orgActivityCostService.updateByPrimaryKeySelective(cost); } } res.setData(orgActivity); return res; } /** * 企业年度研究开发费用结构明细表列表入口 * * @return * @throws ParseException */ @RequestMapping(value = "/activityCostList", method = RequestMethod.POST) public Result activityCostList(String activityNumber, String startDateFormattedDate, String endDateFormattedDate, String pageNo, String pageSize, String uid) throws ParseException { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgActivityCostService.listOrgActivityCost(activityNumber, startDateFormattedDate, endDateFormattedDate, pNo, pSize, uid)); } return res; } /** * 企业年度研究开发费用结构明细表(新增+修改) * * @return * @throws ParseException */ @RequestMapping(value = "/activityCost", method = RequestMethod.POST) public Result activityCost(OrgActivityCost orgActivityCost, String signDateFormattedDate) throws ParseException { Result res = new Result(); if (StringUtils.isBlank(signDateFormattedDate)) { orgActivityCost.setSignDate(DateUtils.parseDate(signDateFormattedDate, "yyyy-MM-dd")); } if (null == orgActivityCost.getId()) { OrgActivity ac = orgActivityService.selectOrgActivityByPrimaryKey(orgActivityCost.getAid()); orgActivityCost.setStartDate(ac.getStartDate()); orgActivityCost.setEndDate(ac.getEndDate()); orgActivityCost.setId(UUID.randomUUID().toString()); orgActivityCost.setUid(TokenManager.getUserId()); orgActivityCost.setDeletedSign(0); orgActivityCostService.insert(orgActivityCost); } else { orgActivityCostService.updateByPrimaryKeySelective(orgActivityCost); } return res; } /** * 上年度高新技术产品(服务)情况(新增+修改) * * @param orgTechProduct * @return */ @RequestMapping(value = "/techProduct", method = RequestMethod.POST) public Result techProduct(OrgTechProduct orgTechProduct) { Result res = new Result(); if (null == orgTechProduct.getId()) { orgTechProduct.setId(UUID.randomUUID().toString()); orgTechProduct.setDeletedSign(0); Calendar now = Calendar.getInstance(); now.set(Calendar.MILLISECOND, 0); orgTechProduct.setCreateTime(now.getTime()); orgTechProduct.setYear(Calendar.getInstance().get(Calendar.YEAR) - 1); orgTechProductService.insert(orgTechProduct); } else { orgTechProductService.updateByPrimaryKeySelective(orgTechProduct); } res.setData(orgTechProduct); return res; } /** * 企业纳税申报信息入口 * * @return */ @RequestMapping(value = "/ratepay", method = RequestMethod.POST) public Result ratepay(Integer year, String pageNo, String pageSize, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgRatepayService.listOrgRatepay(year, pNo, pSize, uid)); } return res; } /** * 企业纳税申报信息录入+修改 */ @RequestMapping(value = "/disposeRatepay", method = RequestMethod.POST) public Result disposeRatepay(OrgRatepay orgRatepay) { Result res = new Result(); if (null == orgRatepay.getId()) { if (null == orgRatepayService.selectRatepayByUidAndYear(orgRatepay.getUid(), orgRatepay.getYear())) { orgRatepay.setId(UUID.randomUUID().toString()); orgRatepay.setDeletedSign(0); orgRatepayService.insert(orgRatepay); } else { res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度纳税申报表已录入!")); return res; } } else { orgRatepayService.updateByPrimaryKeySelective(orgRatepay); } return res; } /** * 财务报表信息入口 * * @return */ @RequestMapping(value = "/finance", method = RequestMethod.POST) public Result finance(Integer year, String pageNo, String pageSize, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgFinanceService.listFinance(year, pNo, pSize, uid)); } return res; } /** * 财务报表录入+修改 * * @param orgFinance * @return */ @RequestMapping(value = "/disposeFinance", method = RequestMethod.POST) public Result disposeFinance(OrgFinance orgFinance) { Result res = new Result(); if (null == orgFinance.getId()) { if (null == orgFinanceService.selectFinanceByUidAndYear(orgFinance.getUid(), orgFinance.getYear())) { orgFinance.setId(UUID.randomUUID().toString()); orgFinance.setDeletedSign(0); orgFinanceService.insert(orgFinance); } else { res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度财务报表已录入!")); return res; } } else { orgFinanceService.updateByPrimaryKeySelective(orgFinance); } return res; } /** * 获取当前用户已录入项目标号列表 * * @param uid * @return */ @RequestMapping(value = "/activityNumber", method = RequestMethod.POST) public Result listActivityNumber(String uid) { Result res = new Result(); List activityNumberBo = orgActivityService.selectOrgActivityNumberBoByUid(uid); res.setData(activityNumberBo); return res; } /** * 科技成果转化情况列表入口 * * @param pageNo * @param pageSize * @return */ @RequestMapping(value = "/achievementList", method = RequestMethod.POST) public Result achievementList(String pageNo, String pageSize, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgTechAchievementService.listOrgTechAchievement(pNo, pSize, uid)); } return res; } /** * 科技成果转化情况新增+修改 * * @param achievement * @return * @throws ParseException */ @RequestMapping(value = "/disposeAchievement", method = RequestMethod.POST) public Result disposeAchievement(OrgTechAchievement achievement) throws ParseException { Result res = new Result(); if (null == achievement.getId()) { achievement.setId(UUID.randomUUID().toString()); achievement.setDeletedSign(0); orgTechAchievementService.inset(achievement); } else { orgTechAchievementService.updateByPrimaryKeySelective(achievement); } return res; } /** * 企业荣誉及其他证明材料列表入口 * * @return */ @RequestMapping(value = "/honorList", method = RequestMethod.POST) public Result honorList(String pageNo, String pageSize, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgHonorDatumService.listOrgHonorDatum(pNo, pSize, uid)); } return res; } /** * 企业荣誉及其他证明材料新增+修改 * * @param achievement * @return * @throws ParseException */ @RequestMapping(value = "/disposeHonor", method = RequestMethod.POST) public Result disposeHonor(OrgHonorDatum honor, String issuingTimeFormattedDate, String uid) throws ParseException { Result res = new Result(); if (!StringUtils.isBlank(issuingTimeFormattedDate)) { honor.setIssuingTime(DateUtils.parseDate(issuingTimeFormattedDate, "yyyy-MM-dd")); } if (null == honor.getId()) { honor.setId(UUID.randomUUID().toString()); honor.setUid(uid); honor.setDeletedSign(0); orgHonorDatumService.inset(honor); } else { orgHonorDatumService.updateByPrimaryKeySelective(honor); } return res; } /** * 技术中心入口 * * @return */ @RequestMapping(value = "/center", method = RequestMethod.POST) public Result center(String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { res.setData(orgTechCenterService.selectOrgTechCenterByUid(uid)); } return res; } /** * 技术中心新增+修改 * * @return * @throws ParseException */ @RequestMapping(value = "/disposeCenter", method = RequestMethod.POST) public Result disposeCenter(OrgTechCenter orgTechCenter, String foundingTimeFormattedDate, String uid) throws ParseException { Result res = new Result(); if (!StringUtils.isBlank(foundingTimeFormattedDate)) { orgTechCenter.setFoundingTime(DateUtils.parseDate(foundingTimeFormattedDate, "yyyy-MM-dd")); } if (null == orgTechCenter.getId()) { orgTechCenter.setId(UUID.randomUUID().toString()); orgTechCenter.setUid(uid); orgTechCenter.setDeletedSign(0); orgTechCenterService.insert(orgTechCenter); } else { orgTechCenterService.updateByPrimaryKeySelective(orgTechCenter); } return res; } /** * 获取公司联系人 * * @return */ @RequestMapping(value = "/getContacts", method = RequestMethod.POST) public Result getContacts(String uid) { Result res = new Result(); res.setData(organizationIdentityService.selectContactsByUserId(uid)); return res; } /** * 申请高企认定 * * @return */ @RequestMapping(value = "/applyCognizance", method = RequestMethod.POST) public Result applyCognizance(Integer contacts, String comment, String consultant, String uid, Integer year, Integer state) { Result res = new Result(); if (null != orgCognizanceService.selectCognizanceByUidAndYear(year, uid)) { res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度高企认定已申请!")); } OrgCognizance c = new OrgCognizance(); c.setId(UUID.randomUUID().toString()); c.setUid(uid); c.setContacts(contacts); c.setComment(comment); c.setConsultant(consultant); c.setYear(year); c.setDeletedSign(0); c.setState(state); Calendar now = Calendar.getInstance(); now.set(Calendar.MILLISECOND, 0); c.setRecordTime(now.getTime()); orgCognizanceService.insert(c); OrgCognizanceLog log = new OrgCognizanceLog(); log.setId(UUID.randomUUID().toString()); log.setCid(c.getId()); log.setRecordTime(c.getCreateTime()); log.setState(state); log.setComment(comment); log.setPrincipal(userService.selectByPrimaryKey(uid).getAid()); log.setOperator(TokenManager.getAdminId()); orgCognizanceLogService.insert(log); return res; } /** * 高企认定列表入口 * * @param locationProvince * @param unitName * @return */ @RequestMapping(value = "/listCognizance", method = RequestMethod.POST) public Result listCognizance(String uid, String locationProvince, String pageNo, String pageSize) { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgCognizanceService.listCognizance(uid, locationProvince, pNo, pSize)); return res; } /** * 高企认定流转状态 * * @param cid * @return */ @RequestMapping(value = "/cognizanceLog", method = RequestMethod.POST) public Result cognizanceLog(String cid) { Result res = new Result(); List list = orgCognizanceLogService.selectOrgCognizanceLogByCid(cid); res.setData(list); return res; } /** * 高企认定详情入口 * * @param uid * @param cid * @return */ @RequestMapping(value = "/cognizanceDetail", method = RequestMethod.POST) public Result cognizanceDetail(String uid, String cid, Integer year) { Result res = new Result(); res.setData(handleCognizanceDetail(uid, cid, year)); return res; } /** * 保存高企认定详情 * * @throws ParseException */ @RequestMapping(value = "/disposeCognizanceDetail", method = RequestMethod.POST) public Result disposeCognizanceDetail(OrgCognizance cog, OrgCognizanceLog log, String recordTimeFormattedDate) throws ParseException { Result res = new Result(); if (null != log.getState()) { cog.setState(log.getState()); switch (log.getState()) { case 1: cog.setCreateTime(log.getRecordTime()); break; case 2: cog.setAcceptDate(log.getRecordTime()); break; case 5: cog.setIssuingDate(log.getRecordTime()); break; } log.setId(UUID.randomUUID().toString()); log.setCid(cog.getId()); log.setOperator(TokenManager.getAdminId()); if (!StringUtils.isBlank(recordTimeFormattedDate)) { log.setRecordTime(DateUtils.parseDate(recordTimeFormattedDate, "yyyy-MM-dd")); } orgCognizanceLogService.insert(log); } orgCognizanceService.updateByPrimaryKeySelective(cog); return res; } /** * 刪除高企认定 * * @param ids * @return */ @RequestMapping(value = "/deleteCognizance", method = RequestMethod.POST) public Result deleteAnnualReport(@RequestParam(name = "ids[]", required = true) String[] ids) { Result res = new Result(); List id = new ArrayList(); for (String s : ids) { id.add(s); } res.setData(orgCognizanceService.batchDeleteByPrimaryKey(id)); return res; } /** * 企业创新能力入口 * * @param uid * @return */ @RequestMapping(value = "/able", method = RequestMethod.POST) public Result able(String uid) { Result res = new Result(); res.setData(userAbilityService.selectUserAbilityByUserId(uid)); return res; } /** * 企业创新能力新增+保存 * * @param u * @return */ @RequestMapping(value = "/disposeAble", method = RequestMethod.POST) public Result disposeAble(UserAbility u) { Result res = new Result(); if (null == u.getId()) { u.setId(UUID.randomUUID().toString()); userAbilityService.insert(u); } else { userAbilityService.updateByPrimaryKeySelective(u); } return res; } /** * 年报列表 * * @return */ @RequestMapping(value = "/annualReport", method = RequestMethod.POST) public Result annualReport(String uid, Integer year, Integer state, String pageSize, String pageNo) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(orgAnnualReportService.listOrgAnnualReport(year, state, pNo, pSize, uid)); } return res; } /** * 企业年报详情 * * @param uid * @param year * @return */ @RequestMapping(value = "/annualReportDetail", method = RequestMethod.POST) public Result annualReportDetail(String uid, Integer year) { Result res = new Result(); res.setData(handleAnnualReport(uid, year)); return res; } /** * 高企年报新增+修改 * * @param orgAnnualReport * @return */ @RequestMapping(value = "/disposeAnnualReport", method = RequestMethod.POST) public Result disposeAnnualReport(OrgAnnualReport orgAnnualReport) { Result res = new Result(); if (null == orgAnnualReport.getId()) { if (null != orgAnnualReportService.selectAnnualReportByYearAndUid(orgAnnualReport.getYear(), orgAnnualReport.getUid())) { res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年企业年报已录入!")); return res; } else { orgAnnualReport.setId(UUID.randomUUID().toString()); Calendar now = Calendar.getInstance(); now.set(Calendar.MILLISECOND, 0); orgAnnualReport.setCreateTime(now.getTime()); orgAnnualReport.setLastUpdateTime(orgAnnualReport.getCreateTime()); orgAnnualReport.setDeletedSign(0); orgAnnualReportService.insert(orgAnnualReport); } } else { Calendar now = Calendar.getInstance(); now.set(Calendar.MILLISECOND, 0); orgAnnualReport.setLastUpdateTime(now.getTime()); orgAnnualReportService.updateByPrimaryKeySelective(orgAnnualReport); } return res; } /** * 上传相关模版 * * @param req * @return */ @RequestMapping(value = "/uploadTemplate", method = RequestMethod.POST) public Result uploadPatentTemplate(HttpServletRequest req, String sign) { Result res = new Result(); System.out.println("init"); String fileName = ""; List files = getFiles(req); MultipartFile mf = files.get(0); String suffix = mf.getOriginalFilename().substring(mf.getOriginalFilename().lastIndexOf(".")); System.err.println("suffix" + " " + suffix); if (suffix.equals(".doc") || suffix.equals(".docx")) { if ("patent_prory_statement".equals(sign)) { fileName = "patent_prory_statement" + suffix; } else { fileName = System.nanoTime() + ""; } String name = handleFile(res, req, fileName, files, mf); res.setData(name); System.out.println(name); if (res.getData() != "" && res.getData() != null && null == aftFileService.selectAftFileBySign(sign)) { AftFile f = new AftFile(); f.setId(UUID.randomUUID().toString()); if ("patent_prory_statement".equals(sign)) { f.setFileName("专利代理委托书模版"); f.setSign(sign); } f.setFilePath("/admin/" + fileName); f.setDeleletedSign(0); aftFileService.insert(f); } } else { res.getError().add(buildError(ErrorConstants.FILE_PATTERN_ERROR, "文件格式错误,请重新上传!")); } return res; } /** * * @return */ // 判断用户是否通过认证 private Result checkCertify(Result res, String uid) { OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(uid); if (null == o || 5 != o.getAuditStatus()) { res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!")); } return res; } // org团体列表 private Pagination getOrgList(String mobile, String email, String[] createTime, Integer number, String aftUsername, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException { return userService.listOrg(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize); } // user个人列表 private Pagination getUserList(String mobile, String email, String[] createTime, Integer number, String aftUsername, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException { return userService.listUser(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize); } // 高企详情 private CognizanceDetailBo handleCognizanceDetail(String uid, String cid, Integer year) { return orgCognizanceService.selectCognizanceDetailBo(uid, cid, year); } // 年报 private AnnualReportBo handleAnnualReport(String uid, Integer year) { return orgAnnualReportService.selectAnnualReportBo(uid, year); } private String handleFile(Result res, HttpServletRequest req, String fileName, List files, MultipartFile mf) { if (!files.isEmpty()) { try { mf.transferTo(toAdminPrivateFile(fileName)); LoggerUtils.debug(getClass(), fileName + " 文件上传成功"); } catch (IllegalStateException | IOException e) { LoggerUtils.error(getClass(), "文件上传失败", e); res.getError().add(buildError("", "文件上传失败!")); return ""; } } else { res.getError().add(buildError("", "文件上传失败!")); return ""; } return fileName; } }