Merge remote-tracking branch 'origin/pet' into pet

hyx_2024-10-12_xgfPerson
huangyuxuan 2024-09-19 14:37:03 +08:00
commit 5d728f4d16
18 changed files with 1411 additions and 8 deletions

View File

@ -215,7 +215,7 @@
<artifactId>aliyun-java-sdk-core</artifactId> <artifactId>aliyun-java-sdk-core</artifactId>
<version>3.3.1</version> <version>3.3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.aliyun</groupId> <groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId> <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version> <version>1.0.0</version>

View File

@ -0,0 +1,180 @@
package com.zcloud.controller.accident;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.accident.AccidentRecords;
import com.zcloud.service.accident.AccidentRecordsService;
import com.zcloud.util.ObjectExcelView;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@RequiredArgsConstructor
@RequestMapping("/accident")
public class AccidentRecordsController extends BaseController {
private final AccidentRecordsService accidentRecordsService;
/**
*
*
* @param page
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/page")
public Map<String, Object> queryPage(Page page, HttpServletRequest request) {
page.setPd(new PageData(request));
Map<String, Object> result = new HashMap<>();
result.put("result", "success");
result.put("varList", accidentRecordsService.queryPage(page));
result.put("page", page);
return result;
}
/**
* id
*
* @param id id
* @return
*/
@ResponseBody
@RequestMapping("/{id}")
public Map<String, Object> getById(@PathVariable("id") String id) {
Map<String, Object> result = new HashMap<>();
result.put("result", "success");
result.put("info", accidentRecordsService.getById(Optional.of(id).orElseThrow(() -> new RuntimeException("id不能为空"))));
return result;
}
/**
*
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/save")
public Map<String, Object> save(HttpServletRequest request) {
AccidentRecords accidentRecords = BeanUtil.mapToBean(new PageData(request), AccidentRecords.class, true);
accidentRecordsService.save(accidentRecords);
Map<String, Object> result = new HashMap<>();
result.put("result", "success");
return result;
}
/**
*
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/update")
public Map<String, Object> update(HttpServletRequest request) {
PageData pageData = new PageData(request);
AccidentRecords accidentRecords = BeanUtil.mapToBean(pageData, AccidentRecords.class, true);
accidentRecords.setId(Optional.of(accidentRecords.getId()).orElseThrow(() -> new RuntimeException("id不能为空")));
accidentRecordsService.update(accidentRecords);
Map<String, Object> result = new HashMap<>();
result.put("result", "success");
return result;
}
/**
*
*
* @param values id
* @return
*/
@ResponseBody
@RequestMapping("/delete/{ids}")
public Map<String, Object> delete(@PathVariable("ids") String values) {
if (StrUtil.isEmpty(values)) {
throw new RuntimeException("id不能为空");
}
List<String> ids = Arrays.stream(values.split(",")).filter(ObjectUtil::isNotEmpty)
.collect(Collectors.toList());
accidentRecordsService.delete(ids);
Map<String, Object> result = new HashMap<>();
result.put("result", "success");
return result;
}
/**
* excel
*
* @param request
* @return
*/
@RequestMapping("/export/excel")
public ModelAndView exportExcel(HttpServletRequest request) {
Map<String, Object> dataMap = accidentRecordsService.exportExcel(new PageData(request));
return new ModelAndView(new ObjectExcelView(), dataMap);
}
// /**
// * 导入excel
// *
// * @param file 文件
// */
// @RequestMapping("/import/excel")
// public void importExcel(@RequestParam("file") MultipartFile file) {
// if (file == null || file.isEmpty()) {
// throw new RuntimeException("文件不能为空");
// }
// accidentRecordsService.importExcel(file);
// }
/**
*
*
* @param file
* @return
*/
@ResponseBody
@RequestMapping("/import/photos")
public Map<String, Object> importPhotos(@RequestParam("file") MultipartFile file) {
if (file == null || file.isEmpty()) {
throw new RuntimeException("文件不能为空");
}
Map<String, Object> result = new HashMap<>();
result.put("result", "success"); // 路径
result.put("path", accidentRecordsService.importPhotos(file));
return result;
}
/**
*
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/delete/photos")
public Map<String, Object> deletePhotos(HttpServletRequest request) {
String path = new PageData(request).getString("path");
if (StrUtil.isEmpty(path)) {
throw new RuntimeException("路径不能为空");
}
accidentRecordsService.deletePhotos(path);
Map<String, Object> result = new HashMap<>();
result.put("result", "success"); // 路径
return result;
}
}

View File

@ -194,6 +194,21 @@ public class AppFireRecordController extends BaseController {
map.put("varList", res); map.put("varList", res);
return map; return map;
} }
@RequestMapping("getCheckRecordListV3")
@ResponseBody
public Object getCheckRecordListV3(Page page) {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = getPageData();
page.setPd(pd);
List<PageData> res = fireRecordService.getCheckListByAppV3(page);
// List<PageData> res = fireRecordService.getCheckRecordList(pd);
map.put("result", errInfo);
map.put("page", page);
map.put("varList", res);
return map;
}
/** /**
* @Description: * @Description:
* @Author: dearLin * @Author: dearLin

View File

@ -11,7 +11,6 @@ import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.zcloud.dto.UpdateEnum; import com.zcloud.dto.UpdateEnum;
import com.zcloud.entity.system.Dictionaries; import com.zcloud.entity.system.Dictionaries;
import com.zcloud.entity.system.User;
import com.zcloud.service.bus.*; import com.zcloud.service.bus.*;
import com.zcloud.service.system.*; import com.zcloud.service.system.*;
import com.zcloud.syncData.SyncPlatformAdvice; import com.zcloud.syncData.SyncPlatformAdvice;
@ -20,10 +19,8 @@ import com.zcloud.util.*;
import org.apache.commons.collections.map.ListOrderedMap; import org.apache.commons.collections.map.ListOrderedMap;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils; import org.apache.commons.lang.time.DateUtils;
import org.apache.fop.layoutmgr.PaddingElement;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.SimpleHash; import org.apache.shiro.crypto.hash.SimpleHash;
import org.hyperic.sigar.pager.PageList;
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.Controller; import org.springframework.stereotype.Controller;
@ -40,8 +37,6 @@ import com.zcloud.entity.PageData;
import com.zcloud.entity.system.Role; import com.zcloud.entity.system.Role;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
import sun.security.krb5.internal.PAData;
import sun.util.logging.resources.logging;
/** /**
* *
@ -803,7 +798,7 @@ public class UsersController extends BaseController {
usersService.editUserFuns(pd); //执行修改 usersService.editUserFuns(pd); //执行修改
map.put("result", errInfo); map.put("result", errInfo);
map.put("code", "0"); map.put("code", "0");
map.put("syncInfo", JSONUtils.toJSONString(usersService.findById(pd))); map.put("syncInfo", JSONUtil.toJsonStr(usersService.findById(pd)));
return map; return map;
} }
@ -835,7 +830,7 @@ public class UsersController extends BaseController {
FHLOG.save(Jurisdiction.getUsername(), "从个人资料中修改" + pd.getString("USERNAME") + "的资料"); //记录日志 FHLOG.save(Jurisdiction.getUsername(), "从个人资料中修改" + pd.getString("USERNAME") + "的资料"); //记录日志
map.put("result", errInfo); map.put("result", errInfo);
map.put("code", "0"); map.put("code", "0");
map.put("syncInfo", JSONUtils.toJSONString(usersService.findById(pd))); map.put("syncInfo", JSONUtil.toJsonStr(usersService.findById(pd)));
return map; return map;
} }

View File

@ -0,0 +1,221 @@
package com.zcloud.entity.accident;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
/**
*
*/
@Slf4j
@Data
@NoArgsConstructor
public class AccidentRecords implements Serializable {
/**
* ID
*/
@NotNull(message = "主键ID不能为null")
private String id;
/**
*
*/
@Size(max = 50, message = "事故案号最大长度要小于 50")
private String incidentNumber;
/**
*
*/
@Size(max = 100, message = "事故名称最大长度要小于 100")
private String incidentName;
/**
*
*/
private String incidentType;
/**
*
*/
@Size(max = 100, message = "所属公司最大长度要小于 100")
private String corpinfoId;
/**
*
*/
@Size(max = 50, message = "事故级别最大长度要小于 50")
private String incidentLevel;
/**
*
*/
@Size(max = 50, message = "事故性质最大长度要小于 50")
private String incidentNature;
/**
*
*/
@Size(max = 200, message = "事故发生地点最大长度要小于 200")
private String location;
/**
*
*/
private Date incidentDate;
/**
*
*/
@Size(max = 100, message = "直接经济损失(万元)最大长度要小于 100")
private Integer directLoss;
/**
*
*/
private Integer injured;
/**
*
*/
private Integer fatalities;
/**
*
*/
private Integer seriouslyInjured;
/**
*
*/
@Size(max = 200, message = "事故起因最大长度要小于 200")
private String cause;
/**
*
*/
private String summary;
/**
* 使 BLOB
*/
private String photos;
/**
*
*/
private String analysis;
/**
*
*/
private String suggestions;
/**
*
*/
private String measures;
/**
*
*/
@Size(max = 50, message = "填表人最大长度要小于 50")
private String creator;
/**
*
*/
private Date reportDate;
/**
*
*/
@Size(max = 50, message = "创建人最大长度要小于 50")
private String createdBy;
/**
*
*/
private Date createdTime;
/**
*
*/
@Size(max = 50, message = "修改人最大长度要小于 50")
private String updatedBy;
/**
*
*/
private Date updatedTime;
/**
* 0=1=
*/
@NotNull(message = "逻辑删除标志0=未删除1=已删除不能为null")
private Integer isDeleted;
private static final long serialVersionUID = 1L;
// public AccidentRecords(AccidentRecordsExcel reader, DictionariesService service) throws Exception {
// this.id = IdUtil.getSnowflake(1, 1).nextId();
// this.corpinfoId = reader.getCompanyName();
// this.incidentNumber = reader.getIncidentNumber();
// this.incidentName = reader.getIncidentName();
// this.incidentType = findByName(reader.getIncidentType(), service, "8d4140a900184b60836ad1a6490fd510");
// this.incidentLevel = findByName(reader.getIncidentLevel(), service, "b61a1edc59c0430c8741c5f51aa26c3c");
// this.incidentNature = reader.getIncidentNature();
// this.location = reader.getLocation();
// this.incidentDate = dateFormat(reader.getIncidentDate());
// this.directLoss = reader.getDirectLoss();
// this.injured = reader.getInjured();
// this.fatalities = reader.getFatalities();
// this.seriouslyInjured = reader.getSeriouslyInjured();
// this.cause = reader.getCause();
// this.summary = reader.getSummary();
// this.analysis = reader.getAnalysis();
// this.suggestions = reader.getSuggestions();
// this.measures = reader.getMeasures();
// this.creator = reader.getCreator();
// this.reportDate = dateFormat(reader.getReportDate());
// this.createdBy = Jurisdiction.getUsername();
// this.createdTime = new Date();
// }
//
// // 缓存字典 避免频繁请求数据库
// public static final Map<String, List<Dictionaries>> dictMap = new ConcurrentHashMap<>();
//
// private String findByName(String bianma, DictionariesService service, String parentId) throws Exception {
// if (StrUtil.isEmpty(bianma)) {
// return null;
// }
//
// if (dictMap.containsKey(parentId)) {
// Optional<Dictionaries> optional = dictMap.get(parentId).stream().filter(d -> d.getBIANMA().equals(bianma)).findAny();
// return optional.map(Dictionaries::getDICTIONARIES_ID).orElse(null);
// }
// List<Dictionaries> dict = service.listSubDictByParentId(parentId);
// dict = dict == null ? new ArrayList<>() : dict;
// dictMap.put(parentId, dict);
// return dict.stream().filter(d -> d != null && d.getBIANMA().equals(bianma))
// .findAny().map(Dictionaries::getDICTIONARIES_ID).orElse(null);
// }
//
// private Date dateFormat(String dateStr) {
// if (StrUtil.isEmpty(dateStr)) {
// return null;
// }
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// try {
// return formatter.parse(dateStr);
// } catch (ParseException e) {
// log.error("日期转换失败", e);
// throw new RuntimeException("日期转换失败支持的格式yyyy-MM-dd HH:mm:ss");
// }
// }
}

View File

@ -0,0 +1,16 @@
package com.zcloud.entity.accident;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target(FIELD)
@Retention(RUNTIME)
@Documented
public @interface ExcelValue {
String value();
}

View File

@ -0,0 +1,135 @@
package com.zcloud.entity.accident.dto;
import cn.hutool.core.date.DateUtil;
import com.zcloud.entity.accident.ExcelValue;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class AccidentRecordsExcel implements Serializable {
/**
*
*/
@ExcelValue(value = " 事故案号")
private String incidentNumber;
/**
*
*/
@ExcelValue(value = " 事故名称")
private String incidentName;
/**
*
*/
@ExcelValue(value = " 事故类型")
private String incidentType;
/**
*
*/
@ExcelValue(value = "所属公司")
private String companyName;
/**
*
*/
@ExcelValue(value = "事故级别")
private String incidentLevel;
// /**
// * 事故性质
// */
// @ExcelValue(value = "事故性质")
// private String incidentNature;
/**
*
*/
@ExcelValue(value = "事故发生地点")
private String location;
/**
*
*/
@ExcelValue(value = "事故发生时间")
private String incidentDate;
/**
*
*/
@ExcelValue(value = "直接经济损失(万元)")
private Integer directLoss;
/**
*
*/
@ExcelValue(value = "受伤人数")
private Integer injured;
/**
*
*/
@ExcelValue(value = "死亡人数")
private Integer fatalities;
/**
*
*/
@ExcelValue(value = "重伤人数")
private Integer seriouslyInjured;
/**
*
*/
@ExcelValue(value = "事故起因")
private String cause;
/**
*
*/
@ExcelValue(value = "事故概述")
private String summary;
/**
*
*/
@ExcelValue(value = "原因分析及责任认定")
private String analysis;
/**
*
*/
@ExcelValue(value = "考核建议")
private String suggestions;
/**
*
*/
@ExcelValue(value = "整改措施")
private String measures;
/**
*
*/
@ExcelValue(value = "填表人")
private String creator;
/**
*
*/
@ExcelValue(value = "报出日期")
private String reportDate;
public void setIncidentDate(Date incidentDate) {
this.incidentDate = DateUtil.format(incidentDate, "yyyy年MM月dd日HH时mm分ss秒");
}
public void setReportDate(Date reportDate) {
this.reportDate = DateUtil.format(reportDate, "yyyy年MM月dd日HH时mm分ss秒");
}
}

View File

@ -0,0 +1,4 @@
package com.zcloud.entity.accident.validated;
public interface Create {
}

View File

@ -0,0 +1,4 @@
package com.zcloud.entity.accident.validated;
public interface Update {
}

View File

@ -0,0 +1,61 @@
package com.zcloud.mapper.datasource.accident;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.accident.AccidentRecords;
import com.zcloud.entity.accident.dto.AccidentRecordsExcel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface AccidentRecordsMapper {
/**
*
*
* @param page
* @return
*/
List<PageData> listPage(Page page);
/**
* id
*
* @param id id
* @return
*/
PageData getById(String id);
/**
*
*
* @param accidentRecords
* @return
*/
int save(AccidentRecords accidentRecords);
/**
*
*
* @param accidentRecords
* @return
*/
int updateById(AccidentRecords accidentRecords);
/**
*
*
* @param ids
* @return
*/
int delete(@Param("ids") List<String> ids);
/**
* excel
*
* @param pd
* @return
*/
List<AccidentRecordsExcel> listExcel(@Param("pd") PageData pd);
}

View File

@ -121,4 +121,6 @@ public interface FireRecordMapper {
void doRemoveRecordPointHiddenByCidRidDid(PageData checkInfo); void doRemoveRecordPointHiddenByCidRidDid(PageData checkInfo);
PageData getPhotoUploadMethod(PageData pageData); PageData getPhotoUploadMethod(PageData pageData);
List<PageData> datalistPageV3(Page page);
} }

View File

@ -0,0 +1,79 @@
package com.zcloud.service.accident;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.accident.AccidentRecords;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
public interface AccidentRecordsService {
/**
*
*
* @param page
* @return
*/
List<PageData> queryPage(Page page);
/**
*
*
* @param id
* @return
*/
PageData getById(String id);
/**
*
*
* @param accidentRecords
*/
void save(AccidentRecords accidentRecords);
/**
*
*
* @param bean
*/
void update(AccidentRecords bean);
/**
*
*
* @param ids
*/
void delete(List<String> ids);
/**
* Excel
*
* @param pd
* @return
*/
Map<String,Object> exportExcel(PageData pd);
// /**
// * 导入Excel
// *
// * @param file 文件
// */
// void importExcel(MultipartFile file);
/**
*
*
* @param file
* @return
*/
String importPhotos(MultipartFile file);
/**
*
*
* @param path
*/
void deletePhotos(String path);
}

View File

@ -0,0 +1,187 @@
package com.zcloud.service.accident.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.accident.AccidentRecords;
import com.zcloud.entity.accident.ExcelValue;
import com.zcloud.entity.accident.dto.AccidentRecordsExcel;
import com.zcloud.mapper.datasource.accident.AccidentRecordsMapper;
import com.zcloud.service.accident.AccidentRecordsService;
import com.zcloud.service.bus.ImgFilesService;
import com.zcloud.util.Const;
import com.zcloud.util.Jurisdiction;
import com.zcloud.util.Smb;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class AccidentRecordsServiceImpl implements AccidentRecordsService {
private final AccidentRecordsMapper accidentRecordsMapper;
private static final List<Field> HEADER_ALIAS_CACHE;
private final ImgFilesService imgFilesService;
static {
HEADER_ALIAS_CACHE = Arrays.stream(ReflectUtil.getFields(AccidentRecordsExcel.class))
.filter(field -> field.isAnnotationPresent(ExcelValue.class))
.collect(Collectors.toList());
}
@Override
public List<PageData> queryPage(Page page) {
PageData data = page.getPd();
data.put("corpInfoId", Jurisdiction.getCORPINFO_ID());
return accidentRecordsMapper.listPage(page);
}
@Override
public PageData getById(String id) {
return accidentRecordsMapper.getById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(AccidentRecords accidentRecords) {
accidentRecords.setId(IdUtil.fastSimpleUUID());
accidentRecords.setCreatedBy(Jurisdiction.getUsername());
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);
// 设置成东八区时间
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
DateUtil.parse(dateFormat.format(date), DatePattern.NORM_DATETIME_PATTERN);
accidentRecords.setIsDeleted(0);
String corpinfoId = StrUtil.isEmpty(accidentRecords.getCorpinfoId()) ? Jurisdiction.getCORPINFO_ID() : accidentRecords.getCorpinfoId();
accidentRecords.setCorpinfoId(corpinfoId);
Assert.isTrue(accidentRecordsMapper.save(accidentRecords) == 1, "新增事故记录失败");
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(AccidentRecords accidentRecords) {
accidentRecords.setUpdatedBy(Jurisdiction.getUsername());
accidentRecords.setUpdatedTime(new Date());
String corpinfoId = StrUtil.isEmpty(accidentRecords.getCorpinfoId()) ? Jurisdiction.getCORPINFO_ID() : accidentRecords.getCorpinfoId();
accidentRecords.setCorpinfoId(corpinfoId);
Assert.isTrue(accidentRecordsMapper.updateById(accidentRecords) == 1, "更新事故记录失败");
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(List<String> ids) {
Assert.isTrue(accidentRecordsMapper.delete(ids) == ids.size(), "删除事故记录失败");
}
@Override
public Map<String, Object> exportExcel(PageData pd) {
// 查询数据
pd.put("corpInfoId", Jurisdiction.getCORPINFO_ID());
List<AccidentRecordsExcel> excels = accidentRecordsMapper.listExcel(pd);
// 检查查询结果是否为空
if (excels == null || excels.isEmpty()) {
throw new RuntimeException("没有查询到数据");
}
Map<String, Object> dataMap = new HashMap<String, Object>() {{
put("filename", "事故调查");
put("titles", HEADER_ALIAS_CACHE.stream().map(field -> field.getAnnotation(ExcelValue.class)
.value()).collect(Collectors.toList()));
}};
List<PageData> varList = excels.stream().map(excel -> {
PageData data = new PageData();
for (int i = 0; i < HEADER_ALIAS_CACHE.size(); i++) {
data.put("var" + (i + 1), ReflectUtil.getFieldValue(excel, HEADER_ALIAS_CACHE.get(i)));
}
return data;
}).collect(Collectors.toList());
dataMap.put("varList", varList);
return dataMap;
}
// @Override
// public void importExcel(MultipartFile file) {
// // ExecutorType.BATCH: 这个执行器会批量执行所有更新语句。
// SqlSession sqlSession = null;
// try (ExcelReader reader = ExcelUtil.getReader(file.getInputStream())) {
// // 标记别名
// HEADER_ALIAS_CACHE.forEach((k, v) -> reader.addHeaderAlias(v, k));
// List<AccidentRecordsExcel> recordsExcels = reader.readAll(AccidentRecordsExcel.class);
// if (CollUtil.isEmpty(recordsExcels)) {
// throw new RuntimeException("没有数据");
// }
// sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
// AccidentRecordsMapper mapper = sqlSession.getMapper(AccidentRecordsMapper.class);
// for (int i = 0; i < recordsExcels.size(); i++) {
// mapper.save(new AccidentRecords(recordsExcels.get(i), dictionariesService));
// if ((i + 1) % 300 == 0 || i == recordsExcels.size() - 1) {
// sqlSession.flushStatements();
// }
// }
// // 避免刷新数据字典不生效 每次导出重新查询字典
// AccidentRecords.dictMap.clear();
// sqlSession.commit();
// } catch (RuntimeException e) {
// if (sqlSession != null) {
// sqlSession.rollback();
// }
// log.error("导入excel失败", e);
// throw e;
// } catch (Exception e) {
// if (sqlSession != null) {
// sqlSession.rollback();
// }
// log.error("导入excel失败", e);
// throw new RuntimeException("导入excel失败");
// } finally {
// IoUtil.close(sqlSession);
// }
// }
@Override
public String importPhotos(MultipartFile file) {
String fileName = IdUtil.fastSimpleUUID() + "." + FileUtil.extName(file.getOriginalFilename());
PageData pd = new PageData();
pd.put("IMGFILES_ID", IdUtil.fastSimpleUUID());
pd.put("FOREIGN_KEY", IdUtil.fastSimpleUUID());
pd.put("TYPE", 117);
try {
String path = Const.FILEPATHFILE + IdUtil.fastSimpleUUID() + "/" + DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN);
Smb.sshSftp(file, fileName, path);
pd.put("FILEPATH", path + "/" + fileName);
imgFilesService.save(pd);
return pd.getString("FILEPATH");
} catch (Exception e) {
log.error("导入图片失败", e);
throw new RuntimeException("导入图片失败");
}
}
@Override
public void deletePhotos(String path) {
try {
Smb.deleteFile(path);
} catch (Exception e) {
throw new RuntimeException("图片删除失败");
}
}
}

View File

@ -142,4 +142,6 @@ public interface FireRecordService {
void doRemoveRecordPointHiddenByCidRidDid(PageData checkInfo); void doRemoveRecordPointHiddenByCidRidDid(PageData checkInfo);
PageData getPhotoUploadMethod(PageData pageData); PageData getPhotoUploadMethod(PageData pageData);
List<PageData> getCheckListByAppV3(Page page);
} }

