From 2fcd97552d16718cc7997629fd637a73a5a4483f Mon Sep 17 00:00:00 2001 From: 郑永安 <zyazyz250@sina.com> Date: 星期一, 19 六月 2023 14:44:19 +0800 Subject: [PATCH] 删除 --- src/main/java/com/gk/firework/Controller/LicenseController.java | 611 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 611 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/gk/firework/Controller/LicenseController.java b/src/main/java/com/gk/firework/Controller/LicenseController.java new file mode 100644 index 0000000..feaa871 --- /dev/null +++ b/src/main/java/com/gk/firework/Controller/LicenseController.java @@ -0,0 +1,611 @@ +package com.gk.firework.Controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.gk.firework.Controller.Base.BaseController; +import com.gk.firework.Domain.*; +import com.gk.firework.Domain.Enum.ErrorCode; +import com.gk.firework.Domain.Enum.LicenseStatus; +import com.gk.firework.Domain.Enum.ProvinceCode; +import com.gk.firework.Domain.Exception.BusinessException; +import com.gk.firework.Domain.Utils.Base64Encrypt; +import com.gk.firework.Domain.Utils.Msg; +import com.gk.firework.Domain.Utils.PageInfo; +import com.gk.firework.Domain.Utils.StringUtils; +import com.gk.firework.Domain.Vo.LicenseVo; +import com.gk.firework.Service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.validation.BindingResult; +import org.springframework.validation.FieldError; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author : jingjy + * @date : 2021/5/11 16:48 + */ +@Api(tags = "许可证") +@RequestMapping("/license") +@RestController +public class LicenseController extends BaseController { + + private static final Byte ADD_OPTION = 1; + private static final Byte EDIT_OPTION = 2; + private static final Byte DEL_OPTION = 3; + + private static final Byte LICENSE_PF = 2; + private static final Byte LICENSE_LS = 3; + + private static final int LICENSE_CODE_LENGTH = 16; + + /** + * 未审核:0;等待审核:1;已审核:2;拒绝审核:3; + **/ + private static final Byte STATUS_NOT_REVIEW = 0; + private static final Byte STATUS_WAIT_REVIEW = 1; + private static final Byte STATUS_REVIEWED = 2; + private static final Byte STATUS_REJECT_REVIEW = 3; + + + @Autowired + private LicenseService licenseService; + @Autowired + private UserService userService; + @Autowired + private LicenseStorageService licenseStorageService; + @Autowired + private EnterpriseService enterpriseService; + @Autowired + private EnterpriseLicenseService enterpriseLicenseService; + + + @ApiOperation(value = "许可证信息", notes = "分页查询", httpMethod = "GET") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageIndex", value = "当前页面索引", required = true), + @ApiImplicitParam(name = "pageSize", value = "页面个数", required = true), + @ApiImplicitParam(name = "sort", value = "排序字段", required = true), + @ApiImplicitParam(name = "order", value = "排序方法(ASC/DESC)", required = true), + @ApiImplicitParam(name = "name", value = "单位名称"), + @ApiImplicitParam(name = "type", value = "1.生产;2.批发;3.零售 (传String类型的数字)"), + @ApiImplicitParam(name = "effectdate", value = "生效日期(传String类型日期)"), + @ApiImplicitParam(name = "noeffectdate", value = "失效日期(传String类型日期)"), + @ApiImplicitParam(name = "status", value = "状态(1.有效;2.注销)(传String类型的数字)"), + @ApiImplicitParam(name = "issuingunit", value = "发证机关"), + @ApiImplicitParam(name = "reviewer", value = "发证人"), + @ApiImplicitParam(name = "province", value = "省"), + @ApiImplicitParam(name = "city", value = "市"), + @ApiImplicitParam(name = "district", value = "区"), + + }) + @GetMapping("/info") + public Msg getLicenseInfo(@RequestParam(value = "name", required = false) String name, + @RequestParam(value = "type", required = false) String type, + @RequestParam(value = "effectdate", required = false) String effectdate, + @RequestParam(value = "noeffectdate", required = false) String noeffectdate, + @RequestParam(value = "status", required = false) String status, + @RequestParam(value = "issuingunit", required = false) String issuingunit, + @RequestParam(value = "reviewer", required = false) String reviewer, + @RequestParam(value = "province", required = false) String province, + @RequestParam(value = "city", required = false) String city, + @RequestParam(value = "district", required = false) String district, + @RequestParam(value = "starttime1", required = false)String starttime1, + @RequestParam(value = "endtime1", required = false) String endtime1, + @RequestParam(value = "starttime2", required = false)String starttime2, + @RequestParam(value = "endtime2", required = false)String endtime2, + @RequestParam(value = "reviewstatus", required = false)Integer reviewstatus, + @RequestParam(value = "validstatus", required = false)Byte validstatus, + @RequestParam(value = "licensecode", required = false)String licensecode, + @RequestParam(defaultValue = "0") Integer pageIndex, + @RequestParam(defaultValue = "10") Integer pageSize, + String sort, String order) { + Msg msg = new Msg(true); + PageInfo pageInfo = new PageInfo(pageIndex, pageSize, sort, order); + Map<String, Object> condition = new HashMap<>(16); + + if (StringUtils.isNotBlank(type)) { + condition.put("type", type); + } + if (StringUtils.isNotBlank(effectdate)) { + condition.put("effectdate", effectdate); + } + if (StringUtils.isNotBlank(noeffectdate)) { + condition.put("noeffectdate", noeffectdate); + } + if (StringUtils.isNotBlank(status)) { + condition.put("status", status); + } + if (StringUtils.isNotBlank(issuingunit)) { + condition.put("issuingunit", issuingunit); + } + if (StringUtils.isNotBlank(reviewer)) { + condition.put("reviewer", reviewer); + } + condition.put("filterProvince", province); + condition.put("filterCity", city); + condition.put("filterDistrict", district); + condition.put("starttime1", starttime1); + condition.put("endtime1", endtime1); + condition.put("starttime2", starttime2); + condition.put("endtime2", endtime2); + condition.put("licensestatus", LicenseStatus.parse(licensecode)); + condition.put("validstatus", validstatus); + condition.put("reviewstatus", reviewstatus); + UserInfo userInfo = userService.getById(getUser().getId()); + if (userInfo.getCompanyid() != null) { + condition.put("name", userInfo.getCompany()); + } else if (userInfo.getType() == 3) { + if (StringUtils.isNotBlank(name)) { + condition.put("name", name); + } + if (StringUtils.isNotBlank(userInfo.getProvince())) { + condition.put("province", userInfo.getProvince()); + } + if (StringUtils.isNotBlank(userInfo.getCity())) { + condition.put("city", userInfo.getCity()); + } + if (StringUtils.isNotBlank(userInfo.getArea())) { + condition.put("district", userInfo.getArea()); + } + }else { + if (StringUtils.isNotBlank(name)) { + condition.put("name", name); + } + } + + pageInfo.setCondition(condition); + licenseService.selectDataGrid(pageInfo); + msg.setResult(pageInfo); + return msg; + } + + @GetMapping("/export") + Msg exportLicense(@RequestParam(value = "name", required = false) String name, + @RequestParam(value = "type", required = false) String type, + @RequestParam(value = "status", required = false) String status, + @RequestParam(value = "issuingunit", required = false) String issuingunit, + @RequestParam(value = "reviewer", required = false) String reviewer, + @RequestParam(value = "province", required = false) String province, + @RequestParam(value = "city", required = false) String city, + @RequestParam(value = "district", required = false) String district, + @RequestParam(value = "starttime1", required = false) String starttime1, + @RequestParam(value = "endtime1", required = false) String endtime1, + @RequestParam(value = "starttime2", required = false) String starttime2, + @RequestParam(value = "endtime2", required = false) String endtime2, + @RequestParam(value = "reviewstatus", required = false) Integer reviewstatus, + String sort, String order) { + Map<String,Object> condition = new HashMap<>(); + condition.put("type", type); + condition.put("status", status); + condition.put("issuingunit", issuingunit); + condition.put("reviewer", reviewer); + condition.put("filterProvince", province); + condition.put("filterCity", city); + condition.put("filterDistrict", district); + condition.put("starttime1", starttime1); + condition.put("endtime1", endtime1); + condition.put("starttime2", starttime2); + condition.put("endtime2", endtime2); + condition.put("reviewstatus", reviewstatus); + UserInfo userInfo = userService.getById(getUser().getId()); + if (userInfo.getCompanyid() != null) { + condition.put("name", userInfo.getCompany()); + } else if (userInfo.getType() == 3) { + if (StringUtils.isNotBlank(name)) { + condition.put("name", name); + } + if (StringUtils.isNotBlank(userInfo.getProvince())) { + condition.put("province", userInfo.getProvince()); + } + if (StringUtils.isNotBlank(userInfo.getCity())) { + condition.put("city", userInfo.getCity()); + } + if (StringUtils.isNotBlank(userInfo.getArea())) { + condition.put("district", userInfo.getArea()); + } + }else { + if (StringUtils.isNotBlank(name)) { + condition.put("name", name); + } + } + + List<LicenseVo> licenseVos = licenseService.exportLicense(condition); + return success(licenseVos); + } + + @PostMapping("/addLicense") + public Msg addLicense(@Validated @RequestBody LicenseVo licenseVo, BindingResult bindingResult) { + Msg msg = new Msg(true); + if (bindingResult.hasErrors()) { + StringBuilder stringBuilder = new StringBuilder(); + for (String s : bindingResult.getFieldErrors().stream() + .map(FieldError::getDefaultMessage).collect(Collectors.toList())) { + stringBuilder.append(s); + stringBuilder.append(","); + } + msg.setCode("999"); + msg.setMessage(stringBuilder.toString()); + return msg; + } + Msg checkMsg = checkLicense(licenseVo, ADD_OPTION); + if (!checkMsg.getCode().equals(ErrorCode.SUCCESS.getCode())) { + return checkMsg; + } + LicenseInfo licenseInfo1 = licenseService.getLastOne(); + Integer sn = licenseInfo1.getSn(); + sn++; + licenseVo.setSn(sn); + String abbr = ""; + String typeCode = ""; + for (ProvinceCode code : ProvinceCode.values()) { + if (licenseVo.getProvince().equals(code.getName())) { + abbr = code.getAbbr(); + } + } + if (StringUtils.isBlank(abbr)) { + msg.setCode("200"); + msg.setMessage("省份对应错误,生成许可证编号失败!"); + return msg; + } + if (licenseVo.getType().equals(LICENSE_PF)) { + typeCode = "PF"; + } else if (licenseVo.getType().equals(LICENSE_LS)) { + typeCode = "LS"; + } + Calendar cal = Calendar.getInstance(); + int year = cal.get(Calendar.YEAR); + + String licenseCode = "(" + abbr + ")" + typeCode + "〔" + year + "〕" + String.format("%05d", sn); + if (licenseCode.length() != LICENSE_CODE_LENGTH) { + msg.setCode("999"); + msg.setMessage("错误,生成许可证编号失败!"); + return msg; + } + licenseVo.setLicensecode(licenseCode); + JSONArray jsonArray = JSONArray.parseArray(licenseVo.getLicenseStorage()); + List<LicenseStorage> licenseStorageList = jsonArray.toJavaList(LicenseStorage.class); + for (LicenseStorage licenseStorage : licenseStorageList) { + licenseStorage.setLicensecode(licenseCode); + } + licenseStorageService.saveBatch(licenseStorageList); + licenseVo.setCreatedat(new Date()); + licenseVo.setCreatedby(getUser().getUsername()); + licenseVo.setLicensestatus(LicenseStatus.NEW); + licenseVo.setValidstatus((byte) 1); + licenseService.save(licenseVo); + return msg; + } + + @PostMapping("/editLicense") + public Msg editLicense(@Validated @RequestBody LicenseVo licenseVo, BindingResult bindingResult) { + Msg msg = new Msg(true); + if (bindingResult.hasErrors()) { + StringBuilder stringBuilder = new StringBuilder(); + for (String s : bindingResult.getFieldErrors().stream() + .map(FieldError::getDefaultMessage).collect(Collectors.toList())) { + stringBuilder.append(s); + stringBuilder.append(","); + } + msg.setCode("999"); + msg.setMessage(stringBuilder.toString()); + return msg; + } + Msg checkMsg = checkLicense(licenseVo, EDIT_OPTION); + //控制许可证相关信息是否更新在企业信息中 + boolean flag = false; + if (!checkMsg.getCode().equals(ErrorCode.SUCCESS.getCode())) { + return checkMsg; + } + UserInfo userInfo = userService.getById(getUser().getId()); + JSONArray jsonArray = JSONArray.parseArray(licenseVo.getLicenseStorage()); + List<LicenseStorage> licenseStorages = jsonArray.toJavaList(LicenseStorage.class); + for (LicenseStorage licenseStorage : licenseStorages) { + licenseStorage.setLicensecode(licenseVo.getLicensecode()); + } + + LicenseInfo licenseInfo = licenseService.getLicenseById(licenseVo.getId()); + Byte reviewStatus = licenseVo.getReviewstatus(); + if (licenseInfo == null) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("未找到对应的许可证信息,审核失败!"); + return msg; + } + if (licenseInfo.getReviewstatus().equals(STATUS_REVIEWED)){ + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("许可证信息已审核,无法修改!"); + return msg; + } + + if (userInfo.getCompanyid() == null) { + // 审核需要判断用户角色权限 + if (!reviewStatus.equals(STATUS_REVIEWED) && !reviewStatus.equals(STATUS_REJECT_REVIEW)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("权限错误,审核失败!"); + return msg; + } + + if (licenseInfo.getReviewstatus().equals(STATUS_NOT_REVIEW) && !reviewStatus.equals(STATUS_WAIT_REVIEW)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("当前许可证未提交审核,操作失败!"); + return msg; + } + + if (licenseInfo.getReviewstatus().equals(STATUS_WAIT_REVIEW)) { + if (!reviewStatus.equals(STATUS_REVIEWED) && !reviewStatus.equals(STATUS_REJECT_REVIEW)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("当前许可证为待审核,操作失败!"); + return msg; + } + } + + if (licenseInfo.getReviewstatus().equals(STATUS_REVIEWED)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("当前许可证已审核完毕,操作失败!"); + return msg; + } + + //判断是否能够审核 + if (reviewStatus.equals(STATUS_REVIEWED)){ + if (!reviewStatus.equals(licenseInfo.getReviewstatus())) { + if (licenseVo.getEffectdate() == null || licenseVo.getNoeffectdate() == null) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("有效期不能为空"); + return msg; + } + + if (StringUtils.isBlank(licenseVo.getIssuingunit()) || licenseVo.getIssuingdate() == null) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("发证机关和发证日期不能为空"); + return msg; + } + } + licenseVo.setReviewer(getUser().getUsername()); + licenseVo.setReviewat(new Date()); + flag = true; + } + }else{ + if (licenseInfo.getReviewstatus().equals(STATUS_WAIT_REVIEW)){ + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("许可证信息等待审核中,无法修改!"); + return msg; + } + } + + + licenseStorageService.updateBatchById(licenseStorages); + licenseVo.setModifiedat(new Date()); + licenseVo.setModifiedby(getUser().getUsername()); + licenseService.updateById(licenseVo); + if (flag){ + Enterprise enterprise = enterpriseService.selectEnterpriseByName(licenseInfo.getName()); + enterprise.setValidstarttime(licenseVo.getEffectdate()); + enterprise.setValidendtime(licenseVo.getNoeffectdate()); + enterpriseService.updateById(enterprise); + EnterpriseLicense enterpriseLicense = new EnterpriseLicense(); + if (licenseVo.getType().equals(LICENSE_PF)){ + enterpriseLicense.setLicensename("烟花爆竹经营(批发)许可证"); + }else if (licenseVo.getType().equals(LICENSE_LS)){ + enterpriseLicense.setLicensename("烟花爆竹经营(零售)许可证"); + } + enterpriseLicense.setLicensenumber(licenseVo.getLicensecode()); + enterpriseLicense.setEnterpriseid(enterprise.getId()); + enterpriseLicense.setAuthority(licenseVo.getIssuingunit()); + enterpriseLicense.setRanges(licenseService.dealDealingRange(licenseVo.getDealingrange()).toString()); + enterpriseLicense.setValidendtime(licenseVo.getReviewat()); + enterpriseLicense.setValidstarttime(licenseVo.getEffectdate()); + enterpriseLicense.setValidflag(true); + enterpriseLicense.setCreatetime(new Date()); + enterpriseLicense.setCreateby(getUser().getId()); + enterpriseLicense.setCreatebyname(getUser().getUsername()); + enterpriseLicenseService.save(enterpriseLicense); + //issale = 1 修改 截止有效期 + List<UserInfo> userList = userService.selectByCompanyId(enterprise.getId(),0); + if (userList.size() != 2) { + throw new BusinessException("发生错误,请联系管理员"); + } + for (UserInfo info : userList) { + //修改许可证 同时修改issale=1的用户有效期 + if (info.getIssale() == (byte) 1) { + Date validendtime = enterprise.getValidendtime(); + Calendar instance = Calendar.getInstance(); + instance.setTime(validendtime); + instance.set(Calendar.HOUR_OF_DAY, 23); + instance.set(Calendar.MINUTE, 59); + instance.set(Calendar.SECOND, 59); + info.setExpiredate(instance.getTime()); + userService.updateById(info); + } + } + } + return msg; + } + + @ApiOperation(value = "许可证审核", httpMethod = "PUT") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "审核许可证ID", required = true), + @ApiImplicitParam(name = "reviewstatus", value = "审核状态(0.未审核;1.等待审核;2.已审核;3.审核驳回) 数字类型", required = true),}) + @PostMapping("/review") + private Msg reviewLicense(@RequestParam(value = "id") Long id, + @RequestParam(value = "reviewstatus") Byte reviewstatus) { + Msg msg = new Msg(true); + + LicenseInfo licenseInfo = licenseService.getLicenseById(id); + if (licenseInfo == null) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("未找到对应的许可证信息,审核失败!"); + return msg; + } + + UserInfo userInfo = userService.getById(getUser().getId()); + if (userInfo.getCompanyid() == null) { + if (!reviewstatus.equals(STATUS_NOT_REVIEW) || !reviewstatus.equals(STATUS_WAIT_REVIEW)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("权限错误,审核失败!"); + return msg; + } + } + + + if (licenseInfo.getReviewstatus().equals(STATUS_NOT_REVIEW) && !reviewstatus.equals(STATUS_WAIT_REVIEW)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("当前许可证未提交审核,操作失败!"); + return msg; + } + + if (licenseInfo.getReviewstatus().equals(STATUS_WAIT_REVIEW)) { + if (!reviewstatus.equals(STATUS_REVIEWED) && !reviewstatus.equals(STATUS_REJECT_REVIEW)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("当前许可证为待审核,操作失败!"); + return msg; + } + } + if (licenseInfo.getReviewstatus().equals(STATUS_REVIEWED)) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("当前许可证已审核完毕,操作失败!"); + return msg; + } + licenseInfo.setReviewstatus(reviewstatus); + licenseService.updateById(licenseInfo); + + return msg; + } + + + @ApiOperation(value = "许可证删除", httpMethod = "PUT") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "许可证ID", required = true)}) + @PostMapping("/delete") + private Msg delLicense(@RequestParam(value = "id") Long id) { + Msg msg = new Msg(true); + + LicenseInfo licenseInfo = licenseService.getLicenseById(id); + if (licenseInfo == null) { + msg.setCode(ErrorCode.ERROR_999.getMsg()); + msg.setMessage("未找到对应的许可证信息,审核失败!"); + return msg; + } + + if (licenseInfo.getReviewstatus().equals(STATUS_REVIEWED)) { + msg.setCode(ErrorCode.ERROR_999.getCode()); + msg.setMessage("当前许可证已审核完毕,无法删除!"); + return msg; + } + + licenseInfo.setFlag((byte) 1); + licenseService.updateById(licenseInfo); + + return msg; + } + + + @ApiOperation(value = "许可证驳回", httpMethod = "PUT") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "许可证ID", required = true)}) + @PostMapping("/reject") + private Msg rejectLicense(@RequestBody JSONObject data) { + licenseService.rejectLicense(data,getUser()); + return success(); + } + + private Msg checkLicense(LicenseVo licenseVo, Byte option) { + Msg msg = new Msg(false); + if (licenseVo == null) { + msg.setMessage("操作失败:未找到对应的许可证信息"); + return msg; + } + if (option.equals(EDIT_OPTION)) { + if (licenseVo.getId() == null) { + msg.setMessage("操作失败:未找到对应的许可证信息"); + return msg; + } + } + if (licenseVo.getType() == null) { + msg.setMessage("类型不能为空"); + return msg; + } + + if (licenseVo.getName() == null) { + msg.setMessage("类别名称不能为空"); + return msg; + } + if (licenseVo.getCode() == null) { + msg.setMessage("统一社会信用代码不能为空"); + return msg; + } + if (StringUtils.isBlank(licenseVo.getMainpersonname()) + || StringUtils.isBlank(licenseVo.getMainpersonidcardnum()) + || StringUtils.isBlank(licenseVo.getMainpersontel())) { + msg.setMessage("主要负责人信息不能为空"); + return msg; + } + if (StringUtils.isBlank(licenseVo.getSafetypersonname()) + || StringUtils.isBlank(licenseVo.getSafetypersonidcardnum()) + || StringUtils.isBlank(licenseVo.getSafetypersontel())) { + msg.setMessage("安全负责人信息不能为空"); + return msg; + } + if (StringUtils.isBlank(licenseVo.getProvince()) || StringUtils.isBlank(licenseVo.getCity()) + || StringUtils.isBlank(licenseVo.getDistrict()) || StringUtils.isBlank(licenseVo.getAddress())) { + msg.setMessage("单位地址/注册地址不能为空"); + return msg; + } + + if (licenseVo.getType().equals(LICENSE_PF) || licenseVo.getType().equals(LICENSE_LS)) { + if (StringUtils.isBlank(licenseVo.getLicenseStorage())) { + msg.setMessage("批发企业和生产企业仓库信息不能为空"); + return msg; + } + } + msg.setCode("200"); + return msg; + } + + + @PostMapping("/delay") + public Msg delay(@RequestBody JSONObject jso) { + Long id = jso.getLong("id"); + String issuingunit = jso.getString("issuingunit"); + Date issuingdate = jso.getDate("issuingdate"); + Date validstarttime = jso.getDate("validstarttime"); + Date validendtime = jso.getDate("validendtime"); + licenseService.delayLicense(id, issuingunit, issuingdate, validstarttime, validendtime,getUser()); + return success(); + } + + @PostMapping("/mod") + public Msg mod(@Validated @RequestBody LicenseVo licenseVo, BindingResult bindingResult) { + //判断 + Msg msg = new Msg(true); + if (bindingResult.hasErrors()) { + StringBuilder stringBuilder = new StringBuilder(); + for (String s : bindingResult.getFieldErrors().stream() + .map(FieldError::getDefaultMessage).collect(Collectors.toList())) { + stringBuilder.append(s); + stringBuilder.append(","); + } + msg.setCode("999"); + msg.setMessage(stringBuilder.toString()); + } + Msg checkMsg = checkLicense(licenseVo, EDIT_OPTION); + if (!checkMsg.getCode().equals(ErrorCode.SUCCESS.getCode())) { + return checkMsg; + } + + licenseService.generateLicenseDetail(licenseVo); + JSONArray jsonArray = JSONArray.parseArray(licenseVo.getLicenseStorage()); + List<LicenseStorage> licenseStorageList = jsonArray.toJavaList(LicenseStorage.class); + for (LicenseStorage licenseStorage : licenseStorageList) { + licenseStorage.setLicensecode(licenseVo.getLicensecode()); + } + licenseService.modLicense(licenseVo, licenseStorageList, getUser()); + return success(); + } + +} -- Gitblit v1.9.2