Merge remote-tracking branch 'origin/master'

This commit is contained in:
wangzhijiang
2022-04-14 18:09:53 +08:00
18 changed files with 676 additions and 317 deletions
@@ -46,7 +46,7 @@ public class DictAspect {
@Around("excudeService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long time1=System.currentTimeMillis();
long time1=System.currentTimeMillis();
Object result = pjp.proceed();
long time2=System.currentTimeMillis();
log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms");
@@ -84,46 +84,57 @@ public class DictAspect {
if (((Result) result).getResult() instanceof IPage) {
List<JSONObject> items = new ArrayList<>();
for (Object record : ((IPage) ((Result) result).getResult()).getRecords()) {
ObjectMapper mapper = new ObjectMapper();
String json="{}";
try {
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败"+e.getMessage(),e);
}
JSONObject item = JSONObject.parseObject(json);
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
//for (Field field : record.getClass().getDeclaredFields()) {
for (Field field : oConvertUtils.getAllFields(record)) {
//update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
//翻译字典值对应的txt
String textValue = translateDictValue(code, text, table, key);
log.debug(" 字典Val : "+ textValue);
log.debug(" __翻译字典字段__ "+field.getName() + CommonConstant.DICT_TEXT_SUFFIX+": "+ textValue);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
//date类型默认转换string格式化日期
if (field.getType().getName().equals("java.util.Date")&&field.getAnnotation(JsonFormat.class)==null&&item.get(field.getName())!=null){
SimpleDateFormat aDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
JSONObject item = getJsonObject(record);
items.add(item);
}
((IPage) ((Result) result).getResult()).setRecords(items);
}else if(((Result) result).getResult() instanceof List){
List<JSONObject> items = new ArrayList<>();
for (Object record : (List)((Result) result).getResult()) {
JSONObject item = getJsonObject(record);
items.add(item);
}
((Result) result).setResult(items);
}
}
}
private JSONObject getJsonObject(Object record) {
ObjectMapper mapper = new ObjectMapper();
String json = "{}";
try {
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败" + e.getMessage(), e);
}
JSONObject item = JSONObject.parseObject(json);
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
//for (Field field : record.getClass().getDeclaredFields()) {
for (Field field : oConvertUtils.getAllFields(record)) {
//update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
//翻译字典值对应的txt
String textValue = translateDictValue(code, text, table, key);
log.debug(" 字典Val : " + textValue);
log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + ": " + textValue);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
//date类型默认转换string格式化日期
if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
return item;
}
/**
* 翻译字典文本
* @param code
@@ -142,7 +142,7 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
@AutoLog(value = "文档库信息表-通过id查询")
@ApiOperation(value="文档库信息表-通过id查询", notes="文档库信息表-通过id查询")
@GetMapping(value = "/queryById")
// @RequiresPermissions("document:queryById")
@RequiresPermissions("document:queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
BussDocumentLibraryEO bussDocumentLibraryEO = bussDocumentLibraryEOService.queryById(id);
if(bussDocumentLibraryEO==null) {
@@ -48,21 +48,14 @@ public class DummyInventoryInfoEOController extends JeroController<DummyInventor
* 分页列表查询
*
* @param dummyInventoryInfoEO
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "虚拟清单详情表-分页列表查询")
@ApiOperation(value="虚拟清单详情表-分页列表查询", notes="虚拟清单详情表-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(DummyInventoryInfoEO dummyInventoryInfoEO,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<DummyInventoryInfoEO> queryWrapper = QueryGenerator.initQueryWrapper(dummyInventoryInfoEO, req.getParameterMap());
Page<DummyInventoryInfoEO> page = new Page<DummyInventoryInfoEO>(pageNo, pageSize);
IPage<DummyInventoryInfoEO> pageList = dummyInventoryInfoEOService.page(page, queryWrapper);
public Result<?> queryPageList(DummyInventoryInfoEO dummyInventoryInfoEO,HttpServletRequest req) {
IPage<DummyInventoryInfoEO> pageList = dummyInventoryInfoEOService.getPageInfo(dummyInventoryInfoEO,req);
return Result.OK(pageList);
}
@@ -74,8 +67,8 @@ public class DummyInventoryInfoEOController extends JeroController<DummyInventor
@AutoLog(value = "虚拟清单详情表-列表查询")
@ApiOperation(value="虚拟清单详情表-列表查询", notes="虚拟清单详情表-列表查询")
@GetMapping(value = "/list")
public Result<List<DummyInventoryInfoEO>> queryList() {
List<DummyInventoryInfoEO> list = dummyInventoryInfoEOService.queryList();
public Result<List<DummyInventoryInfoEO>> queryList(DummyInventoryInfoEO dummyInventoryInfoEO,HttpServletRequest req) {
List<DummyInventoryInfoEO> list = dummyInventoryInfoEOService.queryList(dummyInventoryInfoEO,req);
return Result.OK(list);
}
@@ -213,8 +206,8 @@ public class DummyInventoryInfoEOController extends JeroController<DummyInventor
@AutoLog(value = "复制")
@ApiOperation(value="复制", notes="复制")
@GetMapping(value = "/copyInfoByIds")
public Result<?> copyInfoByIds(@RequestParam(name="id",required=true) String ids,
@RequestParam(name="id",required=true) String cut) {
public Result<?> copyInfoByIds(@RequestParam(name="ids",required=true) String ids,
@RequestParam(name="cut",required=true) String cut) {
try {
dummyInventoryInfoEOService.copyInfoByIds(ids);
} catch (Exception e) {
@@ -235,20 +228,16 @@ public class DummyInventoryInfoEOController extends JeroController<DummyInventor
/**
* 批量设置
*
* @param dummyInventoryInfoEOList
* @param dummyInventoryInfoEO
* @return
*/
@AutoLog(value = "虚拟清单详情表-添加")
@ApiOperation(value="虚拟清单详情表-添加", notes="虚拟清单详情表-添加")
@PostMapping(value = "/setBatch")
public Result<?> setBatch(@Validated @RequestBody List<DummyInventoryInfoEO> dummyInventoryInfoEOList) {
String cut = "";
if(dummyInventoryInfoEOList.size() != 0){
cut = dummyInventoryInfoEOList.get(0).getCut();
}
public Result<?> setBatch(@RequestBody DummyInventoryInfoEO dummyInventoryInfoEO) {
String cut = dummyInventoryInfoEO.getCut();
try {
dummyInventoryInfoEOService.setBatch(dummyInventoryInfoEOList);
dummyInventoryInfoEOService.setBatch(dummyInventoryInfoEO);
} catch (Exception e) {
if(CutEnum.CN.getValue().equals(cut)){
return Result.error("批量设置失败!");
@@ -93,6 +93,9 @@ public class DummyInventoryInfoEO implements Serializable {
@ApiModelProperty(value = "技术领域")
private java.lang.String technologyTerritory;
@TableField(exist = false)
private java.lang.String technologyTerritoryName;
/**新车型实施日期*/
@Excel(name = "新车型实施日期", width = 15)
@ApiModelProperty(value = "新车型实施日期")
@@ -125,21 +128,25 @@ public class DummyInventoryInfoEO implements Serializable {
/**实施类别*/
@Excel(name = "实施类别", width = 15)
@ApiModelProperty(value = "实施类别")
@Dict(dicCode ="implement_type")
private java.lang.String implementType;
/**认证类型*/
@Excel(name = "认证类型", width = 15)
@ApiModelProperty(value = "认证类型")
@Dict(dicCode ="attestation_type")
private java.lang.String attestationType;
/**认证级别*/
@Excel(name = "认证级别", width = 15)
@ApiModelProperty(value = "认证级别")
@Dict(dicCode ="attestation_rank")
private java.lang.String attestationRank;
/**责任领域*/
@Excel(name = "责任领域", width = 15)
@ApiModelProperty(value = "责任领域")
@Dict(dicCode ="duty_territory")
private java.lang.String dutyTerritory;
/**备注*/
@@ -150,6 +157,7 @@ public class DummyInventoryInfoEO implements Serializable {
/**设计符合性确认-交付物类型*/
@Excel(name = "设计符合性确认-交付物类型", width = 15)
@ApiModelProperty(value = "设计符合性确认-交付物类型")
@Dict(dicCode ="deliverable_template")
private java.lang.String designDeliverableType;
/**设计符合性确认-交付物模板*/
@@ -157,6 +165,9 @@ public class DummyInventoryInfoEO implements Serializable {
@ApiModelProperty(value = "设计符合性确认-交付物模板")
private java.lang.String designDeliverableTemplate;
@TableField(exist = false)
private java.lang.String designDeliverableTemplateName;
/**设计符合性确认-发起人*/
@Excel(name = "设计符合性确认-发起人", width = 15)
@ApiModelProperty(value = "设计符合性确认-发起人")
@@ -177,6 +188,9 @@ public class DummyInventoryInfoEO implements Serializable {
@ApiModelProperty(value = "prehomo确认-交付物模板")
private java.lang.String prehomoDeliverableTemplate;
@TableField(exist = false)
private java.lang.String prehomoDeliverableTemplateName;
/**prehomo确认-发起人*/
@Excel(name = "prehomo确认-发起人", width = 15)
@ApiModelProperty(value = "prehomo确认-发起人")
@@ -197,6 +211,9 @@ public class DummyInventoryInfoEO implements Serializable {
@ApiModelProperty(value = "验证符合性确认-交付物模板")
private java.lang.String verifyDeliverableTemplate;
@TableField(exist = false)
private java.lang.String verifyDeliverableTemplateName;
/**验证符合性确认-发起人*/
@Excel(name = "验证符合性确认-发起人", width = 15)
@ApiModelProperty(value = "验证符合性确认-发起人")
@@ -214,4 +231,10 @@ public class DummyInventoryInfoEO implements Serializable {
@TableField(exist = false)
private String ids;
@TableField(exist = false)
private Integer pageNo;
@TableField(exist = false)
private Integer pageSize;
}
@@ -1,5 +1,6 @@
package com.jero.modules.dummy.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.dummy.entity.DummyInventoryInfoEO;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -62,14 +63,16 @@ public interface IDummyInventoryInfoEOService extends IService<DummyInventoryInf
*
* @return
*/
List<DummyInventoryInfoEO> queryList();
List<DummyInventoryInfoEO> queryList(DummyInventoryInfoEO dummyInventoryInfoEO,HttpServletRequest req);
IPage<DummyInventoryInfoEO> getPageInfo(DummyInventoryInfoEO dummyInventoryInfoEO,HttpServletRequest req);
/**
* 批量设置
* @param dummyInventoryInfoEOList
* @param dummyInventoryInfoEO
*/
void setBatch(List<DummyInventoryInfoEO> dummyInventoryInfoEOList);
void setBatch(DummyInventoryInfoEO dummyInventoryInfoEO);
/**
* 模板下载
@@ -1,12 +1,21 @@
package com.jero.modules.dummy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.document.entity.BussDocumentLibraryEO;
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
import com.jero.modules.dummy.entity.DummyInventoryInfoEO;
import com.jero.modules.dummy.mapper.DummyInventoryInfoEOMapper;
import com.jero.modules.dummy.service.IDummyInventoryInfoEOService;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.system.entity.SysCategory;
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,8 +26,11 @@ import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @Description: 虚拟清单详情表
@@ -32,6 +44,25 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
@Autowired
private IBussDocumentLibraryEOService iBussDocumentLibraryEOService;
@Autowired
private SysCategoryServiceImpl sysCategoryService;
@Autowired
private IOSSFileService iOSSFileService;
@Override
public IPage<DummyInventoryInfoEO> getPageInfo(DummyInventoryInfoEO dummyInventoryInfoEO,HttpServletRequest req) {
QueryWrapper<DummyInventoryInfoEO> queryWrapper = QueryGenerator.initQueryWrapper(dummyInventoryInfoEO, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
Page<DummyInventoryInfoEO> page = new Page<DummyInventoryInfoEO>(dummyInventoryInfoEO.getPageNo(), dummyInventoryInfoEO.getPageSize());
IPage<DummyInventoryInfoEO> pageInfo = this.page(page, queryWrapper);
//技术领域处理
// treeDict(dummyInventoryInfoEO, pageInfo);
return pageInfo;
}
/**
* 保存
*
@@ -40,6 +71,7 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
*/
@Override
public void add(DummyInventoryInfoEO dummyInventoryInfoEO) {
//需要验重(验重--已添加过的不能再添加,提示该标准已存在清单中,不可添加)
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getIds())){
LambdaQueryWrapper<BussDocumentLibraryEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(BussDocumentLibraryEO::getId, Arrays.asList(dummyInventoryInfoEO.getIds().split(",")));
@@ -91,8 +123,25 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
*/
@Override
public void deleteByIds(List<String> ids) {
removeByIds(ids);
}
//文件同步删除
LambdaQueryWrapper<DummyInventoryInfoEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(DummyInventoryInfoEO::getId,ids);
List<DummyInventoryInfoEO> dummyInventoryInfoEOList = this.list(wrapper);
List<String> fileIdList = new ArrayList<>();
for (DummyInventoryInfoEO dummyInventoryInfoEO : dummyInventoryInfoEOList) {
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getDesignDeliverableTemplate())){
fileIdList.addAll(Arrays.asList(dummyInventoryInfoEO.getDesignDeliverableTemplate().split(",")));
}
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getPrehomoDeliverableTemplate())){
fileIdList.addAll(Arrays.asList(dummyInventoryInfoEO.getPrehomoDeliverableTemplate().split(",")));
}
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getVerifyDeliverableTemplate())){
fileIdList.addAll(Arrays.asList(dummyInventoryInfoEO.getVerifyDeliverableTemplate().split(",")));
}
}
iOSSFileService.removeByIds(fileIdList);
removeByIds(ids);
}
/**
* 通过id查询
@@ -111,8 +160,13 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
* @return
*/
@Override
public List<DummyInventoryInfoEO> queryList() {
return list();
public List<DummyInventoryInfoEO> queryList(DummyInventoryInfoEO dummyInventoryInfoEO,HttpServletRequest req) {
QueryWrapper<DummyInventoryInfoEO> queryWrapper = QueryGenerator.initQueryWrapper(dummyInventoryInfoEO,req.getParameterMap());
queryWrapper.orderByDesc("create_time");
List<DummyInventoryInfoEO> dummyInventoryInfoEOList = this.list(queryWrapper);
//技术领域处理
treeDict(dummyInventoryInfoEO, dummyInventoryInfoEOList);
return dummyInventoryInfoEOList;
}
@@ -122,17 +176,49 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
*/
@Override
public void copyInfoByIds(String ids) {
if(StringUtils.isNotBlank(ids)){
LambdaQueryWrapper<DummyInventoryInfoEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(DummyInventoryInfoEO::getId,Arrays.asList(ids.split(",")));
List<DummyInventoryInfoEO> dummyInventoryInfoEOList = this.list(wrapper);
for (DummyInventoryInfoEO dummyInventoryInfoEO : dummyInventoryInfoEOList) {
dummyInventoryInfoEO.setId(UUID.randomUUID().toString().replace("-", ""));
}
this.saveBatch(dummyInventoryInfoEOList);
}
}
/**
* 批量设置
* @param dummyInventoryInfoEOList
* @param dummyInventoryInfoEO
*/
@Override
public void setBatch(List<DummyInventoryInfoEO> dummyInventoryInfoEOList) {
public void setBatch(DummyInventoryInfoEO dummyInventoryInfoEO) {
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getIds())){
List<DummyInventoryInfoEO> dummyInventoryInfoEOList = new ArrayList<>();
for (String id : dummyInventoryInfoEO.getIds().split(",")) {
DummyInventoryInfoEO dummyInventoryInfoEOTemp = new DummyInventoryInfoEO();
dummyInventoryInfoEOTemp.setId(id);
//实施类别 implementType
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getImplementType())){
dummyInventoryInfoEOTemp.setImplementType(dummyInventoryInfoEO.getImplementType());
}
//认证类型 attestationType
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getAttestationType())){
dummyInventoryInfoEOTemp.setAttestationType(dummyInventoryInfoEO.getAttestationType());
}
//认证级别 attestationRank
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getAttestationRank())){
dummyInventoryInfoEOTemp.setAttestationRank(dummyInventoryInfoEO.getAttestationRank());
}
//责任领域 dutyTerritory
if(StringUtils.isNotBlank(dummyInventoryInfoEO.getDutyTerritory())){
dummyInventoryInfoEOTemp.setDutyTerritory(dummyInventoryInfoEO.getDutyTerritory());
}
dummyInventoryInfoEOList.add(dummyInventoryInfoEOTemp);
}
this.updateBatchById(dummyInventoryInfoEOList);
}
}
/**
@@ -145,4 +231,100 @@ public class DummyInventoryInfoEOServiceImpl extends ServiceImpl<DummyInventoryI
public void exportTemplate(DummyInventoryInfoEO dummyInventoryInfoEO, HttpServletResponse response, HttpServletRequest request) {
}
/**
* 技术领域数据字典处理
* @param dummyInventoryInfoEO
* @param dummyInventoryInfoEOList
*/
private void treeDict(DummyInventoryInfoEO dummyInventoryInfoEO, List<DummyInventoryInfoEO> dummyInventoryInfoEOList) {
Set<String> technologyTerritorySet = new HashSet<>();
List<String> deliverableList = new ArrayList<>();
for (DummyInventoryInfoEO record : dummyInventoryInfoEOList) {
//技术领域
if(StringUtils.isNotBlank(record.getTechnologyTerritory())){
List<String> list = Arrays.asList(record.getTechnologyTerritory().split(","));
technologyTerritorySet.addAll(list);
}
//设计符合性确认交付物模板
if(StringUtils.isNotBlank(record.getDesignDeliverableTemplate())){
deliverableList.addAll(Arrays.asList(record.getDesignDeliverableTemplate().split(",")));
}
// Prehomo确认交付物模板
if(StringUtils.isNotBlank(record.getPrehomoDeliverableTemplate())){
deliverableList.addAll(Arrays.asList(record.getPrehomoDeliverableTemplate().split(",")));
}
// 验证符合性确认交付物模板
if(StringUtils.isNotBlank(record.getVerifyDeliverableTemplate())){
deliverableList.addAll(Arrays.asList(record.getVerifyDeliverableTemplate().split(",")));
}
}
//文件
List<OSSFile> fileInfos = new ArrayList<>();
if(deliverableList.size() != 0){
fileInfos = iOSSFileService.getFileInfos(StringUtils.join(deliverableList, ","));
}
//树形结构数据字典(技术领域)
LambdaQueryWrapper<SysCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.in(SysCategory::getId, technologyTerritorySet);
List<SysCategory> categoryList = sysCategoryService.list(wrapper);
for (DummyInventoryInfoEO record : dummyInventoryInfoEOList) {
//技术领域
if (categoryList.size() != 0 && StringUtils.isNotBlank(record.getTechnologyTerritory())) {
List<String> technologyTerritoryList = Arrays.asList(record.getTechnologyTerritory().split(","));
StringBuilder sb = new StringBuilder();
for (String technologyTerritory : technologyTerritoryList) {
List<SysCategory> collect = categoryList.stream().filter(e -> technologyTerritory.equals(e.getId())).collect(Collectors.toList());
if (CutEnum.CN.getValue().equals(dummyInventoryInfoEO.getCut())) {
sb.append(collect.get(0).getName() + ",");
} else {
sb.append(collect.get(0).getEnName());
}
}
String technologyTerritoryName = "";
if (StringUtils.isNotBlank(sb)) {
technologyTerritoryName = sb.substring(0, sb.length() - 1);
}
record.setTechnologyTerritoryName(technologyTerritoryName);
}
//交付物类型模板
if(fileInfos.size() != 0){
if(StringUtils.isNotBlank(record.getDesignDeliverableTemplate())){
String fileName = getFileName(record, fileInfos,record.getDesignDeliverableTemplate());
if(StringUtils.isNotBlank(fileName)){
record.setDesignDeliverableTemplateName(fileName);
}
}
if(StringUtils.isNotBlank(record.getPrehomoDeliverableTemplate())){
String fileName = getFileName(record, fileInfos,record.getPrehomoDeliverableTemplate());
if(StringUtils.isNotBlank(fileName)){
record.setPrehomoDeliverableTemplateName(fileName);
}
}
if(StringUtils.isNotBlank(record.getVerifyDeliverableTemplate())){
String fileName = getFileName(record, fileInfos,record.getVerifyDeliverableTemplate());
if(StringUtils.isNotBlank(fileName)){
record.setVerifyDeliverableTemplateName(fileName);
}
}
}
}
}
private String getFileName(DummyInventoryInfoEO dummyInventoryInfoEO,List<OSSFile> fileInfos,String deliverableTemplate){
StringBuilder sb = new StringBuilder();
for (String s : deliverableTemplate.split(",")) {
List<OSSFile> collect = fileInfos.stream().filter(e -> s.equals(e.getId())).collect(Collectors.toList());
sb.append(collect.get(0).getFileName() + ",");
}
String sbStr = "";
if(StringUtils.isNotBlank(sb)){
sbStr = sb.substring(0, sb.length() - 1);
}
return sbStr;
}
}
@@ -1,19 +1,27 @@
package com.jero.modules.ocr.controller;
import cn.hutool.core.util.ObjectUtil;
import com.jero.common.api.vo.Result;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.ocr.entity.OcrRecordEO;
import com.jero.modules.ocr.enums.CheckFlagEnum;
import com.jero.modules.ocr.helpers.ConfigManager;
import com.jero.modules.ocr.helpers.DocumentManager;
import com.jero.modules.ocr.helpers.FileUtility;
import com.jero.modules.ocr.helpers.ServiceConverter;
import com.jero.modules.ocr.service.IOcrRecordEOService;
import com.jero.modules.ocr.service.WebSocketServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@@ -40,6 +48,11 @@ import java.util.Scanner;
@Slf4j
public class OcrCheckController {
@Autowired
private IOcrRecordEOService ocrRecordService;
@Autowired
private WebSocketServer webSocketServer;
@Value("${OCR.ocrDownPath}")
private String ocrDownPath;
@@ -78,14 +91,37 @@ public class OcrCheckController {
}
}
@ApiOperation(value = "验证文档是否被锁定")
@GetMapping("/verifyCheckFlag")
public Result<?> verifyCheckFlag(String id) {
if(StringUtils.isBlank(id)){
return Result.error("参数不能为空");
}
OcrRecordEO ocrRecordEO = ocrRecordService.getById(id);
if (CheckFlagEnum.LOCK.getValue().equals(ocrRecordEO.getCheckFlag())) {
return Result.error("该文档当前正在被校核,请稍后重试!");
} else if (CheckFlagEnum.UNLOCK.getValue().equals(ocrRecordEO.getCheckFlag())) {
return Result.OK();
}
// 文档没被校核过
return Result.OK();
}
@ApiOperation(value = "编辑文件")
@RequestMapping("/editorFile")
public ModelAndView index(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
String fileName = "";
if (request.getParameterMap().containsKey("fileName")) {
fileName = request.getParameter("fileName");
}
String id = "";
try {
if (request.getParameterMap().containsKey("fileName")) {
fileName = request.getParameter("fileName");
}
if (request.getParameterMap().containsKey("id")) {
id = request.getParameter("id");
}
// String fileExt = null;
// if (request.getParameterMap().containsKey("fileExt")) {
// fileExt = request.getParameter("fileExt");
@@ -111,37 +147,48 @@ public class OcrCheckController {
// file.SetTypeDesktop(desktopMode);
// file.SetFileName(fileName);
log.info("==========EditorFile==========");
DocumentManager.Init(request, response);
//要编辑的文件名
model.addAttribute("fileName", fileName) ;
//要编辑的文件类型
model.addAttribute("fileType", FileUtility.GetFileExtension(fileName).replace(".", "")) ;
//要编辑的文档类型
model.addAttribute("documentType",FileUtility.GetFileType(fileName).toString().toLowerCase()) ;
//要编辑的文档访问url
log.info("==========EditorFile==========");
DocumentManager.Init(request, response);
//要编辑的文件名
model.addAttribute("fileName", fileName);
//要编辑的文件类型
model.addAttribute("fileType", FileUtility.GetFileExtension(fileName).replace(".", ""));
//要编辑的文档类型
model.addAttribute("documentType", FileUtility.GetFileType(fileName).toString().toLowerCase());
//要编辑的文档访问url
// model.addAttribute("fileUri",DocumentManager.GetFileUri(fileName, true)) ;
// model.addAttribute("callbackUrl", DocumentManager.GetCallback(fileName)) ;
// model.addAttribute("serverUrl", DocumentManager.GetServerUrl(true)) ;
model.addAttribute("fileUri", ocrDownPath + "?fileName=" + fileName) ;
model.addAttribute("callbackUrl", ocrSavePath + "?fileName=" + fileName) ;
model.addAttribute("serverUrl", serverUrl) ;
model.addAttribute("fileKey", ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + ocrDownPath + "?fileName=" + fileName)) ;
model.addAttribute("editorMode", DocumentManager.GetEditedExts().contains(FileUtility.GetFileExtension(fileName)) && !"view".equals(request.getAttribute("mode")) ? "edit" : "view") ;
model.addAttribute("editorUserId",DocumentManager.CurUserHostAddress(null)) ;
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
model.addAttribute("editorUserName", loginUser.getUsername()) ;
model.addAttribute("fileUri", ocrDownPath + "?fileName=" + fileName);
model.addAttribute("callbackUrl", ocrSavePath + "?id=" + id);
model.addAttribute("serverUrl", serverUrl);
model.addAttribute("fileKey", ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + ocrDownPath + "?fileName=" + fileName));
model.addAttribute("editorMode", DocumentManager.GetEditedExts().contains(FileUtility.GetFileExtension(fileName)) && !"view".equals(request.getAttribute("mode")) ? "edit" : "view");
model.addAttribute("editorUserId", DocumentManager.CurUserHostAddress(null));
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
model.addAttribute("editorUserName", loginUser.getUsername());
// model.addAttribute("type", desktopMode ? "desktop" : "embedded");
model.addAttribute("type", true ? "desktop" : "embedded");
model.addAttribute("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.api"));
model.addAttribute("docServiceUrlPreloader", ConfigManager.GetProperty("files.docservice.url.preloader")) ;
model.addAttribute("currentYear", "2022") ;
model.addAttribute("convertExts", String.join(",", DocumentManager.GetConvertExts())) ;
model.addAttribute("editedExts", String.join(",", DocumentManager.GetEditedExts())) ;
model.addAttribute("documentCreated", new SimpleDateFormat("MM/dd/yyyy").format(new Date())) ;
model.addAttribute("permissionsEdit", Boolean.toString(DocumentManager.GetEditedExts().contains(FileUtility.GetFileExtension(fileName))).toLowerCase()) ;
return new ModelAndView("editor") ;
model.addAttribute("type", true ? "desktop" : "embedded");
model.addAttribute("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.api"));
model.addAttribute("docServiceUrlPreloader", ConfigManager.GetProperty("files.docservice.url.preloader"));
model.addAttribute("currentYear", "2022");
model.addAttribute("convertExts", String.join(",", DocumentManager.GetConvertExts()));
model.addAttribute("editedExts", String.join(",", DocumentManager.GetEditedExts()));
model.addAttribute("documentCreated", new SimpleDateFormat("MM/dd/yyyy").format(new Date()));
model.addAttribute("permissionsEdit", Boolean.toString(DocumentManager.GetEditedExts().contains(FileUtility.GetFileExtension(fileName))).toLowerCase());
return new ModelAndView("editor");
} finally {
// 校核锁定
if (StringUtils.isNotBlank(id)) {
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(id);
ocrRecordEO.setCheckFlag(CheckFlagEnum.LOCK.getValue());
// 校核锁定
ocrRecordService.updateById(ocrRecordEO);
}
}
}
/**
@@ -164,17 +211,25 @@ public class OcrCheckController {
@ApiOperation(value = "保存文件")
@RequestMapping("/saveFile")
public void saveFile(HttpServletRequest request, HttpServletResponse response) {
String id = "";
String fileName = "";
if (request.getParameterMap().containsKey("fileName")) {
fileName = request.getParameter("fileName");
}
PrintWriter writer = null;
log.info("==========SaveEditedFile==========");
try {
if (request.getParameterMap().containsKey("id")) {
id = request.getParameter("id");
OcrRecordEO ocrRecordEO = ocrRecordService.getById(id);
if(ObjectUtil.isNotEmpty(ocrRecordEO)){
fileName = ocrRecordEO.getDocRealName();
}
}
log.info("==========SaveEditedFile==========");
writer = response.getWriter();
Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
String body = scanner.hasNext() ? scanner.next() : "";
JSONObject jsonObj = (JSONObject) new JSONParser().parse(body);
log.info("返回结果:" + jsonObj.toString());
log.info("status:" + jsonObj.get("status"));
/*
0 - no document with the key identifier could be found,
@@ -185,7 +240,16 @@ public class OcrCheckController {
6 - document is being edited, but the current document state is saved,
7 - error has occurred while force saving the document.
* */
if ((long) jsonObj.get("status") == 2) {
if ((long) jsonObj.get("status") == 4) {
// status=4 没有编辑内容,直接关闭编辑窗口
// 校核解锁
if(StringUtils.isNotBlank(id)){
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(id);
ocrRecordEO.setCheckFlag(CheckFlagEnum.UNLOCK.getValue());
ocrRecordService.updateById(ocrRecordEO);
}
} else if ((long) jsonObj.get("status") == 2) {
/*
* 当我们关闭编辑窗口后,十秒钟左右onlyoffice会将它存储的我们的编辑后的文件,,此时status = 2,通过request发给我们,我们需要做的就是接收到文件然后回写该文件。
* */
@@ -213,17 +277,40 @@ public class OcrCheckController {
out.flush();
}
connection.disconnect();
// 校核解锁
if(StringUtils.isNotBlank(id)){
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(id);
ocrRecordEO.setCheckFlag(CheckFlagEnum.UNLOCK.getValue());
// 校核解锁
ocrRecordService.updateById(ocrRecordEO);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error(e.getMessage());
// 校核解锁
if(StringUtils.isNotBlank(id)){
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(id);
ocrRecordEO.setCheckFlag(CheckFlagEnum.UNLOCK.getValue());
ocrRecordService.updateById(ocrRecordEO);
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error(e.getMessage());
// 校核解锁
if(StringUtils.isNotBlank(id)){
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(id);
ocrRecordEO.setCheckFlag(CheckFlagEnum.UNLOCK.getValue());
ocrRecordService.updateById(ocrRecordEO);
}
}
/*
* status = 1,我们给onlyoffice的服务返回{"error":"0"}的信息,这样onlyoffice会认为回调接口是没问题的,这样就可以在线编辑文档了,否则的话会弹出窗口说明
* */
writer.write("{\"error\":0}");
}
}
@@ -129,6 +129,10 @@ public class OcrRecordEO implements Serializable {
/**文档库关联文件id*/
@ApiModelProperty(value = "文档库关联文件id")
private String connectId;
/**校核锁定标识*/
@ApiModelProperty(value = "校核锁定标识")
private String checkFlag;
@TableField(exist = false)
private String docRealFile;
@@ -0,0 +1,35 @@
package com.jero.modules.ocr.enums;
/**
* @Author: liyawei
* @Description:
* @Date: Created in 11:20 2022/4/14
*/
public enum CheckFlagEnum {
LOCK("锁定","1"),
UNLOCK("解锁","0");
String name;
String value;
CheckFlagEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -22,5 +22,6 @@
<result column="att_id" property="attId" />
<result column="sync_state" property="syncState" />
<result column="connect_id" property="connectId" />
<result column="check_flag" property="checkFlag" />
</resultMap>
</mapper>
@@ -138,14 +138,14 @@ spring:
# url: jdbc:mysql://10.0.3.44:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://10.10.10.44:3306/laws_weilai_test?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://121.36.69.172:3307/laws_weilai?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
# url: jdbc:mysql://121.36.69.172:3307/laws_weilai_zhn?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
# url: jdbc:mysql://10.10.10.44:3306/laws_weilai_test?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
# username: root
# password: hzwlsoft.com
# password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://121.36.69.172:3307/laws_weilai?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
# url: jdbc:mysql://121.36.69.172:3307/laws_weilai_zhn?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: hzwlsoft.com
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1: