合并分支 'dev_20230216' 到 'master'

Dev 20230216

查看合并请求 laws-foton-slrs/foton-slrs-system-rest!29
This commit is contained in:
高嵩
2023-04-04 09:35:54 +08:00
36 changed files with 2086 additions and 549 deletions
@@ -477,4 +477,8 @@ public interface workFlowFeignClient {
String deleteOAByMandatory(@RequestParam("todoId") String todoId,@RequestParam("assignee") String assignee); String deleteOAByMandatory(@RequestParam("todoId") String todoId,@RequestParam("assignee") String assignee);
@RequestMapping(value = "/bat-wkflow/datas/bus-process-new/selectBusProcessNew",method = RequestMethod.GET) @RequestMapping(value = "/bat-wkflow/datas/bus-process-new/selectBusProcessNew",method = RequestMethod.GET)
String selectBusProcessNew(@RequestParam("taskId")String taskId); String selectBusProcessNew(@RequestParam("taskId")String taskId);
@RequestMapping(value = "/bat-wkflow/datas/bus-process-new/deleteReplyToenNotice",method = RequestMethod.POST)
List<BusProcessNew> deleteReplyToenNotice(@RequestParam("taskId") String taskId,@RequestParam("answerer") String answerer);
@RequestMapping(value = "/bat-wkflow/datas/bus-process-new/selectAskId",method = RequestMethod.GET)
String selectAskId(@RequestParam("taskId") String taskId);
} }
@@ -426,4 +426,12 @@ public class workFlowFeignClientImpl {
public String selectBusProcessNew(@RequestParam("taskId")String taskId) { public String selectBusProcessNew(@RequestParam("taskId")String taskId) {
return workFlowFeignClient.selectBusProcessNew(taskId); return workFlowFeignClient.selectBusProcessNew(taskId);
} }
public List<BusProcessNew> deleteReplyToenNotice(@RequestParam("taskId") String taskId,@RequestParam("answerer") String answerer) {
return workFlowFeignClient.deleteReplyToenNotice(taskId,answerer);
}
public String selectAskId(@RequestParam("taskId") String taskId) {
return workFlowFeignClient.selectAskId(taskId);
}
} }
@@ -56,4 +56,6 @@ public class BusProcessName implements Serializable {
private String isEnd; private String isEnd;
private String taskBackAssignee; private String taskBackAssignee;
private boolean showreceive;
} }
@@ -13,6 +13,7 @@ import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result; import com.adc.da.http.Result;
import com.adc.da.common.Page; import com.adc.da.common.Page;
import com.adc.da.login.util.JwtUtils; import com.adc.da.login.util.JwtUtils;
import com.adc.da.slrs.StandardQA.service.Impl.SarAgenldAcceptButtonServiceImpl;
import com.adc.da.slrs.esRevisePlan.dao.EsRevisePlanDao; import com.adc.da.slrs.esRevisePlan.dao.EsRevisePlanDao;
import com.adc.da.slrs.esRevisePlan.entity.EsRevisePlan; import com.adc.da.slrs.esRevisePlan.entity.EsRevisePlan;
import com.adc.da.slrs.esRevisePlan.service.IEsRevisePlanLogService; import com.adc.da.slrs.esRevisePlan.service.IEsRevisePlanLogService;
@@ -29,6 +30,7 @@ import com.adc.da.workFlow.service.WorkFlowService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import oracle.ucp.proxy.annotation.Post;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
@@ -83,6 +85,9 @@ public class WorkFlowController {
@Autowired @Autowired
private IEsRevisePlanLogService esRevisePlanLogService; private IEsRevisePlanLogService esRevisePlanLogService;
@Autowired
private SarAgenldAcceptButtonServiceImpl sarAgenldAcceptButtonService;
// @Autowired // @Autowired
// private ExportExcelMapper exportExcelMapper; // private ExportExcelMapper exportExcelMapper;
@@ -259,6 +264,7 @@ public class WorkFlowController {
@ApiOperation(value = "管控流程接收任务") @ApiOperation(value = "管控流程接收任务")
@GetMapping("/acceptTack") @GetMapping("/acceptTack")
public Integer acceptTack(@RequestParam("nowEsId") String nowEsId, @RequestParam("oaFlag") String oaFlag, @RequestParam("taskId") String taskId) { public Integer acceptTack(@RequestParam("nowEsId") String nowEsId, @RequestParam("oaFlag") String oaFlag, @RequestParam("taskId") String taskId) {
sarAgenldAcceptButtonService.add(taskId);
return workFlowFeignClient.acceptTack(nowEsId,oaFlag,taskId); return workFlowFeignClient.acceptTack(nowEsId,oaFlag,taskId);
} }
@@ -507,6 +513,16 @@ public class WorkFlowController {
pageInfo.setCount(Long.valueOf(0)); pageInfo.setCount(Long.valueOf(0));
pageInfo.setPageSize(taskCommonQuery.getSize()); pageInfo.setPageSize(taskCommonQuery.getSize());
} }
for (BusProcessName data : pageInfo.getList()){
if(StringUtils.isNotBlank(data.getTaskIds())){
String s = sarAgenldAcceptButtonService.selectIsNot(data.getTaskIds());
if(s.equals("1")){
data.setShowreceive(false);
}else {
data.setShowreceive(true);
}
}
}
return pageInfo; return pageInfo;
} }
@@ -958,6 +974,19 @@ public class WorkFlowController {
public String selectBusProcessNew(@RequestParam("taskId") String taskId) { public String selectBusProcessNew(@RequestParam("taskId") String taskId) {
return workFlowFeignClient.selectBusProcessNew(taskId); return workFlowFeignClient.selectBusProcessNew(taskId);
} }
@ApiOperation(value = "问答中心(第一个人回答以后删除其他人的代办任务以及OA提醒)")
@PostMapping("/deleteReplyToenNotice")
public List<BusProcessNew> deleteReplyToenNotice(@RequestParam("taskId") String taskId,@RequestParam("answerer") String answerer) {
return workFlowFeignClient.deleteReplyToenNotice(taskId,answerer);
}
@ApiOperation(value = "问答中心(通过taskId获取提问Id)")
@GetMapping("/selectAskId")
public String selectAskId(@RequestParam("taskId") String taskId) {
return workFlowFeignClient.selectAskId(taskId);
@ApiOperation(value = "OA待办强制删除") @ApiOperation(value = "OA待办强制删除")
@GetMapping("/deleteOAByMandatory") @GetMapping("/deleteOAByMandatory")
public String deleteOAByMandatory(@RequestParam("todoId") String todoId,@RequestParam("assignee") String assignee) { public String deleteOAByMandatory(@RequestParam("todoId") String todoId,@RequestParam("assignee") String assignee) {
@@ -115,6 +115,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
//企业标准导出 //企业标准导出
addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/exportSarBussionessStand"); addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/exportSarBussionessStand");
addInterceptor.excludePathPatterns("/api/lawss/sarFileSplitItems/exportTemplate");
//预警导出 //预警导出
addInterceptor.excludePathPatterns("/api/sys/EarlyWarning/exportWarning"); addInterceptor.excludePathPatterns("/api/sys/EarlyWarning/exportWarning");
@@ -156,6 +158,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/importSarBussionessStandFile"); addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/importSarBussionessStandFile");
addInterceptor.excludePathPatterns("/api/sarLawsDetailedList/sar-laws-detailed-list/importData"); addInterceptor.excludePathPatterns("/api/sarLawsDetailedList/sar-laws-detailed-list/importData");
//企标标准导入模板下载
addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/exportTemplateFile");
//doc文檔重新轉換 //doc文檔重新轉換
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_GNW"); addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_GNW");
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_QB"); addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_QB");
@@ -5,8 +5,11 @@ import com.adc.da.slrs.StandardQA.dao.AskQuestionsDao;
import com.adc.da.slrs.StandardQA.entity.*; import com.adc.da.slrs.StandardQA.entity.*;
import com.adc.da.slrs.StandardQA.service.Impl.AskQuestionsServiceImpl; import com.adc.da.slrs.StandardQA.service.Impl.AskQuestionsServiceImpl;
import com.adc.da.slrs.StandardQA.service.Impl.AskUserServiceImpl; import com.adc.da.slrs.StandardQA.service.Impl.AskUserServiceImpl;
import com.adc.da.slrs.StandardQA.service.Impl.ReplyServiceImpl;
import com.adc.da.slrs.StandardQA.service.Impl.SubscriptionServiceImpl; import com.adc.da.slrs.StandardQA.service.Impl.SubscriptionServiceImpl;
import com.adc.da.slrs.sarStandardsInfo.service.impl.SarStandardsInfoServiceImpl; import com.adc.da.slrs.sarStandardsInfo.service.impl.SarStandardsInfoServiceImpl;
import com.adc.da.slrs.sarUser.dao.TsUserDao;
import com.adc.da.slrs.sarUser.entity.TsUser;
import com.adc.da.util.LoginUserUtil; import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils; import com.adc.da.util.UUIDUtils;
import com.adc.da.util.http.ResponseMessage; import com.adc.da.util.http.ResponseMessage;
@@ -41,6 +44,12 @@ public class AskQuestionsController extends BaseController<AskQuestions> {
@Autowired @Autowired
private AskUserServiceImpl askUserService; private AskUserServiceImpl askUserService;
@Autowired
private ReplyServiceImpl replyService;
@Autowired
private TsUserDao tsUserDao;
@Autowired @Autowired
private SubscriptionServiceImpl subscriptionService; private SubscriptionServiceImpl subscriptionService;
@@ -262,4 +271,44 @@ public class AskQuestionsController extends BaseController<AskQuestions> {
return Result.success(askQuestionsList); return Result.success(askQuestionsList);
} }
@PostMapping("/selectQuestionReplyInfo")
public ResponseMessage selectQuestionReplyInfo(String id){
List<Object> objects = new ArrayList<>();
if(StringUtils.isNotBlank(id)){
AskQuestions askQuestions = askQuestionsService.getById(id);
if(askQuestions!=null) {
TsUser tsUser = tsUserDao.selectById(askQuestions.getQuestioner());
if(tsUser!=null){
askQuestions.setQuestioner(tsUser.getUname());
}
if(askQuestions.getClassification().equals("BUSINESS_STAND")){
askQuestions.setClassification("企业标准");
}
if(askQuestions.getClassification().equals("FOREIGN")){
askQuestions.setClassification("海外标准");
}
if(askQuestions.getClassification().equals("INLAND")){
askQuestions.setClassification("国内标准");
}
if(askQuestions.getClassification().equals("OTHER")){
askQuestions.setClassification("公共标准");
}
QueryWrapper<Reply> replyQueryWrapper = new QueryWrapper<>();
replyQueryWrapper.eq("ASK_ID", id);
List<Reply> list = replyService.list(replyQueryWrapper);
if(!list.isEmpty()){
for (Reply reply : list){
TsUser ruser = tsUserDao.selectById(reply.getAnswerer());
if(ruser!=null){
reply.setAnswerer(ruser.getUname());
}
}
}
objects.add(askQuestions);
objects.add(list);
}
}
return Result.success(objects);
}
} }
@@ -73,7 +73,6 @@ public class ReplyController extends BaseController<Reply> {
return Result.success("200","归档成功",null); return Result.success("200","归档成功",null);
} }
@PostMapping("/listByPage") @PostMapping("/listByPage")
public ResponseMessage updateReply(@RequestBody ReplyPage reply){ public ResponseMessage updateReply(@RequestBody ReplyPage reply){
return Result.success(replyService.listByPage(reply)); return Result.success(replyService.listByPage(reply));
@@ -90,4 +89,16 @@ public class ReplyController extends BaseController<Reply> {
replyService.updateBatchById(replyList); replyService.updateBatchById(replyList);
return Result.success("200","编辑成功",null); return Result.success("200","编辑成功",null);
} }
@PostMapping("/selectListSize")
public ResponseMessage selectListSize(String askId){
//1:查询当前问题下是否有其他回答 如果是第一次回答则删除 其他人的代办任务,如果非第一次回答则跳过当前步骤
QueryWrapper<Reply> replyQueryWrapper = new QueryWrapper<>();
replyQueryWrapper.eq("ASK_ID",askId);
List<Reply> list = replyService.list(replyQueryWrapper);
if(list.isEmpty()){
return Result.success(null);
}
return Result.success(list);
}
} }
@@ -0,0 +1,30 @@
package com.adc.da.slrs.StandardQA.controller;
import com.adc.da.slrs.StandardQA.service.SarAgenldAcceptButtonService;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/${restPath}/lawss/SarAgenldAcceptButton")
@Api(description = "|SarAgenldAcceptButton|")
public class SarAgenldAcceptButtonController {
@Autowired
private SarAgenldAcceptButtonService sarAgenldAcceptButtonService;
@GetMapping("/selectIsNot")
public String selectIsNot(String pid){
return sarAgenldAcceptButtonService.selectIsNot(pid);
}
@GetMapping("/add")
public ResponseMessage add(String id){
sarAgenldAcceptButtonService.add(id);
return Result.success();
}
}
@@ -0,0 +1,9 @@
package com.adc.da.slrs.StandardQA.dao;
import com.adc.da.slrs.StandardQA.entity.SarAgenldAcceptButton;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface SarAgenldAcceptButtonDao extends BaseMapper<SarAgenldAcceptButton> {
}
@@ -68,4 +68,7 @@ public class Reply extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private List<ConvertMqEO> fileList; private List<ConvertMqEO> fileList;
@TableField(exist = false)
private String taskId;
} }
@@ -0,0 +1,43 @@
package com.adc.da.slrs.StandardQA.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sar_agenld_accept_button")
@ApiModel(value="SarAgenldAcceptButton对象", description="")
@Data
public class SarAgenldAcceptButton {
@ApiModelProperty(value = "主键")
@TableId(value = "ID", type = IdType.UUID)
private String id;
@ApiModelProperty(value = "类型")
@TableField("TASK_ID")
private String taskId;
@ApiModelProperty(value = "类型")
@TableField("TYPE")
private String type;
@TableField("CREATE_TIME")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@TableField("UPDATE_TIME")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}
@@ -0,0 +1,43 @@
package com.adc.da.slrs.StandardQA.service.Impl;
import com.adc.da.slrs.StandardQA.dao.SarAgenldAcceptButtonDao;
import com.adc.da.slrs.StandardQA.entity.SarAgenldAcceptButton;
import com.adc.da.slrs.StandardQA.service.SarAgenldAcceptButtonService;
import com.adc.da.util.http.ResponseMessage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class SarAgenldAcceptButtonServiceImpl extends ServiceImpl<SarAgenldAcceptButtonDao, SarAgenldAcceptButton> implements SarAgenldAcceptButtonService {
@Autowired
private SarAgenldAcceptButtonDao sarAgenldAcceptButtonDao;
@Override
public String selectIsNot(String pid){
QueryWrapper<SarAgenldAcceptButton> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.eq("TASK_ID",pid);
List<SarAgenldAcceptButton> sarAgenldAcceptButtons = sarAgenldAcceptButtonDao.selectList(objectQueryWrapper);
if(!sarAgenldAcceptButtons.isEmpty()){
if(sarAgenldAcceptButtons.get(0).getType().equals("1")){
return "1";
}
}
return "0";
}
public void add(String id) {
SarAgenldAcceptButton sarAgenldAcceptButton = new SarAgenldAcceptButton();
sarAgenldAcceptButton.setTaskId(id);
sarAgenldAcceptButton.setType("1");
sarAgenldAcceptButtonDao.insert(sarAgenldAcceptButton);
}
}
@@ -0,0 +1,10 @@
package com.adc.da.slrs.StandardQA.service;
import com.adc.da.util.http.ResponseMessage;
public interface SarAgenldAcceptButtonService {
void add(String id);
String selectIsNot(String pid);
}
@@ -84,9 +84,24 @@ public class SarBussStandAttrInfoExecl extends BaseEntity {
private String xgjh; private String xgjh;
//附件 //发布稿附件
private String fbgbuss;
//编制说明附件
private String bzsmbuss;
//历史版本附件
private String lsbbbuss;
//其他文件附件
private String qtwjbuss; private String qtwjbuss;
//修改单附件
private String xgd;
//关联文件附件
private String glwjbuss;
//标准中文名称 //标准中文名称
private String standName; private String standName;
@@ -109,7 +124,7 @@ public class SarBussStandAttrInfoExecl extends BaseEntity {
private String issueTime; private String issueTime;
//标准编号 //标准编号
private String standCode; private String standNumber;
//标准英文名称 //标准英文名称
private String standEnName; private String standEnName;
@@ -171,6 +186,10 @@ public class SarBussStandAttrInfoExecl extends BaseEntity {
//备案日期 //备案日期
private String barq; private String barq;
private String menuId;
private String standCode;
@TableField(exist = false) @TableField(exist = false)
private Map<String, Object> attrInfoMap = new LinkedHashMap<>(); private Map<String, Object> attrInfoMap = new LinkedHashMap<>();
@@ -1,6 +1,7 @@
package com.adc.da.slrs.sarBussionessStand.controller; package com.adc.da.slrs.sarBussionessStand.controller;
import cn.hutool.core.util.ZipUtil;
import com.adc.da.Log.BusinessType; import com.adc.da.Log.BusinessType;
import com.adc.da.Log.EpcLog; import com.adc.da.Log.EpcLog;
import com.adc.da.common.FileUnZip; import com.adc.da.common.FileUnZip;
@@ -21,6 +22,7 @@ import com.adc.da.http.PageInfo;
import com.adc.da.http.ResponseMessage; import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result; import com.adc.da.http.Result;
import com.adc.da.util.LoginUserUtil; import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.util.exception.AdcDaBaseException; import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.utils.IOUtils; import com.adc.da.util.utils.IOUtils;
import com.adc.da.util.utils.StringUtils; import com.adc.da.util.utils.StringUtils;
@@ -31,8 +33,12 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDateUtil; 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.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -46,9 +52,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.*;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@@ -416,9 +420,9 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
@ApiOperation(value = "导入功能") @ApiOperation(value = "导入功能")
@PostMapping("/importSarBussionessStandFile") @PostMapping("/importSarBussionessStandFile")
public ResponseMessage<String> importSarBussionessStandFile(@RequestParam(value = "file",required = false)MultipartFile file) throws Exception{ public ResponseMessage<String> importSarBussionessStandFile(@RequestParam(value = "file",required = false)MultipartFile file,String menuId,String userId) throws Exception{
return sarBussionessStandEOService.importSarBussionessStandFile(file); return sarBussionessStandEOService.importSarBussionessStandFile(file,menuId,userId);
} }
@ApiOperation(value = "|SarBussionessStand|判断原文译文") @ApiOperation(value = "|SarBussionessStand|判断原文译文")
@GetMapping("/emptyFileAnewStorage") @GetMapping("/emptyFileAnewStorage")
@@ -437,5 +441,74 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
public ResponseMessage newRpetitionFile (){ public ResponseMessage newRpetitionFile (){
return sarBussionessStandEOService.newRpetitionFile(); return sarBussionessStandEOService.newRpetitionFile();
} }
@ApiOperation(value = "|SarBussionessStand|导入模板下载")
@GetMapping("/exportTemplateFile")
public void exportTemplateFile(String fileName,HttpServletResponse response, HttpServletRequest request)throws Exception{
OutputStream os = null;
OutputStream excelOS = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "标准导入模板";
if (org.apache.commons.lang3.StringUtils.isNotEmpty(fileName)) {
fileOriName = fileName;
}
try{
//创建临时文件夹
String fileNowPath = filePath + "/tempZip/" + UUIDUtils.randomUUID20() + "/" + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
String fileName2 = "导入模板.xls";
HSSFSheet sheetItems = workbook.createSheet("模板");
sheetItems.setDefaultColumnWidth(16);
Row rowHeader = sheetItems.createRow(1);//开始创建标题行
sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 25));
Row row2 = sheetItems.createRow(0);//开始创建填写说明
String exportFieldName = FieldConvertUtil.exportFieldName;
if (org.apache.commons.lang3.StringUtils.isNotBlank(exportFieldName)) {
String[] headerArr = exportFieldName.split(",");
for (int i=0;i < headerArr.length; i++) {
rowHeader.createCell(i).setCellValue(headerArr[i]);
}
}
Cell cellA2 = row2.createCell(0);
cellA2.setCellValue(FieldConvertUtil.exportName);
//sheetItems.setColumnWidth(0, 20 * 150);
row2.setHeight((short) (100 * 25));
HSSFCellStyle cellStyle =workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.LEFT);
cellStyle.setVerticalAlignment(VerticalAlignment.TOP);
cellStyle.setWrapText(true);
cellA2.setCellStyle(cellStyle);
String repFileName = fileName2.replaceAll("/","_");
excelOS = new FileOutputStream(fileNowPath + "/" + repFileName);
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(excelOS);
excelOS.flush();
excelOS.close();
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
}
os.flush();
os.close(); // 后开先关
fis.close(); // 先开后关
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new com.adc.da.exception.AdcDaBaseException("下载文件失败,请重试");
} finally {
org.apache.poi.util.IOUtils.closeQuietly(os);
org.apache.poi.util.IOUtils.closeQuietly(excelOS);
}
}
} }
@@ -126,5 +126,8 @@ public interface SarBussionessStandDao extends BaseMapper<SarBussionessStand> {
List<OldSystem> getBussionessStandInfo(); List<OldSystem> getBussionessStandInfo();
void updateByIdInfo(@Param("strFile")String strFile, @Param("attfId")String attfId); void updateByIdInfo(@Param("strFile")String strFile, @Param("attfId")String attfId);
@Select("select * from sar")
String setDtqbbhbuss(String dtqbbhbuss);
} }
@@ -55,7 +55,7 @@ public interface ISarBussionessStandService extends IService<SarBussionessStand>
void checkFileByEncrypt(); void checkFileByEncrypt();
ResponseMessage emptyFileAnewStorage(String type); ResponseMessage emptyFileAnewStorage(String type);
ResponseMessage<String> importSarBussionessStandFile(MultipartFile file)throws Exception; ResponseMessage<String> importSarBussionessStandFile(MultipartFile file,String menuId,String userId)throws Exception;
ResponseMessage repetitionFile(); ResponseMessage repetitionFile();
@@ -72,6 +72,7 @@ import com.adc.da.slrs.sarStandardsInfo.entity.SarAdvanceSearchVO;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage; import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService; import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.slrs.sarVppsTree.dao.SarVppsTreeDao;
import com.adc.da.slrs.sysInfo.service.SysInfoEOService; import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
import com.adc.da.sys.constant.ValueStateEnum; import com.adc.da.sys.constant.ValueStateEnum;
import com.adc.da.sys.dao.DicTypeEODao; import com.adc.da.sys.dao.DicTypeEODao;
@@ -84,6 +85,7 @@ import com.adc.da.sys.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils; import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.*; import com.adc.da.utils.util.*;
import com.adc.da.utils.util.DateUtil; import com.adc.da.utils.util.DateUtil;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -113,6 +115,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.net.ssl.*; import javax.net.ssl.*;
@@ -126,6 +129,7 @@ import java.security.SecureRandom;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.sql.Clob; import java.sql.Clob;
import java.sql.Connection;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -255,6 +259,11 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Autowired @Autowired
private SarStandardsInfoDao sarStandardsInfoDao; private SarStandardsInfoDao sarStandardsInfoDao;
@Autowired
private ITsResourceService tsResourceService;
@Autowired
private SarVppsTreeDao sarVppsTreeDao;
@Override @Override
public SarBussionessStand getStandInfoByReviseStatus(String reviseStatus,String standSort,String taskId){ public SarBussionessStand getStandInfoByReviseStatus(String reviseStatus,String standSort,String taskId){
@@ -1355,14 +1364,23 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Override @Override
public SarBussionessStand selectStandardsInfoByKey(String id) throws Exception{ public SarBussionessStand selectStandardsInfoByKey(String id) throws Exception{
String info = "企标文本状态";
String pid = dicTypeEODao.selectByPid(info);
List<DicTypeEO> dicTypeEOS = dicTypeEODao.selectByPidInfo(pid);
List<SarBussionessStand> sarBussionessStandlist = this.baseMapper.selectStandardsInfoByKey(id); List<SarBussionessStand> sarBussionessStandlist = this.baseMapper.selectStandardsInfoByKey(id);
SarBussionessStand sarBussionessStandEO = new SarBussionessStand(); SarBussionessStand sarBussionessStandEO = new SarBussionessStand();
if(!sarBussionessStandlist.isEmpty()) { if(!sarBussionessStandlist.isEmpty()) {
List<SarBussionessStand> newStandList = new ArrayList<>(); List<SarBussionessStand> newStandList = new ArrayList<>();
newStandList.add(sarBussionessStandlist.get(0)); newStandList.add(sarBussionessStandlist.get(0));
attrInfoShowDetails(newStandList); attrInfoShowDetails(newStandList);
for (DicTypeEO data : dicTypeEOS){
if(data.getDicTypeCode().equals(newStandList.get(0).getTextStatusBuss())){
newStandList.get(0).setTextStatusBussShow(data.getDicTypeName());
}
}
sarBussionessStandEO = newStandList.get(0); sarBussionessStandEO = newStandList.get(0);
} }
//企标文本状态
return sarBussionessStandEO; return sarBussionessStandEO;
} }
@@ -2029,9 +2047,14 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
* @throws Exception * @throws Exception
*/ */
@Override @Override
public ResponseMessage<String> importSarBussionessStandFile(MultipartFile file)throws Exception { public ResponseMessage<String> importSarBussionessStandFile(MultipartFile file,String menuId,String userId)throws Exception {
List<TsResource> tsResources = tsResourceService.getByMenuId(menuId);
if (ObjectUtils.isEmpty(tsResources)) {
return Result.error("请选择需要导入的目录");
}
//给出头部信息 //给出头部信息
String[] headerExcel = {"企标编号,中文名称,英文名称,文本状态,发布日期,企标实施日期,企标制修订状态,起草部门,废止日期,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,上传时间,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--乘用车vpps中文名称,关联模块--卡车VPPS编码,关联模块--卡车vpps中文名称,附件,企标类型,标准年份,"}; String[] headerExcel = {"*企标类别,企标编号,*标准年份,*企标名称,企标英文名称,*文本状态,发布日期,企标实施日期,起草部门,起草人,适用车型,能源类型,适用产品线,体系类别,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿,编制说明,历史版本,其他文件,修改单,代替企标编号,采用标准,采标程度,引用标准,关联文件,"};
//获取文件全称 //获取文件全称
String fileNameStr = file.getOriginalFilename(); String fileNameStr = file.getOriginalFilename();
@@ -2067,8 +2090,9 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
} }
//File excelfile = fileList.get(0); //File excelfile = fileList.get(0);
int excel = 0; int excel = 0;
List<String> jsonList = new ArrayList<>();
SarBussStandAttrInfoExecl sarBussStandAttrInfo = new SarBussStandAttrInfoExecl();
for (File fileInfo : fileList) { for (File fileInfo : fileList) {
String infoJson = "";
if (fileInfo.getName().contains(".xls") || fileInfo.getName().contains(".xlsx")) { if (fileInfo.getName().contains(".xls") || fileInfo.getName().contains(".xlsx")) {
excel = excel + 1; excel = excel + 1;
if (excel > 1) { if (excel > 1) {
@@ -2081,35 +2105,51 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
if (sheet != null) { if (sheet != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Row row = sheet.getRow(1);
for (int i = 0; i <= 25; i++) {
sb.append(row.getCell(i).getStringCellValue()).append(",");
}
//获取总条数 //获取总条数
int rowNum = sheet.getLastRowNum(); int rowNum = sheet.getPhysicalNumberOfRows();
//循环遍历 //循环遍历
for (int i = 0;i <= rowNum;i++){ for (int i = 1; i <= rowNum; i++) {
Row row = sheet.getRow(i); row = sheet.getRow(i);
Row headerRow = sheet.getRow(0); Row headerRow = sheet.getRow(1);
boolean isBlank = sarLawsInfoEOService.isRowEmpty(row); boolean isBlank = sarLawsInfoEOService.isRowEmpty(row);
if (row != null && !isBlank) { if (row != null && !isBlank) {
int columNos = headerRow.getLastCellNum();// 表头总共的列数 int columNos = row.getLastCellNum();// 表头总共的列数
Map<String, String> rowList = new LinkedHashMap<>(); Map<String, String> rowList = new LinkedHashMap<>();
for (int j = 0; j < columNos; j++) { for (int j = 0; j < columNos; j++) {
Cell cell = row.getCell(j); Cell cell = row.getCell(j);
Cell headerCell = headerRow.getCell(j); Cell headerCell = headerRow.getCell(j);
if (cell != null) { if (cell != null) {
if (i == 0) { if (i == 1) {
cell.setCellType(CellType.STRING); // cell.setCellType(CellType.STRING);
sb.append(cell.getStringCellValue() + ","); // sb.append(cell.getStringCellValue() + ",");
} else { } else {
if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) { if
(CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) {
Date d = cell.getDateCellValue(); Date d = cell.getDateCellValue();
if(d.before(sdf.parse("1900-01-01"))||d.after(sdf.parse("2500-01-01")) ){
return Result.error("输入的日期异常,请按照实际日期填写");
}
rowList.put(headerCell.getStringCellValue(), sdf.format(d)); rowList.put(headerCell.getStringCellValue(), sdf.format(d));
} else { } else
{
cell.setCellType(CellType.STRING); cell.setCellType(CellType.STRING);
rowList.put(headerCell.getStringCellValue(), cell.getStringCellValue()); rowList.put(headerCell.getStringCellValue(), cell.getStringCellValue());
} }
} }
} else { } else {
if (i != 0) { if (i != 0 && i != 1) {
rowList.put(headerCell.getStringCellValue(), ""); rowList.put(headerCell.getStringCellValue(), "");
} }
} }
@@ -2122,90 +2162,344 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
FileUnZip.deleteDir(saveDirectory); FileUnZip.deleteDir(saveDirectory);
return Result.error("fail", "读取失败,请严格按照模板文件导入数据"); return Result.error("fail", "读取失败,请严格按照模板文件导入数据");
} }
SarBussStandAttrInfoExecl sarBussStandAttrInfo = new SarBussStandAttrInfoExecl(); if (i != 0 && i != 1 && !rowList.equals("") && rowList != null ) {
if (i != 0) {
String standCode = rowList.get("企标编号"); int count = 1;
sarBussStandAttrInfo.setStandCode(standCode); count++;
String standName = rowList.get("中文名称"); String standSort = rowList.get("*企标类别");
if (StringUtils.isNotBlank(standSort)) {
if (standSort.length() > 100) {
return Result.error(""+ count +"行企标类别输入过长");
}
switch (standSort){
case "BZJ":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "FT":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q-HD":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q-IOUM":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/ASB":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/BFC":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/BQB":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/CBFC":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FD":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FL":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT A":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT B":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT E":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT F":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT G":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT M":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT P":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT Q":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT R":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT S":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT T":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT V":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT X":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT Y":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/FT Z":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/MGB":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/QCBFC":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/QCFLC":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/SGZGS":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/SH":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q/SY":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "QB/NE":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "QC/T":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "QJ/SH":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "Q房/AYJ":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "TFT":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "津Q/NK":
sarBussStandAttrInfo.setStandSort(standSort);
break;
case "鲁Q/LX":
sarBussStandAttrInfo.setStandSort(standSort);
break;
default:
return Result.error(""+ count +"行请输入正确的企标类别");
}
} else {
return Result.error(""+ count +"行企标类别不能为空");
}
String standNumber = rowList.get("企标编号");
sarBussStandAttrInfo.setStandNumber(standNumber);
String standYear = rowList.get("*标准年份");
if (StringUtils.isNotBlank(standYear)) {
if (standYear.length() > 100) {
return Result.error(""+ count +"行标准年份输入过长");
}
sarBussStandAttrInfo.setStandYear(standYear);
} else {
return Result.error(""+ count +"行标准年份不能为空");
}
String standName = rowList.get("*企标名称");
if (StringUtils.isNotBlank(standName)) { if (StringUtils.isNotBlank(standName)) {
if (standName.length() > 100) { if (standName.length() > 100) {
return Result.error("输入的标名称过长"); return Result.error(""+ count +"输入的标名称过长");
} }
sarBussStandAttrInfo.setStandName(standName); sarBussStandAttrInfo.setStandName(standName);
} else {
return Result.error(""+ count +"行企标名称不能为空");
} }
String standEnName = rowList.get("英文名称"); String standEnName = rowList.get("企标英文名称");
sarBussStandAttrInfo.setStandEnName(standEnName); sarBussStandAttrInfo.setStandEnName(standEnName);
String textStatusBuss = rowList.get("文本状态"); String textStatusBuss = rowList.get("*文本状态");
if (StringUtils.isNotBlank(textStatusBuss)) { if (StringUtils.isNotBlank(textStatusBuss)) {
if (textStatusBuss.length() > 200) { if (textStatusBuss.length() > 200) {
return Result.error("输入的文本状态过长"); return Result.error(""+ count +"输入的文本状态过长");
} }
sarBussStandAttrInfo.setTextStatusBuss(textStatusBuss); switch (textStatusBuss) {
case "发布":
sarBussStandAttrInfo.setTextStatusBuss("6jnqba2mby");
break;
case "被代替":
sarBussStandAttrInfo.setTextStatusBuss("quxujsuev5");
break;
case "参考":
sarBussStandAttrInfo.setTextStatusBuss("01i8opy07d");
break;
case "即将实施":
sarBussStandAttrInfo.setTextStatusBuss("rpvoxsvr60");
break;
case "有效":
sarBussStandAttrInfo.setTextStatusBuss("9z741h2m3j");
break;
case "直接上传":
sarBussStandAttrInfo.setTextStatusBuss("t769k1rkcy");
break;
case "作废":
sarBussStandAttrInfo.setTextStatusBuss("3lqnlgmgcn");
break;
case "待修订-指的其他企业标准":
sarBussStandAttrInfo.setTextStatusBuss("1w7cegukbs");
break;
default:
return Result.error(""+ count +"行请提供正确的文本状态");
}
} else {
return Result.error(""+ count +"行文本状态不能为空");
} }
SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd"); String issueTimeStr =rowList.get("发布日期");
Date issueTime = sdfs.parse( rowList.get("发布日期"));
String issueTimeStr = sdfs.format(issueTime);
if (StringUtils.isNotBlank(issueTimeStr)){ if (StringUtils.isNotBlank(issueTimeStr)){
if (issueTimeStr.contains("-")) {
sarBussStandAttrInfo.setIssueTime(issueTimeStr); sarBussStandAttrInfo.setIssueTime(issueTimeStr);
}else {
return Result.error(""+ count +"行发布日期格式必须为年-月-日");
}
} }
Date putTime = sdfs.parse(rowList.get("企标实施日期")); String putTimeStr = rowList.get("企标实施日期");
String putTimeStr = sdfs.format(putTime);
if (StringUtils.isNotBlank(putTimeStr)){ if (StringUtils.isNotBlank(putTimeStr)){
if (putTimeStr.contains("-")) {
sarBussStandAttrInfo.setPutTime(putTimeStr); sarBussStandAttrInfo.setPutTime(putTimeStr);
}else {
return Result.error(""+ count +"行企标实施日期格式必须为年-月-日");
}
} }
String revisionStatus = rowList.get("企标制修订状态");
sarBussStandAttrInfo.setRevisionStatus(revisionStatus);
String qcdw = rowList.get("起草部门"); String qcdw = rowList.get("起草部门");
if (StringUtils.isNotBlank(qcdw)) { if (StringUtils.isNotBlank(qcdw)) {
if (qcdw.length() > 100) { if (qcdw.length() > 100) {
return Result.error("输入的起草部门过长"); return Result.error(""+ count +"输入的起草部门过长");
} }
sarBussStandAttrInfo.setQcdw(qcdw); sarBussStandAttrInfo.setQcdw(qcdw);
} }
String fzrqbuss = rowList.get("废止日期"); String qcrbuss = rowList.get("起草人");
if (StringUtils.isNotBlank(fzrqbuss)){ if (StringUtils.isNotBlank(qcrbuss)) {
sarBussStandAttrInfo.setFzrqbuss(fzrqbuss); if (qcrbuss.length() > 100) {
return Result.error(""+ count +"行输入的起草人过长");
} }
sarBussStandAttrInfo.setQcrbuss(qcrbuss);
}
String sycxclass = rowList.get("适用车型");
if (StringUtils.isNotBlank(sycxclass) && !sycxclass.equals("")){
String[] strings = sycxclass.split(",");
String sycx = "";
String sycxs = "";
if (ObjectUtils.isNotEmpty(strings)) {
for (int j = 0; j < strings.length; j++) {
sycx = strings[j];
if (sycx.equals("N1") || sycx.equals("N2") || sycx.equals("N3") || sycx.equals("M1") || sycx.equals("M2") || sycx.equals("M3")) {
if (StringUtils.isNotBlank(sycxs)){
sycxs += "," + sycx;
}else {
sycxs = sycx;
}
} else {
return Result.error(""+ count +"行请输入正确的适用车型");
}
}
sarBussStandAttrInfo.setSycxclass(sycxs);
}
}
String nylxclass = rowList.get("能源类型");
if (StringUtils.isNotBlank(nylxclass) && ! nylxclass.equals("")){
String[] stringNylxc = nylxclass.split(",");
String nylx = "";
String nylxs = "";
if (ObjectUtils.isNotEmpty(stringNylxc)){
for (int j = 0; j < stringNylxc.length; j++) {
nylx = stringNylxc[j];
if (nylx.equals("汽油") || nylx.equals("柴油") || nylx.equals("纯电动") || nylx.equals("混合动力") || nylx.equals("燃料电池") || nylx.equals("替代燃料")){
if (StringUtils.isNotBlank(nylxs)){
nylxs += "," + nylx;
}else {
nylxs = nylx;
}
}else {
return Result.error(""+ count +"行请输入正确的能源类型");
}
}
sarBussStandAttrInfo.setNylxclass(nylxs);
}
}
String sycpxclass = rowList.get("适用产品线");
if (StringUtils.isNotBlank(sycpxclass) && !sycpxclass.equals("")){
String[] stringSycpx = sycpxclass.split(",");
String sycpx = "";
String sycpxs = "";
if (ObjectUtils.isNotEmpty(stringSycpx)){
for (int j = 0; j < stringSycpx.length; j++) {
sycpx = stringSycpx[j];
if (sycpx.equals("VAN") || sycpx.equals("微卡") || sycpx.equals("轻卡") || sycpx.equals("皮卡") || sycpx.equals("中卡") || sycpx.equals("重卡") || sycpx.equals("客车")){
if (StringUtils.isNotBlank(sycpxs)){
sycpxs += "," + sycpx;
}else {
sycpxs = sycpx;
}
}else {
return Result.error(""+ count +"行请输入正确的适用产品线");
}
}
sarBussStandAttrInfo.setSycpxclass(sycpxs);
}
}
String txlbbuss = rowList.get("体系类别");
sarBussStandAttrInfo.setTxlbbuss(txlbbuss);
//关联模块-乘用车VPPS编码 23
String cycvppsbmbuss = rowList.get("关联模块-乘用车VPPS编码");
sarBussStandAttrInfo.setCycvppsbmbuss(cycvppsbmbuss);
// 关联模块-乘用车VPPS名称 24
String cycvppscnbuss = sarVppsTreeDao.getCycvppscnbuss(sarBussStandAttrInfo.getCycvppsbmbuss());
sarBussStandAttrInfo.setCycvppscnbuss(cycvppscnbuss);
//// //关联模块--卡车VPPS编码 25
String kcvppsbmbuss = rowList.get("关联模块--卡车VPPS编码");
sarBussStandAttrInfo.setKcvppsbmbuss(kcvppsbmbuss);
//关联模块--卡车VPPS名称 26
String kcvppscnbuss = sarVppsTreeDao.getKcvppscnbuss(sarBussStandAttrInfo.getKcvppsbmbuss());
sarBussStandAttrInfo.setKcvppscnbuss(kcvppscnbuss);
String dtqbbhbuss = rowList.get("代替企标编号"); String dtqbbhbuss = rowList.get("代替企标编号");
sarBussStandAttrInfo.setDtqbbhbuss(dtqbbhbuss); sarBussStandAttrInfo.setDtqbbhbuss(dtqbbhbuss);
String fsrqbuss = rowList.get("复审日期"); //被代替企标编号
if (StringUtils.isNotBlank(fsrqbuss)){ // String bdtqbbhbuss = sarBussionessStandEODao.setDtqbbhbuss(dtqbbhbuss);
sarBussStandAttrInfo.setFsrqbuss(fsrqbuss); // sarBussionessStandEODao.s
}
String qcrbuss = rowList.get("起草人");
if (StringUtils.isNotBlank(qcrbuss)){
if (qcrbuss.length() > 100){
return Result.error("输入的起草人过长");
}
sarBussStandAttrInfo.setQcrbuss(qcrbuss);
}
String bdtqbbhbuss = rowList.get("被代替企标编号");
sarBussStandAttrInfo.setBdtqbbhbuss(bdtqbbhbuss);
//// //采用标准 13 //// //采用标准 13
String cybz = rowList.get("采用标准"); String cybz = rowList.get("采用标准");
if (StringUtils.isNotBlank(cybz) && !cybz.equals("")){
if (cybz.equals("IDT等同采用") || cybz.equals("NEQ非等效采用") || cybz.equals("MOD修改采用")){
sarBussStandAttrInfo.setCybz(cybz); sarBussStandAttrInfo.setCybz(cybz);
}else {
return Result.error(""+ count +"行请提供正确的采用标准");
}
}
String wjscrybuss = rowList.get("文件上传人员");
sarBussStandAttrInfo.setWjscrybuss(wjscrybuss);
//// //采标程度 15 //// //采标程度 15
String cycd = rowList.get("采标程度"); String cycd = rowList.get("采标程度");
@@ -2215,50 +2509,22 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
String yybz = rowList.get("引用标准"); String yybz = rowList.get("引用标准");
sarBussStandAttrInfo.setYybz(yybz); sarBussStandAttrInfo.setYybz(yybz);
String sycxclass = rowList.get("适用车型"); //上传时间
sarBussStandAttrInfo.setSycxclass(sycxclass); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String format = simpleDateFormat.format(date);
sarBussStandAttrInfo.setXcsjbuss(format);
String nylxclass = rowList.get("能源类型"); String fbgbuss = rowList.get("发布稿");
sarBussStandAttrInfo.setNylxclass(nylxclass); if (fbgbuss != null && !fbgbuss.equals("")) {
String[] split = fbgbuss.split(",");
String sycpxclass = rowList.get("适用产品线");
sarBussStandAttrInfo.setSycpxclass(sycpxclass);
String xcsjbuss = rowList.get("上传时间");
if (StringUtils.isNotBlank(xcsjbuss)){
sarBussStandAttrInfo.setXcsjbuss(xcsjbuss);
}
String txlbbuss = rowList.get("体系类别");
sarBussStandAttrInfo.setTxlbbuss(txlbbuss);
//// //备案日期 22
String barq = rowList.get("备案日期");
sarBussStandAttrInfo.setBarq(barq);
//// //关联模块-乘用车VPPS编码 23
String cycvppsbmbuss = rowList.get("关联模块-乘用车VPPS编码");
sarBussStandAttrInfo.setCycvppsbmbuss(cycvppsbmbuss);
//// //关联模块--乘用车vpps中文名称 24
String cycvppscnbuss = rowList.get("关联模块--乘用车vpps中文名称");
sarBussStandAttrInfo.setCycvppscnbuss(cycvppscnbuss);
//// //关联模块--卡车VPPS编码 25
String kcvppsbmbuss = rowList.get("关联模块--卡车VPPS编码");
sarBussStandAttrInfo.setKcvppsbmbuss(kcvppsbmbuss);
//// //关联模块--卡车vpps中文名称 26
String kcvppscnbuss = rowList.get("关联模块--卡车vpps中文名称");
sarBussStandAttrInfo.setKcvppscnbuss(kcvppscnbuss);
String qtwjbuss = rowList.get("附件");
if (qtwjbuss != null && !qtwjbuss.equals("")) {
String[] split = qtwjbuss.split(",");
String s = ""; String s = "";
if (split.length != 0) { if (split.length != 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
String fjName = split[j];
int one = fjName.lastIndexOf(".");
String split2 = fjName.substring(one + 1).toLowerCase();
if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
String name = fileInfo.getName(); String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name); String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]); File files = new File(split1[0] + split[j]);
@@ -2268,40 +2534,174 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
} else { } else {
s = attFileVo.getAttId(); s = attFileVo.getAttId();
} }
} else {
logger.info(""+ count +"" +fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setFbgbuss(s);
}
}
String bzsmbuss = rowList.get("编制说明");
if (bzsmbuss != null && !bzsmbuss.equals("")) {
String[] split = bzsmbuss.split(",");
String s = "";
if (split.length != 0) {
for (int j = 0; j < split.length; j++) {
String fjName = split[j];
int one = fjName.lastIndexOf(".");
String split2 = fjName.substring(one + 1).toLowerCase();
if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]);
AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
if (StringUtils.isNotBlank(attFileVo.getId())) {
s += "," + attFileVo.getAttId();
} else {
s = attFileVo.getAttId();
}
} else {
logger.info(""+ count +""+ fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(""+ count +""+ fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setBzsmbuss(s);
}
}
String lsbbbuss = rowList.get("历史版本");
if (lsbbbuss != null && !lsbbbuss.equals("")) {
String[] split = lsbbbuss.split(",");
String s = "";
if (split.length != 0) {
for (int j = 0; j < split.length; j++) {
String fjName = split[j];
int one = fjName.lastIndexOf(".");
String split2 = fjName.substring(one + 1).toLowerCase();
if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]);
AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
if (StringUtils.isNotBlank(attFileVo.getId())) {
s += "," + attFileVo.getAttId();
} else {
s = attFileVo.getAttId();
}
} else {
logger.info(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setLsbbbuss(s);
}
}
String qtwjbuss = rowList.get("其他文件");
if (qtwjbuss != null && !qtwjbuss.equals("")) {
String[] split = qtwjbuss.split(",");
String s = "";
if (split.length != 0) {
for (int j = 0; j < split.length; j++) {
String fjName = split[j];
int one = fjName.lastIndexOf(".");
String split2 = fjName.substring(one + 1).toLowerCase();
if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx") || split2.equals("png")) {
String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]);
AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
if (StringUtils.isNotBlank(attFileVo.getId())) {
s += "," + attFileVo.getAttId();
} else {
s = attFileVo.getAttId();
}
} else {
logger.info(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx/png格式的附件");
return Result.error(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx/png格式的附件");
}
} }
sarBussStandAttrInfo.setQtwjbuss(s); sarBussStandAttrInfo.setQtwjbuss(s);
} }
} }
String standSort = rowList.get("企标类型"); String xgd = rowList.get("修改单");
if (StringUtils.isNotBlank(standSort)){ if (xgd != null && !xgd.equals("")) {
if (standSort.length() > 100){ String[] split = xgd.split(",");
return Result.error("企标类型输入过长"); String s = "";
if (split.length != 0) {
for (int j = 0; j < split.length; j++) {
String fjName = split[j];
int one = fjName.lastIndexOf(".");
String split2 = fjName.substring(one + 1).toLowerCase();
if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]);
AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
if (StringUtils.isNotBlank(attFileVo.getId())) {
s += "," + attFileVo.getAttId();
} else {
s = attFileVo.getAttId();
}
} else {
logger.info(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setXgd(s);
} }
sarBussStandAttrInfo.setStandSort(standSort);
} }
String standYear = rowList.get("标准年份"); String glwjbuss = rowList.get("关联文件");
if (StringUtils.isNotBlank(standYear)){ if (glwjbuss != null && !glwjbuss.equals("")) {
if (standYear.length() > 100){ String[] split = glwjbuss.split(",");
return Result.error("标准年份输入过长"); String s = "";
if (split.length != 0) {
for (int j = 0; j < split.length; j++) {
String fjName = split[j];
int one = fjName.lastIndexOf(".");
String split2 = fjName.substring(one + 1).toLowerCase();
if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]);
AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
if (StringUtils.isNotBlank(attFileVo.getId())) {
s += "," + attFileVo.getAttId();
} else {
s = attFileVo.getAttId();
}
} else {
logger.info(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(""+ count +""+fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setGlwjbuss(s);
} }
sarBussStandAttrInfo.setStandYear(standYear);
} }
List<SarBussStandAttrInfoExecl> list = new ArrayList<>(); //文件上传人员
list.add(sarBussStandAttrInfo); if ((sarBussStandAttrInfo.getFbgbuss() != null && !sarBussStandAttrInfo.getFbgbuss().equals(""))
|| (sarBussStandAttrInfo.getBzsmbuss() != null && !sarBussStandAttrInfo.getBzsmbuss().equals(""))
com.alibaba.fastjson.JSONArray json = com.alibaba.fastjson.JSONArray.parseArray(JSON.toJSONString(list)); || (sarBussStandAttrInfo.getLsbbbuss() != null && !sarBussStandAttrInfo.getLsbbbuss().equals(""))
com.alibaba.fastjson.JSONObject jsonObjects = null; || (sarBussStandAttrInfo.getQtwjbuss() != null && !sarBussStandAttrInfo.getQtwjbuss().equals(""))
for (int j = 0; j < json.size(); j++) { || (sarBussStandAttrInfo.getXgd() != null && !sarBussStandAttrInfo.getXgd().equals(""))
jsonObjects = json.getJSONObject(j); || (sarBussStandAttrInfo.getGlwjbuss() != null && !sarBussStandAttrInfo.getGlwjbuss().equals(""))){
String userName = tsUserService.userIdByName(userId);
sarBussStandAttrInfo.setWjscrybuss(userName);
} }
infoJson = String.valueOf(jsonObjects);
//入库 sarBussStandAttrInfo.setMenuId(menuId);
processCreateBuss(infoJson);
countSuccess++; String standCode = ifCodeAndName(sarBussStandAttrInfo.getStandName(), sarBussStandAttrInfo.getStandSort(), sarBussStandAttrInfo.getStandYear(), sarBussStandAttrInfo.getStandNumber());
sarBussStandAttrInfo.setStandCode(standCode);
String json = com.alibaba.fastjson.JSONObject.toJSONString(sarBussStandAttrInfo);
if(StringUtils.isNotEmpty(json)){
jsonList.add(json);
}
} }
} }
} }
@@ -2309,10 +2709,20 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
} }
} catch (Exception e) { } catch (Exception e) {
FileUnZip.deleteDir(saveDirectory); FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,请查看需要导入的企标标准号和企标名称是否已存在"); return Result.error("导入失败,需要导入的数据有问题或导入的企标标号或企标名称重复");
} }
} }
} }
//入库
try {
for (String infoJson : jsonList) {
processCreateBuss(infoJson);
countSuccess++;
}
}catch (Exception e){
return Result.error("导入失败,请查看导入的数据是否有问题");
}
String msg = "成功导入" + countSuccess + ""; String msg = "成功导入" + countSuccess + "";
return Result.success("", msg, null); return Result.success("", msg, null);
} catch (Exception e) { } catch (Exception e) {
@@ -2321,6 +2731,38 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
} }
} }
/**
*
* @param standName
* @param standSort
* @param standYear
* @param standNumber
* @return
*/
private String ifCodeAndName(String standName, String standSort, String standYear, String standNumber) {
SarBussionessStand sarBussionessStand = new SarBussionessStand();
//拼接企标编号
String standCode = standSort + " " + standNumber + "-" + standYear;
sarBussionessStand.setStandCode(standCode);
// 根据标准号判断数据是否已存在
//2021年4月9日 此处检查当前是否存在standId
QueryWrapper<SarBussionessStand>queryWrapper = new QueryWrapper<>();
queryWrapper.eq(sarBussionessStand.getStandCode() != null,"STAND_CODE",sarBussionessStand.getStandCode())
.eq(standName != null,"STAND_NAME",standName);
List<SarBussionessStand> list = iSarBussionessStandService.list(queryWrapper);
Integer valIdFlag = 0;
for (SarBussionessStand stand :list){
if ((list.size() ==1 && !list.get(0).getId().equals(stand.getId())) || list.size() >1){
valIdFlag = stand.getValidFlag();
if (valIdFlag == 0){
throw new AdcDaBaseException("企标标准号"+ sarBussionessStand.getStandCode() +"或企标名称"+ sarBussionessStand.getStandName() +"已存在");
}
}
}
return sarBussionessStand.getStandCode();
}
private static List<File> readImpExcelFile(String path) { private static List<File> readImpExcelFile(String path) {
File file = new File(path); File file = new File(path);
List<File> resultlist = new ArrayList<>(); List<File> resultlist = new ArrayList<>();
@@ -2375,22 +2817,27 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
} }
String resData = JSON.toJSONString(attInfoMap, SerializerFeature.WriteMapNullValue); String resData = JSON.toJSONString(attInfoMap, SerializerFeature.WriteMapNullValue);
sarBussionessStand.setSarStandAttrEOStr(resData); sarBussionessStand.setSarStandAttrEOStr(resData);
// 根据标准号判断数据是否已存在
//2021年4月9日 此处检查当前是否存在standId
QueryWrapper<SarBussionessStand>queryWrapper = new QueryWrapper<>();
queryWrapper.eq(sarBussionessStand.getStandCode() != null,"STAND_CODE",sarBussionessStand.getStandCode())
.eq(sarBussionessStand.getStandName() != null,"STAND_NAME",sarBussionessStand.getStandName());
Integer count = iSarBussionessStandService.count(queryWrapper);
if (count > 0){
//return Result.error("当前企标标准号和企标名称已存在");
throw new AdcDaBaseException("企标标准号"+ sarBussionessStand.getStandCode() +"或企标名称"+ sarBussionessStand.getStandName() +"已存在");
}
String standCode = ""; // String textStatusBussShow = sarBussionessStand.getTextStatusBuss();
if(StringUtils.isNotBlank(sarBussionessStand.getStandCode()) && !"null".equals(sarBussionessStand.getStandCode())){
standCode = sarBussionessStand.getStandCode(); // //拼接企标编号
} // String standCode = sarBussionessStand.getStandSort() + " " + sarBussionessStand.getStandNumber() + "-" + sarBussionessStand.getStandYear();
List<SarBussionessStand> lawsList = iSarBussionessStandService.selectStandardsByStandNumber(standCode); // sarBussionessStand.setStandCode(standCode);
// // 根据标准号判断数据是否已存在
// //2021年4月9日 此处检查当前是否存在standId
// QueryWrapper<SarBussionessStand>queryWrapper = new QueryWrapper<>();
// queryWrapper.eq(sarBussionessStand.getStandCode() != null,"STAND_CODE",sarBussionessStand.getStandCode())
// .eq(sarBussionessStand.getStandName() != null,"STAND_NAME",sarBussionessStand.getStandName());
// List<SarBussionessStand> list = iSarBussionessStandService.list(queryWrapper);
// Integer valIdFlag = 0;
// for (SarBussionessStand stand :list){
// if ((list.size() ==1 && !list.get(0).getId().equals(stand.getId())) || list.size() >1){
// valIdFlag = stand.getValidFlag();
// if (valIdFlag == 0){
// throw new AdcDaBaseException("企标标准号"+ sarBussionessStand.getStandCode() +"或企标名称"+ sarBussionessStand.getStandName() +"已存在");
// }
// }
// }
//此处判断是否是带入的标准 //此处判断是否是带入的标准
if(StringUtils.isNotBlank(sarBussionessStand.getId())) { if(StringUtils.isNotBlank(sarBussionessStand.getId())) {
@@ -2408,8 +2855,8 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
iSarBussionessStandService.updateSarBussionessStand(sarBussionessStand); iSarBussionessStandService.updateSarBussionessStand(sarBussionessStand);
} else {//标准号ID都不存在的情况 } else {//标准号ID都不存在的情况
// 新增方法 // 新增方法
sarBussionessStand.setStandCode(standCode); //sarBussionessStand.setTextStatusBussShow(textStatusBussShow);
iSarBussionessStandService.createSarBussionessStand(sarBussionessStand); saveSarBussionessStand(sarBussionessStand);
} }
} }
return null; return null;
@@ -2474,8 +2921,8 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
//查询字典表,形成Hash映射提升速度 //查询字典表,形成Hash映射提升速度
List<DicTypeEO> dicInfo = dicTypeEODao.getDicInfo("dic_type_code", "dic_type_name"); List<DicTypeEO> dicInfo = dicTypeEODao.getDicInfo("dic_type_code", "dic_type_name");
Map<String, String> dicMap = dicInfo.stream() Map<String, String> dicMap = dicInfo.stream()
.filter(item-> !item.getDicTypeName().isEmpty()) .filter(item-> !item.getDicTypeCode().isEmpty())
.collect(Collectors.toMap(DicTypeEO::getDicTypeName,DicTypeEO::getDicTypeCode,(value1, value2 )->value2)); .collect(Collectors.toMap(DicTypeEO::getDicTypeCode,DicTypeEO::getDicTypeName,(value1, value2 )->value2));
for(SarBussStandAttrInfoExecl row : sarlist){ for(SarBussStandAttrInfoExecl row : sarlist){
attrInfoDetailsImport(row); attrInfoDetailsImport(row);
@@ -3958,4 +4405,54 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
} }
return "标准Id==="+standId+"修改文件==="+strFile+"删除文件=="+strFileInfo; return "标准Id==="+standId+"修改文件==="+strFile+"删除文件=="+strFileInfo;
} }
public ResponseMessage<SarBussionessStand> saveSarBussionessStand(SarBussionessStand sarBussionessStandEO) throws Exception {
//标准信息表中插入一条数据
sarBussionessStandEO.setValidFlag(ValueStateEnum.VALUE_TRUE.getValue());
sarBussionessStandEO.setCreationTime(new Date());
sarBussionessStandEO.setModifyTime(new Date());
sarBussionessStandEO.setId(UUIDUtils.randomUUID20());
if (StringUtils.isEmpty(sarBussionessStandEO.getMenuId())){
sarBussionessStandEO.setMenuId("3");
}
//根据新建标准所在目录确定此处是否需要在标准目录关联表中插入数据
if (StringUtils.isNotEmpty(sarBussionessStandEO.getMenuId())) {
SarBussStandMenu sarStandMenuEO = new SarBussStandMenu();
sarStandMenuEO.setBussStandId(sarBussionessStandEO.getId());
sarStandMenuEO.setMenuId(sarBussionessStandEO.getMenuId());
sarStandMenuEO.setValidFlag(ValueStateEnum.VALUE_TRUE.getValue());
sarStandMenuEO.setId(UUIDUtils.randomUUID20());
sarBussStandMenuEODao.insertSelective(sarStandMenuEO);
}
int insertresult = this.baseMapper.insert(sarBussionessStandEO);
if (insertresult >= 1) {
// 根据代替标准号 修改代替标准号标准中的被代替标准号
updateReplaceConnect(sarBussionessStandEO);
//编写预警信息
// writeWarnings(sarBussionessStandEO);
// 处理属性表信息
if (StringUtils.isNotBlank(sarBussionessStandEO.getSarStandAttrEOStr())) {
createStandAttrInfo(sarBussionessStandEO,false);
}
// 增加关联事件
String sortName = sysInfoEOService.getDicNamesByCodes(sarBussionessStandEO.getStandSort(),"JKSADFH564S");
String number = sortName + " " + sarBussionessStandEO.getStandCode();
if (StringUtils.isNotBlank(sarBussionessStandEO.getStandYear())) {
number += "-" + sarBussionessStandEO.getStandYear();
}
String content = "入库" + number + "" + sarBussionessStandEO.getStandName() + "";
String prcCreateUser = StringUtils.isNotBlank(sarBussionessStandEO.getPrcCreateUser()) ? sarBussionessStandEO.getPrcCreateUser() : "";
sarUpdLogEOService.createBaseProcessLog(sarBussionessStandEO.getId(),"BUSINESS",content,prcCreateUser);
saveNewFeed(sarBussionessStandEO,"2");
if(elasflag) {
attrInfoShowSearchDetails(sarBussionessStandEO,"add");
createStandMQService.sendBussStandMQ(sarBussionessStandEO,"add");
}
return Result.success("00", "插入数据成功", sarBussionessStandEO);
} else {
return Result.error("01", "插入输入过程中出错");
}
}
} }
@@ -59,4 +59,7 @@ public interface ITsResourceService extends IService<TsResource> {
List<String> getChildMenuList(String menuId); List<String> getChildMenuList(String menuId);
boolean dealWithData(); boolean dealWithData();
List<TsResource> getByMenuId(String menuId)throws Exception;
} }
@@ -1,5 +1,6 @@
package com.adc.da.slrs.sarResource.service.impl; package com.adc.da.slrs.sarResource.service.impl;
import com.adc.da.exception.AdcDaBaseException;
import com.adc.da.http.ResponseMessage; import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result; import com.adc.da.http.Result;
@@ -490,6 +491,14 @@ public class TsResourceServiceImpl extends ServiceImpl<TsResourceDao, TsResource
return true; return true;
} }
@Override
public List<TsResource> getByMenuId(String menuId) throws Exception{
QueryWrapper<TsResource> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("ID",menuId);
List<TsResource> tsResources = baseMapper.selectList(queryWrapper);
return tsResources;
}
public boolean dealData(TsResource tsResource,Map<String,TsResource> map){ public boolean dealData(TsResource tsResource,Map<String,TsResource> map){
if (null!=tsResource.getParentId() && !"".equals(tsResource.getParentId()) && !"0".equals(tsResource.getParentId())){ if (null!=tsResource.getParentId() && !"".equals(tsResource.getParentId()) && !"0".equals(tsResource.getParentId())){
tsResource.setParentIds(tsResource.getParentIds()+tsResource.getParentId()+","); tsResource.setParentIds(tsResource.getParentIds()+tsResource.getParentId()+",");
@@ -72,4 +72,7 @@ public interface TsUserDao extends BaseMapper<TsUser> {
Integer selectUserByRole(@Param("role") RoleUserDTO roleSelectDTO); Integer selectUserByRole(@Param("role") RoleUserDTO roleSelectDTO);
List<TsUser> selectUserByRoleByPage(@Param("role") RoleUserDTO roleSelectDTO); List<TsUser> selectUserByRoleByPage(@Param("role") RoleUserDTO roleSelectDTO);
@Select("select UNAME from ts_user where USID = #{userId}")
String selectByName(String userId);
} }
@@ -90,4 +90,6 @@ public interface ITsUserService extends IService<TsUser> {
List<UpDTO> selectNameById(List<String> strings,String type); List<UpDTO> selectNameById(List<String> strings,String type);
IPage<TsUser> getAllUsers(TsUser tsUser); IPage<TsUser> getAllUsers(TsUser tsUser);
String userIdByName(String userId);
} }
@@ -522,5 +522,11 @@ public class TsUserServiceImpl extends ServiceImpl<TsUserDao, TsUser> implements
return tsUserPage; return tsUserPage;
} }
@Override
public String userIdByName(String userId) {
String userName = tsUserDao.selectByName(userId);
return userName;
}
} }
@@ -2,6 +2,8 @@ package com.adc.da.slrs.sarVppsTree.dao;
import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree; import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/** /**
* <p> * <p>
@@ -13,4 +15,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface SarVppsTreeDao extends BaseMapper<SarVppsTree> { public interface SarVppsTreeDao extends BaseMapper<SarVppsTree> {
@Select("select sar_vpps_tree.CHINESE_NAME from sar_vpps_tree where sar_vpps_tree.VPPS_CODE = #{cycvppsbmbuss} and sar_vpps_tree.TYPE = 'car';")
String getCycvppscnbuss(@Param("cycvppsbmbuss") String cycvppsbmbuss);
@Select("select sar_vpps_tree.CHINESE_NAME from sar_vpps_tree where sar_vpps_tree.VPPS_CODE = #{kcvppsbmbuss} and sar_vpps_tree.TYPE = 'truck';")
String getKcvppscnbuss(@Param("kcvppsbmbuss") String kcvppsbmbuss);
} }
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ZipUtil;
import com.adc.da.att.controller.AttFileEOController; import com.adc.da.att.controller.AttFileEOController;
import com.adc.da.att.entity.AttFileEO; import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService; import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.att.util.CommonExportUtil;
import com.adc.da.base.web.BaseController; import com.adc.da.base.web.BaseController;
import com.adc.da.common.ConvertHtml2Excel; import com.adc.da.common.ConvertHtml2Excel;
import com.adc.da.common.FileUnZip; import com.adc.da.common.FileUnZip;
@@ -546,8 +547,7 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
// 导入参数设置,默认即可 // 导入参数设置,默认即可
ImportParams params = new ImportParams(); ImportParams params = new ImportParams();
try { try {
String fields[] = {"条款号", "条款名称","内容简介","责任部门", String fields[] = {"条款号", "条款名称","条款内容","条款附件"};
"FO","责任工程师","SVPPS","适用车辆类型","要求类型","企标覆盖关系"};
params.setImportFields(fields); params.setImportFields(fields);
List<SarFileSplitItemsImportDto> result = new ArrayList<>(); List<SarFileSplitItemsImportDto> result = new ArrayList<>();
// 解析excel,并返回校验信息 // 解析excel,并返回校验信息
@@ -583,6 +583,12 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
//是则不读取 //是则不读取
continue; continue;
} }
//判断此行数据是否全部为空
if(sarStandImportDto.getItemsNum().contains("模板说明")){
i++;
//是则不读取
continue;
}
i = 0; i = 0;
datasUpdate.add(sarStandImportDto); datasUpdate.add(sarStandImportDto);
} }
@@ -658,5 +664,26 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
return Result.error("0", "该条数据标准号在标准库中不存在"); return Result.error("0", "该条数据标准号在标准库中不存在");
} }
//导入模板下载
@ApiOperation(value = "拆分导入模板下载")
@GetMapping(value = "/exportTemplate")
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
String[] headers = { "条款号","条款名称","条款内容","条款附件"};
try{
String fileName = "拆分导入模板下载/导入模板";
StringBuilder descBuilder = new StringBuilder()
.append("模板说明:")
.append("\n")
.append("1:条款号,条款名称,条款内容不能为空")
.append("\n")
.append("2:将附件存放在zip格式的文件夹中,名称与后缀输入于附件中即可")
.append("\n")
.append("3:图片格式格式为jpg")
.append("\n");
//生成模板
CommonExportUtil.exportTemplate(fileName,headers,descBuilder.toString(), response,request);
}catch (Exception e){
throw new AdcDaBaseException("下载文件失败,请重试");
}
}
} }
@@ -1,12 +1,14 @@
package com.adc.da.slrs.standardSplit.dto; package com.adc.da.slrs.standardSplit.dto;
import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/** /**
* @Description: * @Description:
* @Author: yangxuenan * @Author: yangxuenan
* date: 2020/5/9 14:40 * date: 2020/5/9 14:40
*/ */
@Data
public class SarFileSplitItemsImportDto { public class SarFileSplitItemsImportDto {
@Excel(name = "条款号", orderNum = "1") @Excel(name = "条款号", orderNum = "1")
private String itemsNum; private String itemsNum;
@@ -14,32 +16,35 @@ public class SarFileSplitItemsImportDto {
@Excel(name = "条款名称", orderNum = "1") @Excel(name = "条款名称", orderNum = "1")
private String itemsName; private String itemsName;
@Excel(name = "内容简介", orderNum = "1") @Excel(name = "条款附件", orderNum = "1")
private String itermsConditions; private String itermsConditions;
@Excel(name = "责任部门", orderNum = "1") // @Excel(name = "责任部门", orderNum = "1")
private String responsibleUnit; // private String responsibleUnit;
@Excel(name = "条款内容", orderNum = "1")
private String mag;
// @Excel(name = "责任部门", orderNum = "1") // @Excel(name = "责任部门", orderNum = "1")
private String newcarPutTime; // private String newcarPutTime;
@Excel(name = "FO", orderNum = "1") // @Excel(name = "FO", orderNum = "1")
private String fo; // private String fo;
@Excel(name = "责任工程师", orderNum = "1") // @Excel(name = "责任工程师", orderNum = "1")
private String dutyEngineer; // private String dutyEngineer;
//
// @Excel(name = "SVPPS", orderNum = "1")
// private String svpps;
@Excel(name = "SVPPS", orderNum = "1") // @Excel(name = "适用车辆类型", orderNum = "1")
private String svpps; // private String applyArctic;
//
@Excel(name = "适用车辆类型", orderNum = "1") // @Excel(name = "要求类型", orderNum = "1")
private String applyArctic; // private String claimType;
//
@Excel(name = "要求类型", orderNum = "1") // @Excel(name = "企标覆盖关系", orderNum = "1")
private String claimType; // private String busStandCover;
@Excel(name = "企标覆盖关系", orderNum = "1")
private String busStandCover;
@@ -56,93 +61,4 @@ public class SarFileSplitItemsImportDto {
// private String relevanceFile; // private String relevanceFile;
// //
// private String relevanceFileName; // private String relevanceFileName;
public String getItemsNum() {
return itemsNum;
}
public void setItemsNum(String itemsNum) {
this.itemsNum = itemsNum;
}
public String getItemsName() {
return itemsName;
}
public void setItemsName(String itemsName) {
this.itemsName = itemsName;
}
public String getItermsConditions() {
return itermsConditions;
}
public void setItermsConditions(String itermsConditions) {
this.itermsConditions = itermsConditions;
}
public String getResponsibleUnit() {
return responsibleUnit;
}
public void setResponsibleUnit(String responsibleUnit) {
this.responsibleUnit = responsibleUnit;
}
public String getNewcarPutTime() {
return newcarPutTime;
}
public void setNewcarPutTime(String newcarPutTime) {
this.newcarPutTime = newcarPutTime;
}
public String getFo() {
return fo;
}
public void setFo(String fo) {
this.fo = fo;
}
public String getDutyEngineer() {
return dutyEngineer;
}
public void setDutyEngineer(String dutyEngineer) {
this.dutyEngineer = dutyEngineer;
}
public String getSvpps() {
return svpps;
}
public void setSvpps(String svpps) {
this.svpps = svpps;
}
public String getApplyArctic() {
return applyArctic;
}
public void setApplyArctic(String applyArctic) {
this.applyArctic = applyArctic;
}
public String getClaimType() {
return claimType;
}
public void setClaimType(String claimType) {
this.claimType = claimType;
}
public String getBusStandCover() {
return busStandCover;
}
public void setBusStandCover(String busStandCover) {
this.busStandCover = busStandCover;
}
} }
@@ -15,10 +15,11 @@ import com.adc.da.common.ReadWordTable;
import com.adc.da.slrs.standardSplit.entity.*; import com.adc.da.slrs.standardSplit.entity.*;
import com.adc.da.slrs.standardSplit.service.SarFileSplitInfoEOService; import com.adc.da.slrs.standardSplit.service.SarFileSplitInfoEOService;
import com.adc.da.sys.common.SelectionResult; import com.adc.da.sys.common.SelectionResult;
import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.sys.entity.DicTypeEO;
import com.adc.da.sys.service.IDicTypeEOService;
import com.adc.da.sys.util.LoginUserUtil; import com.adc.da.sys.util.LoginUserUtil;
import com.adc.da.sys.util.UUIDUtils; import com.adc.da.sys.util.UUIDUtils;
import com.adc.da.utils.util.InitStandAttrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
@@ -37,7 +38,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.adc.da.common.SplitFilePragraTypeEnum; import com.adc.da.common.SplitFilePragraTypeEnum;
@@ -94,6 +94,10 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
private SarFileSplitItemsParamsEODao sarFileSplitItemsParamsEODao; private SarFileSplitItemsParamsEODao sarFileSplitItemsParamsEODao;
@Autowired @Autowired
private SarFileSplitInfoEODao dao; private SarFileSplitInfoEODao dao;
@Autowired
private DicTypeEODao dicTypeEODao;
@Autowired
private IDicTypeEOService dicTypeEOService;
@Override @Override
public List<SarFileSplitInfoEO> queryByPage(BasePage page) throws Exception{ public List<SarFileSplitInfoEO> queryByPage(BasePage page) throws Exception{
@@ -184,8 +188,9 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
String regex = "^[0-9]*$"; String regex = "^[0-9]*$";
for (IBodyElement element : elements) { for (IBodyElement element : elements) {
// 段落 // 段落
XWPFParagraph p = null;
if (element instanceof XWPFParagraph) { if (element instanceof XWPFParagraph) {
XWPFParagraph p = (XWPFParagraph)element; p = (XWPFParagraph)element;
// 处理段落生成编号不识别问题 // 处理段落生成编号不识别问题
String paragraphString = p.getText(); String paragraphString = p.getText();
@@ -660,8 +665,36 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
} }
private void addItermsConditionsOfTable(SarFileSplitItemsEO message, List<SarFileSplitItemsValEO> itemsValList, XWPFTable table) throws IOException { private void addItermsConditionsOfTable(SarFileSplitItemsEO message, List<SarFileSplitItemsValEO> itemsValList, XWPFTable table) throws IOException {
StringBuffer buffer = new StringBuffer();
StringBuilder tabaleStringNew = new StringBuilder(""); StringBuilder tabaleStringNew = new StringBuilder("");
//将表格转为html字符串 //将表格转为html字符串
int numberOfRows = table.getNumberOfRows();
for (int i = 0; i <numberOfRows ; i++) {
List<XWPFTableCell> tableCells = table.getRow(i).getTableCells();
for (int j = 0; j <tableCells.size() ; j++) {
List<XWPFParagraph> paragraphs = tableCells.get(j).getParagraphs();
for (XWPFParagraph data : paragraphs){
for (XWPFRun xwrun : data.getRuns()) {
VerticalAlign subscript = xwrun.getSubscript();
String smalltext = xwrun.getText(0);
if (ObjectUtils.isNotEmpty(smalltext)) {
switch (subscript) {
case BASELINE:
xwrun.setText(smalltext);
break;
case SUBSCRIPT:
xwrun.setText("<span class=sub>" + smalltext + "</span>");
break;
case SUPERSCRIPT:
xwrun.setText("<span class=sup>" + smalltext + "</span>");
break;
}
}
}
}
}
}
ReadWordTable readWordTable = new ReadWordTable(); ReadWordTable readWordTable = new ReadWordTable();
String tableStr = readWordTable.readTable(table); String tableStr = readWordTable.readTable(table);
tabaleStringNew.append(tableStr); tabaleStringNew.append(tableStr);
@@ -709,6 +742,13 @@ public class SarFileSplitInfoEOServiceImpl implements SarFileSplitInfoEOService
// } // }
} }
} }
for (SarFileSplitInfoEO data : rows){
List<DicTypeEO> dicTypeEO = dicTypeEODao.selectPidByCode(data.getFileType());
if(dicTypeEO!=null){
data.setFileTypeShow(dicTypeEO.get(0).getDicTypeName());
}
}
return rows; return rows;
} }
@@ -71,6 +71,9 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
@Autowired @Autowired
private SarFileSplitInfoEOService sarFileSplitInfoEOService; private SarFileSplitInfoEOService sarFileSplitInfoEOService;
@Value("${elasticsearch.img}")
private String elasticsearchImg;//图片拆分自调地址
@Override @Override
public Map<String, Object> getByPage(SarFileSplitItemsEOPage page) { public Map<String, Object> getByPage(SarFileSplitItemsEOPage page) {
@@ -468,7 +471,6 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
}else { }else {
infoId = UUIDUtils.randomUUID20(); infoId = UUIDUtils.randomUUID20();
} }
//验证导入数据是否符合规则
Map map = validateImportDatas(list,filepath); Map map = validateImportDatas(list,filepath);
boolean isOk = (boolean) map.get("result"); boolean isOk = (boolean) map.get("result");
if (!isOk) { if (!isOk) {
@@ -532,10 +534,11 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
AttFileVo attFileVo = attFileEOService.saveFileInfo(nowfilelist.get(0)); AttFileVo attFileVo = attFileEOService.saveFileInfo(nowfilelist.get(0));
if (attFileVo != null) { if (attFileVo != null) {
isText = false; isText = false;
String path = "file" + attFileVo.getFilePath()+attFileVo.getFileName(); //String path = "E:/data/slrs/file" + attFileVo.getFilePath()+attFileVo.getOldFileName();
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>"; String pathSrc = elasticsearchImg + "/api/att/attFile/getFileInfo?fileId=" + attFileVo.getId();
String imgCon = "<img class=\'wordImg\' src=\'" + pathSrc + "\'>";
valEO.setType("IMG"); valEO.setType("IMG");
valEO.setItemContent(imgCon); valEO.setItemContent(imgCon + "<p>" + importDto.getMag() + "<p>");
} }
} }
if (isText) { if (isText) {
@@ -566,10 +569,11 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
AttFileVo attFileVo = attFileEOService.saveFileInfo(nowfilelist.get(0)); AttFileVo attFileVo = attFileEOService.saveFileInfo(nowfilelist.get(0));
if (attFileVo != null) { if (attFileVo != null) {
isText = false; isText = false;
String path = "file" + attFileVo.getFilePath()+attFileVo.getFileName(); //String path = "E:/data/slrs/file" + attFileVo.getFilePath()+attFileVo.getOldFileName();
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>"; String pathSrc = elasticsearchImg + "/api/att/attFile/getFileInfo?fileId=" + attFileVo.getId();
String imgCon = "<img class=\'wordImg\' src=\'" + pathSrc + "\'>";
valEO.setType("IMG"); valEO.setType("IMG");
valEO.setItemContent(imgCon); valEO.setItemContent(imgCon + "<p>" + importDto.getMag() + "<p>");
} }
} }
if (isText) { if (isText) {
@@ -602,10 +606,11 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
AttFileVo attFileVo = attFileEOService.saveFileInfo(nowfilelist.get(0)); AttFileVo attFileVo = attFileEOService.saveFileInfo(nowfilelist.get(0));
if (attFileVo != null) { if (attFileVo != null) {
isText = false; isText = false;
String path = "file" + attFileVo.getFilePath()+attFileVo.getFileName(); //String path = "E:/data/slrs/file" + attFileVo.getFilePath()+attFileVo.getOldFileName();
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>"; String pathSrc = elasticsearchImg + "/api/att/attFile/getFileInfo?fileId=" + attFileVo.getId();
String imgCon = "<img class=\'wordImg\' src=\'" + pathSrc + "\'>";
valEO.setType("IMG"); valEO.setType("IMG");
valEO.setItemContent(imgCon); valEO.setItemContent(imgCon + "<p>" + importDto.getMag() + "<p>");
} }
} }
if (isText) { if (isText) {
@@ -629,6 +634,7 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
sarFileSplitInfoEO.setValidFlag(0); sarFileSplitInfoEO.setValidFlag(0);
sarFileSplitInfoEO.setResult("1"); sarFileSplitInfoEO.setResult("1");
sarFileSplitInfoEO.setModifyUser(LoginUserUtil.getUserId()); sarFileSplitInfoEO.setModifyUser(LoginUserUtil.getUserId());
sarFileSplitInfoEO.setStandId(sarFileSplitInfoEO.getStandId());
sarFileSplitInfoEOService.insertSelective(sarFileSplitInfoEO); sarFileSplitInfoEOService.insertSelective(sarFileSplitInfoEO);
} }
@@ -640,6 +646,14 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
menuPidMap.put("总目录",menuid ); menuPidMap.put("总目录",menuid );
} }
for (SarFileSplitItemsEO itemsEO : addItemsEOList) { for (SarFileSplitItemsEO itemsEO : addItemsEOList) {
List<SarFileSplitItemsValEO> itemValEOList = itemsEO.getItemValEOList();
if(itemValEOList!=null){
String tupian = "";
for (SarFileSplitItemsValEO data : itemValEOList){
tupian = tupian+data.getItemContent();
}
itemsEO.setItermsConditions(tupian);
}
String menuIdT = createItemsInfo(itemsEO,infoId,countSuccess,menuPidMap); String menuIdT = createItemsInfo(itemsEO,infoId,countSuccess,menuPidMap);
menuPidMap.put(itemsEO.getItemsNum(),menuIdT); menuPidMap.put(itemsEO.getItemsNum(),menuIdT);
countSuccess++; countSuccess++;
@@ -724,6 +738,11 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
int num = 0; //记录是第几条数据 int num = 0; //记录是第几条数据
//循环验证数据 //循环验证数据
for (SarFileSplitItemsImportDto dto : datas) { for (SarFileSplitItemsImportDto dto : datas) {
if(dto.getItemsNum().contains("模板说明")){
continue;
}
i++; i++;
int countError = 0; //记录失败数据数量 int countError = 0; //记录失败数据数量
DicTypeEO dic = new DicTypeEO(); DicTypeEO dic = new DicTypeEO();
@@ -755,148 +774,151 @@ public class SarFileSplitItemsEOServiceImpl implements SarFileSplitItemsEOServic
countError++; countError++;
} }
} }
String saveApplyCode = ""; // String saveApplyCode = "";
if (StringUtils.isNotEmpty(dto.getApplyArctic())) { // if (StringUtils.isNotEmpty(dto.getApplyArctic())) {
dto.setApplyArctic(dto.getApplyArctic().replace("", ",")); // dto.setApplyArctic(dto.getApplyArctic().replace("", ","));
String applys[] = dto.getApplyArctic().split(","); // String applys[] = dto.getApplyArctic().split(",");
if(applys.length>20){ // if(applys.length>20){
errorMsg += "适用车型选项不能超过20个;"; // errorMsg += "适用车型选项不能超过20个;";
countError++; // countError++;
} else if (dto.getApplyArctic().length() > 500) { // } else if (dto.getApplyArctic().length() > 500) {
errorMsg += "适用车型不能超过500个字符;"; // errorMsg += "适用车型不能超过500个字符;";
// countError++;
// } else {
// Set set = new HashSet();
// for (int a = 0; a < applys.length; a++) {
// dic.setDicTypeName(applys[a]);
// dic.setDicTypeCode("ENERGYTYPES");
// getDic = dicTypeEODao.getDicTypeByDicTypeName(dic);
// if (getDic.size() == 1) {
// saveApplyCode += getDic.get(0).getDicTypeCode() + ",";
// } else if (getDic.size() > 0) {
// errorMsg += "适用车型" + applys[a] + "不明确;";
// countError++;
// break;
// } else {
// errorMsg += "适用车型" + applys[a] + "不存在;";
// countError++;
// break;
// }
// set.add(applys[a]);
// if (a==applys.length-1 && applys.length != set.size()){
// errorMsg += "适用车型存在重复数据;";
// countError++;
// }
// }
// if (!saveApplyCode.equals("")){
// dto.setApplyArctic(saveApplyCode.substring(0,saveApplyCode.length()-1));
// }
// }
// }
// if(!claimStypelist.contains(dto.getClaimType())) {
// if (StringUtils.isNotEmpty(dto.getClaimType())) {
// dic.setDicTypeName(dto.getClaimType());
// dic.setDicTypeCode("REQUESTTYPE");
// if (dto.getClaimType().length() > 500) {
// errorMsg += "要求类型不能超过500个字符;";
// countError++;
// } else {
// getDic = dicTypeEODao.getDicTypeByDicTypeName(dic);
// Set set = new HashSet();
// if (getDic != null) {
// if (getDic.size() == 1) {
// dto.setClaimType(getDic.get(0).getDicTypeCode());
// claimStypelist.add(getDic.get(0).getDicTypeCode());
// } else if (getDic.size() > 0) {
// errorMsg += "要求类型不明确;";
// countError++;
// } else {
// errorMsg += "要求类型不存在;";
// countError++;
// }
// } else {
// errorMsg += "要求类型不存在;";
// countError++;
// }
// }
// }
// }
if (StringUtils.isEmpty(dto.getMag())) {
errorMsg += "条款内容不能为空;";
countError++; countError++;
} else { } else {
Set set = new HashSet(); if(dto.getMag().length() > 50000){
for (int a = 0; a < applys.length; a++) { errorMsg += "条款内容不能超过50000个字符;";
dic.setDicTypeName(applys[a]);
dic.setDicTypeCode("ENERGYTYPES");
getDic = dicTypeEODao.getDicTypeByDicTypeName(dic);
if (getDic.size() == 1) {
saveApplyCode += getDic.get(0).getDicTypeCode() + ",";
} else if (getDic.size() > 0) {
errorMsg += "适用车型" + applys[a] + "不明确;";
countError++;
break;
} else {
errorMsg += "适用车型" + applys[a] + "不存在;";
countError++;
break;
}
set.add(applys[a]);
if (a==applys.length-1 && applys.length != set.size()){
errorMsg += "适用车型存在重复数据;";
countError++; countError++;
} }
} }
if (!saveApplyCode.equals("")){ // if(!foList.contains(dto.getFo())) {
dto.setApplyArctic(saveApplyCode.substring(0,saveApplyCode.length()-1)); // if (StringUtils.isNotEmpty(dto.getFo())) {
} // if (dto.getFo().length() > 200) {
} // errorMsg += "FO不能超过200个字符;";
} // countError++;
if(!claimStypelist.contains(dto.getClaimType())) { // } else {
if (StringUtils.isNotEmpty(dto.getClaimType())) { // String uname = roleEODao.getIdsByNames(dto.getFo().split(","));
dic.setDicTypeName(dto.getClaimType()); // if (StringUtils.isNotBlank(uname)) {
dic.setDicTypeCode("REQUESTTYPE"); // dto.setFo(uname);
if (dto.getClaimType().length() > 500) { // foList.addAll(Arrays.asList(uname.split(",")));
errorMsg += "要求类型不能超过500个字符;"; // } else {
countError++; // errorMsg += "FO不存在;";
} else { // countError++;
getDic = dicTypeEODao.getDicTypeByDicTypeName(dic); // }
Set set = new HashSet(); // }
if (getDic != null) { // }
if (getDic.size() == 1) { // }
dto.setClaimType(getDic.get(0).getDicTypeCode()); // if(!dutyEngineerList.contains(dto.getDutyEngineer())) {
claimStypelist.add(getDic.get(0).getDicTypeCode()); // if (StringUtils.isNotEmpty(dto.getDutyEngineer())) {
} else if (getDic.size() > 0) { // if (dto.getDutyEngineer().length() > 100) {
errorMsg += "要求类型不明确;"; // errorMsg += "责任工程师不能超过100个字符;";
countError++; // countError++;
} else { // } else {
errorMsg += "要求类型不存在;"; // String emList = roleEODao.getIdsByNames(dto.getDutyEngineer().split(","));
countError++; // if (StringUtils.isNotBlank(emList)) {
} // dto.setDutyEngineer(emList);
} else { // dutyEngineerList.addAll(Arrays.asList(dto.getDutyEngineer().split(",")));
errorMsg += "要求类型不存在;"; // } else {
countError++; // errorMsg += "系统中没有用户:" + dto.getDutyEngineer();
} // countError++;
} // }
} // }
} // }
if(StringUtils.isNotEmpty(dto.getItermsConditions())){ // }
if(dto.getItermsConditions().length() > 50000){ // if(StringUtils.isNotEmpty(dto.getSvpps())){
errorMsg += "内容简介不能超过50000个字符;"; // if(dto.getSvpps().length() > 200){
countError++; // errorMsg += "SVPPS不能超过200个字符;";
} // countError++;
} // }else {
if(!foList.contains(dto.getFo())) { // String svppsShow = sysInfoEOService.getSvppsIdByName(dto.getSvpps());
if (StringUtils.isNotEmpty(dto.getFo())) { // dto.setSvpps(svppsShow);
if (dto.getFo().length() > 200) { // }
errorMsg += "FO不能超过200个字符;"; // }
countError++; // if(StringUtils.isNotEmpty(dto.getBusStandCover())){
} else { // if(dto.getBusStandCover().length() > 200){
String uname = roleEODao.getIdsByNames(dto.getFo().split(",")); // errorMsg += "企标覆盖关系不能超过200个字符;";
if (StringUtils.isNotBlank(uname)) { // countError++;
dto.setFo(uname); // }else {
foList.addAll(Arrays.asList(uname.split(","))); // List<DicTypeEO> getDicType = dicTypeEODao.getDicTypeByDicCode("BZFGGXOUIUJ");
} else { // for (DicTypeEO dicTypeEO:getDicType) {
errorMsg += "FO不存在;"; // if (dicTypeEO.getDicTypeName().equals(dto.getBusStandCover())){
countError++; // dto.setBusStandCover(dicTypeEO.getDicTypeCode());
} // }
} // }
} // }
} // }
if(!dutyEngineerList.contains(dto.getDutyEngineer())) { // if(StringUtils.isNotBlank(dto.getResponsibleUnit())){
if (StringUtils.isNotEmpty(dto.getDutyEngineer())) { // if(dto.getResponsibleUnit().length() > 100){
if (dto.getDutyEngineer().length() > 100) { // errorMsg += "责任部门不能超过100个字符;";
errorMsg += "责任工程师不能超过100个字符;"; // countError++;
countError++; // }else {
} else { // String id = sysInfoEOService.getOrgIdByName(dto.getResponsibleUnit(),"DEPART");
String emList = roleEODao.getIdsByNames(dto.getDutyEngineer().split(",")); // if(StringUtils.isNotBlank(id)){
if (StringUtils.isNotBlank(emList)) { // dto.setResponsibleUnit(id);
dto.setDutyEngineer(emList); // } else {
dutyEngineerList.addAll(Arrays.asList(dto.getDutyEngineer().split(","))); // errorMsg += "系统中没有部门"+dto.getResponsibleUnit();
} else { // countError++;
errorMsg += "系统中没有用户:" + dto.getDutyEngineer(); // }
countError++; // }
} // }
}
}
}
if(StringUtils.isNotEmpty(dto.getSvpps())){
if(dto.getSvpps().length() > 200){
errorMsg += "SVPPS不能超过200个字符;";
countError++;
}else {
String svppsShow = sysInfoEOService.getSvppsIdByName(dto.getSvpps());
dto.setSvpps(svppsShow);
}
}
if(StringUtils.isNotEmpty(dto.getBusStandCover())){
if(dto.getBusStandCover().length() > 200){
errorMsg += "企标覆盖关系不能超过200个字符;";
countError++;
}else {
List<DicTypeEO> getDicType = dicTypeEODao.getDicTypeByDicCode("BZFGGXOUIUJ");
for (DicTypeEO dicTypeEO:getDicType) {
if (dicTypeEO.getDicTypeName().equals(dto.getBusStandCover())){
dto.setBusStandCover(dicTypeEO.getDicTypeCode());
}
}
}
}
if(StringUtils.isNotBlank(dto.getResponsibleUnit())){
if(dto.getResponsibleUnit().length() > 100){
errorMsg += "责任部门不能超过100个字符;";
countError++;
}else {
String id = sysInfoEOService.getOrgIdByName(dto.getResponsibleUnit(),"DEPART");
if(StringUtils.isNotBlank(id)){
dto.setResponsibleUnit(id);
} else {
errorMsg += "系统中没有部门"+dto.getResponsibleUnit();
countError++;
}
}
}
if (countError > 0) { if (countError > 0) {
stringMessage.add(errorMsg); stringMessage.add(errorMsg);
} }
@@ -68,6 +68,18 @@ public class FieldConvertUtil {
"在产车实施日期(项目),EOP实施日期(项目),实施说明,认证交付物,认证对象,监管类型,适用车辆类型,责任部门,相关部门,FO,项目评估角色," + "在产车实施日期(项目),EOP实施日期(项目),实施说明,认证交付物,认证对象,监管类型,适用车辆类型,责任部门,相关部门,FO,项目评估角色," +
"文本说明,标签,要求类型,清单类型,入库模块"; "文本说明,标签,要求类型,清单类型,入库模块";
public static String exportName = "填写说明\n" +
"1.导入数据从第三行开始,第一行为填写说明,第二行为表头,第三行是正式数据\n" +
"2.所有带*号的字段必须填写\n" +
"3.企标类别(例如:BZJ、FT、Q-HD、Q-IOUM、Q/ASB、Q/BFC、Q/BQB等),文本状态(包含:发布、被代替、参考、即将实施、有效、直接上传、作废、待修订-指的其他企业标准),采用标准(包含:IDT等同采用、NEQ非等效采用、MOD修改采用)字段是单选属性,必须和系统中的对应字段选项相匹配\n" +
"4.适用车型,能源类型,适用产品线字段是多选属性,必须和系统中的对应字段选项相匹配,填写多个时采用英文逗号分割\n" +
"5.发布日期,企标实施日期字段为年-月-日格式,必须精确到日,例如(2023-04-01)\n" +
"6.企标编号,企标名称,企标英文名称字段为文本,填写文本内容\n" +
"7.关联模块-乘用车VPPS编码和关联模块--卡车VPPS编码是填写数据库中已有的编码从而带出乘用车VPPS名称和卡车VPPS名称\n" +
"8.发布稿,编制说明,历史版本,其他文件,修改单,关联文件为附件文件,需要放在Excel文档同级目录中";
public static String exportFieldName = "*企标类别,企标编号,*标准年份,*企标名称,企标英文名称,*文本状态,发布日期,企标实施日期,起草部门,起草人,适用车型,能源类型,适用产品线,体系类别,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿,编制说明,历史版本,其他文件,修改单,代替企标编号,采用标准,采标程度,引用标准,关联文件,";
/*** /***
* @Description: Clob类型 转String * @Description: Clob类型 转String
* @Author: super_liu * @Author: super_liu
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.slrs.StandardQA.dao.SarAgenldAcceptButtonDao">
</mapper>
@@ -1956,5 +1956,14 @@
</if> </if>
</select> </select>
<!-- 分页查询-->
<select id="queryByPage" resultMap="BaseResultMap"
parameterType="com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage">
SELECT
<include refid="Base_Column_List_DIS"/>
from SAR_STANDARDS_INFO
limit ${page.pager.startIndex-1},${page.pageSize}
</select>
</mapper> </mapper>
@@ -0,0 +1,269 @@
package com.adc.da.att.util;
import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.utils.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author liyawei
* @Create 2021/7/26
*/
public class CommonExportUtil {
private static final Logger logger = LoggerFactory.getLogger(CommonExportUtil.class);
/**
* 导出excel
* @param columnList 数据库字段名集合
* @param headerList 导出表头集合
* @param datalist
* @param response
* @param request
* @param exportName
* @param tableName
* @throws Exception
*/
public static void exportExcel(List<String> columnList, List<String> headerList, List<Map<String,Object>> datalist, HttpServletResponse response, HttpServletRequest request,
String exportName, String tableName) throws Exception{
final OutputStream os = response.getOutputStream(); // 获得ServletOutputStream对象
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
//response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(exportName+".xlsx", "UTF-8") + ';');
response.setHeader("Content-Disposition",
"attachment; filename=" + ReadExcel.encodeFileName(exportName+".xlsx", request));
//导出excel
copyrightContractCount(columnList ,headerList ,datalist ,os ,tableName);
}
/**
*
* @param fileName 文件名
* @param headers 表头
* @param desc 填写说明
* @param response
* @param request
* @throws Exception
*/
public static void exportTemplate(String fileName , String[] headers , String desc, HttpServletResponse response, HttpServletRequest request) throws Exception {
// 声明一个工作薄
XSSFWorkbook workbook = new XSSFWorkbook();
// 生成一个表格
XSSFSheet sheet = workbook.createSheet();
//设置表格样式
XSSFCellStyle cellStyle = (XSSFCellStyle) generateCommonCellStyle(workbook,true);
OutputStream os = response.getOutputStream();
try{
// 设置表格默认列宽度为15个字节
//sheet.setDefaultColumnWidth((short) 18);
XSSFRow row = sheet.createRow(0);
for (short i = 0; i < headers.length; i++) {
XSSFCell cell = row.createCell(i);
XSSFRichTextString text = new XSSFRichTextString(headers[i]);
cell.setCellValue(text);
cell.setCellStyle(cellStyle);
}
// 如果填写说明存在,则创建
if (StringUtils.isNotEmpty(desc)){
XSSFRow descRow = sheet.createRow(1);
descRow.setHeightInPoints(80.0F);
XSSFCell descCell = descRow.createCell(0);
descCell.setCellValue(desc);
descCell.setCellStyle(generateDescCellStyle(workbook,true));
CellRangeAddress region = new CellRangeAddress(1, 1,0,headers.length);
sheet.addMergedRegion(region);
}
response.setCharacterEncoding("UTF-8");
// response.setContentType("application/force-download");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition",
"attachment; filename=" + ReadExcel.encodeFileName(fileName+".xlsx", request));
response.flushBuffer();
workbook.write(os);
} catch (IOException e) {
logger.error("发生异常,异常信息为:"+e.getMessage(), e);
throw new AdcDaBaseException("下载文件失败,请重试");
}finally {
workbook.close();
IOUtils.closeQuietly(os);
}
}
/**
* 导出excel
* @param columnList
* @param headerList
* @param dataList
* @param os
* @param tableName
* @throws Exception
*/
public static void copyrightContractCount(List columnList,List headerList,List dataList ,OutputStream os,String tableName) throws Exception{
try{
Workbook workbook = new XSSFWorkbook();
//产生通用单元格样式
CellStyle style = generateCommonCellStyle(workbook,false);
//创建sheet表单,同时写入标题
CellStyle titleStyle = generateCommonCellStyle(workbook,true);
Sheet sheet = generateSheet(workbook, tableName, columnList, titleStyle);
//写入标题行
writeColumnName(sheet ,headerList ,titleStyle);
//写入数据行
writeDataRow(sheet, columnList, dataList, style);
//输入excel文件
workbook.write(os);
os.close();
//os.flush();
if (workbook != null) {
workbook.close();
}
} catch (IOException e) {
logger.error("发生异常,异常信息为:"+e.getMessage(), e);
throw new AdcDaBaseException("下载文件失败,请重试");
}finally {
IOUtils.closeQuietly(os);
}
}
/**
* 表格导入数据
* @param sheet
* @param columnList
* @param dataList
* @param style
*/
public static void writeDataRow(Sheet sheet, List columnList, List<Map<String,Object>> dataList, CellStyle style){
//columnList 列数
int rowIndex = 2;
for(int i = 0 ; i<dataList.size() ;i++) {
//创建一行
Row dataRow = sheet.createRow(rowIndex++);
//获取该行数据
Map<String,Object> rowDataMap = dataList.get(i);
if (columnList != null && columnList.size() > 0) {
for (int j = 0; j < columnList.size() ;j++) {
//创建单元格
Cell dataCell = dataRow.createCell(j);
//设置单元格样式
dataCell.setCellStyle(style);
//从数据map中获取对应列的数据
if(rowDataMap.get(columnList.get(j)) == null){
continue;
}
String value = String.valueOf(rowDataMap.get(columnList.get(j)));
//将数据写入单元格
dataCell.setCellValue(value);
}
}
}
}
/**
* 第二行设置导出的列名
* @param sheet
* @param headerList
* @param style
*/
public static void writeColumnName(Sheet sheet , List<String> headerList , CellStyle style){
Row titleRow = sheet.createRow(1);
int index = 0;
for(int i = 0;i < headerList.size();i ++){
Cell titleCell = titleRow.createCell(index);
titleCell.setCellStyle(style);
titleCell.setCellValue(headerList.get(i));
index ++;
}
}
/**
* 创建sheet表单,第一行合并单元格设置表格名
* @param workbook
* @param tableName
* @param columnList
* @param style
* @return
*/
public static Sheet generateSheet(Workbook workbook, String tableName, List columnList, CellStyle style){
//创建sheet表单
Sheet sheet = workbook.createSheet(tableName);
//在表单中创建一行
Row tableRow = sheet.createRow(0);
//在行中创建单元格
for(int i = 0;i < columnList.size();i ++){
Cell cell = tableRow.createCell(i);
cell.setCellStyle(style);
}
//获取第一个单元格
Cell tableCell = tableRow.getCell(0);
//给第一个单元格添加数据
tableCell.setCellValue(tableName);
//合并单元格
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, columnList.size()-1));
return sheet;
}
/**
* 设置单元格样式
* @param workbook
* @return
*/
public static CellStyle generateCommonCellStyle(Workbook workbook, boolean isBold){
//设置表格样式
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
cellStyle.setBorderLeft(BorderStyle.THIN); //左边框
cellStyle.setBorderRight(BorderStyle.THIN); //右边框
cellStyle.setBorderTop(BorderStyle.THIN); //上边框
cellStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 上下居中
cellStyle.setWrapText(true); // 设置自动换行
Font headerFont = getFont(workbook, (short) 10,isBold); // 创建字体样式
cellStyle.setFont(headerFont); // 为标题样式设置字体样式
return cellStyle;
}
/**
* 设置填写说明样式
* @param workbook
* @return
*/
public static CellStyle generateDescCellStyle(Workbook workbook, boolean isBold){
//设置表格样式
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 上下居中
cellStyle.setWrapText(true); // 设置自动换行
Font headerFont = getFont(workbook, (short) 10,isBold); // 创建字体样式
cellStyle.setFont(headerFont); // 为标题样式设置字体样式
return cellStyle;
}
public static Font getFont(Workbook workbook, short size, boolean isBold) {
Font font = workbook.createFont();
font.setFontName("宋体"); // 字体样式
font.setBold(isBold); // 是否加粗
font.setFontHeightInPoints(size); // 字体大小
return font;
}
}
@@ -0,0 +1,175 @@
package com.adc.da.att.util;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
/**
* @des : excel信息读取
* @author: duyunbao
* @email: 1114808306@qq.com
* @date 2017/10/27 17:06
**/
public class ReadExcel {
private static final Logger logger = LoggerFactory.getLogger(ReadExcel.class);
/**
* 总行数
*/
private int totalRows = 0;
/**
* 总条数
*/
private int totalCells = 0;
/**
* 错误信息接收器
*/
private String errorMsg;
public ReadExcel() {
// 不做操作
}
public int getTotalRows() {
return totalRows;
}
public int getTotalCells() {
return totalCells;
}
public String getErrorInfo() {//获取错误信息
return errorMsg;
}
/**
* @method_name: validateExcel
* @des : 验证excel格式
* @author: duyunbao
* @param: [filePath]
* @return: boolean
* @date: 2017/10/27 17:07
**/
public boolean validateExcel(String filePath) {
if (filePath == null || !(WDWUtil.isExcel2003(filePath) || WDWUtil.isExcel2007(filePath))) {
errorMsg = "文件名不是excel格式";
return false;
}
return true;
}
/**
* @method_name: getExcelInfo
* @des : 读EXCEL文件,获取信息集合
* @author: duyunbao
* @param: [fileName, Mfile]
* @return: org.apache.poi.ss.usermodel.Workbook
* @date: 2017/10/27 17:08
**/
public Workbook getExcelInfo(String fileName, MultipartFile Mfile) {
Workbook wb = null;
//把spring文件上传的MultipartFile转换成CommonsMultipartFile类型
CommonsMultipartFile cf = (CommonsMultipartFile) Mfile; //获取本地存储路径
//初始化输入流
InputStream is = null;
try {
//根据文件名判断文件是2003版本还是2007版本
boolean isExcel2003 = true;
if (WDWUtil.isExcel2007(fileName)) {
isExcel2003 = false;
}
is = cf.getInputStream();
//根据excel里面的内容读取客户信息
wb = getExcelInfo(is, isExcel2003, wb);
is.close();
} catch (Exception e) {
logger.error(e.getMessage(),e);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
is = null;
logger.error(e.getMessage(),e);
}
}
}
return wb;
}
/***
* @method_name: getExcelInfo
* @des : 判断excel版本
* @author: duyunbao
* @param: [is, isExcel2003, wb]
* @return: org.apache.poi.ss.usermodel.Workbook
* @date: 2017/10/27 17:08
**/
private Workbook getExcelInfo(InputStream is, boolean isExcel2003, Workbook wb) {
Workbook workbook =wb;
try {
/** 根据版本选择创建Workbook的方式 */
//当excel是2003时
if (isExcel2003) {
workbook = new HSSFWorkbook(is);
} else {//当excel是2007时
workbook = new XSSFWorkbook(is);
}
} catch (IOException e) {
logger.error(e.getMessage(),e);
}
return workbook;
}
/**
* 获取sheet的名称
* @MethodName:getSheetName
* @author: 马晓晨
* @email: 747052172@qq.com
* @date 2017年11月24日 上午9:49:22
* @version V1.0
* @param filename
* @param file
* @param sheetIndex
* @return
*/
public String getSheetName(String filename, MultipartFile file, Integer sheetIndex) {
Workbook wb = getExcelInfo(filename, file);
return wb.getSheetName(sheetIndex);
}
/**
*
* @Title: encodeFileName
* @Description: 导出文件转换文件名称编码
* @param @param fileNames
* @param @param request
* @param @return 设定文件
* @return String 返回类型
* @throws
*/
public static String encodeFileName(String fileNames , HttpServletRequest request) {
try {
String agent = request.getHeader("User-Agent");
if (agent.contains("Firefox")) {
fileNames = new String(fileNames.getBytes("UTF-8"), "ISO8859-1"); // firefox浏览器
} else {
fileNames = URLEncoder.encode(fileNames, "utf-8");
//谷歌中空格变为+问题
fileNames = fileNames.replaceAll("\\+","%20");
}
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
return fileNames ;
}
}
@@ -0,0 +1,164 @@
package com.adc.da.att.util;
import org.apache.commons.lang3.StringUtils;
import java.util.regex.Pattern;
/**
* @des : excel版本判断类
* @author: duyunbao
* @email: 1114808306@qq.com
* @date 2017/10/27 16:59
**/
public class WDWUtil {
/**
* @method_name: isExcel2003
* @des :是否是2003的excel,返回true是2003
* @author: duyunbao
* @param: [filePath]
* @return: boolean
* @date: 2017/10/27 16:57
**/
public static boolean isExcel2003(String filePath) {
return filePath.matches("^.+\\.(?i)(xls)$");
}
/**
* @method_name: isExcel2007
* @des : 是否是2007的excel,返回true是2007
* @author: duyunbao
* @param: [filePath]
* @return: boolean
* @date: 2017/10/27 16:57
**/
public static boolean isExcel2007(String filePath) {
return filePath.matches("^.+\\.(?i)(xlsx)$");
}
/**
* 判断字符串是否是整数
* @MethodName:isInteger
* @author: DuYunbao
* @date: 2018/5/22 18:00
*/
public static boolean isNumeric(String str){
for (int i = str.length();--i>=0;){
if (!Character.isDigit(str.charAt(i))){
return false;
}
}
return true;
}
/**方法二:推荐,速度最快
* 判断是否为整数
* @param str 传入的字符串
* @return 是整数返回true,否则返回false
*/
public static boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
/**
* 字母或数字
*
* @MethodName:isLetterDigitOrChinese
* @author: DuYunbao
* @date: 2018/5/30 15:26
*/
public static boolean isLetterOrNumber(String str) {
String regex = "^(\\d|[a-zA-Z])+$";
return !str.matches(regex);
}
/**
* 汉字、字母、()
*
* @MethodName:isLetterOrChineseOrChar1
* @author: DuYunbao
* @date: 2018/5/30 15:53
*/
public static boolean isLetterOrChineseOrChar1(String str) {
String regex = "[^\\a-\\z\\A-\\Z\\u4E00-\\u9FA5\\()\\()]";
return str.matches(regex);
}
/**
* 汉字、字母、数字
*
* @MethodName:isLetterOrChineseOrNumber
* @author: DuYunbao
* @date: 2018/5/30 15:56
*/
public static boolean isLetterOrChineseOrNumber(String str) {
String regex = "^[\\u4E00-\\u9FA5A-Za-z0-9]+$";
return !str.matches(regex);
}
/**
* 汉字、字母、()、-、下划线
*
* @MethodName:isChineseOrLetterOrUnderlineOrChar1
* @author: DuYunbao
* @date: 2018/5/30 16:03
*/
public static boolean isChineseOrLetterOrUnderlineOrChar1(String str) {
String regex = "^[\\u4E00-\\u9FA5A-Za-z_\\-\\()\\()]+$";
return !str.matches(regex);
}
/**
* 数字
*
* @MethodName:isNumbee
* @author: DuYunbao
* @date: 2018/5/30 16:09
*/
public static boolean isNumber(String str) {
String regex = "\\D";
return str.matches(regex);
}
/**
* 数字、大写字母、-
*
* @MethodName:isNumberOrLowerLetterOrChar1
* @author: DuYunbao
* @date: 2018/5/30 16:41
*/
public static boolean isNumberOrLowerLetterOrChar1(String str) {
String regex = "^[A-Z0-9\\-]+$";
return !str.matches(regex);
}
/**
* 汉字、数字、字母、()、-、下划线
*
* @MethodName:isChineseOrNumberOrLetterOrUnderlineOrChar
* @author: DuYunbao
* @date: 2018/5/30 16:45
*/
public static boolean isChineseOrNumberOrLetterOrUnderlineOrChar(String str) {
String regex = "^[\\u4E00-\\u9FA5A-Za-z0-9_\\-\\()\\()]+$";
return !str.matches(regex);
}
/**
* 去除整数含有小数点
* @MethodName:subStr
* @author: DuYunbao
* @date: 2018/5/31 11:19
*/
public static String subStr(String text) {
if (StringUtils.isNotEmpty(text)) {
if(text.contains(".0") && text.substring(text.length()-2,text.length()).equals(".0")) {
text = text.substring(0,text.length()-2);
}
}
return text;
}
}
@@ -85,4 +85,9 @@ public interface DicTypeEODao extends BaseMapper<DicTypeEO> {
*/ */
public List<DicTypeEO> getDicInfo(@Param("filed") String... filed); public List<DicTypeEO> getDicInfo(@Param("filed") String... filed);
String selectByPid(@Param("Info") String Info);
List<DicTypeEO> selectByPidInfo(@Param("pid") String pid);
List<DicTypeEO> selectPidByCode(@Param("fileType") String fileType);
} }
@@ -614,4 +614,30 @@
</select> </select>
<select id="selectByPid" resultType="java.lang.String">
SELECT
ID
FROM
ts_dictionary
WHERE
DICTIONARY_NAME = #{Info}
</select>
<select id="selectByPidInfo" resultType="com.adc.da.sys.entity.DicTypeEO">
SELECT
*
FROM
ts_dictype
WHERE
DIC_ID = #{pid}
</select>
<select id="selectPidByCode" resultType="com.adc.da.sys.entity.DicTypeEO">
SELECT
*
FROM
ts_dictype
WHERE
DIC_TYPE_CODE = #{fileType}
</select>
</mapper> </mapper>