View File

@ -799,4 +799,9 @@ public class FireRecordServiceImpl implements FireRecordService {
public PageData getPhotoUploadMethod(PageData pageData) { public PageData getPhotoUploadMethod(PageData pageData) {
return fireRecordMapper.getPhotoUploadMethod(pageData); return fireRecordMapper.getPhotoUploadMethod(pageData);
} }
@Override
public List<PageData> getCheckListByAppV3(Page page) {
return fireRecordMapper.datalistPageV3(page);
}
} }

View File

@ -0,0 +1,322 @@
<?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.zcloud.mapper.datasource.accident.AccidentRecordsMapper">
<select id="listPage" parameterType="com.zcloud.entity.Page" resultType="pd">
select ACCIDENT_ID as id, CORP_NAME as companyName, LOCATION as 'location', INCIDENT_DATE as 'incidentDate', INCIDENT_NAME as 'incidentName'
from bus_accident as ar
left join bus_corp_info as bci on ar.CORPINFO_ID = bci.CORPINFO_ID
<where>
<if test="pd.corpInfoId != null and pd.corpInfoId != ''">
and ar.CORPINFO_ID = #{pd.corpInfoId}
</if>
<if test="pd.incidentName != null and pd.incidentName != ''">
and INCIDENT_NAME like concat('%', #{pd.incidentName}, '%')
</if>
<if test="pd.startTime != null and pd.startTime != '' and pd.endTime != null and pd.startTime != ''">
and INCIDENT_DATE between #{pd.startTime} and #{pd.endTime}
</if>
<if test="pd.location != null and pd.location != ''">
and LOCATION like concat('%', #{pd.location}, '%')
</if>
<if test="pd.incidentLevel != null and pd.incidentLevel != ''">
and INCIDENT_LEVEL = #{pd.incidentLevel}
</if>
<if test="pd.incidentType != null and pd.incidentType != ''">
and INCIDENT_TYPE = #{pd.incidentType}
</if>
<if test="1 == 1">
and IS_DELETED = 0
</if>
</where>
order by INCIDENT_DATE desc , companyName
</select>
<select id="getById" resultType="com.zcloud.entity.PageData">
select ACCIDENT_ID as id,
INCIDENT_NUMBER as incidentNumber,
INCIDENT_NAME as incidentName,
INCIDENT_TYPE as incidentType,
INCIDENT_LEVEL as incidentLevel,
CORP_NAME as companyName,
INCIDENT_NATURE as incidentNature,
LOCATION as location,
INCIDENT_DATE as incidentDate,
DIRECT_LOSS as directLoss,
INJURED as injured,
FATALITIES as fatalities,
SERIOUSLY_INJURED as seriouslyInjured,
CAUSE as cause,
SUMMARY as summary,
PHOTOS as photos,
ANALYSIS as analysis,
SUGGESTIONS as suggestions,
MEASURES as measures,
ar.CREATOR as creator,
REPORT_DATE as reportDate
from bus_accident as ar
left join bus_corp_info as bci on ar.corpinfo_id = bci.CORPINFO_ID
where ar.ACCIDENT_ID = #{id}
and ar.IS_DELETED = 0;
</select>
<insert id="save" parameterType="com.zcloud.entity.accident.AccidentRecords">
insert into bus_accident
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
ACCIDENT_ID,
</if>
<if test="incidentNumber != null">
INCIDENT_NUMBER,
</if>
<if test="incidentName != null">
INCIDENT_NAME,
</if>
<if test="incidentType != null">
INCIDENT_TYPE,
</if>
<if test="corpinfoId != null">
CORPINFO_ID,
</if>
<if test="incidentLevel != null">
INCIDENT_LEVEL,
</if>
<if test="incidentNature != null">
INCIDENT_NATURE,
</if>
<if test="location != null">
LOCATION,
</if>
<if test="incidentDate != null">
INCIDENT_DATE,
</if>
<if test="directLoss != null">
DIRECT_LOSS,
</if>
<if test="injured != null">
INJURED,
</if>
<if test="fatalities != null">
FATALITIES,
</if>
<if test="seriouslyInjured != null">
SERIOUSLY_INJURED,
</if>
<if test="cause != null">
CAUSE,
</if>
<if test="summary != null">
SUMMARY,
</if>
<if test="photos != null">
PHOTOS,
</if>
<if test="analysis != null">
ANALYSIS,
</if>
<if test="suggestions != null">
SUGGESTIONS,
</if>
<if test="measures != null">
MEASURES,
</if>
<if test="creator != null">
CREATOR,
</if>
<if test="reportDate != null">
REPORT_DATE,
</if>
<if test="createdBy != null">
CREATED_BY,
</if>
<if test="createdTime != null">
CREATED_TIME,
</if>
<if test="updatedBy != null">
UPDATED_BY,
</if>
<if test="updatedTime != null">
UPDATED_TIME,
</if>
<if test="isDeleted != null">
IS_DELETED
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="incidentNumber != null">
#{incidentNumber},
</if>
<if test="incidentName != null">
#{incidentName},
</if>
<if test="incidentType != null">
#{incidentType},
</if>
<if test="corpinfoId != null">
#{corpinfoId},
</if>
<if test="incidentLevel != null">
#{incidentLevel},
</if>
<if test="incidentNature != null">
#{incidentNature},
</if>
<if test="location != null">
#{location},
</if>
<if test="incidentDate != null">
#{incidentDate},
</if>
<if test="directLoss != null">
#{directLoss},
</if>
<if test="injured != null">
#{injured},
</if>
<if test="fatalities != null">
#{fatalities},
</if>
<if test="seriouslyInjured != null">
#{seriouslyInjured},
</if>
<if test="cause != null">
#{cause},
</if>
<if test="summary != null">
#{summary},
</if>
<if test="photos != null">
#{photos},
</if>
<if test="analysis != null">
#{analysis},
</if>
<if test="suggestions != null">
#{suggestions},
</if>
<if test="measures != null">
#{measures},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="reportDate != null">
#{reportDate},
</if>
<if test="createdBy != null">
#{createdBy},
</if>
<if test="createdTime != null">
#{createdTime},
</if>
<if test="updatedBy != null">
#{updatedBy},
</if>
<if test="updatedTime != null">
#{updatedTime},
</if>
<if test="isDeleted != null">
#{isDeleted}
</if>
</trim>
</insert>
<update id="updateById" parameterType="com.zcloud.entity.accident.AccidentRecords">
UPDATE bus_accident
<set>
<if test="incidentNumber != null">incident_number = #{incidentNumber},</if>
<if test="incidentName != null">incident_name = #{incidentName},</if>
<if test="incidentType != null">incident_type = #{incidentType},</if>
<if test="corpinfoId != null">corpinfo_id = #{corpinfoId},</if>
<if test="incidentLevel != null">incident_level = #{incidentLevel},</if>
<if test="incidentNature != null">incident_nature = #{incidentNature},</if>
<if test="location != null">location = #{location},</if>
<if test="incidentDate != null">incident_date = #{incidentDate},</if>
<if test="directLoss != null">direct_loss = #{directLoss},</if>
<if test="injured != null">injured = #{injured},</if>
<if test="fatalities != null">fatalities = #{fatalities},</if>
<if test="seriouslyInjured != null">seriously_injured = #{seriouslyInjured},</if>
<if test="cause != null">cause = #{cause},</if>
<if test="summary != null">summary = #{summary},</if>
<if test="photos != null">photos = #{photos},</if>
<if test="analysis != null">analysis = #{analysis},</if>
<if test="suggestions != null">suggestions = #{suggestions},</if>
<if test="measures != null">measures = #{measures},</if>
<if test="creator != null">creator = #{creator},</if>
<if test="reportDate != null">report_date = #{reportDate},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="isDeleted != null">is_deleted = #{isDeleted}</if>
</set>
WHERE accident_id = #{id} and is_deleted = 0
</update>
<update id="delete">
update bus_accident
set is_deleted = 1
where
accident_id IN
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="listExcel" resultType="com.zcloud.entity.accident.dto.AccidentRecordsExcel" parameterType="pd">
select incident_number as incidentNumber,
incident_name as incidentName,
(select NAME
from sys_dictionaries
where PARENT_ID = '8d4140a900184b60836ad1a6490fd510'
and BIANMA = incident_type) as 'incidentType',
(select NAME
from sys_dictionaries
where PARENT_ID = 'b61a1edc59c0430c8741c5f51aa26c3c'
and BIANMA = incident_level) as 'incidentLevel',
CORP_NAME as 'companyName',
`location` as location,
incident_date as 'incidentDate',
direct_loss as directLoss,
injured,
fatalities,
seriously_injured as seriouslyInjured,
cause,
summary,
analysis,
suggestions,
measures,
ar.creator as creator,
report_date as 'reportDate'
from bus_accident as ar
left join bus_corp_info as bci on ar.corpinfo_id = bci.CORPINFO_ID
<where>
<if test="pd.corpInfoId != null and pd.corpInfoId != ''">
and ar.corpinfo_id = #{pd.corpInfoId}
</if>
<if test="pd.incidentName != null and pd.incidentName != ''">
and incident_name like concat('%', #{pd.incidentName}, '%')
</if>
<if test="pd.incidentDates != null and pd.incidentDates.size() == 2">
and incident_date between #{pd.incidentDates[0]} and #{pd.incidentDates[1]}
</if>
<if test="pd.location != null and pd.location != ''">
and location like concat('%', #{pd.location}, '%')
</if>
<if test="pd.incidentLevel != null and pd.incidentLevel != ''">
and incident_level like concat('%', #{pd.incidentLevel}, '%')
</if>
<if test="pd.incidentType != null">
and incident_type = #{pd.incidentType}
</if>
<if test="1 == 1">
and is_deleted = 0
</if>
</where>
order by incident_date desc, companyName
</select>
</mapper>

View File

@ -1031,5 +1031,58 @@
frp.EQUIPMENT_POINT_ID = #{EQUIPMENT_POINT_ID} frp.EQUIPMENT_POINT_ID = #{EQUIPMENT_POINT_ID}
AND frp.ISDELETE = '0' AND frp.ISDELETE = '0'
</select> </select>
<select id="datalistPageV3" resultType="com.zcloud.entity.PageData" parameterType="com.zcloud.entity.Page">
SELECT
cl.FIRE_CHECK_STANDARD_NAME,
fr.FIRE_CHECK_ID,
cl.FIRE_CHECK_TYPE AS FIRE_CHECK_TYPE_ID,
d.`NAME` AS DEPARTMENT_NAME,
su.`NAME` AS USER_NAME,
count(
IF
( fr.FINISHED = 0, NULL, fr.FINISHED )) COUNT,
IF
( temp.FINISHED > 0, temp.FINISHED, 0 ) checkCount,
cl.STATE,
sys_dictionaries.`NAME` AS PERIODNAME
FROM
bus_fire_record AS fr
LEFT JOIN bus_fire_record_point AS cp ON fr.FIRE_CHECK_ID = cp.FIRE_CHECK_ID
LEFT JOIN bus_fire_checklist AS cl ON cp.FIRE_CHECK_ID = cl.FIRE_CHECK_ID
LEFT JOIN oa_department AS d ON cl.DEPARTMENT_ID = d.DEPARTMENT_ID
LEFT JOIN sys_user AS su ON cl.USER_ID = su.USER_ID
LEFT JOIN sys_dictionaries ON cl.FIRE_CHECK_TYPE = sys_dictionaries.BIANMA
LEFT JOIN ( SELECT count(FINISHED) FINISHED ,FIRE_CHECK_ID FROM bus_fire_record WHERE
CONCAT(date_format(current_date(),'%Y-%m-%d'),' 00:00:00') BETWEEN PERIODSTART AND PERIODEND and isdelete = 0 and FINISHED = '1' GROUP BY
FIRE_CHECK_ID ) temp ON
fr.FIRE_CHECK_ID = temp.FIRE_CHECK_ID
LEFT JOIN ( SELECT * FROM bus_fire_record WHERE CONCAT(date_format(current_date()-1,'%Y-%m-%d'),' 00:00:00')
BETWEEN PERIODSTART AND
PERIODEND GROUP BY FIRE_CHECK_ID ) st ON fr.FIRE_CHECK_ID = st.FIRE_CHECK_ID
WHERE
fr.ISDELETE = 0
AND cl.ISDELETE = 0
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<!--公司领导-->
<when test='pd.roleLevel == "0"'>
<if test="pd.CORPINFO_ID!=null and pd.CORPINFO_ID != ''">
AND cp.CORPINFO_ID = #{pd.CORPINFO_ID,jdbcType=VARCHAR}
</if>
</when>
<when test='pd.roleLevel == "1"'>
and cp.DEPARTMENT_ID in (${pd.supDeparIds})
</when>
<when test='pd.roleLevel == "2"'>
<if test="pd.FIRE_POINT_ID != null and pd.FIRE_POINT_ID != ''">
AND cp.FIRE_POINT_ID = #{pd.FIRE_POINT_ID}
</if>
</when>
</choose>
</if>
GROUP BY
FIRE_CHECK_ID
order by fr. CREATTIME
</select>
</mapper> </mapper>

View File

@ -0,0 +1,122 @@
package com.zcloud.service.accident.service;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.accident.AccidentRecords;
import com.zcloud.entity.accident.dto.AccidentRecordsExcel;
import com.zcloud.mapper.datasource.accident.AccidentRecordsMapper;
import com.zcloud.service.accident.impl.AccidentRecordsServiceImpl;
import com.zcloud.util.Jurisdiction;
import org.apache.commons.io.FilenameUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
@SpringBootTest
@RunWith(SpringRunner.class)
public class AccidentRecordsServiceTest {
@Autowired
@InjectMocks
private AccidentRecordsServiceImpl accidentRecordsService;
@MockBean
private AccidentRecordsMapper accidentRecordsMapper;
// @MockBean
// private DictionariesService dictionariesService;
//
// @MockBean
// private SqlSessionFactory sqlSessionFactory;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testQueryPage() {
Page page = new Page();
List<PageData> expectedList = new ArrayList<>();
when(accidentRecordsMapper.listPage(page)).thenReturn(expectedList);
List<PageData> resultList = accidentRecordsService.queryPage(page);
assertEquals(expectedList, resultList);
verify(accidentRecordsMapper, times(1)).listPage(page);
}
@Test
public void testGetById() {
}
@Test
public void testSave() {
}
@Test
public void testUpdate() {
AccidentRecords accidentRecords = new AccidentRecords();
accidentRecords.setUpdatedBy(Jurisdiction.getUsername());
accidentRecords.setUpdatedTime(new Date());
accidentRecordsService.update(accidentRecords);
verify(accidentRecordsMapper, times(1)).updateById(accidentRecords);
}
@Test
public void testDelete() {
Long[] ids = {1L, 2L};
//accidentRecordsService.delete(ids);
//verify(accidentRecordsMapper, times(1)).delete(ids);
}
@Test
public void testExportExcel() throws Exception {
PageData pd = new PageData();
List<AccidentRecordsExcel> expectedList = new ArrayList<>();
when(accidentRecordsMapper.listExcel(pd)).thenReturn(expectedList);
HttpServletResponse response = mock(HttpServletResponse.class);
//accidentRecordsService.exportExcel(pd, response);
verify(response, times(1)).setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
verify(response, times(1)).setCharacterEncoding("utf-8");
verify(response, times(1)).setHeader("Content-Disposition", "attachment;filename*=utf-8''事故调查表.xlsx");
}
// @Test
// public void testImportExcel() throws Exception {
// InputStream inputStream = new ByteArrayInputStream(ExcelUtil.write(new ArrayList<>(), true).getBytes());
// MultipartFile file = mock(MultipartFile.class);
// when(file.getInputStream()).thenReturn(inputStream);
//
// accidentRecordsService.importExcel(file);
//
// verify(sqlSessionFactory, times(1)).openSession(ExecutorType.BATCH, false);
// }
public static void main(String[] args) {
String extension = FilenameUtils.getExtension("akjsfhahjf.apk");
System.out.println(extension);
}
}