package com.goafanti.admin.controller; import java.io.IOException; import java.math.BigDecimal; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang3.time.DateFormatUtils; 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.Admin; 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.AnnualReportMainBo; import com.goafanti.techservice.cognizance.bo.AnnualReportPropertyRightBo; import com.goafanti.techservice.cognizance.bo.CognizanceCatagoryBo; import com.goafanti.techservice.cognizance.bo.CognizanceDetailBo; import com.goafanti.techservice.cognizance.bo.CognizanceManageCostBo; import com.goafanti.techservice.cognizance.bo.CognizanceOrgInfoBo; import com.goafanti.techservice.cognizance.bo.CognizanceResearchCostBo; 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); List admins = adminService.selectAllAdmin(); if (!admins.isEmpty()) { Collections.shuffle(admins); u.setAid(admins.get(0).getId()); } 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()) { orgHumanResource.setId(UUID.randomUUID().toString()); 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(); OrganizationIdentity i = organizationIdentityService.selectOrgIdentityByUserId(uid); Map map = new LinkedHashMap(); if (!StringUtils.isBlank(i.getFirstContacts()) && !StringUtils.isBlank(i.getFirstMobile())) { map.put(i.getFirstContacts(), i.getFirstMobile()); } if (!StringUtils.isBlank(i.getSecondContacts()) && !StringUtils.isBlank(i.getSecondMobile())) { map.put(i.getSecondContacts(), i.getSecondMobile()); } if (!StringUtils.isBlank(i.getThirdContacts()) && !StringUtils.isBlank(i.getThirdMobile())) { map.put(i.getThirdContacts(), i.getThirdMobile()); } res.setData(map); return res; } /** * 申请高企认定 * * @return */ @RequestMapping(value = "/applyCognizance", method = RequestMethod.POST) public Result applyCognizance(String 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; } cog.setConsultant(null == log.getOperator() ? "" : log.getOperator()); 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) { CognizanceDetailBo cog = new CognizanceDetailBo(); CognizanceOrgInfoBo orgInfo = orgCognizanceService.selectCognizanceOrgInfoBoByUidAndCid(uid, cid); cog.setUid(null == orgInfo.getUid() ? "" : orgInfo.getUid()); cog.setCid(null == orgInfo.getCid() ? "" : orgInfo.getCid()); cog.setUnitName(null == orgInfo.getUnitName() ? "" : orgInfo.getUnitName()); cog.setOrgCode(null == orgInfo.getOrgCode() ? "" : orgInfo.getOrgCode()); cog.setPostalAddress(null == orgInfo.getPostalAddress() ? "" : orgInfo.getPostalAddress()); cog.setContacts(null == orgInfo.getContacts() ? "" : orgInfo.getContacts()); cog.setTechnicalField1(null == orgInfo.getTechnicalField1() ? 0 : orgInfo.getTechnicalField1()); cog.setTechnicalField2(null == orgInfo.getTechnicalField2() ? 0 : orgInfo.getTechnicalField2()); cog.setTechnicalField3(null == orgInfo.getTechnicalField3() ? 0 : orgInfo.getTechnicalField3()); cog.setBasicResearchCost( null == orgInfo.getBasicResearchCost() ? new BigDecimal(0) : orgInfo.getBasicResearchCost()); cog.setAccident(null == orgInfo.getAccient() ? 0 : orgInfo.getAccient()); CognizanceResearchCostBo researchCost = orgCognizanceService.selectCognizanceResearchCostBoByUidAndYear(year, uid); cog.setResearchCost( null == researchCost.getResearchCost() ? new BigDecimal(0) : researchCost.getResearchCost()); cog.setTerritory(null == researchCost.getTerritory() ? new BigDecimal(0) : researchCost.getTerritory()); CognizanceManageCostBo manageCost = orgCognizanceService.selectCognizanceManageCostBoByUidAndYear(year, uid); cog.setNetAsset1(null == manageCost.getNetAsset1() ? new BigDecimal(0) : manageCost.getNetAsset1()); cog.setNetAsset2(null == manageCost.getNetAsset2() ? new BigDecimal(0) : manageCost.getNetAsset2()); cog.setNetAsset3(null == manageCost.getNetAsset3() ? new BigDecimal(0) : manageCost.getNetAsset3()); cog.setSalesRevenue1(null == manageCost.getSalesRevenue1() ? new BigDecimal(0) : manageCost.getSalesRevenue1()); cog.setSalesRevenue2(null == manageCost.getSalesRevenue2() ? new BigDecimal(0) : manageCost.getSalesRevenue2()); cog.setSalesRevenue3(null == manageCost.getSalesRevenue3() ? new BigDecimal(0) : manageCost.getSalesRevenue3()); cog.setGrossProfit1(null == manageCost.getGrossProfit1() ? new BigDecimal(0) : manageCost.getGrossProfit1()); cog.setGrossProfit2(null == manageCost.getGrossProfit2() ? new BigDecimal(0) : manageCost.getGrossProfit2()); cog.setGrossProfit3(null == manageCost.getGrossProfit3() ? new BigDecimal(0) : manageCost.getGrossProfit3()); CognizanceCatagoryBo catagory = orgCognizanceService.selectCognizanceCatagoryBoByUidAndYear(year, uid); cog.setFirstCatagory(null == catagory.getFirstCatagory() ? 0 : catagory.getFirstCatagory()); cog.setSecondCatagory(null == catagory.getSecondCatagory() ? 0 : catagory.getSecondCatagory()); cog.setFirmTotal(null == catagory.getFirmTotal() ? 0 : catagory.getFirmTotal()); cog.setTechTotal(null == catagory.getTechTotal() ? 0 : catagory.getTechTotal()); cog.setTotalRevenue(null == catagory.getTotalRevenue() ? new BigDecimal(0) : catagory.getTotalRevenue()); BigDecimal revenue = orgCognizanceService.selectLastYearRevenueByUidAndYear(year, uid); cog.setLastYearRevenue(null == revenue ? new BigDecimal(0) : revenue); return cog; } private AnnualReportBo handleAnnualReport(String uid, Integer year) { AnnualReportBo report = new AnnualReportBo(); AnnualReportPropertyRightBo p = orgAnnualReportService.selectAnnualReportPropertyRightBoByYearAndUid(year, uid); report.setInventionPatent(null == p.getInventionPatent() ? 0 : p.getInventionPatent()); report.setDefensePatent(null == p.getDefensePatent() ? 0 : p.getDefensePatent()); report.setNationalCrop(null == p.getNationalCrop() ? 0 : p.getNationalCrop()); report.setNewPlantCariety(null == p.getNewPlantCariety() ? 0 : p.getNewPlantCariety()); report.setNationalDrug(null == p.getNationalDrug() ? 0 : p.getNationalDrug()); report.setChineseMedicine(null == p.getChineseMedicine() ? 0 : p.getChineseMedicine()); report.setUtilityPatent(null == p.getUtilityPatent() ? 0 : p.getUtilityPatent()); report.setCircuitDesign(null == p.getCircuitDesign() ? 0 : p.getCircuitDesign()); report.setExteriorPatent(null == p.getExteriorPatent() ? 0 : p.getExteriorPatent()); report.setSoftwareWorks(null == p.getSoftwareWorks() ? 0 : p.getSoftwareWorks()); BigDecimal t = orgAnnualReportService.selectAnnualReportTerritoryByYearAndUid(year, uid); report.setTerritory(null == t ? new BigDecimal(0) : t); AnnualReportMainBo m = orgAnnualReportService.selectAnnualReportMainBoByYearAndUid(year, uid); report.setUid(m.getUid()); report.setUnitName(m.getUnitName()); report.setOrgCode(m.getOrgCode()); report.setLocationProvince(m.getLocationProvince()); report.setLocationCity(m.getLocationCity()); report.setLocationArea(m.getLocationArea()); report.setListed(m.getListed().toString()); if (null != m.getListedDate()) { report.setListedDate(DateFormatUtils.format(m.getListedDate(), "yyyy-MM-dd")); } report.setListedType(m.getListedType().toString()); report.setStockCode(m.getStockCode()); report.setFirmTotal(null == m.getFirmTotal() ? 0 : m.getFirmTotal()); report.setTechTotal(null == m.getTechTotal() ? 0 : m.getTechTotal()); report.setNewEmployment(null == m.getNewEmployment() ? 0 : m.getNewEmployment()); report.setGraduateNumber(null == m.getGraduateNumber() ? 0 : m.getGraduateNumber()); report.setSalesRevenue(null == m.getSalesRevenue() ? new BigDecimal(0) : m.getSalesRevenue()); report.setGrossProfit(null == m.getGrossProfit() ? new BigDecimal(0) : m.getGrossProfit()); report.setNetAsset(null == m.getNetAsset() ? new BigDecimal(0) : m.getNetAsset()); report.setCertificateNumber(m.getCertificateNumber()); if (null != m.getIssuingDate()) { report.setIssuingDate(DateFormatUtils.format(m.getIssuingDate(), "yyyy-MM-dd")); } report.setContacts(m.getContacts()); report.setResearchCost(null == m.getResearchCost() ? new BigDecimal(0) : m.getResearchCost()); report.setTotalRevenue(null == m.getTotalRevenue() ? new BigDecimal(0) : m.getTotalRevenue()); report.setLastYearRevenue(null == m.getLastYearRevenue() ? new BigDecimal(0) : m.getLastYearRevenue()); return report; } 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; } }