From 7ae47063b4649eae4c30eaaa88dd3dfce0585565 Mon Sep 17 00:00:00 2001 From: super_liu <396572590@qq.com> Date: Fri, 4 Jun 2021 22:53:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=81=E7=A7=BB=E5=9B=BD=E5=86=85?= =?UTF-8?q?=E6=A0=87=E5=87=86=E6=B3=95=E8=A7=84=E9=83=A8=E5=88=865=20?= =?UTF-8?q?=E6=A0=87=E5=87=86=E5=8F=B7=E9=AA=8C=E8=AF=81=20=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=20=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SarLawsInfoController.java | 59 ++ .../slrs/sarLawsInfo/dao/SarLawsInfoDao.java | 16 + .../slrs/sarLawsInfo/entity/SarLawsInfo.java | 110 +++ .../sarLawsInfo/page/SarLawsInfoEOPage.java | 113 +++ .../page/SarLawsItemValEOPage.java | 39 + .../sarLawsInfo/page/SarLawsItemsEOPage.java | 62 ++ .../service/ISarLawsInfoService.java | 19 + .../service/impl/SarLawsInfoServiceImpl.java | 80 ++ .../entity/SarStandAttrDetails.java | 6 + .../SarStandardsInfoController.java | 252 ++++++- .../entity/SarStandardsInfo.java | 3 + .../service/ISarStandardsInfoService.java | 6 +- .../impl/SarStandardsInfoServiceImpl.java | 685 ++++++++++++++++++ .../mapper/sarLawsInfo/SarLawsInfoMapper.xml | 5 + .../mybatis/mapper/sys/DicTypeEOMapper.xml | 2 +- 15 files changed, 1426 insertions(+), 31 deletions(-) create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/controller/SarLawsInfoController.java create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/dao/SarLawsInfoDao.java create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/entity/SarLawsInfo.java create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsInfoEOPage.java create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemValEOPage.java create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemsEOPage.java create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/ISarLawsInfoService.java create mode 100644 adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/impl/SarLawsInfoServiceImpl.java create mode 100644 adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInfo/SarLawsInfoMapper.xml diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/controller/SarLawsInfoController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/controller/SarLawsInfoController.java new file mode 100644 index 00000000..55024a5c --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/controller/SarLawsInfoController.java @@ -0,0 +1,59 @@ +package com.adc.da.slrs.sarLawsInfo.controller; + + +import cn.hutool.core.util.ZipUtil; +import com.adc.da.http.PageInfo; +import com.adc.da.http.ResponseMessage; +import com.adc.da.http.Result; +import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage; +import com.adc.da.slrs.sarLawsInfo.service.ISarLawsInfoService; +import com.adc.da.util.LoginUserUtil; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; +import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo; +import io.swagger.annotations.Api; +import com.adc.da.base.web.BaseController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +/** +*

+ * 前端控制器 + *

+* +* @author super_liu +* @since 2021-06-01 +*/ +@RestController +@Api(tags = "福田标准法规--标准法规库--法规信息") +@RequestMapping("/sarLawsInfo/sar-laws-info") +public class SarLawsInfoController extends BaseController { + private static final Logger logger = LoggerFactory.getLogger(SarLawsInfoController.class); + + @Autowired + private ISarLawsInfoService sarLawsInfoEOService; + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/dao/SarLawsInfoDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/dao/SarLawsInfoDao.java new file mode 100644 index 00000000..fec8a70c --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/dao/SarLawsInfoDao.java @@ -0,0 +1,16 @@ +package com.adc.da.slrs.sarLawsInfo.dao; + +import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface SarLawsInfoDao extends BaseMapper { + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/entity/SarLawsInfo.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/entity/SarLawsInfo.java new file mode 100644 index 00000000..c64b04e5 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/entity/SarLawsInfo.java @@ -0,0 +1,110 @@ +package com.adc.da.slrs.sarLawsInfo.entity; + +import com.adc.da.base.entity.BaseEntity; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@ApiModel(value="SarLawsInfo对象", description="") +public class SarLawsInfo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId("ID") + private String id; + + @ApiModelProperty(value = "法规分类(INLAND国内,FOREIGN国外)") + @TableField("LAWS_TYPE") + private String lawsType; + + @ApiModelProperty(value = "国家地区") + @TableField("COUNTRY") + private String country; + + @ApiModelProperty(value = "文件性质") + @TableField("LAWS_PROPERTY") + private String lawsProperty; + + @ApiModelProperty(value = "文件号") + @TableField("LAWS_NUMBER") + private String lawsNumber; + + @ApiModelProperty(value = "文件名称") + @TableField("LAWS_NAME") + private String lawsName; + + @ApiModelProperty(value = "文件状态") + @TableField("LAWS_STATE") + private String lawsState; + + @ApiModelProperty(value = "发布日期") + @TableField("ISSUE_TIME") + private String issueTime; + + @ApiModelProperty(value = "实施日期") + @TableField("PUT_TIME") + private LocalDateTime putTime; + + @ApiModelProperty(value = "代替文件号") + @TableField("REPLACE_LAWS_NUM") + private String replaceLawsNum; + + @ApiModelProperty(value = "文件英文名称") + @TableField("LAWS_EN_NAME") + private String lawsEnName; + + @ApiModelProperty(value = "被代替文件号") + @TableField("REPLACED_LAWS_NUM") + private String replacedLawsNum; + + @TableField("CREATION_USER") + private String creationUser; + + @ApiModelProperty(value = "是否有效") + @TableField("VALID_FLAG") + private BigDecimal validFlag; + + @ApiModelProperty(value = "创建时间") + @TableField("CREATION_TIME") + private LocalDateTime creationTime; + + @ApiModelProperty(value = "修改时间") + @TableField("MODIFY_TIME") + private LocalDateTime modifyTime; + + @ApiModelProperty(value = "内容摘要") + @TableField("SYNOPSIS") + private String synopsis; + + @ApiModelProperty(value = "引用标准") + @TableField("CITE_STAND") + private String citeStand; + + @ApiModelProperty(value = "被引用标准") + @TableField("CITED_STAND") + private String citedStand; + + @ApiModelProperty(value = "是否法规清单相关(0否 1是)") + @TableField("IS_RELATE_ACCESS") + private String isRelateAccess; + + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsInfoEOPage.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsInfoEOPage.java new file mode 100644 index 00000000..03e39fbe --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsInfoEOPage.java @@ -0,0 +1,113 @@ +package com.adc.da.slrs.sarLawsInfo.page; + +import com.adc.da.base.page.BasePage; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ + +@Data +@ApiModel(value="SarLawsInfo分页对象", description="") +public class SarLawsInfoEOPage extends BasePage { + + private Date modifyTime; + private Date modifyTime1; + private Date modifyTime2; + private String modifyTimeOperator = "="; + private Date creationTime; + private Date creationTime1; + private Date creationTime2; + private String creationTimeOperator = "="; + private String validFlag; + private String validFlagOperator = "="; + private String creationUser; + private String creationUserOperator = "="; + private String relevanceFile; + private String relevanceFileOperator = "="; + private String opinionFile; + private String opinionFileOperator = "="; + private String lawsFile; + private String lawsFileOperator = "="; + private String linkUri; + private String linkUriOperator = "="; + private String responsibleUnit; + private String responsibleUnitOperator = "="; + private String applyAuth; + private String applyAuthOperator = "like"; + private String energyKind; + private String energyKindOperator = "like"; + private String applyArctic; + private String applyArcticOperator = "like"; + private String replaceLawsNum; + private String replacedLawsNum; + //需求变动,特此修改(byl),原 private String replaceLawsNumOperator = "="; + private String replaceLawsNumOperator = "like"; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date putTime; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date putTime1; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date putTime2; + private String putTimeOperator = "="; + private String issueTime; + private String issueTime1; + private String issueTime2; + private String issueTimeOperator = "="; + private String lawsState; + private String lawsStateOperator = "="; + private String issueUnit; + private String issueUnitOperator = "="; + private String lawsName; + private String lawsNameOperator = "like"; + private String lawsNumber; + private String lawsNumberOperator = "like"; + private String lawsProperty; + private String lawsPropertyOperator = "="; + private String country; + private String countryOperator = "="; + private String lawsType; + private String lawsTypeOperator = "="; + private String id; + private String idOperator = "="; + private String menuId; + private List menuIdList; + //为了在sql中区分修改操作 + private String updateFlag; + //新加字段 + private String synopsis; + private String lawsEnName; + private String category; + private String[] replaceLawsNumList; + private String[] applyArcticList; + private String[] energyKindList; + private String[] applyAuthList; + private List menuRoleList; + private String numberName; + private String synchronId; + private String[] idlist; + // 树结构增加搜索条件 + private String collectMenuId; + private String labelMenuId; + private String advanceSearchVOStr; + private String advanceSearchStr; + private String isRelateAccess; + private String ids; + private String proType; + private String userId; + private Integer nowOrder; + private Integer nowOrderBy; + private String orderBy1 = "SAR_LAWS_INFO.issue_time"; + private String order1 = "desc"; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemValEOPage.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemValEOPage.java new file mode 100644 index 00000000..439873da --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemValEOPage.java @@ -0,0 +1,39 @@ +package com.adc.da.slrs.sarLawsInfo.page; + +import com.adc.da.base.page.BasePage; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ + +@Data +@ApiModel(value="", description="") +public class SarLawsItemValEOPage extends BasePage { + + private String modifyTime; + private String modifyTime1; + private String modifyTime2; + private String modifyTimeOperator = "="; + private String creationTime; + private String creationTime1; + private String creationTime2; + private String creationTimeOperator = "="; + private String validFlag; + private String validFlagOperator = "="; + private String propertyVal; + private String propertyValOperator = "="; + private String propertyType; + private String propertyTypeOperator = "="; + private String lawsItemId; + private String lawsItemIdOperator = "="; + private String id; + private String idOperator = "="; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemsEOPage.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemsEOPage.java new file mode 100644 index 00000000..45639734 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/page/SarLawsItemsEOPage.java @@ -0,0 +1,62 @@ +package com.adc.da.slrs.sarLawsInfo.page; + +import com.adc.da.base.page.BasePage; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + *

+ * + *

+ * + * @author super_liu + * @since 2021-06-01 + */ + +@Data +@ApiModel(value="", description="") +public class SarLawsItemsEOPage extends BasePage { + + private String modifyTime; + private String modifyTime1; + private String modifyTime2; + private String modifyTimeOperator = "="; + private String creationTime; + private String creationTime1; + private String creationTime2; + private String creationTimeOperator = "="; + private String creationUser; + private String creationUserOperator = "="; + private String validFlag; + private String validFlagOperator = "="; + private String remarks; + private String remarksOperator = "="; + private String responsibleUnit; + private String responsibleUnitOperator = "like"; + private String energyKind; + private String energyKindOperator = "="; + private String applyArctic; + private String applyArcticOperator = "="; + private String tackTime; + private String tackTime1; + private String tackTime2; + private String tackTimeOperator = "="; + private String parts; + private String partsOperator = "="; + private String itemsName; + private String itemsNameOperator = "="; + private String itemsNum; + private String itemsNumOperator = "="; + private String lawsId; + private String lawsIdOperator = "="; + private String id; + private String idOperator = "="; + private String updateFlag; + private String processFlag; + private String nameOrRequest; + private String[] idlist; + private String fileType; + private String proType; + private String productId; + +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/ISarLawsInfoService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/ISarLawsInfoService.java new file mode 100644 index 00000000..44d6d4d6 --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/ISarLawsInfoService.java @@ -0,0 +1,19 @@ +package com.adc.da.slrs.sarLawsInfo.service; + +import com.adc.da.person.entity.PersonMsgEO; +import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo; +import com.baomidou.mybatisplus.extension.service.IService; +import org.apache.poi.ss.usermodel.Row; + +/** + *

+ * 服务类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +public interface ISarLawsInfoService extends IService { + + boolean isRowEmpty(Row row); +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/impl/SarLawsInfoServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/impl/SarLawsInfoServiceImpl.java new file mode 100644 index 00000000..edda404e --- /dev/null +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsInfo/service/impl/SarLawsInfoServiceImpl.java @@ -0,0 +1,80 @@ +package com.adc.da.slrs.sarLawsInfo.service.impl; + +import com.adc.da.common.SelectionTypeEnum; +import com.adc.da.person.entity.PersonMsgEO; +import com.adc.da.person.service.IPersonMsgEOService; +import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo; +import com.adc.da.slrs.sarLawsInfo.dao.SarLawsInfoDao; +import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage; +import com.adc.da.slrs.sarLawsInfo.service.ISarLawsInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.sql.Clob; +import java.util.*; + +/** + *

+ * 服务实现类 + *

+ * + * @author super_liu + * @since 2021-06-01 + */ +@Service +public class SarLawsInfoServiceImpl extends ServiceImpl implements ISarLawsInfoService { + + @Autowired + private SarLawsInfoDao dao; + + @Autowired + private IPersonMsgEOService personMsgEOService; + + //判断row是否为空 空返回true + public boolean isRowEmpty(Row row) { + if (null == row) { + return true; + } + int firstCellNum = row.getFirstCellNum(); //第一个列位置 + int lastCellNum = row.getLastCellNum(); //最后一列位置 + int nullCellNum = 0; //空列数量 + for (int c = firstCellNum; c < lastCellNum; c++) { + Cell cell = row.getCell(c); + if (null == cell || CellType.BLANK == cell.getCellType()) { + nullCellNum ++; + continue; + } + String value = ""; + switch (cell.getCellType()) { + case NUMERIC: // 数字 + //如果为时间格式的内容 + value = String.valueOf(cell.getNumericCellValue()); + break; + case STRING: // 字符串 + value = cell.getStringCellValue(); + break; + case BOOLEAN: // Boolean + value = cell.getBooleanCellValue() + ""; + break; + case FORMULA: // 公式 + value = cell.getCellFormula() + ""; + break; + default: + break; + } + if (StringUtils.isEmpty(value)) { + nullCellNum ++; + } + } + //所有列都为空 + if (nullCellNum == (lastCellNum - firstCellNum)) { + return true; + } + return false; + } +} diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/entity/SarStandAttrDetails.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/entity/SarStandAttrDetails.java index c270b78f..7d6af359 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/entity/SarStandAttrDetails.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandAttrDetails/entity/SarStandAttrDetails.java @@ -108,4 +108,10 @@ public class SarStandAttrDetails extends BaseEntity { @TableField("IS_JANSUO") private String isJansuo; + @TableField(exist = false) + private String attrValue; + + @TableField(exist = false) + private String areaName; + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java index 6400279a..3bd0cda9 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/controller/SarStandardsInfoController.java @@ -9,6 +9,7 @@ import com.adc.da.exception.AdcDaBaseException; import com.adc.da.http.PageInfo; import com.adc.da.http.ResponseMessage; import com.adc.da.http.Result; +import com.adc.da.slrs.sarLawsInfo.service.ISarLawsInfoService; import com.adc.da.slrs.sarStandardsInfo.entity.*; import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; import com.adc.da.util.LoginUserUtil; @@ -66,6 +67,9 @@ public class SarStandardsInfoController extends BaseController @Value("${file.downloadUrl}") private String fileDownloadPath; + @Autowired + ISarLawsInfoService sarLawsInfoEOService; + @ApiOperation(value = "|SarStandardsInfoEO|自定义分页查询") @GetMapping("/getSarStandardsInfoPage") //@RequiresPermissions("lawss:sarStandardsInfo:getSarStandardsInfoPage") @@ -180,33 +184,227 @@ public class SarStandardsInfoController extends BaseController } } -// @ApiOperation(value = "|SysCorpEO|导出excel") -// @GetMapping(value = "/exportStandardsInfoExcel") -// public void exportStandardsInfoExcel(StandardsInfoExcelVO standardsInfoExcelVO,HttpServletResponse response, -// HttpServletRequest request) throws Exception { -// OutputStream os = null; -// Workbook workbook = null; -// try { -// if(StringUtils.isEmpty(standardsInfoExcelVO.getExportName())||standardsInfoExcelVO.getExportName().equals("null")){ -// standardsInfoExcelVO.setExportName("标准法规信息"); -// } -// response.setHeader("Content-Disposition", -// "attachment; filename=" + ReadExcel.encodeFileName(standardsInfoExcelVO.getExportName()+".xlsx", -// request)); -// response.setContentType("application/force-download"); -// // 导出所有数据 -// List datas = sarStandardsInfoEOService.getExportDatas(standardsInfoExcelVO); -// workbook = StandExportUtil.exportDatas(datas,standardsInfoExcelVO.getStandType()); -// os = response.getOutputStream(); -// workbook.write(os); -// os.flush(); -// } catch (IOException e) { -// logger.error(e.getMessage(), e); -// throw new AdcDaBaseException("下载文件失败,请重试"); -// } finally { -// IOUtils.closeQuietly(os); -// } -// } + @ApiOperation(value = "|SysCorpEO|导出excel") + @GetMapping(value = "/exportStandardsInfoExcel") + public void exportStandardsInfoExcel(StandardsInfoExcelVO standardsInfoExcelVO,HttpServletResponse response, + HttpServletRequest request) throws Exception { + OutputStream os = null; + Workbook workbook = null; + try { + if(StringUtils.isEmpty(standardsInfoExcelVO.getExportName())||standardsInfoExcelVO.getExportName().equals("null")){ + standardsInfoExcelVO.setExportName("标准法规信息"); + } + response.setHeader("Content-Disposition", + "attachment; filename=" + ReadExcel.encodeFileName(standardsInfoExcelVO.getExportName()+".xlsx", + request)); + response.setContentType("application/force-download"); + // 导出所有数据 + List datas = sarStandardsInfoEOService.getExportDatas(standardsInfoExcelVO); + workbook = StandExportUtil.exportDatas(datas,standardsInfoExcelVO.getStandType()); + os = response.getOutputStream(); + workbook.write(os); + os.flush(); + } catch (IOException e) { + logger.error(e.getMessage(), e); + throw new AdcDaBaseException("下载文件失败,请重试"); + } finally { + IOUtils.closeQuietly(os); + } + } + @ApiOperation(value = "|SarStandardsInfoEO|导入") + @PostMapping(value = "/importZipStandardsInfo") + //401问题2021-03-31暂时注释掉 liuhuiwen +// @RequiresPermissions("lawss:sarStandardsInfo:importZipStandardsInfo") + public ResponseMessage importStandardsInfoFile(@RequestParam(value = "file", required = false) MultipartFile file, String standType, String menuId) throws Exception { + //验证文件名是否合格 + //截取后缀名 + int pos = file.getOriginalFilename().lastIndexOf("."); + String str = file.getOriginalFilename().substring(pos+1).toLowerCase(); + String filenameorg = file.getOriginalFilename().substring(0,pos); + //判断上传文件必须是zip + if (!str.equals("zip")) { + return Result.error("fail", "请上传zip文件"); + } + String path = filePath + "/modal/"+filenameorg; + File saveDirectory = new File(path); + if(!saveDirectory.isDirectory()){ + saveDirectory.mkdir(); + } + FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +"/"+ file.getOriginalFilename())); + try{ + //解压缩 + String zipEntryName = FileUnZip.unZipFiles(path +"/"+ file.getOriginalFilename(),path); + // 数据相关处理, + // 1.获取其中的Excel, + List excelfilelist = FileUnZip.readImpExcelFile(zipEntryName); + System.gc(); + if(excelfilelist.size()<1){ + int i = 0; + for(File file1:excelfilelist){ + if(file1.getName().indexOf("导入模板")>-1){ + i++; + } + } + if(i==0){ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", "压缩包内没有上传导入模板Excel"); + } + } else if (excelfilelist.size()>1) { + int i = 0; + for(File file1:excelfilelist){ + if(file1.getName().indexOf("导入模板")>-1){ + i++; + } + } + if(i>1){ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", "压缩包内有多个导入模板Excel"); + } + } + File excelfile = excelfilelist.get(0); + for(File file1:excelfilelist){ + if(file1.getName().indexOf("导入模板")>-1){ + excelfile = file1; + } + } + // 导入参数设置,默认即可 + Workbook workbook = null; + try { + workbook = WorkbookFactory.create(excelfile); + List> dataList = new ArrayList<>(); + if (workbook != null) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + Sheet sheet = workbook.getSheetAt(0); + if (sheet != null) { + StringBuilder headerSb = new StringBuilder(); + int rowNos = sheet.getLastRowNum();// 得到excel的总记录条数 + for (int i = 0; i <= rowNos; i++) {// 遍历行 + Row row = sheet.getRow(i); + Row headerRow = sheet.getRow(0); + boolean isBlank = sarLawsInfoEOService.isRowEmpty(row); + if(row != null && !isBlank){ + int columNos = headerRow.getLastCellNum();// 表头总共的列数 + Map rowList = new LinkedHashMap<>(); + for (int j = 0; j < columNos; j++) { + Cell cell = row.getCell(j); + Cell headerCell = headerRow.getCell(j); + if(cell != null){ + if (i == 0) { + cell.setCellType(CellType.STRING); + headerSb.append(cell.getStringCellValue() + ","); + } else { + if(CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)){ + Date d = cell.getDateCellValue(); + rowList.put(headerCell.getStringCellValue(),df.format(d)); + }else{ + cell.setCellType(CellType.STRING); + rowList.put(headerCell.getStringCellValue(),cell.getStringCellValue()); + } + } + } else { + if (i != 0) { + rowList.put(headerCell.getStringCellValue(),""); + } + } + } + if (i != 0) { + dataList.add(rowList); + } + } + } + // 校验头部是否符合模板 + String fields = FieldConvertUtil.exportBaseFieldNames + "," + FieldConvertUtil.exportAttrFieldNamesInland + ","; + if ("FOREIGN".equals(standType)) { + fields = FieldConvertUtil.exportBaseFieldNamesForeign + "," + FieldConvertUtil.exportAttrFieldNamesForeign + ","; + } + String excelHeader = headerSb.toString(); + if (!fields.equals(excelHeader)) { + workbook.close(); + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", "读取失败,请严格按照模板文件导入数据"); + } + } + } + //导入 + if(dataList!=null &&!dataList.isEmpty()){ + try { + String unzipfilepath = zipEntryName; + ResponseMessage message = sarStandardsInfoEOService.importSarStandardsInfoData(dataList, standType,menuId,unzipfilepath); + workbook.close(); + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return message; + } catch (Exception e) { + workbook.close(); + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", e.getMessage()); + } + }else{ + if (workbook != null) { + workbook.close(); + } + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", "没有可导入的数据,请检查!"); + } + } catch (NoSuchElementException e){ + if (workbook != null) { + workbook.close(); + } + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", "没有可导入的数据,请检查!"); + } catch (Exception e) { + if (workbook != null) { + workbook.close(); + } + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", "读取失败,请严格按照模板文件导入数据"); + } + } catch (Exception e) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + return Result.error("fail", "读取失败,请严格按照模板文件导入数据"); + } + } + + @ApiOperation(value = "|SarStandardsInfoEO|验证输入的标准号") + @PostMapping("/validateStandNumber") + //@RequiresPermissions("lawss:sarStandardsInfo:selectReplaceStandNum") + public ResponseMessage validateStandNumber(SarStandardsInfoEOPage page) throws Exception { + if (StringUtils.isNotEmpty(page.getStandNumber()) && StringUtils.isNotEmpty(page.getStandSort())) { + String standnumber = ""; + if(StringUtils.isNotEmpty(page.getStandYear()) && !"null".equals(page.getStandYear())){ + standnumber = page.getStandSort() + " " + page.getStandNumber() + "-" + page.getStandYear(); + } else { + standnumber = page.getStandSort() + " " + page.getStandNumber(); + } + List standlist = sarStandardsInfoEOService.selectStandardsByStandnumber(standnumber, page.getStandType()); + if (standlist.size() > 0) { + if (StringUtils.isNotEmpty(page.getId())) { + // 如果是修改,判断id是否一样 + for (int i = 0; i < standlist.size(); i++) { + if (standlist.get(i).getId().equals(page.getId())) { + continue; + } else { + return Result.error(standnumber + "标准号已存在"); + } + } + return Result.success(); + } else { + return Result.error(standnumber + "标准号已存在"); + } + } else { + return Result.success(); + } + } else { + return Result.success(); + } + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java index f5ccb599..26fa5ffe 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/entity/SarStandardsInfo.java @@ -1,6 +1,7 @@ package com.adc.da.slrs.sarStandardsInfo.entity; import com.adc.da.base.entity.BaseEntity; +import com.adc.da.slrs.sarStandAttrDetails.entity.SarStandAttrDetails; import com.adc.da.slrs.sarStandItems.entity.SarStandItems; import com.adc.da.sys.entity.DicTypeEO; import com.baomidou.mybatisplus.annotation.TableId; @@ -139,6 +140,8 @@ public class SarStandardsInfo extends BaseEntity { @TableField(exist = false) private List dicTypeList = new ArrayList(); // 记录标准涉及到的所有数据字典数据 @TableField(exist = false) + private List attrInfoList = new ArrayList<>(); + @TableField(exist = false) private Map attrInfoMap = new LinkedHashMap<>(); //属性表字段与值 @TableField(exist = false) private String sarStandAttrEOStr; //新增修改时属性表信息 diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java index ccf35969..e3befe02 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/ISarStandardsInfoService.java @@ -28,11 +28,11 @@ public interface ISarStandardsInfoService extends IService { // int deleteSarStandards(String ids); // -// List getExportDatas (StandardsInfoExcelVO standardsInfoExcelVO) throws Exception; + List getExportDatas (StandardsInfoExcelVO standardsInfoExcelVO) throws Exception; // -// ResponseMessage importSarStandardsInfoData(List> dataList, String standType, String menuId, String filepath); + ResponseMessage importSarStandardsInfoData(List> dataList, String standType, String menuId, String filepath); // -// List selectStandardsByStandnumber(String replaceStandNum, String standType); + List selectStandardsByStandnumber(String replaceStandNum, String standType); // // SarStandardsInfo selectStandardsInfoByKey(String id) throws Exception; // diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java index a5b4467a..78dda268 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarStandardsInfo/service/impl/SarStandardsInfoServiceImpl.java @@ -2,11 +2,16 @@ package com.adc.da.slrs.sarStandardsInfo.service.impl; import com.adc.da.att.entity.AttFileEO; import com.adc.da.att.service.IAttFileEOService; +import com.adc.da.att.vo.AttFileVo; import com.adc.da.common.*; +import com.adc.da.http.ResponseMessage; +import com.adc.da.http.Result; import com.adc.da.person.dao.PersonCollectEODao; import com.adc.da.person.dao.PersonShareEODao; import com.adc.da.person.entity.PersonMsgEO; import com.adc.da.person.service.IPersonCollectEOService; +import com.adc.da.slrs.sarStandAttrDetails.dao.SarStandAttrDetailsDao; +import com.adc.da.slrs.sarStandAttrDetails.entity.SarStandAttrDetails; import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao; import com.adc.da.slrs.sarStandFile.dao.SarStandFileDao; import com.adc.da.slrs.sarStandFile.entity.SarStandFile; @@ -27,23 +32,30 @@ import com.adc.da.slrs.sysInfo.service.SysInfoEOService; import com.adc.da.sys.common.SelectionResult; import com.adc.da.sys.constant.ValueStateEnum; import com.adc.da.sys.dao.DicTypeEODao; +import com.adc.da.sys.entity.DicTypeEO; import com.adc.da.util.LoginUserUtil; import com.adc.da.util.UUIDUtils; import com.adc.da.utils.util.*; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.serializer.SerializerFeature; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import net.sf.json.JSONObject; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.io.File; import java.sql.Clob; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** *

@@ -92,6 +104,9 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl + */ + public List getExportDatas (StandardsInfoExcelVO standardsInfoExcelVO) throws Exception { + SarStandardsInfoEOPage page = new SarStandardsInfoEOPage(); + BeanUtils.copyProperties(standardsInfoExcelVO,page); + if ("apart".equals(standardsInfoExcelVO.getExportType())) { + page.setIdlist(standardsInfoExcelVO.getExportContent().split(",")); + } else { + JSONObject jsonObject = JSONObject.fromObject(standardsInfoExcelVO.getExportContent()); + page = (SarStandardsInfoEOPage)JSONObject.toBean(jsonObject, SarStandardsInfoEOPage.class); + page.setStandType(standardsInfoExcelVO.getStandType()); + //查询当前登录人角色拥有权限的菜单 + List getMenuIdList = sarMenuEOService.queryRoleMenuIdList(page.getStandType()+"_STAND",null); + if(getMenuIdList != null && !getMenuIdList.isEmpty()){ + page.setMenuRoleList(getMenuIdList); + } else { + page.setMenuRoleList(null); + } + List ids = sarMenuEOService.getChildMenuList(page.getMenuId()); + if (ids != null && !ids.isEmpty()) { + page.setMenuAllChildrenIdList(ids); + } + if (org.apache.commons.lang.StringUtils.isNotBlank(page.getAdvanceSearchVOStr())) { + List searchList = com.alibaba.fastjson.JSONObject.parseArray(page.getAdvanceSearchVOStr(),SarAdvanceSearchVO.class); + String advanceStr = SarAdvanceSearchUtil.createSql(searchList); + if (StringUtils.isNotBlank(advanceStr)) { + page.setAdvanceSearchStr(advanceStr); + } else { + page.setAdvanceSearchStr(null); + } + } + } + page.setOrderBy("SAR_STANDARDS_INFO.issue_time is null,SAR_STANDARDS_INFO.issue_time desc,SAR_STANDARDS_INFO.id"); + page.setUserId(LoginUserUtil.getUserId()); + List getList = dao.getSarStandardsExportInfo(page); + attrInfoShow(getList); + return getList; + } + + public ResponseMessage importSarStandardsInfoData(List> dataList, String standType, String menuId, String filepath){ +//此处需要做各种验证,数据库操作 + try { + //验证导入数据是否符合规则 + Map map = validateImportDatas(dataList, standType, filepath); + boolean isOk = (boolean) map.get("result"); + if (!isOk) { + //验证没有通过 + String message = (String) map.get("message"); + return Result.error("fail", message); + } + + //将导入数据循环新增至相应表 + List list = (List) map.get("resultList"); + int countSuccess = 0; + for (SarStandardsInfo sarStandardsInfoEO : list) { + sarStandardsInfoEO.setStandType(standType); + sarStandardsInfoEO.setMenuId(menuId); + createSarStandardsInfo(sarStandardsInfoEO); + countSuccess++; + } + String msg = "成功导入" + countSuccess + "条"; + return Result.success("0", msg, null); + } catch (Exception e) { + logger.error(e.getMessage(),e); + return Result.error("导入失败"); + } + } + + public Map validateImportDatas(List> dataList, String standType, String filepath) throws Exception{ + //存放数据验证结果信息 + List stringMessage = new ArrayList<>(); + int i = 1; //记录行号 + List standnumberlist = new ArrayList<>(); // 记录验证过后的编码,用来判断是否有重复 + //循环验证数据 + List standList = new ArrayList<>(); + for (Map dataMap : dataList) { + i++; + int countError = 0; //记录失败数据数量 + String errorMsg = "

第" + i + "行:

"; + List baseFieldsList = Arrays.asList(FieldConvertUtil.exportBaseFieldNames.split(",")); + List attrFieldsList = Arrays.asList(FieldConvertUtil.exportAttrFieldNamesInland.split(",")); + if ("FOREIGN".equals(standType)) { + baseFieldsList = Arrays.asList(FieldConvertUtil.exportBaseFieldNamesForeign.split(",")); + attrFieldsList = Arrays.asList(FieldConvertUtil.exportAttrFieldNamesForeign.split(",")); + } + // 遍历map 找出基础表,属性表数据字段和对应值 + SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo(); + List attrList = new ArrayList<>(); + String zrbmOrgNames = ""; + for (Map.Entry entry : dataMap.entrySet()) { + String name = entry.getKey(); + String value = entry.getValue(); + if ("责任部门".equals(name)) { + zrbmOrgNames = value; + } + if (baseFieldsList.contains(name)) { + SarStandImportDto.compareFieldAndName(name,value,sarStandardsInfoEO); + } else if (attrFieldsList.contains(name)){ + // 根据name查字段 + SarStandAttrDetails fieldEO = sarStandAttrDetailsEODao.selectFieldByName(name,standType+"_STAND"); + if (fieldEO != null) { + fieldEO.setAttrValue(value); + attrList.add(fieldEO); + } + } + } + sarStandardsInfoEO.setAttrInfoList(attrList); + // 验证基础表数据信息 + Map beseResultMap = validateBaseDatas(sarStandardsInfoEO,standType,errorMsg,countError,standnumberlist); + errorMsg = beseResultMap.get("errorMsg"); + countError = Integer.parseInt(beseResultMap.get("countError")); + Map attrResultMap = validateAttrDatas(sarStandardsInfoEO,standType,filepath,errorMsg,countError,zrbmOrgNames); + errorMsg = attrResultMap.get("errorMsg"); + countError = Integer.parseInt(attrResultMap.get("countError")); + if (countError > 0) { + stringMessage.add(errorMsg); + } + standList.add(sarStandardsInfoEO); + } + Map map = new HashMap(); + if (stringMessage.isEmpty()) { + map.put("result", true); + map.put("resultList", standList); + map.put("message", ""); + } else { + map.put("result", false); + String html = ""; + for (String message : stringMessage) { + html += message + "
"; + } + map.put("message", html); + } + return map; + } + + public Map validateBaseDatas(SarStandardsInfo dto, String standType,String errorMsg,int countError,List standnumberlist) throws Exception { + Map map = new HashMap(); + // 验证国家及关联标准类别 + DicTypeEO dic = new DicTypeEO(); + List getDic = new ArrayList<>(); + boolean aorb = false; + //重要度 B 只有 编号 类别 名称 英文名称 标准年份 必填 + if (StringUtils.isNotEmpty(dto.getIsRelateAccess())) { + if ("A".equals(dto.getIsRelateAccess())) { + dto.setIsRelateAccess("1"); + aorb = true; + } else if ("B".equals(dto.getIsRelateAccess())) { + dto.setIsRelateAccess("0"); + } else { + errorMsg += "

重要度只能为A/B;

"; + countError++; + } + } else { + errorMsg += "

重要度不能为空;

"; + countError++; + } + + //编号必填 + if (StringUtils.isNotEmpty(dto.getStandNumber())) { + String str = getRightDate(dto.getStandNumber()); + dto.setStandNumber(str); + if (dto.getStandNumber().length() > 100) { + errorMsg += "

标准编号不能超过100个字符;

"; + countError++; + } + String regEx="^[A-z0-9-.]*$"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(str); + if (!m.matches()) { + errorMsg += "

标准编号只能输入字母 数字 . -;

"; + countError++; + } + } else { + errorMsg += "

标准编号不能为空;

"; + countError++; + } + + //类别必填 + if (StringUtils.isNotEmpty(dto.getStandSort())) { + dic.setDicTypeName(dto.getStandSort()); + dic.setDicTypeCode("STANDCLASSIFY"); + getDic = dicTypeEODao.getDicTypeByDicTypeName(dic); + if (getDic.size() == 1) { + dto.setStandSort(getDic.get(0).getDicTypeCode()); + } else if (getDic.size() > 0) { + errorMsg += "

标准类别不明确;

"; + countError++; + } else { + errorMsg += "

标准类别不存在;

"; + countError++; + } + } else { + errorMsg += "

标准类别不能为空;

"; + countError++; + } + //年份必填 + if (StringUtils.isNotEmpty(dto.getStandYear())) { + String regEx="^[0-9a-zA-Z]+$"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(dto.getStandYear()); + if (!m.matches() || dto.getStandYear().length() > 20) { + errorMsg += "

标准年份只能输入20位以内的数字,字母;

"; + countError++; + } + } else if (StringUtils.isEmpty(dto.getStandYear()) && "INLAND".equals(standType)) { + errorMsg += "

标准年份不能为空;

"; + countError++; + } + //中文名称 + if (StringUtils.isNotEmpty(dto.getStandName())) { + String str = getRightDate(dto.getStandName()); + dto.setStandName(str); + if (dto.getStandName().length() > 500) { + errorMsg += "

中文名称不能超过500个字符;

"; + countError++; + } + } else { + errorMsg += "

中文名称不能为空;

"; + countError++; + } + + //英文名称 + if (StringUtils.isNotEmpty(dto.getStandEnName())) { + String str = getRightDate(dto.getStandEnName()); + dto.setStandEnName(str); + if (dto.getStandEnName().length() > 1000) { + errorMsg += "

英文名称不能超过1000个字符;

"; + countError++; + } + Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); + Matcher m = p.matcher(str); + if (m.find()) { + errorMsg += "

英文名称不能输入中文;

"; + countError++; + } + } else { + errorMsg += "

英文名称不能为空;

"; + countError++; + } + + if (StringUtils.isNotEmpty(dto.getCountry())) { + if ("INLAND".equals(standType)) { + if (!"中国".equals(dto.getCountry())) { + errorMsg += "

国内标准法规适用区域只能为中国;

"; + countError++; + } + } + if (dto.getCountry().length() > 100){ + errorMsg += "

适用区域不能超过100个字符;

"; + countError++; + } else { + String countryName = dto.getCountry(); + dic.setDicTypeName(dto.getCountry()); + dic.setDicTypeCode("COUNTRY"); + getDic = dicTypeEODao.getDicTypeByDicTypeName(dic); + if (getDic.size() == 1) { + dto.setCountry(getDic.get(0).getDicTypeCode()); + // 在国家地区不为空的情况下去判断标准类别 + } else if (getDic.size() > 0) { + errorMsg += "

适用区域不明确;

"; + countError++; + } else { + errorMsg += "

适用区域不存在;

"; + countError++; + } + } + } + + + + if (StringUtils.isNotEmpty(dto.getStandState())) { + dic.setDicTypeName(dto.getStandState()); + dic.setDicTypeCode("STANDSTATE"); + if (dto.getStandState().length() > 500) { + errorMsg += "

标准状态不能超过500个字符;

"; + countError++; + } else if (!"计划修订".equals(dto.getStandState())) { + errorMsg += "

标准状态只能填写为计划修订;

"; + countError++; + } else { + getDic = dicTypeEODao.getDicTypeByDicTypeName(dic); + if (getDic != null) { + if (getDic.size() == 1) { + dto.setStandState(getDic.get(0).getDicTypeCode()); + } else if (getDic.size() > 0) { + errorMsg += "

标准状态不明确;

"; + countError++; + } else { + errorMsg += "

标准状态不存在;

"; + countError++; + } + } else { + errorMsg += "

标准状态不存在;

"; + countError++; + } + } + } + if (StringUtils.isNotBlank(dto.getIssueTime())) { + if (!DateUtil.isValidDate(dto.getIssueTime()) && !"已发布".equals(dto.getIssueTime()) && !"TBD".equals(dto.getIssueTime())) { + errorMsg += "

发布日期格式不正确;

"; + countError++; + } + } else if ("1".equals(dto.getIsRelateAccess()) && StringUtils.isBlank(dto.getIssueTime())) { + if(aorb) { + errorMsg += "

发布日期不能为空;

"; + countError++; + } + } + if (StringUtils.isNotEmpty(dto.getSynopsis())) { + String str = getRightDate(dto.getSynopsis()); + dto.setSynopsis(str); + if (dto.getSynopsis().length() > 500) { + errorMsg += "

文本说明不能超过500个字符;

"; + countError++; + } + } + // 标准号唯一性验证 + if (StringUtils.isNotEmpty(dto.getStandNumber()) && StringUtils.isNotEmpty(dto.getStandYear()) && StringUtils.isNotEmpty(dto.getStandSort())) { + String standnumber = dto.getStandSort() + " " + dto.getStandNumber() + "-" + dto.getStandYear(); + String numberLen = standnumber+"-"+dto.getStandYear(); + if(numberLen.length()<=1000){ + SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo(); + sarStandardsInfoEO.setStandNumber(standnumber); + sarStandardsInfoEO.setStandType(standType); + List standlist = dao.selectStandardsByStandnumber(sarStandardsInfoEO); + if (standlist.size() > 0) { + errorMsg += standnumber + "

标准号已存在;

"; + countError++; + } else if (standnumberlist.contains(standnumber)) { + errorMsg += "

导入数据存在标准号" + standnumber + "的重复数据;

"; + countError++; + } else { + standnumberlist.add(standnumber); + } + } + } + map.put("errorMsg",errorMsg); + map.put("countError",String.valueOf(countError)); + return map; + } + + public Map validateAttrDatas(SarStandardsInfo dto, String standType,String filepath,String errorMsg,int countError,String zrbmOrgNames) throws Exception { + Map map = new HashMap(); + //根据重要度判断字段必填 + String isMustStr = "no"; + List isMustList = new ArrayList<>(); + if ("1".equals(dto.getIsRelateAccess())) { + if ("INLAND".equals(standType)) { + isMustStr = "GKDW,CYSD,CLLX,YQLX,XCXSSRQ,ZCCSSRQ,EOPSSRQ,FBJG,ZRBM,FGWHR,DTBJH,YYBJ,CBBH";//,DTBJH,YYBJ + } else if ("FOREIGN".equals(standType)) { + isMustStr = "CLLX,YQLX,XCXSSRQ,ZCCSSRQ,EOPSSRQ,ZRBM,FGWHR,DTBJH,DXBZ,YYBJ,CBBH"; + } + }else{ + if ("INLAND".equals(standType)) { + isMustStr = "FGWHR";//,DTBJH,YYBJ + } + } + isMustList = Arrays.asList(isMustStr.split(",")); + Boolean putTimeState = false; + String putTimeFieldStr = "XCXSSRQ,ZCCSSRQ,EOPSSRQ"; + List putTimeFieldList = Arrays.asList(putTimeFieldStr.split(",")); + List attrList = dto.getAttrInfoList(); + if (attrList != null && !attrList.isEmpty()) { + if (StringUtils.isNotBlank(zrbmOrgNames)) { + zrbmOrgNames = sysInfoEOService.getOrgIdByName(zrbmOrgNames,null); + } + Map attrInfoMap = new HashMap<>(); + for (SarStandAttrDetails detailsEO : attrList) { + // 根据不同字段类型进行不同验证 + String attrType = detailsEO.getAttrType(); + String attrName = detailsEO.getAttrName(); + String attrValue = detailsEO.getAttrValue(); + String attrField = detailsEO.getAttrField(); + String selVal = detailsEO.getSelVal(); + Long attrLen = detailsEO.getAttrLen(); + // 判断是否为必填项 + if (isMustList.contains(attrField) && StringUtils.isEmpty(attrValue)) { + errorMsg += "

"+attrName + "不能为空;

"; + countError++; + } + if (StandAttrTypeEnum.INPUT_STR.getValue().equals(attrType)) { + if (StringUtils.isNotEmpty(attrValue)) { + String str = getRightDate(attrValue); + attrValue = str; + if (attrValue.length() > attrLen) { + errorMsg += "

"+attrName + "不能超过"+ attrLen +"个字符;

"; + countError++; + } + } + if ("DTBJH".equals(attrField) || ",YYBJ".equals(attrField) || "BYYBJ".equals(attrField) || "CBBH".equals(attrField)) { + String regEx = "^[\\s0-9a-zA-Z/.-]*"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(attrValue); + if (!m.matches()) { + String name = ""; + switch (attrField){ + case "DTBJH": + name = "代替标准编号"; + break; + case "CBBH": + name = "对应其他标准"; + break; + case "YYBJ": + name = "引用标准"; + break; + case "BYYBJ": + name = "被引用标准"; + break; + default: + break; + } + errorMsg += "

" + name + "只能为(字母、数字、.、-);

"; + countError++; + } + } + attrInfoMap.put(attrField,attrValue); + } else if (StandAttrTypeEnum.INPUT_NUM.getValue().equals(attrType)) { + if (StringUtils.isNotEmpty(attrValue)) { + String str = getRightDate(attrValue); + attrValue = str; + if (attrValue.length() > attrLen) { + errorMsg += "

"+attrName + "不能超过"+ attrLen +"个字符;

"; + countError++; + } + } + int value = Integer.parseInt(attrValue); + attrInfoMap.put(attrField,value); + } else if (StandAttrTypeEnum.SELECT_OPTION.getValue().equals(attrType) || StandAttrTypeEnum.SEL_OPTS.getValue().equals(attrType)) { + String saveCode = ""; + if (StringUtils.isNotEmpty(attrValue)) { + attrValue = attrValue.replace(",", ","); + String[] valueArr = attrValue.split(","); + if (StandAttrTypeEnum.SELECT_OPTION.getValue().equals(attrType) && valueArr.length > 1) { + errorMsg += "

"+attrName + "单选字段只能输入一个选项;

"; + countError++; + } else if(valueArr.length>20){ + errorMsg += "

"+attrName + "选项不能超过20个;

"; + countError++; + } else if (attrValue.length() > attrLen) { + errorMsg += "

"+attrName + "不能超过500个字符;

"; + countError++; + } else { + Set set = new HashSet(); + if ("SVPPS".equals(attrField)) { + for (int e = 0; e < valueArr.length; e++) { + set.add(valueArr[e]); + String svppsId = sysInfoEOService.getSvppsIdByName(valueArr[e]); + if (StringUtils.isNotBlank(svppsId)) { + saveCode += svppsId + ','; + } else { + errorMsg += "

"+attrName + valueArr[e] + "不存在;

"; + countError++; + } + } + }else if (SelectionTypeEnum.GZZXX.getValue().equals(selVal)) { + for (int e = 0; e < valueArr.length; e++) { + set.add(valueArr[e]); + String id = sysInfoEOService.getGroupIdByNames(valueArr[e]); + if (StringUtils.isNotBlank(id)) { + saveCode += id + ','; + } else { + errorMsg += "

"+attrName + valueArr[e] + "不存在;

"; + countError++; + } + } + } else if (SelectionTypeEnum.USERLIST.getValue().equals(selVal)) { + if ("FO".equals(attrField) && StringUtils.isBlank(zrbmOrgNames)) { + set.add(valueArr); + errorMsg += "

FO不存在;

"; + countError++; + } else { + for (int e = 0; e < valueArr.length; e++) { + set.add(valueArr[e]); + if (!"FO".equals(attrField)) { + zrbmOrgNames = ""; + } + String userId = sysInfoEOService.getUserIdByName(valueArr[e],zrbmOrgNames); + if (StringUtils.isNotBlank(userId)) { + saveCode += userId + ','; + } else { + errorMsg += "

"+attrName + valueArr[e] + "不存在;

"; + countError++; + } + } + } + } else if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal)) { + for (int e = 0; e < valueArr.length; e++) { + set.add(valueArr[e]); + String id = null; + if (attrName.equals("责任部门") || attrName.equals("相关部门")){ + id = sysInfoEOService.getOrgIdByName(valueArr[e],"DEPART"); + }else { + id = sysInfoEOService.getOrgIdByName(valueArr[e],null); + } + if (StringUtils.isNotBlank(id)) { + saveCode += id + ','; + } else { + errorMsg +="

"+ attrName + valueArr[e] + "不存在;

"; + countError++; + } + } + } else if (SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) { + for (int e = 0; e < valueArr.length; e++) { + set.add(valueArr[e]); + String id = sysInfoEOService.getRoleIdByName(valueArr[e]); + if (StringUtils.isNotBlank(id)) { + saveCode += id + ','; + } else { + errorMsg +="

"+ attrName + valueArr[e] + "不存在;

"; + countError++; + } + } + } else { + for (int e = 0; e < valueArr.length; e++) { + set.add(valueArr[e]); + DicTypeEO dic = new DicTypeEO(); + List getDic = new ArrayList<>(); + dic.setDicTypeName(valueArr[e]); + dic.setDicTypeCode(selVal); + getDic = dicTypeEODao.getDicTypeByDicTypeName(dic); + if (getDic != null && getDic.size() > 0) { + saveCode += getDic.get(0).getDicTypeCode() + ','; + } else { + errorMsg += "

"+attrName + valueArr[e] + "不存在;

"; + countError++; + } + } + } + if (valueArr.length > set.size()){ + errorMsg +="

"+ attrName + "存在重复数据;

"; + countError++; + } + if (!saveCode.equals("")){ + saveCode = saveCode.substring(0,saveCode.length()-1); + } + } + } + attrInfoMap.put(attrField,saveCode); + } else if (StandAttrTypeEnum.DATE_PICKER.getValue().equals(attrType)) { + if (StringUtils.isNotBlank(attrValue)) { + String[] timeArr = attrValue.split(","); + if (timeArr.length > 1) { + errorMsg += "

"+attrName + "只能输入一个日期;

"; + countError++; + } else { + if (!DateUtil.isValidDate(attrValue)) { + errorMsg += "

"+attrName + "格式不正确;

"; + countError++; + } else { + attrInfoMap.put(attrField,attrValue); + } + } + } + } else if (StandAttrTypeEnum.DATE_PIC_OPTS.getValue().equals(attrType)) { + if (StringUtils.isNotBlank(attrValue)) { + String[] timeArr = attrValue.split(","); + if (timeArr.length > 8) { + errorMsg += "

"+attrName + "不能超过8个日期;

"; + countError++; + } else { + if (putTimeFieldList.contains(attrField) && DateUtil.isValidDate(attrValue)) { + putTimeState = true; + } + if (!DateUtil.isValidDate(attrValue) && !"N/A".equals(attrValue) && !"TBD".equals(attrValue) && !"已实施".equals(attrValue)) { + errorMsg += "

"+attrName + "格式不正确;

"; + countError++; + } else { + attrInfoMap.put(attrField,attrValue); + } + } + } else { + if (putTimeFieldList.contains(attrField)) { + putTimeState = true; + } + } + } else if (StandAttrTypeEnum.FILE.getValue().equals(attrType)) { + String saveFiles = ""; + if (StringUtils.isNotEmpty(attrValue)) { + attrValue = attrValue.replace(",", ","); + String[] filelist = attrValue.split(","); + if (filelist != null && filelist.length > 8) { + errorMsg += "

"+attrName + "不能超过8个

"; + countError++; + } else { + for (int ind = 0; ind < filelist.length; ind++) { + String filename = filelist[ind]; + String resultMes = ExcelUtil.validatePattern(filename); + if(StringUtils.isNotEmpty(resultMes)){ + errorMsg +="

"+ attrName + resultMes +"

"; + countError++; + continue; + } + List nowfilelist = FileUnZip.readFileByFilename(filepath, filename); + if (nowfilelist.size() <= 0) { + errorMsg += "

压缩包中没有" + filename + "文件;

"; + countError++; + } else { + // 判断文件大小是否超过200M + if (nowfilelist.get(0).length() > 200 * 1024 * 1024) { + errorMsg +="

"+ filename + "文件大小超过200M;

"; + countError++; + continue; + } + AttFileVo fileid = attFileEOService.saveFileInfo(nowfilelist.get(0)); + saveFiles += fileid.getAttId() + ","; + } + } + if (saveFiles != "") { + saveFiles = saveFiles.substring(0, saveFiles.length() - 1); + } + } + } + attrInfoMap.put(attrField,saveFiles); + } else if (StandAttrTypeEnum.TEXTAREA.getValue().equals(attrType)) { + if (StringUtils.isNotEmpty(attrValue)) { + String str = getRightDate(attrValue); + attrValue = str; + if (attrValue.length() > attrLen) { + errorMsg += "

"+attrName + "不能超过"+ attrLen +"个字符;

"; + countError++; + } + } + attrInfoMap.put(attrField,attrValue); + } + } + //三个实施日期至少有一个日期格式 +// if (!putTimeState) { +// errorMsg += "实施日期必须有一项为日期格式;"; +// countError++; +// } + String attrStr = JSON.toJSONString(attrInfoMap, SerializerFeature.WriteMapNullValue); + dto.setSarStandAttrEOStr(attrStr); + } + map.put("errorMsg",errorMsg); + map.put("countError",String.valueOf(countError)); + return map; + } + + + public String getRightDate(String str) { + String strhours = str; + if (strhours.length() > 2) { + String strh = strhours.substring(strhours.length() - 2, strhours.length()); //截取 + if (strh.equals(".0")) { + strhours = strhours.substring(0, strhours.length() - 2); //截掉 + } + } + return strhours; + } + + /** + * 新增过程中验证标准号 + * + * @param + * @return + * @author gaoyan + * date 2018-11-13 + */ + public List selectStandardsByStandnumber(String replaceStandNum, String standType) { + SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo(); + sarStandardsInfoEO.setStandNumber(replaceStandNum); + sarStandardsInfoEO.setStandType(standType); + return dao.selectStandardsByStandnumber(sarStandardsInfoEO); + } + } diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInfo/SarLawsInfoMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInfo/SarLawsInfoMapper.xml new file mode 100644 index 00000000..25dff691 --- /dev/null +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarLawsInfo/SarLawsInfoMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml b/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml index 1f1c03cc..c3f20585 100644 --- a/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml +++ b/adc-da-sys/src/main/resources/mybatis/mapper/sys/DicTypeEOMapper.xml @@ -569,7 +569,7 @@