Commit 667c954e authored by KeYong's avatar KeYong

Merge remote-tracking branch 'origin/developer' into develop

# Conflicts: # amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/controller/DutyCarController.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/IDutyCommonService.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/impl/DutyCommonServiceImpl.java
parents f7d4a0b0 44686417
...@@ -587,6 +587,7 @@ public class DateUtils { ...@@ -587,6 +587,7 @@ public class DateUtils {
e.printStackTrace(); e.printStackTrace();
} }
return now; return now;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
...@@ -600,7 +601,8 @@ public class DateUtils { ...@@ -600,7 +601,8 @@ public class DateUtils {
/* /*
System.out.println(getDaysOfMonth(dateParse("2017-02-01", null))); System.out.println(getDaysOfMonth(dateParse("2017-02-01", null)));
System.out.println(getDaysOfYear(dateParse("2017-01-30", null)));*/ System.out.println(getDaysOfYear(dateParse("2017-01-30", null)));*/
//System.out.println(dateFormat(dateAddMonths(dateParse("2017-02-07", StrUtils.MONTH_PATTERN), -12), StrUtils.MONTH_PATTERN)); //System.out.println(dateFormat(dateAddMonths(dateParse("2017-02-07", StrUtils.MONTH_PATTERN), -12), StrUtils
// .MONTH_PATTERN));
/*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null)); /*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null));
System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/ System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/
} }
......
...@@ -6,6 +6,7 @@ import java.lang.reflect.Method; ...@@ -6,6 +6,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Random;
/** /**
* 生成树工具类 * 生成树工具类
...@@ -328,5 +329,15 @@ public class TreeParser { ...@@ -328,5 +329,15 @@ public class TreeParser {
return childList; return childList;
} }
public static String genTreeCode() {
int length = 6;
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(62);
sb.append(str.charAt(number));
}
return sb.toString();
}
} }
package com.yeejoin.amos.boot.module.common.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.typroject.tyboot.core.foundation.utils.Bean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel(value = "DutyCarDto", description = "值班车辆")
public class DutyCarExcelDto implements Serializable {
@ExcelIgnore
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "序号", index = 0)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelIgnore
@ApiModelProperty(value = "消防队伍id")
private String teamId;
@ExcelProperty(value = "消防队伍", index = 1)
@ApiModelProperty(value = "消防队伍名称")
private String teamName;
@ExcelIgnore
@ApiModelProperty(value = "用户id")
private String userId;
@ExcelProperty(value = "姓名", index = 2)
@ApiModelProperty(value = "用户名称")
private String userName;
@ExcelIgnore
@ApiModelProperty(value = "岗位id")
private String postType;
@ExcelProperty(value = "岗位", index = 3)
@ApiModelProperty(value = "岗位名称")
private String postTypeName;
@ExcelIgnore
@ApiModelProperty(value = "车辆id")
private String carId;
@ExplicitConstraint(indexNum = 4, sourceClass = RoleNameExplicitConstraint.class, method = "getCarList") //固定下拉内容
@ExcelProperty(value = "车辆名称(车牌)", index = 4)
@ApiModelProperty(value = "车辆名称")
private String carName;
@ExcelIgnore
@ApiModelProperty(value = "值班信息")
private List<DutyPersonShiftDto> dutyShift = new ArrayList<>();
}
package com.yeejoin.amos.boot.module.common.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel(value = "DutyPersonDto", description = "值班人")
public class DutyPersonExcelDto implements Serializable {
@ExcelIgnore
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "序号", index = 0)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelProperty(value = "用户id", index = 1)
@ApiModelProperty(value = "用户id")
private String userId;
@ExcelProperty(value = "姓名", index = 2)
@ApiModelProperty(value = "用户名称")
private String userName;
@ExcelIgnore
@ApiModelProperty(value = "部门id")
private String deptId;
@ExcelIgnore
@ApiModelProperty(value = "部门名称")
private String deptName;
@ApiModelProperty(value = "岗位id")
private String postType;
@ApiModelProperty(value = "岗位名称")
private String postTypeName;
@ApiModelProperty(value = "值班信息")
private List<DutyPersonShiftDto> dutyShift;
}
...@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.common.api.dto; ...@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.common.api.enums.ExcelSelectData;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint; import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint; import com.yeejoin.amos.boot.module.common.api.excel.RoleNameExplicitConstraint;
......
...@@ -38,4 +38,7 @@ public class FireTeamCardDto { ...@@ -38,4 +38,7 @@ public class FireTeamCardDto {
private Integer dispatchNum; private Integer dispatchNum;
@ApiModelProperty(value = "执勤数量") @ApiModelProperty(value = "执勤数量")
private Integer onDutyNum; private Integer onDutyNum;
@ApiModelProperty(value = "树结构层级code")
private String treeCode;
} }
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.common.api.dto; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* *
* @author DELL * @author DELL
...@@ -27,4 +29,7 @@ public class FireTeamListDto { ...@@ -27,4 +29,7 @@ public class FireTeamListDto {
@ApiModelProperty(value = "树节点id") @ApiModelProperty(value = "树节点id")
private Long nodeId; private Long nodeId;
@ApiModelProperty(value = "树节点子节点id集合")
private List<String> nodeIds;
} }
...@@ -68,7 +68,7 @@ public class FirefightersExcelDto extends BaseDto { ...@@ -68,7 +68,7 @@ public class FirefightersExcelDto extends BaseDto {
private Date birthdayTime; private Date birthdayTime;
@ExplicitConstraint(indexNum = 7, source = {"男", "女"}) //固定下拉内容 @ExplicitConstraint(indexNum = 7, source = {"男", "女"}) //固定下拉内容
@ExcelProperty(value = "性别", index = 5) @ExcelProperty(value = "性别", index = 7)
@ApiModelProperty(value = "性别") @ApiModelProperty(value = "性别")
private String gender; private String gender;
......
...@@ -80,4 +80,6 @@ public class FireTeam extends BaseEntity { ...@@ -80,4 +80,6 @@ public class FireTeam extends BaseEntity {
@TableField(fill=FieldFill.INSERT_UPDATE) @TableField(fill=FieldFill.INSERT_UPDATE)
private String recUserName; private String recUserName;
@ApiModelProperty(value = "树结构层级code")
private String treeCode;
} }
package com.yeejoin.amos.boot.module.common.api.enums;
/**
* @Author: Xing Lei
* @Description:
* @Date: 2020/4/7 13:50
*/
public enum TitleEnum {
NUMBER("序号", "number"),
FIRE_TEAM("消防队伍", "teamName"),
USER_ID("用户ID", "userId"),
USER_NAME("姓名", "userName"),
POST("岗位", "post"),
CAR("车辆", "carName"),
ARRANGE("班次", "arrange");
TitleEnum(String name, String key) {
this.name = name;
this.key = key;
}
private String name;
private String key;
public String getName() {
return name;
}
public String getKey() {
return key;
}
}
package com.yeejoin.amos.boot.module.common.api.excel;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams;
import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler;
import org.apache.poi.ss.usermodel.*;
/**
* @title: ExcelStyleUtil
* @Author fpy
* @Date: 2021/7/8 15:36
* @Version 1.0
*/
public class ExcelStyleUtil implements IExcelExportStyler {
private static final short STRING_FORMAT = (short) BuiltinFormats.getBuiltinFormat("TEXT");
private static final short FONT_SIZE_TEN = 10;
private static final short FONT_SIZE_ELEVEN = 11;
private static final short FONT_SIZE_TWELVE = 12;
/**
* 大标题样式
*/
private CellStyle headerStyle;
/**
* 每列标题样式
*/
private CellStyle titleStyle;
/**
* 数据行样式
*/
private CellStyle styles;
public ExcelStyleUtil(Workbook workbook) {
this.init(workbook);
}
/**
* 初始化样式
*
* @param workbook
*/
private void init(Workbook workbook) {
//this.headerStyle = initHeaderStyle(workbook);
this.titleStyle = initTitleStyle(workbook);
this.styles = initStyles(workbook);
}
/**
* 大标题样式
*
* @param color
* @return
*/
@Override
public CellStyle getHeaderStyle(short color) {
return headerStyle;
}
/**
* 每列标题样式
*
* @param color
* @return
*/
@Override
public CellStyle getTitleStyle(short color) {
return titleStyle;
}
/**
* 数据行样式
*
* @param parity 可以用来表示奇偶行
* @param entity 数据内容
* @return 样式
*/
@Override
public CellStyle getStyles(boolean parity, ExcelExportEntity entity) {
return styles;
}
/**
* 获取样式方法
*
* @param dataRow 数据行
* @param obj 对象
* @param data 数据
*/
@Override
public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data) {
return getStyles(true, entity);
}
/**
* 模板使用的样式设置
*/
@Override
public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams) {
return null;
}
/**
* 初始化--大标题样式
*
* @param workbook
* @return
*/
private CellStyle initHeaderStyle(Workbook workbook) {
CellStyle style = getBaseCellStyle(workbook);
style.setFont(getFont(workbook, FONT_SIZE_TWELVE, true));
return style;
}
/**
* 初始化--每列标题样式
*
* @param workbook
* @return
*/
private CellStyle initTitleStyle(Workbook workbook) {
CellStyle style = getBaseCellStyle(workbook);
//style.setFont(getFont(workbook, FONT_SIZE_ELEVEN, false));
//背景色
style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
return style;
}
/**
* 初始化--数据行样式
*
* @param workbook
* @return
*/
private CellStyle initStyles(Workbook workbook) {
CellStyle style = getBaseCellStyle(workbook);
style.setFont(getFont(workbook, FONT_SIZE_TEN, false));
style.setDataFormat(STRING_FORMAT);
return style;
}
/**
* 基础样式
*
* @return
*/
private CellStyle getBaseCellStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
//下边框
style.setBorderBottom(BorderStyle.THIN);
//左边框
style.setBorderLeft(BorderStyle.THIN);
//上边框
style.setBorderTop(BorderStyle.THIN);
//右边框
style.setBorderRight(BorderStyle.THIN);
//水平居中
style.setAlignment(HorizontalAlignment.CENTER);
//上下居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
//设置自动换行
style.setWrapText(true);
return style;
}
/**
* 字体样式
*
* @param size 字体大小
* @param isBold 是否加粗
* @return
*/
private Font getFont(Workbook workbook, short size, boolean isBold) {
Font font = workbook.createFont();
//字体样式
font.setFontName("宋体");
//是否加粗
font.setBold(isBold);
//字体大小
font.setFontHeightInPoints(size);
return font;
}
}
\ No newline at end of file
...@@ -4,17 +4,23 @@ import java.io.IOException; ...@@ -4,17 +4,23 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.BorderStyle; import cn.afterturn.easypoi.excel.ExcelExportUtil;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import cn.afterturn.easypoi.excel.entity.ExportParams;
import org.apache.poi.ss.usermodel.IndexedColors; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import org.apache.poi.ss.usermodel.VerticalAlignment; import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.enums.TitleEnum;
import org.apache.poi.hssf.usermodel.DVConstraint;
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
...@@ -24,72 +30,139 @@ import com.alibaba.excel.support.ExcelTypeEnum; ...@@ -24,72 +30,139 @@ import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont; import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper;
public class ExcelUtil { public class ExcelUtil {
/**
private static final Integer DUTY_CAR_START_INDEX = 5;
/**
* 生成excel模板 * 生成excel模板
* *
* @param response * @param response
* @param fileName 下载的文件名, * @param fileName 下载的文件名,
* @param sheetName sheet名 * @param sheetName sheet名
* @param data 导出的数据 * @param data 导出的数据
* @param model 导出的头 * @param model 导出的头
* @param flag true模板填充下拉 false 不填充 * @param flag true模板填充下拉 false 不填充
*/ */
public static void createTemplate(HttpServletResponse response, String fileName, public static void createTemplate(HttpServletResponse response, String fileName,
String sheetName, List<? extends Object> data, String sheetName, List<? extends Object> data,
Class<?> model, DataSources dataDictionaryMapper,boolean flag) { Class<?> model, DataSources dataDictionaryMapper, boolean flag) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle(); HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
try { try {
//下拉列表集合 //下拉列表集合
Map<Integer, String[]> explicitListConstraintMap = new HashMap<>(); Map<Integer, String[]> explicitListConstraintMap = new HashMap<>();
if(flag) { if (flag) {
//循环获取对应列得下拉列表信息 //循环获取对应列得下拉列表信息
Field[] declaredFields = model.getDeclaredFields(); Field[] declaredFields = model.getDeclaredFields();
for (int i = 0; i < declaredFields.length; i++) { for (int i = 0; i < declaredFields.length; i++) {
Field field = declaredFields[i]; Field field = declaredFields[i];
//解析注解信息 //解析注解信息
ExplicitConstraint explicitConstraint = field.getAnnotation(ExplicitConstraint.class); ExplicitConstraint explicitConstraint = field.getAnnotation(ExplicitConstraint.class);
resolveExplicitConstraint(explicitListConstraintMap,explicitConstraint,dataDictionaryMapper); resolveExplicitConstraint(explicitListConstraintMap, explicitConstraint, dataDictionaryMapper);
} }
} }
EasyExcel.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX), model). EasyExcel.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX), model)
excelType(ExcelTypeEnum.XLSX).sheet(sheetName) .excelType(ExcelTypeEnum.XLSX).sheet(sheetName)
.registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap)) .registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler()) .registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy) .registerWriteHandler(horizontalCellStyleStrategy)
.doWrite(data); .doWrite(data);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("系统异常!"); throw new RuntimeException("系统异常!");
} }
}
/**
* 生成excel模板
*
* @param response
* @param fileName 下载的文件名,
* @param sheetName sheet名
* @param data 导出的数据
* @param model 导出的头
* @param flag true模板填充下拉 false 不填充
*/
public static void createDutyTemplate(HttpServletResponse response, String fileName, String sheetName, List<?
extends Object> data, Class<?> model, List<String> dayByMonth, String[] dutyNameList,
DataSources dataDictionaryMapper,
boolean flag) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
try {
//下拉列表集合
Map<Integer, String[]> explicitListConstraintMap = new HashMap<>();
List<List<String>> dutyCarTitleList = new ArrayList<>();
//循环获取对应列得下拉列表信息
Field[] declaredFields = model.getDeclaredFields();
if (flag) {
for (int i = 0; i < declaredFields.length; i++) {
Field field = declaredFields[i];
//解析注解信息
ExplicitConstraint explicitConstraint = field.getAnnotation(ExplicitConstraint.class);
resolveExplicitConstraint(explicitListConstraintMap, explicitConstraint, dataDictionaryMapper);
}
}
// 组装表头
for (int i = 0; i < declaredFields.length; i++) {
Field field = declaredFields[i];
ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
if (excelProperty != null) {
ArrayList<String> head = new ArrayList<>();
head.add(excelProperty.value()[0]);
dutyCarTitleList.add(head);
}
}
int size = dutyCarTitleList.size();
if (dayByMonth != null) {
for (int i = 0; i < dayByMonth.size(); i++) {
explicitListConstraintMap.put(size + i, dutyNameList);
ArrayList<String> dutyDay = new ArrayList<>();
dutyDay.add(dayByMonth.get(i));
dutyCarTitleList.add(dutyDay);
}
}
EasyExcel.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX)).head(dutyCarTitleList).excelType(ExcelTypeEnum.XLSX)
.sheet(sheetName).registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy)
.doWrite(data);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
} }
/** /**
* 读取 Excel(第一个 sheet) 指定行开始读取 * 读取 Excel(第一个 sheet) 指定行开始读取
* @param excel 文件 *
* @param rowType 模板实体类 * @param excel 文件
* @param header 指定不读取的表头行数, * @param rowType 模板实体类
* @param header 指定不读取的表头行数,
* @param <T> * @param <T>
* @return 集合数据 * @return 集合数据
* @throws Exception * @throws Exception
*/ */
public static <T> List<T> readFirstSheetExcel(MultipartFile excel, Class<T> rowType,int header) throws Exception { public static <T> List<T> readFirstSheetExcel(MultipartFile excel, Class<T> rowType, int header) throws Exception {
ExcelReader reader = getReader(excel, header); ExcelReader reader = getReader(excel, header);
if (reader == null) { if (reader == null) {
return new ArrayList<>(); return new ArrayList<>();
} }
return readExcel(reader, rowType, 0); return readExcel(reader, rowType, 0);
} }
/** /**
* 读取 Excel(多个 sheet) * 读取 Excel(多个 sheet)
* @param reader 读取的excel *
* @param rowModel excel模板实体类 * @param reader 读取的excel
* @param rowModel excel模板实体类
* @param sheetCount sheet * @param sheetCount sheet
* @param <T> * @param <T>
* @return * @return
...@@ -106,62 +179,62 @@ public class ExcelUtil { ...@@ -106,62 +179,62 @@ public class ExcelUtil {
reader.read(readSheet); reader.read(readSheet);
return excelListener.getList(); return excelListener.getList();
} }
/** /**
* * @param excel 需要解析的 Excel 文件
* @param excel 需要解析的 Excel 文件 * @param header 指定不读取表头行数,
* @param header 指定不读取表头行数, * @return
* @return * @throws Exception
* @throws Exception */
*/ public static ExcelReader getReader(MultipartFile excel, int header) throws Exception {
public static ExcelReader getReader(MultipartFile excel,int header) throws Exception { String fileName = excel.getOriginalFilename();
String fileName = excel.getOriginalFilename(); if (fileName == null) {
if (fileName == null) { throw new Exception("文件不存在!");
throw new Exception("文件不存在!"); }
} if (!fileName.toLowerCase().endsWith(ExcelTypeEnum.XLS.getValue()) && !fileName.toLowerCase().endsWith(ExcelTypeEnum.XLSX.getValue())) {
if (!fileName.toLowerCase().endsWith(ExcelTypeEnum.XLS.getValue()) && !fileName.toLowerCase().endsWith(ExcelTypeEnum.XLSX.getValue())) { throw new Exception("文件类型异常!");
throw new Exception("文件类型异常!"); }
} InputStream inputStream;
InputStream inputStream; try {
try { inputStream = excel.getInputStream();
inputStream = excel.getInputStream(); return EasyExcel.read(inputStream).
return EasyExcel.read(inputStream). headRowNumber(header).
headRowNumber(header). build();
build(); } catch (IOException e) {
} catch (IOException e) { //do something
//do something }
} return null;
return null; }
}
/** /**
* 解析注解内容 获取下列表信息 * 解析注解内容 获取下列表信息
*
* @param explicitConstraint * @param explicitConstraint
* @return * @return
*/ */
public static Map<Integer, String[]> resolveExplicitConstraint( Map<Integer, String[]> explicitListConstraintMap,ExplicitConstraint explicitConstraint, DataSources dataDictionaryMapper){ public static Map<Integer, String[]> resolveExplicitConstraint(Map<Integer, String[]> explicitListConstraintMap,
ExplicitConstraint explicitConstraint,
DataSources dataDictionaryMapper) {
if (explicitConstraint == null) { if (explicitConstraint == null) {
return null; return null;
} }
//固定下拉信息 //固定下拉信息
String[] source = explicitConstraint.source(); String[] source = explicitConstraint.source();
if (source.length > 0) { if (source.length > 0) {
explicitListConstraintMap.put(explicitConstraint.indexNum(), source); explicitListConstraintMap.put(explicitConstraint.indexNum(), source);
} }
//动态下拉信息 //动态下拉信息
Class<? extends ExplicitInterface>[] classes = explicitConstraint.sourceClass(); Class<? extends ExplicitInterface>[] classes = explicitConstraint.sourceClass();
if (classes.length>0){ if (classes.length > 0) {
ExplicitInterface explicitInterface = null; ExplicitInterface explicitInterface = null;
try { try {
explicitInterface = classes[0].newInstance(); explicitInterface = classes[0].newInstance();
String[] source1 = explicitInterface.source(explicitConstraint.type(),explicitConstraint.method(),dataDictionaryMapper); String[] source1 = explicitInterface.source(explicitConstraint.type(), explicitConstraint.method(),
if (source1.length>0){ dataDictionaryMapper);
explicitListConstraintMap.put(explicitConstraint.indexNum(), source1); if (source1.length > 0) {
explicitListConstraintMap.put(explicitConstraint.indexNum(), source1);
} }
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -174,13 +247,12 @@ public class ExcelUtil { ...@@ -174,13 +247,12 @@ public class ExcelUtil {
return null; return null;
} }
/** /**
* 导出文件时为Writer生成OutputStream * 导出文件时为Writer生成OutputStream
*/ */
private static OutputStream getOutputStream(String fileName, HttpServletResponse response, ExcelTypeEnum excelTypeEnum) throws Exception { private static OutputStream getOutputStream(String fileName, HttpServletResponse response,
ExcelTypeEnum excelTypeEnum) throws Exception {
//创建本地文件 //创建本地文件
String filePath = fileName + excelTypeEnum.getValue(); String filePath = fileName + excelTypeEnum.getValue();
try { try {
...@@ -193,14 +265,14 @@ public class ExcelUtil { ...@@ -193,14 +265,14 @@ public class ExcelUtil {
throw new Exception("系统异常"); throw new Exception("系统异常");
} }
} }
/** /**
* 创建我的cell 策略 * 创建我的cell 策略
* *
* @return * @return
*/ */
public static HorizontalCellStyleStrategy setMyCellStyle() { public static HorizontalCellStyleStrategy setMyCellStyle() {
// // 头的策略 // // 头的策略
// WriteCellStyle headWriteCellStyle = new WriteCellStyle(); // WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// // 设置表头居中对齐 // // 设置表头居中对齐
...@@ -218,12 +290,13 @@ public class ExcelUtil { ...@@ -218,12 +290,13 @@ public class ExcelUtil {
// // 设置内容靠中对齐 // // 设置内容靠中对齐
// contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); // contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
// // 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现 // // 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
// HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); // HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy
// (headWriteCellStyle, contentWriteCellStyle);
// // 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭 // // 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭
// return horizontalCellStyleStrategy; // return horizontalCellStyleStrategy;
// 表头样式策略 // 表头样式策略
WriteCellStyle headWriteCellStyle = new WriteCellStyle(); WriteCellStyle headWriteCellStyle = new WriteCellStyle();
//设置表头居中对齐 //设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
...@@ -234,7 +307,7 @@ public class ExcelUtil { ...@@ -234,7 +307,7 @@ public class ExcelUtil {
headWriteFont.setFontName("宋体"); headWriteFont.setFontName("宋体");
headWriteFont.setFontHeightInPoints((short) 10); headWriteFont.setFontHeightInPoints((short) 10);
headWriteCellStyle.setWriteFont(headWriteFont); headWriteCellStyle.setWriteFont(headWriteFont);
//2 内容样式策略 //2 内容样式策略
WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
WriteFont contentWriteFont = new WriteFont(); WriteFont contentWriteFont = new WriteFont();
...@@ -250,17 +323,13 @@ public class ExcelUtil { ...@@ -250,17 +323,13 @@ public class ExcelUtil {
// contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND); // contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
//设置水平居中 //设置水平居中
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
//设置边框样式 //设置边框样式
contentWriteCellStyle.setBorderLeft(BorderStyle.THIN); contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
contentWriteCellStyle.setBorderTop(BorderStyle.THIN); contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
contentWriteCellStyle.setBorderRight(BorderStyle.THIN); contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
contentWriteCellStyle.setBorderBottom(BorderStyle.THIN); contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
} }
} }
...@@ -26,9 +26,15 @@ public interface DynamicFormInstanceMapper extends BaseMapper<DynamicFormInstanc ...@@ -26,9 +26,15 @@ public interface DynamicFormInstanceMapper extends BaseMapper<DynamicFormInstanc
* @param appKey 应用标识 * @param appKey 应用标识
* @param fieldCodes 列 * @param fieldCodes 列
* @param groupCode 分组code * @param groupCode 分组code
* @param params 查询参数map
* @return List<Map> * @return List<Map>
*/ */
List<Map<String, Object>> listAll(@Param("appKey") String appKey, @Param("fieldCodes") Map<String, Object> fieldCodes, @Param("groupCode") String groupCode); List<Map<String, Object>> listAll(
@Param("appKey") String appKey,
@Param("fieldCodes") Map<String, Object> fieldCodes,
@Param("groupCode") String groupCode,
@Param("params") Map<String, String> params
);
/** /**
* 分页查询 * 分页查询
...@@ -39,5 +45,11 @@ public interface DynamicFormInstanceMapper extends BaseMapper<DynamicFormInstanc ...@@ -39,5 +45,11 @@ public interface DynamicFormInstanceMapper extends BaseMapper<DynamicFormInstanc
* @param groupCode 表单类型 * @param groupCode 表单类型
* @return IPage<Map<String, Object>> * @return IPage<Map<String, Object>>
*/ */
IPage<Map<String, Object>> pageList(Page page, @Param("appKey") String appKey, @Param("fieldCodes") Map<String, Object> fieldCodes, @Param("groupCode") String groupCode, @Param("params") Map<String,String> params ); IPage<Map<String, Object>> pageList(
Page page,
@Param("appKey") String appKey,
@Param("fieldCodes") Map<String, Object> fieldCodes,
@Param("groupCode") String groupCode,
@Param("params") Map<String,String> params
);
} }
...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto; ...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto;
import com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto; import com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto; import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam; import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -58,8 +59,16 @@ public interface FireTeamMapper extends BaseMapper<FireTeam> { ...@@ -58,8 +59,16 @@ public interface FireTeamMapper extends BaseMapper<FireTeam> {
/** /**
* 根据队伍id查询队伍下人员列表 * 根据队伍id查询队伍下人员列表
* *
* @param teamIds
* @return
*/
List<FirefightersDto> queryFighterByTeamId(@Param("teamIds") List<String> teamIds);
/**
* 根据当前队伍id查询该队伍下所有子队伍
*
* @param teamId * @param teamId
* @return * @return
*/ */
List<FirefightersDto> queryFighterByTeamId(Long teamId); List<FireTeam> listFireTeamById(Long teamId);
} }
...@@ -30,4 +30,12 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -30,4 +30,12 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<OrgUsr> queryOrgUsrListByBizOrgCode(String bizOrgCode); List<OrgUsr> queryOrgUsrListByBizOrgCode(String bizOrgCode);
List<OrgPersonExcelDto> queryOrgPersonDtoList(boolean isDelete); List<OrgPersonExcelDto> queryOrgPersonDtoList(boolean isDelete);
/**
* 根据id查询当前单位下的所有子单位、部门
*
* @param orgUserId
* @return
*/
List<OrgUsr> listOrgUserById(Long orgUserId);
} }
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</select> </select>
<select id="genRangeDate" resultType="map"> <select id="genRangeDate" resultType="map">
SELECT SELECT
DATE( DATE_ADD( #{beginDate}, INTERVAL @s DAY ) ) AS date, DATE_FORMAT(DATE( DATE_ADD( #{beginDate}, INTERVAL @s DAY )),'%Y-%m-%d') AS date,
@s := @s + 1 AS `index` @s := @s + 1 AS `index`
FROM FROM
mysql.help_topic, mysql.help_topic,
......
...@@ -39,6 +39,20 @@ ...@@ -39,6 +39,20 @@
and i.APP_KEY = #{appKey} and i.APP_KEY = #{appKey}
GROUP by GROUP by
i.INSTANCE_ID)d i.INSTANCE_ID)d
<if test="params != null and params.size() > 0">
where
1=1
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldCodes[key] == 'like' and value !=null and value !=''">
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.${key} = #{value}
</when>
</choose>
</foreach>
</if>
order by instanceId desc order by instanceId desc
</select> </select>
<select id="pageList" resultType="java.util.Map"> <select id="pageList" resultType="java.util.Map">
......
...@@ -13,6 +13,19 @@ ...@@ -13,6 +13,19 @@
and ft.type_code = 118 and ft.type_code = 118
GROUP BY ft.sequence_nbr GROUP BY ft.sequence_nbr
</select> </select>
<select id="queryFighterByTeamId" resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto">
select *
from cb_firefighters
where is_delete = 0
and fire_team_id in
<if test="teamIds != null">
<foreach collection="teamIds" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</select>
<select id="getFireTeamForPage" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto"> <select id="getFireTeamForPage" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto">
SELECT SELECT
a.sequence_nbr sequenceNbr, a.sequence_nbr sequenceNbr,
...@@ -30,21 +43,37 @@ ...@@ -30,21 +43,37 @@
<if test='par.typeCode != null'>and a.type_code = #{par.typeCode}</if> <if test='par.typeCode != null'>and a.type_code = #{par.typeCode}</if>
<if test='par.companyCode != null'>and a.company_code = #{par.companyCode}</if> <if test='par.companyCode != null'>and a.company_code = #{par.companyCode}</if>
<if test='par.name != null'>and a.name like concat('%', #{par.name}, '%')</if> <if test='par.name != null'>and a.name like concat('%', #{par.name}, '%')</if>
<if test='par.nodeType != null and par.nodeType == "1"'>and a.company = #{par.nodeId}</if> <if test='par.nodeType != null and par.nodeType == "1" and par.nodeIds != null'>
<if test='par.nodeType != null and par.nodeType == "0"'>and a.parent = #{par.nodeId} or a.sequence_nbr = and a.company in
#{par.nodeId}</if> <foreach collection="par.nodeIds" separator="," open="(" item="nodeId" close=")">
#{nodeId}
</foreach>
</if>
<if test='par.nodeType != null and par.nodeType == "0" and par.nodeIds != null'>
<if test="par.nodeIds.size() > 0" >
and a.parent in
<foreach collection="par.nodeIds" separator="," open="(" item="nodeId" close=")">
#{nodeId}
</foreach>
or a.sequence_nbr = #{par.nodeId}
</if>
<if test="par.nodeIds.size() == 0" >
and a.sequence_nbr = #{par.nodeId}
</if>
</if>
</select> </select>
<select id="listFireTeamDto" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto"> <select id="listFireTeamDto" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireTeamDto">
select t.*, p.name parentName select t.*, p.name parentName
from cb_fire_team t from cb_fire_team t
left join cb_fire_team p on t.parent = p.sequence_nbr left join cb_fire_team p on t.parent = p.sequence_nbr
where t.is_delete = #{isDelete} where t.is_delete = #{isDelete}
</select> </select>
<select id="queryFighterByTeamId" resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto"> <select id="listFireTeamById" resultType="com.yeejoin.amos.boot.module.common.api.entity.FireTeam">
select * SELECT *
from cb_firefighters FROM cb_fire_team
where is_delete = 0 WHERE is_delete = 0
and fire_team_id = #{teamId} <if test="teamId != null">
AND tree_code LIKE CONCAT((SELECT tree_code FROM cb_fire_team WHERE sequence_nbr = #{teamId}),'%');
</if>
</select> </select>
</mapper> </mapper>
...@@ -201,4 +201,12 @@ ...@@ -201,4 +201,12 @@
on u.sequence_nbr = v.instance_id on u.sequence_nbr = v.instance_id
where u.is_delete = #{isDelete} where u.is_delete = #{isDelete}
</select> </select>
<select id="listOrgUserById" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT *
FROM cb_org_usr
WHERE is_delete = 0
<if test="orgUserId != null">
AND biz_org_code LIKE CONCAT((SELECT biz_org_code FROM cb_org_usr WHERE sequence_nbr = #{orgUserId}),'%');
</if>
</select>
</mapper> </mapper>
...@@ -11,4 +11,5 @@ public class ExcelEnums { ...@@ -11,4 +11,5 @@ public class ExcelEnums {
public static final String XFDW = "XFDW";//("XFDW","消防队伍") public static final String XFDW = "XFDW";//("XFDW","消防队伍")
public static final String WXXFZ = "WXXFZ";//("WXXFZ","微型消防站") public static final String WXXFZ = "WXXFZ";//("WXXFZ","微型消防站")
public static final String XFRY = "XFRY";//("XFRY","消防人员") public static final String XFRY = "XFRY";//("XFRY","消防人员")
public static final String CLZQ = "CLZQ";//("CLZQ","车辆执勤")
} }
...@@ -212,7 +212,7 @@ public class DataDictionaryController extends BaseController { ...@@ -212,7 +212,7 @@ public class DataDictionaryController extends BaseController {
}else{ }else{
Collection<DataDictionary> list=iDataDictionaryService.list(queryWrapper); Collection<DataDictionary> list=iDataDictionaryService.list(queryWrapper);
List<MenuFrom> menus =TreeParser.getTreexin(null, list, DataDictionary.class.getName(),"getCode",0, List<MenuFrom> menus =TreeParser.getTreexin(null, list, DataDictionary.class.getName(),"getCode",0,
"getName", "getParent", "getNodeType"); "getName", "getParent", null);
MenuFrom Me= new MenuFrom( "-1", "-1", "-1", "危化品库", "危化品库", "危化品库", "-1", null); MenuFrom Me= new MenuFrom( "-1", "-1", "-1", "危化品库", "危化品库", "危化品库", "-1", null);
Me.setIsLeaf(false); Me.setIsLeaf(false);
Me.setChildren(menus); Me.setChildren(menus);
...@@ -242,7 +242,7 @@ public class DataDictionaryController extends BaseController { ...@@ -242,7 +242,7 @@ public class DataDictionaryController extends BaseController {
Collection<DataDictionary> list=iDataDictionaryService.list(queryWrapper); Collection<DataDictionary> list=iDataDictionaryService.list(queryWrapper);
List<MenuFrom> menus = null; List<MenuFrom> menus = null;
menus = TreeParser.getTreexin(null, list, DataDictionary.class.getName(),"getCode",0, "getName", menus = TreeParser.getTreexin(null, list, DataDictionary.class.getName(),"getCode",0, "getName",
"getParent", "getNodeType"); "getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE_XIN+type, JSON.toJSON(menus),time); redisUtils.set(RedisKey.DATA_DICTIONARY_CODE_XIN+type, JSON.toJSON(menus),time);
objectObjectHashMap.put(type,menus); objectObjectHashMap.put(type,menus);
} }
......
...@@ -59,7 +59,7 @@ public class DutyCarController extends BaseController { ...@@ -59,7 +59,7 @@ public class DutyCarController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/list") @GetMapping(value = "/list")
@ApiOperation(httpMethod = "GET", value = "值班列表视图", notes = "值班列表视图") @ApiOperation(httpMethod = "GET", value = "值班列表视图-不分页", notes = "值班列表视图-不分页")
public ResponseModel list( public ResponseModel list(
@ApiParam(value = "开始日期", required = true) @RequestParam String beginDate, @ApiParam(value = "开始日期", required = true) @RequestParam String beginDate,
@ApiParam(value = "结束日期", required = true) @RequestParam String endDate) throws ParseException { @ApiParam(value = "结束日期", required = true) @RequestParam String endDate) throws ParseException {
...@@ -123,4 +123,15 @@ public class DutyCarController extends BaseController { ...@@ -123,4 +123,15 @@ public class DutyCarController extends BaseController {
iDutyCarService.downloadList(beginDate, endDate, response); iDutyCarService.downloadList(beginDate, endDate, response);
} }
/**
* 值班数据删除
* @param instanceId 实例id
* @return ResponseModel
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping("/{instanceId}")
@ApiOperation(httpMethod = "DELETE", value = "值班数据删除", notes = "值班数据删除")
public ResponseModel deleteDutyData(@PathVariable Long instanceId) {
return ResponseHelper.buildResponse(iDutyCarService.deleteDutyData(instanceId));
}
} }
...@@ -57,7 +57,7 @@ public class DutyPersonController extends BaseController { ...@@ -57,7 +57,7 @@ public class DutyPersonController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/list") @GetMapping(value = "/list")
@ApiOperation(httpMethod = "GET", value = "值班列表视图", notes = "值班列表视图") @ApiOperation(httpMethod = "GET", value = "值班列表视图-不分页", notes = "值班列表视图-不分页")
public ResponseModel list(@ApiParam(value = "开始日期", required = true) @RequestParam String beginDate, public ResponseModel list(@ApiParam(value = "开始日期", required = true) @RequestParam String beginDate,
@ApiParam(value = "结束日期", required = true) @RequestParam String endDate) throws ParseException { @ApiParam(value = "结束日期", required = true) @RequestParam String endDate) throws ParseException {
return ResponseHelper.buildResponse(iDutyPersonService.list(beginDate, endDate)); return ResponseHelper.buildResponse(iDutyPersonService.list(beginDate, endDate));
...@@ -108,4 +108,16 @@ public class DutyPersonController extends BaseController { ...@@ -108,4 +108,16 @@ public class DutyPersonController extends BaseController {
@RequestBody DutyPersonDto dutyPersonDto) { @RequestBody DutyPersonDto dutyPersonDto) {
return ResponseHelper.buildResponse(iDutyPersonService.update(instanceId, dutyPersonDto)); return ResponseHelper.buildResponse(iDutyPersonService.update(instanceId, dutyPersonDto));
} }
/**
* 值班数据删除
* @param instanceId 实例id
* @return ResponseModel
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping("/{instanceId}")
@ApiOperation(httpMethod = "DELETE", value = "值班数据删除", notes = "值班数据删除")
public ResponseModel deleteDutyData(@PathVariable Long instanceId) {
return ResponseHelper.buildResponse(iDutyPersonService.deleteDutyData(instanceId));
}
} }
package com.yeejoin.amos.boot.module.common.biz.service; package com.yeejoin.amos.boot.module.common.biz.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.common.api.dto.DownloadCarDto;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
...@@ -14,11 +13,12 @@ import java.util.Map; ...@@ -14,11 +13,12 @@ import java.util.Map;
public interface IDutyCommonService { public interface IDutyCommonService {
/** /**
* 分页查询 * 分页查询
* @param current 当前页 *
* @param size 页大小 * @param current 当前页
* @param size 页大小
* @param beginDate 开始日期 * @param beginDate 开始日期
* @param endDate 结束日期 * @param endDate 结束日期
* @return IPage<Map<String, Object>> * @return IPage<Map < String, Object>>
*/ */
IPage<Map<String, Object>> pageList(int current, int size, String beginDate, String endDate) throws ParseException; IPage<Map<String, Object>> pageList(int current, int size, String beginDate, String endDate) throws ParseException;
...@@ -42,9 +42,24 @@ public interface IDutyCommonService { ...@@ -42,9 +42,24 @@ public interface IDutyCommonService {
/** /**
* 获取表单参数 * 获取表单参数
*
* @return String * @return String
*/ */
String getGroupCode(); String getGroupCode();
void downloadList(String beginDate, String endDate, HttpServletResponse response) throws ParseException; void downloadList(String beginDate, String endDate, HttpServletResponse response) throws ParseException;
/**
* 值班数据入库
*
* @param dataList 数据
*/
void saveImportData(List<Map<String, Object>> dataList);
/**
* 删除值班数据
* @param instanceId 实例id
* @return Boolean
*/
Boolean deleteDutyData(Long instanceId);
} }
...@@ -7,8 +7,6 @@ import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn; ...@@ -7,8 +7,6 @@ import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance; import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.biz.service.IDutyCarService; import com.yeejoin.amos.boot.module.common.biz.service.IDutyCarService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -62,19 +60,8 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -62,19 +60,8 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
Map<String, Object> map = Bean.BeantoMap(dutyCarDto); Map<String, Object> map = Bean.BeantoMap(dutyCarDto);
//4.已列为主 填充动态表单数据 //4.已列为主 填充动态表单数据
List<DynamicFormInstance> entrys = new ArrayList<>(); List<DynamicFormInstance> entrys = new ArrayList<>();
for (DynamicFormColumn column : columns) { updateFormValue(entrys, map, instanceId, columns, instanceMap);
DynamicFormInstance formInstance = instanceMap.get(column.getFieldCode()); if (!entrys.isEmpty()) {
if (!ObjectUtils.isEmpty(formInstance)) {
//有的更新
formInstance.setFieldValue(map.get(column.getFieldCode()) != null ? map.get(column.getFieldCode()).toString() : "");
} else {
//没有的新增
formInstance = new DynamicFormInstance();
buildFormInstanceData(instanceId, map, column, formInstance);
}
entrys.add(formInstance);
}
if(!entrys.isEmpty()){
dynamicFormInstanceService.saveOrUpdateBatch(entrys); dynamicFormInstanceService.saveOrUpdateBatch(entrys);
} }
//5.更新值班信息人日期数据 //5.更新值班信息人日期数据
...@@ -95,11 +82,6 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -95,11 +82,6 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
} }
private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, DynamicFormInstance formInstance) { private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, DynamicFormInstance formInstance) {
Bean.copyExistPropertis(column, formInstance); fillFormInstanceData(instanceId, map, column, formInstance, sequence.nextId());
formInstance.setAppKey(RequestContext.getAppKey());
formInstance.setInstanceId(instanceId);
formInstance.setSequenceNbr(sequence.nextId());
formInstance.setFormColumnId(column.getSequenceNbr());
formInstance.setFieldValue(map.get(column.getFieldCode()) != null ? map.get(column.getFieldCode()).toString() : "");
} }
} }
...@@ -5,15 +5,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -5,15 +5,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift; import com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn; import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.api.enums.DutyViewTypeEnum; import com.yeejoin.amos.boot.module.common.api.enums.DutyViewTypeEnum;
import com.yeejoin.amos.boot.module.common.biz.service.IDutyCommonService; import com.yeejoin.amos.boot.module.common.biz.service.IDutyCommonService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -38,6 +44,9 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -38,6 +44,9 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
@Autowired @Autowired
Sequence sequence; Sequence sequence;
@Autowired
HttpServletRequest request;
/** /**
* 每天单个班次执勤人数全部小于等于3人 * 每天单个班次执勤人数全部小于等于3人
*/ */
...@@ -53,10 +62,11 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -53,10 +62,11 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
public IPage<Map<String, Object>> pageList(int current, int size, String beginDate, String endDate) throws ParseException { public IPage<Map<String, Object>> pageList(int current, int size, String beginDate, String endDate) throws ParseException {
//1.已column为准 进行返回 //1.已column为准 进行返回
String groupCode = this.getGroupCode(); String groupCode = this.getGroupCode();
Map<String, String> params = this.getRequestParamMap();
List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode)); List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode));
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class); Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class);
Page page = new Page(current, size); Page page = new Page(current, size);
IPage<Map<String, Object>> iPage = dynamicFormInstanceService.getBaseMapper().pageList(page, RequestContext.getAppKey(), fieldCodes, groupCode, null); IPage<Map<String, Object>> iPage = dynamicFormInstanceService.getBaseMapper().pageList(page, RequestContext.getAppKey(), fieldCodes, groupCode, params);
for (Map<String, Object> m : iPage.getRecords()) { for (Map<String, Object> m : iPage.getRecords()) {
this.fillDutyShiftData(beginDate, endDate, m); this.fillDutyShiftData(beginDate, endDate, m);
} }
...@@ -79,6 +89,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -79,6 +89,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
return rangeDate.stream().map(p -> { return rangeDate.stream().map(p -> {
Map<String, Object> result = new LinkedHashMap<>(); Map<String, Object> result = new LinkedHashMap<>();
result.put("key", p.get("date")); result.put("key", p.get("date"));
result.put("viewType", viewTypeEnum.getCode());
result.put("data", this.buildViewData(viewTypeEnum, p.get("date").toString(), RequestContext.getAppKey())); result.put("data", this.buildViewData(viewTypeEnum, p.get("date").toString(), RequestContext.getAppKey()));
return result; return result;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
...@@ -116,9 +127,10 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -116,9 +127,10 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
public List<Map<String, Object>> list(String beginDate, String endDate) throws ParseException { public List<Map<String, Object>> list(String beginDate, String endDate) throws ParseException {
//1.已column为准 进行返回 //1.已column为准 进行返回
String groupCode = this.getGroupCode(); String groupCode = this.getGroupCode();
Map<String, String> params = this.getRequestParamMap();
List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode)); List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode));
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class); Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class);
List<Map<String, Object>> list = dynamicFormInstanceService.getBaseMapper().listAll(RequestContext.getAppKey(), fieldCodes, groupCode); List<Map<String, Object>> list = dynamicFormInstanceService.getBaseMapper().listAll(RequestContext.getAppKey(), fieldCodes, groupCode, params);
//2.组织值班数据 //2.组织值班数据
for (Map<String, Object> map : list) { for (Map<String, Object> map : list) {
this.fillDutyShiftData(beginDate, endDate, map); this.fillDutyShiftData(beginDate, endDate, map);
...@@ -126,6 +138,25 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -126,6 +138,25 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
return list; return list;
} }
private Map<String, String> getRequestParamMap() {
Map<String, String[]> parameterMap = request.getParameterMap();
Map<String, String[]> localMap = new HashMap<>();
localMap.putAll(parameterMap);
localMap.remove("current");
localMap.remove("size");
localMap.remove("beginDate");
localMap.remove("endDate");
Map<String, String> params = new HashMap<>();
if (!ValidationUtil.isEmpty(localMap)) {
for (String key : localMap.keySet()) {
if (!ValidationUtil.isEmpty(localMap.get(key))) {
params.put(key, localMap.get(key)[0]);
}
}
}
return params;
}
@Override @Override
public String getGroupCode() { public String getGroupCode() {
return null; return null;
...@@ -158,4 +189,95 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -158,4 +189,95 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
// ExcelUtils.exportExcel(workbook, fileName, response); // ExcelUtils.exportExcel(workbook, fileName, response);
} }
@Override
public void saveImportData(List<Map<String, Object>> dataList) {
List<DynamicFormInstance> formInstanceList = new ArrayList<>();
List<DutyPersonShift> dutyPersonShifts = new ArrayList<>();
dataList.forEach(d -> {
//TODO: 业务唯一索引,用户id
String userId = d.get("userId").toString();
List<DynamicFormInstance> instances = dynamicFormInstanceService.list(new LambdaQueryWrapper<DynamicFormInstance>()
.eq(DynamicFormInstance::getFieldCode, userId)
.eq(DynamicFormInstance::getGroupCode, this.getGroupCode()));
Long instanceId = null;
List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, this.getGroupCode()));
//1.组装动态表单数据
if (!instances.isEmpty()) {
//0.定位instanceId,准备进行更新操作
instanceId = instances.get(0).getInstanceId();
//1.查询已有数据
List<DynamicFormInstance> instancesInDb = dynamicFormInstanceService.list(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
//2.list 转 map
Map<Object, DynamicFormInstance> instanceMap = Bean.listToMap(instancesInDb, "fieldCode", DynamicFormInstance.class);
//3.待更新数据组装,待批量入库
this.updateFormValue(formInstanceList, d, instanceId, columns, instanceMap);
} else {
//0.新数据,生成id
instanceId = sequence.nextId();
Long finalInstanceId1 = instanceId;
//1.组装数据
List<DynamicFormInstance> newInstances = columns.stream().map(column -> {
DynamicFormInstance instance = new DynamicFormInstance();
buildFormInstanceData(finalInstanceId1, d, column, instance);
return instance;
}).collect(Collectors.toList());
//2.待更新数据组装,待批量入库
formInstanceList.addAll(newInstances);
}
//2.组装值班数据
List<DutyPersonShiftDto> shiftDtos = (List<DutyPersonShiftDto>) d.get("dutyShift");
Long finalInstanceId = instanceId;
//todo: 只更新当天及值班之后数据
Set<DutyPersonShift> needToDb = shiftDtos.stream().filter(s -> DateUtils.dateCompare(s.getDutyDate(), new Date()) >= 0).map(shiftDto -> {
DutyPersonShift dutyPersonShift = new DutyPersonShift();
Bean.copyExistPropertis(shiftDto, dutyPersonShift);
dutyPersonShift.setInstanceId(finalInstanceId);
dutyPersonShift.setAppKey(RequestContext.getAppKey());
return dutyPersonShift;
}).collect(Collectors.toSet());
dutyPersonShifts.addAll(needToDb);
});
if (!formInstanceList.isEmpty()) {
dynamicFormInstanceService.saveOrUpdateBatch(formInstanceList);
}
if (!dutyPersonShifts.isEmpty()) {
dutyPersonShiftService.saveOrUpdateBatch(dutyPersonShifts);
}
}
public void updateFormValue(List<DynamicFormInstance> formInstanceList, Map<String, Object> d, Long instanceId, List<DynamicFormColumn> columns, Map<Object, DynamicFormInstance> instanceMap) {
for (DynamicFormColumn column : columns) {
DynamicFormInstance formInstance = instanceMap.get(column.getFieldCode());
if (!ObjectUtils.isEmpty(formInstance)) {
//有的更新
formInstance.setFieldValue(d.get(column.getFieldCode()) != null ? d.get(column.getFieldCode()).toString() : "");
} else {
//没有的新增
formInstance = new DynamicFormInstance();
buildFormInstanceData(instanceId, d, column, formInstance);
}
formInstanceList.add(formInstance);
}
}
private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, DynamicFormInstance formInstance) {
DutyCarServiceImpl.fillFormInstanceData(instanceId, map, column, formInstance, sequence.nextId());
}
static void fillFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, DynamicFormInstance formInstance, long l) {
Bean.copyExistPropertis(column, formInstance);
formInstance.setAppKey(RequestContext.getAppKey());
formInstance.setInstanceId(instanceId);
formInstance.setSequenceNbr(l);
formInstance.setFormColumnId(column.getSequenceNbr());
formInstance.setFieldValue(map.get(column.getFieldCode()) != null ? map.get(column.getFieldCode()).toString() : "");
}
@Transactional(rollbackFor = Exception.class)
@Override
public Boolean deleteDutyData(Long instanceId){
dynamicFormInstanceService.remove(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId,instanceId));
dutyPersonShiftService.remove(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId,instanceId));
return true;
}
} }
...@@ -95,11 +95,6 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut ...@@ -95,11 +95,6 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
} }
private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, DynamicFormInstance formInstance) { private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, DynamicFormInstance formInstance) {
Bean.copyExistPropertis(column, formInstance); fillFormInstanceData(instanceId, map, column, formInstance, sequence.nextId());
formInstance.setAppKey(RequestContext.getAppKey());
formInstance.setInstanceId(instanceId);
formInstance.setSequenceNbr(sequence.nextId());
formInstance.setFormColumnId(column.getSequenceNbr());
formInstance.setFieldValue(map.get(column.getFieldCode()) != null ? map.get(column.getFieldCode()).toString() : "");
} }
} }
...@@ -19,7 +19,6 @@ import org.springframework.beans.BeanUtils; ...@@ -19,7 +19,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
...@@ -259,7 +258,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -259,7 +258,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
List<Map<String, Object>> personList = new ArrayList<>(); List<Map<String, Object>> personList = new ArrayList<>();
// 查询动态表单Phone // 查询动态表单Phone
Map<String, Object> phone = new HashMap<>(); Map<String, Object> phone = new HashMap<>();
phone.put("alert_called_id", company.getSequenceNbr()); phone.put("instance_id", company.getSequenceNbr());
phone.put("field_code", "companyPhone"); phone.put("field_code", "companyPhone");
QueryWrapper<DynamicFormInstance> phoneWrapper = new QueryWrapper<DynamicFormInstance>(); QueryWrapper<DynamicFormInstance> phoneWrapper = new QueryWrapper<DynamicFormInstance>();
phoneWrapper.allEq(phone); phoneWrapper.allEq(phone);
...@@ -846,4 +845,14 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -846,4 +845,14 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return excelOrgPersonDtoList; return excelOrgPersonDtoList;
} }
/**
* 根据id查询当前单位下的所有子单位、部门
*
* @param orgUserId
* @return
*/
public List<OrgUsr> listOrgUserById(Long orgUserId) {
return this.baseMapper.listOrgUserById(orgUserId);
}
} }
package com.yeejoin.amos.boot.module.common.biz.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @title: DateUtils
* @Author fpy
* @Date: 2021/7/8 14:58
* @Version 1.0
*/
public class DateUtils {
private static final SimpleDateFormat shortSdf = new SimpleDateFormat("yyyy/M/d");
private static final Calendar calendar = Calendar.getInstance();
/**
* 获取某月的日期List
*
* @param yearParam
* @param monthParam
* @return
*/
public static List<String> getDayByMonth(int yearParam, int monthParam) {
List list = new ArrayList();
Calendar aCalendar = Calendar.getInstance(Locale.CHINA);
aCalendar.set(yearParam, monthParam - 1, 1);
int year = aCalendar.get(Calendar.YEAR);//年份
int month = aCalendar.get(Calendar.MONTH) + 1;//月份
int day = aCalendar.getActualMaximum(Calendar.DATE);
for (int i = 1; i <= day; i++) {
list.add(year + "/" + month + "/" + i);
}
return list;
}
/**
* 获取某月的日期List
*
* @param dateStr
* @return
*/
public static List<Date> getDayByMonth(String dateStr) {
List list = new ArrayList();
Date date = null;
try {
date = shortSdf.parse(dateStr);
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH) + 1;//月份
int year = calendar.get(Calendar.YEAR);//年份
int day = calendar.getActualMaximum(Calendar.DATE);
for (int i = 1; i <= day; i++) {
list.add(year + "/" + month + "/" + i);
}
} catch (ParseException e) {
e.printStackTrace();
}
return list;
}
/**
* 日期返回Date类型
*
* @param dateStr
* @return
*/
public static int strToDateShort(String dateStr) {
try {
Date date = shortSdf.parse(dateStr);
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH) + 1;
return month;
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jcs.biz.controller; package com.yeejoin.amos.boot.module.jcs.biz.controller;
import java.util.ArrayList; import java.io.InputStream;
import java.util.List; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.yeejoin.amos.boot.biz.common.feign.AmosFeignService;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.module.common.api.dto.*; import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.entity.*; import com.yeejoin.amos.boot.module.common.api.entity.*;
import com.yeejoin.amos.boot.module.common.api.enums.TitleEnum;
import com.yeejoin.amos.boot.module.common.biz.service.impl.*; import com.yeejoin.amos.boot.module.common.biz.service.impl.*;
import com.yeejoin.amos.boot.module.common.biz.utils.DateUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft; import com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.EquipmentServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireTeamServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireTeamServiceImpl;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
...@@ -57,6 +68,16 @@ public class ExcelController extends BaseController { ...@@ -57,6 +68,16 @@ public class ExcelController extends BaseController {
FireStationServiceImpl fireStationService; FireStationServiceImpl fireStationService;
@Autowired @Autowired
FirefightersServiceImpl firefightersService; FirefightersServiceImpl firefightersService;
@Autowired
DutyCarServiceImpl dutyCarService;
@Autowired
AmosFeignService amosFeignService;
@Autowired
EquipmentServiceImpl equipmentService;
@Autowired
DutyShiftServiceImpl dutyShiftService;
@Autowired
DutyCommonServiceImpl dutyCommonServiceImpl;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
...@@ -151,6 +172,10 @@ public class ExcelController extends BaseController { ...@@ -151,6 +172,10 @@ public class ExcelController extends BaseController {
case ExcelEnums.XFRY: case ExcelEnums.XFRY:
excelImportFirefighters(multipartFile); excelImportFirefighters(multipartFile);
break; break;
case ExcelEnums.CLZQ:
excelImportDutyCar(multipartFile);
break;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -158,6 +183,82 @@ public class ExcelController extends BaseController { ...@@ -158,6 +183,82 @@ public class ExcelController extends BaseController {
} }
} }
private void excelImportDutyCar(MultipartFile multipartFile) throws Exception {
String fileName = multipartFile.getOriginalFilename();
if (fileName == null) {
throw new Exception("文件不存在!");
}
if (!fileName.toLowerCase().endsWith(ExcelTypeEnum.XLS.getValue()) && !fileName.toLowerCase().endsWith(ExcelTypeEnum.XLSX.getValue())) {
throw new Exception("文件类型异常!");
}
InputStream input = multipartFile.getInputStream();
HSSFWorkbook xssfWorkbook = new HSSFWorkbook(input);
HSSFSheet sheet = xssfWorkbook.getSheetAt(0);
List<Map<String, Object>> dataList = new ArrayList<>();
if (sheet != null) {
//获取表头月份
String dateStr = "";
Row titleRow = sheet.getRow(0);
Cell monthCell = titleRow.getCell(5);
dateStr = monthCell == null ? "" : monthCell.toString();
List<Date> dayByMonth = DateUtils.getDayByMonth(dateStr);
initDutyCarData(sheet, dataList, dayByMonth);
}
dutyCommonServiceImpl.saveImportData(dataList);
}
private void initDutyCarData(HSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
//遍历行,i = 1,从第二行开始,第一行是表头跳过。
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
DutyCarDto dutyCarDto = new DutyCarDto();
//row是一行数据,row.getCell(i),代表拿到这一行,第i列数据
Row row = sheet.getRow(i);
if (row == null) {
continue;
}
Cell cell = null;
cell = row.getCell(1);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyCarDto.setTeamName(split[0]);
dutyCarDto.setTeamId(split[1]);
}
cell = row.getCell(2);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyCarDto.setUserName(split[0]);
dutyCarDto.setUserId(split[1]);
}
cell = row.getCell(3);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyCarDto.setPostTypeName(split[0]);
dutyCarDto.setPostType(split[1]);
}
cell = row.getCell(4);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyCarDto.setCarName(split[0]);
dutyCarDto.setCarId(split[1]);
}
List<DutyPersonShiftDto> dutyShift = dutyCarDto.getDutyShift();
for (int j = 0; j < dayByMonth.size(); j++) {
cell = row.getCell(4 + j);
String dutyType = cell == null ? "" : cell.toString();
if (!StringUtils.isEmpty(dutyType)) {
DutyPersonShiftDto dutyPersonShiftDto = new DutyPersonShiftDto();
dutyPersonShiftDto.setDutyDate(dayByMonth.get(j));
dutyPersonShiftDto.setShiftId(Long.valueOf(dutyType.split("@")[1]));
dutyShift.add(dutyPersonShiftDto);
}
}
Map<String, Object> dutyCarDtoMap = Bean.BeantoMap(dutyCarDto);
dataList.add(dutyCarDtoMap);
}
}
private void excelImportFirefighters(MultipartFile multipartFile) throws Exception { private void excelImportFirefighters(MultipartFile multipartFile) throws Exception {
List<FirefightersExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, List<FirefightersExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
FirefightersExcelDto.class, 1); FirefightersExcelDto.class, 1);
...@@ -390,5 +491,45 @@ public class ExcelController extends BaseController { ...@@ -390,5 +491,45 @@ public class ExcelController extends BaseController {
fireExpertsServiceImpl.saveBatch(excelEntityList); fireExpertsServiceImpl.saveBatch(excelEntityList);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出值班模板", notes = "导出值班模板")
@GetMapping(value = "/duty_car_template/{year}/{month}")
public void dutyCarTemplate(HttpServletResponse response, @PathVariable("year") int year,
@PathVariable("month") int month, ExcelDto excelDto,
@RequestParam(value = "orgCode", required = false) String orgCode) {
try {
List<Map<String, Object>> contentList = new ArrayList<>();
// 根据id列表获取队伍下的人
List<DutyCarDto> orgTeam = new ArrayList<>();
if (!orgTeam.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
orgTeam.forEach(o -> {
Map<String, Object> map = new HashMap<>();
map.put(TitleEnum.NUMBER.getKey(), "" + (row.getAndIncrement()));
map.put(TitleEnum.FIRE_TEAM.getKey(), o.getTeamName());
map.put(TitleEnum.USER_NAME.getKey(), o.getUserName());
map.put(TitleEnum.POST.getKey(), o.getPostTypeName());
contentList.add(map);
});
}
// 获取日期
List<String> dayByMonth = DateUtils.getDayByMonth(year, month);
// 获取排班类型
String[] dutyNameList = getDutyNameList();
ExcelUtil.createDutyTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), contentList,
DutyCarExcelDto.class, dayByMonth, dutyNameList, dataSourcesImpl, true);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
}
private String[] getDutyNameList() {
List<String> dutyShiftList = new ArrayList<>();
List<DutyShiftDto> dutyShiftDtoList = dutyShiftService.queryForDutyShiftList();
dutyShiftDtoList.forEach(item -> dutyShiftList.add(item.getName() + "@" + item.getSequenceNbr()));
String[] dutyNameList = dutyShiftList.toArray(new String[dutyShiftList.size()]);
return dutyNameList;
}
} }
...@@ -8,9 +8,11 @@ import java.util.Map; ...@@ -8,9 +8,11 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto; import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -62,8 +65,7 @@ public class FireTeamController extends BaseController { ...@@ -62,8 +65,7 @@ public class FireTeamController extends BaseController {
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增消防队伍", notes = "新增消防队伍") @ApiOperation(httpMethod = "POST", value = "新增消防队伍", notes = "新增消防队伍")
public ResponseModel<Object> saveFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) { public ResponseModel<Object> saveFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) {
iFireTeamService.save(fireTeam); return ResponseHelper.buildResponse(iFireTeamService.saveFireTeam(fireTeam));
return ResponseHelper.buildResponse(null);
} }
/** /**
...@@ -89,8 +91,7 @@ public class FireTeamController extends BaseController { ...@@ -89,8 +91,7 @@ public class FireTeamController extends BaseController {
@RequestMapping(value = "/updateById", method = RequestMethod.PUT) @RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改消防队伍", notes = "修改消防队伍") @ApiOperation(httpMethod = "PUT", value = "修改消防队伍", notes = "修改消防队伍")
public ResponseModel<Object> updateByIdFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) { public ResponseModel<Object> updateByIdFireTeam(HttpServletRequest request, @RequestBody FireTeam fireTeam) {
iFireTeamService.updateById(fireTeam); return ResponseHelper.buildResponse(iFireTeamService.saveFireTeam(fireTeam));
return ResponseHelper.buildResponse(null);
} }
/** /**
...@@ -228,10 +229,14 @@ public class FireTeamController extends BaseController { ...@@ -228,10 +229,14 @@ public class FireTeamController extends BaseController {
* @throws Exception * @throws Exception
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{teamId}/fighter", method = RequestMethod.GET) @RequestMapping(value = "/fighter", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "查询消防队伍下的人员", notes = "查询消防队伍下的人员") @ApiOperation(httpMethod = "GET", value = "查询消防队伍下的人员", notes = "查询消防队伍下的人员")
public ResponseModel<List<FirefightersDto>> listFighterByTeamId(@PathVariable("teamId") Long teamId) { public ResponseModel<List<FirefightersDto>> listFighterByTeamId(@RequestParam("teamIds") String teamIds) {
List<FirefightersDto> fighters = iFireTeamService.getFighterByTeamId(teamId); List<String> teamIdList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(teamIds)) {
teamIdList = Lists.newArrayList(teamIds.split(","));
}
List<FirefightersDto> fighters = iFireTeamService.getFighterByTeamId(teamIdList);
return ResponseHelper.buildResponse(fighters); return ResponseHelper.buildResponse(fighters);
} }
} }
\ No newline at end of file
...@@ -223,7 +223,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -223,7 +223,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmittedObject.setUserName((String) orgUser.get("bizOrgName")); alertSubmittedObject.setUserName((String) orgUser.get("bizOrgName"));
alertSubmittedObject.setUserPhone((String) orgUser.get("telephone")); alertSubmittedObject.setUserPhone((String) orgUser.get("telephone"));
mobiles.add((String) orgUser.get("telephone")); if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) {
mobiles.add((String) orgUser.get("telephone"));
}
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
} }
// 组装报送内容 // 组装报送内容
...@@ -317,7 +319,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -317,7 +319,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmittedObject.setUserName(person.getPersonName()); alertSubmittedObject.setUserName(person.getPersonName());
alertSubmittedObject.setUserPhone(person.getPersonPhone()); alertSubmittedObject.setUserPhone(person.getPersonPhone());
alertSubmittedObject.setRecUserName(userName); alertSubmittedObject.setRecUserName(userName);
mobiles.add(person.getPersonPhone()); if (!ValidationUtil.isEmpty(person.getPersonPhone())) {
mobiles.add(person.getPersonPhone());
}
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
}); });
}); });
......
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom; import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto; import com.yeejoin.amos.boot.module.common.api.dto.FireTeamCardDto;
import com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto; import com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto;
...@@ -16,16 +17,19 @@ import com.yeejoin.amos.boot.module.common.api.excel.DataSources; ...@@ -16,16 +17,19 @@ import com.yeejoin.amos.boot.module.common.api.excel.DataSources;
import com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper; import com.yeejoin.amos.boot.module.common.api.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
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.http.*; import org.springframework.http.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -41,6 +45,8 @@ public class DataSourcesImpl implements DataSources { ...@@ -41,6 +45,8 @@ public class DataSourcesImpl implements DataSources {
FirefightersServiceImpl firefightersService; FirefightersServiceImpl firefightersService;
@Autowired @Autowired
FireTeamServiceImpl fireTeamService; FireTeamServiceImpl fireTeamService;
@Autowired
EquipFeignClient equipFeignClient;
@Autowired @Autowired
...@@ -94,11 +100,26 @@ public class DataSourcesImpl implements DataSources { ...@@ -94,11 +100,26 @@ public class DataSourcesImpl implements DataSources {
break; break;
case "getMaritalStatus": case "getMaritalStatus":
str = ExcelSelectData.MARITAL_STATUS; str = ExcelSelectData.MARITAL_STATUS;
break;
case "getCarList":
str = getCarList();
break;
} }
} }
return str; return str;
} }
private String[] getCarList() {
ResponseModel<Object> response = equipFeignClient.getFireCarListAll();
List<Map<String, Object>> carList = (List<Map<String, Object>>) response.getResult();
List<String> carNameList = Lists.newArrayList();
carList.forEach(car -> {
carNameList.add(car.get("name") + "(" + car.get("carNum") + ")" + "@" + car.get("id"));
});
String[] str = carNameList.toArray(new String[carNameList.size()]);
return str;
}
private String[] getFireTeam() { private String[] getFireTeam() {
Page<FireTeamCardDto> pageBean = new Page<>(1, Integer.MAX_VALUE); Page<FireTeamCardDto> pageBean = new Page<>(1, Integer.MAX_VALUE);
IPage<FireTeamCardDto> fireTeamCardDtoIPage = fireTeamService.listFireTeamByPage(pageBean, IPage<FireTeamCardDto> fireTeamCardDtoIPage = fireTeamService.listFireTeamByPage(pageBean,
......
...@@ -25,9 +25,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -25,9 +25,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -76,6 +78,18 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -76,6 +78,18 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
"teamId"), Collectors.counting())); "teamId"), Collectors.counting()));
} }
} }
// 查询单位
if (Objects.equals("1", team.getNodeType())) {
List<OrgUsr> companyDeptList = orgUsrService.listOrgUserById(team.getNodeId());
team.setNodeIds(companyDeptList.stream().map(e -> e.getSequenceNbr().toString()).collect(Collectors.toList()));
}
// 查询队伍
if (Objects.equals("0", team.getNodeType())) {
List<FireTeam> teamList = listFireTeamById(team.getNodeId());
team.setNodeIds(teamList.stream().map(e -> e.getSequenceNbr().toString()).collect(Collectors.toList()));
}
IPage<FireTeamCardDto> fireTeamListPage = this.baseMapper.getFireTeamForPage(page, team); IPage<FireTeamCardDto> fireTeamListPage = this.baseMapper.getFireTeamForPage(page, team);
List<FireTeamCardDto> fireTeamList = fireTeamListPage.getRecords(); List<FireTeamCardDto> fireTeamList = fireTeamListPage.getRecords();
Map<Object, Long> finalTeamCarCountMap = teamCarCountMap; Map<Object, Long> finalTeamCarCountMap = teamCarCountMap;
...@@ -84,14 +98,14 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -84,14 +98,14 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
t.setCarNum(finalTeamCarCountMap.get(t.getSequenceNbr().toString()).intValue()); t.setCarNum(finalTeamCarCountMap.get(t.getSequenceNbr().toString()).intValue());
} }
}); });
// 如果队伍下没有队伍则将自己加入返回列表
if ("0".equals(team.getNodeType()) && !ValidationUtil.isEmpty(fireTeamList) && fireTeamList.size() > 1) {
fireTeamList = fireTeamList.stream().filter(t -> t.getSequenceNbr().equals(team.getNodeId())).collect(Collectors.toList());
}
fireTeamListPage.setRecords(fireTeamList); fireTeamListPage.setRecords(fireTeamList);
return fireTeamListPage; return fireTeamListPage;
} }
public List<FireTeam> listFireTeamById(Long teamId) {
return this.baseMapper.listFireTeamById(teamId);
}
public List<FireTeamDto> queryFireTeamForList(Boolean isDelete) { public List<FireTeamDto> queryFireTeamForList(Boolean isDelete) {
return fireTeamMapper.listFireTeamDto(isDelete); return fireTeamMapper.listFireTeamDto(isDelete);
} }
...@@ -135,7 +149,7 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -135,7 +149,7 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
team.setParent(team.getCompany()); team.setParent(team.getCompany());
} }
teamMenuList.add(new MenuFrom(team.getSequenceNbr().toString(), team.getName(), teamMenuList.add(new MenuFrom(team.getSequenceNbr().toString(), team.getName(),
team.getParent().toString(), "1")); team.getParent().toString(), "0"));
}); });
companyDeptMenuList.addAll(teamMenuList); companyDeptMenuList.addAll(teamMenuList);
List<MenuFrom> menuList = TreeParser.getTreexin("-1", companyDeptMenuList, MenuFrom.class.getName(), "getKey", List<MenuFrom> menuList = TreeParser.getTreexin("-1", companyDeptMenuList, MenuFrom.class.getName(), "getKey",
...@@ -147,10 +161,26 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -147,10 +161,26 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
/** /**
* 根据队伍id查询队伍下人员列表 * 根据队伍id查询队伍下人员列表
* *
* @param teamId * @param teamIds
* @return * @return
*/ */
public List<FirefightersDto> getFighterByTeamId(Long teamId) { public List<FirefightersDto> getFighterByTeamId(List<String> teamIds) {
return this.baseMapper.queryFighterByTeamId(teamId); return this.baseMapper.queryFighterByTeamId(teamIds);
}
public FireTeam saveFireTeam(FireTeam fireTeam) {
if (ValidationUtil.isEmpty(fireTeam.getParent())) {
fireTeam.setTreeCode(TreeParser.genTreeCode());
} else {
FireTeam parentTeam = getById(fireTeam.getParent());
fireTeam.setTreeCode(parentTeam.getTreeCode() + TreeParser.genTreeCode());
}
if (ValidationUtil.isEmpty(fireTeam.getSequenceNbr())) {
save(fireTeam);
} else {
updateById(fireTeam);
}
return fireTeam;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment