包头车辆批量导入
This commit is contained in:
parent
f6f586e497
commit
46ebe72425
@ -361,7 +361,7 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
}
|
||||
|
||||
//合作单位ids设备
|
||||
//and (FIND_IN_SET(100,xxx.enterprise_ids) or FIND_IN_SET(102,xxx.enterprise_ids))
|
||||
//and (FIND_IN_SET(100,xxx.enterprise_ids) or FIND_IN_SET(102,xxx.enterprise_ids)) or xxx.enterprise_ids = ""
|
||||
List<String> filterEnterpriseIds = getNeedFilterLeftExpression(plainSelect, this.getFieldEnterpriseIdsTables(), ds);
|
||||
if (CollUtil.isNotEmpty(filterEnterpriseIds)) {
|
||||
List<String> enterpriseIds = userEnterpriseService.getEnterpriseIdsIfSubProject();
|
||||
@ -369,7 +369,7 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
for (String filterEnterpriseId : filterEnterpriseIds) {
|
||||
List<String> list1 = enterpriseIds.stream().map(s -> "FIND_IN_SET(" + s + "," + filterEnterpriseId + ")").collect(Collectors.toList());
|
||||
String s1 = StrUtil.join(" or ", list1);
|
||||
String sql = " (" + s1 + ")";
|
||||
String sql = " (" + s1 + ") or " + filterEnterpriseId + " = \"\"";
|
||||
Expression expression = null;
|
||||
try {
|
||||
expression = CCJSqlParserUtil.parseCondExpression(sql);
|
||||
|
||||
@ -2498,7 +2498,7 @@ public class HikvisionCall {
|
||||
public String saveToLocal(String url) {
|
||||
String fileName = IdUtil.simpleUUID() + ".png";
|
||||
UrlUtil.saveToLocal(url, PathUtil.getBasePath(), fileName);
|
||||
minioUtils.downloadFile(fileName);
|
||||
minioUtils.uploadBySameName(fileName, false);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,9 @@
|
||||
package com.zhgd.xmgl.modules.baotou.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.ContractorMonthlyDetail;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.ContractorMonthlyTemplate;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.DeviceUnit;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.ProjectGroup;
|
||||
import com.zhgd.xmgl.modules.baotou.service.*;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
@ -19,16 +13,13 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/contractorMonthly")
|
||||
@ -76,7 +67,7 @@ public class ContractorMonthlyController {
|
||||
})
|
||||
@PostMapping(value = "/queryEnterpriseInfoPageList")
|
||||
public Result<IPage<EnterpriseInfo>> queryPageList(@RequestBody Map<String, Object> map) {
|
||||
IPage<EnterpriseInfo> pageList = projectEnterpriseService.selectProjectEnterprisePage(map);
|
||||
IPage<EnterpriseInfo> pageList = projectEnterpriseService.queryPageList(map);
|
||||
return Result.success(pageList);
|
||||
}
|
||||
|
||||
|
||||
@ -47,15 +47,18 @@ public class PlanChooseCategory implements Serializable {
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value="更新时间 yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime ;
|
||||
@TableField(exist = false)
|
||||
private String categoryName ;
|
||||
@TableField(exist = false)
|
||||
private String recordName ;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "层级名称")
|
||||
private String fullName ;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "祖级列表")
|
||||
private java.lang.String ancestors;
|
||||
@TableField(exist = false)
|
||||
private String categoryName;
|
||||
@TableField(exist = false)
|
||||
private String recordName;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "层级名称")
|
||||
private String fullName;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "祖级列表")
|
||||
private java.lang.String ancestors;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "1项目里程碑2装置里程碑")
|
||||
private java.lang.Integer projectType;
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
,pwc.category_name as category_name
|
||||
,pr.job_name as record_name
|
||||
,pwc.ancestors
|
||||
,pwc.project_type
|
||||
from plan_choose_category t
|
||||
left join plan_work_category pwc on t.category_id = pwc.id
|
||||
left join plan_record pr on pr.id=t.record_id
|
||||
@ -18,6 +19,8 @@
|
||||
select t.*
|
||||
,pwc.category_name as category_name
|
||||
,pr.job_name as record_name
|
||||
,pwc.ancestors
|
||||
,pwc.project_type
|
||||
from plan_choose_category t
|
||||
left join plan_work_category pwc on t.category_id = pwc.id
|
||||
left join plan_record pr on pr.id=t.record_id
|
||||
|
||||
@ -32,8 +32,10 @@ import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -369,5 +371,24 @@ public class CarInfoController {
|
||||
return Result.success(carInfoService.validEnterpriseStatus(param));
|
||||
}
|
||||
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "", operDesc = "车辆导入模板下载")
|
||||
@ApiOperation(value = "车辆导入模板下载", notes = "车辆导入模板下载", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
})
|
||||
@GetMapping(value = "/exportExcelCarTemplate")
|
||||
public void exportExcelCarTemplate(HttpServletResponse response, String projectSn) {
|
||||
carInfoService.exportExcelCarTemplate(response, projectSn);
|
||||
}
|
||||
|
||||
@OperLog(operModul = "车辆黑白名单管理", operType = "", operDesc = "车辆模板批量导入")
|
||||
@ApiOperation(value = "车辆模板批量导入", notes = "车辆模板批量导入")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "excelFile", value = "导入文件", paramType = "query", required = true, dataType = "String"),
|
||||
})
|
||||
@PostMapping(value = "/uploadExcelCar")
|
||||
public Result uploadExcelCar(MultipartFile excelFile, String projectSn) {
|
||||
return carInfoService.uploadExcelCar(excelFile, projectSn);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,10 +63,10 @@ public class CarInfo implements Serializable {
|
||||
@ApiModelProperty(value = "项目SN")
|
||||
private java.lang.String projectSn;
|
||||
/**
|
||||
* 车辆类型 1渣土车辆,2外来车辆,3 工作车辆
|
||||
* 车辆类型
|
||||
*/
|
||||
@Excel(name = "车辆类型 1渣土车辆,2外来车辆,3 工作车辆", width = 15)
|
||||
@ApiModelProperty(value = "车辆类型 1渣土车辆,2外来车辆,3 工作车辆")
|
||||
@Excel(name = "车辆类型", width = 15)
|
||||
@ApiModelProperty(value = "车辆类型")
|
||||
private java.lang.Long carType;
|
||||
|
||||
@Excel(name = "驾驶劳务人员ID", width = 15)
|
||||
@ -157,4 +157,23 @@ public class CarInfo implements Serializable {
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "从审批流过来")
|
||||
private Boolean fromFlow;
|
||||
|
||||
public String toExistString() {
|
||||
return "CarInfo{" +
|
||||
"id=" + id +
|
||||
", carNumber='" + carNumber + '\'' +
|
||||
", carColor='" + carColor + '\'' +
|
||||
", projectSn='" + projectSn + '\'' +
|
||||
", carType=" + carType +
|
||||
", driverWorkerId='" + driverWorkerId + '\'' +
|
||||
", driverWorkerName='" + driverWorkerName + '\'' +
|
||||
", driverTelephone='" + driverTelephone + '\'' +
|
||||
", isBlack=" + isBlack +
|
||||
", carModuleType=" + carModuleType +
|
||||
", reserveStartTime=" + reserveStartTime +
|
||||
", reserveEndTime=" + reserveEndTime +
|
||||
", entryAndExitPermit=" + entryAndExitPermit +
|
||||
", enterpriseId=" + enterpriseId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,11 +2,14 @@ package com.zhgd.xmgl.modules.car.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
import com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -153,4 +156,8 @@ public interface ICarInfoService extends IService<CarInfo> {
|
||||
* @param carInfo
|
||||
*/
|
||||
void validEnterpriseTime(CarInfo carInfo);
|
||||
|
||||
void exportExcelCarTemplate(HttpServletResponse response, String projectSn);
|
||||
|
||||
Result uploadExcelCar(MultipartFile excelFile, String projectSn);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.zhgd.xmgl.modules.car.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -13,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.gexin.fastjson.JSONObject;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.redis.lock.redisson.DistributedLock;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
@ -25,27 +27,38 @@ import com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo;
|
||||
import com.zhgd.xmgl.modules.car.enums.CarInfoCarModuleTypeEnum;
|
||||
import com.zhgd.xmgl.modules.car.mapper.*;
|
||||
import com.zhgd.xmgl.modules.car.service.ICarInfoService;
|
||||
import com.zhgd.xmgl.modules.car.service.ICarTypeService;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.project.service.impl.ProjectServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
|
||||
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
|
||||
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionCompareDataServiceImpl;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zhgd.xmgl.async.AsyncHikvision.getSyncTimeWithInitAndDeleteSyncIfAbsent;
|
||||
@ -82,6 +95,9 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
MinioUtils minioUtils;
|
||||
@Lazy
|
||||
@Autowired
|
||||
WorkerInfoServiceImpl workerInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private XzHikvisionSyncMapper xzHikvisionSyncMapper;
|
||||
@Autowired
|
||||
private EnterpriseInfoServiceImpl enterpriseInfoService;
|
||||
@ -107,6 +123,12 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
private AsyncWorker asyncWorker;
|
||||
@Autowired
|
||||
private AsyncHikvision asyncHikvision;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectEnterpriseService projectEnterpriseService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ICarTypeService carTypeService;
|
||||
|
||||
@Override
|
||||
public IPage<CarInfo> selectCarListPage(Map<String, Object> map) {
|
||||
@ -127,8 +149,7 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CarInfo::getProjectSn, c.getProjectSn())
|
||||
.eq(CarInfo::getCarNumber, c.getCarNumber())
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
|
||||
;
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION);
|
||||
CarInfo old = carInfoMapper.selectOne(queryWrapper);
|
||||
c.setSendSuccessStatus(4);
|
||||
if (old != null) {
|
||||
@ -198,6 +219,137 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportExcelCarTemplate(HttpServletResponse response, String projectSn) {
|
||||
List<EnterpriseInfo> enterpriseInfos = projectEnterpriseService.queryPageList(new MapBuilder<String, Object>()
|
||||
.put("projectSn", projectSn)
|
||||
.build()).getRecords();
|
||||
List<CarType> carTypes = carTypeService.list(new LambdaQueryWrapper<CarType>()
|
||||
.eq(CarType::getProjectSn, projectSn));
|
||||
ExcelUtils.exportExcelCarTemplate(response, enterpriseInfos, carTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result uploadExcelCar(MultipartFile excelFile, String projectSn) {
|
||||
Result<String> result = new Result<String>();
|
||||
StringBuilder existName = new StringBuilder("");
|
||||
ArrayList<String> errIdCards = new ArrayList<>();
|
||||
String rtMsg = "";
|
||||
String existMsg = "";
|
||||
try {
|
||||
InputStream is = excelFile.getInputStream();
|
||||
List<Map<String, String>> list = ExcelUtils.jxlExlToList(is, 0);
|
||||
if (list == null || list.size() == 0) {
|
||||
throw new OpenAlertException(MessageUtil.get("excelNotDataErr"));
|
||||
}
|
||||
this.checkParams(list, projectSn);
|
||||
Map<String, EnterpriseInfo> enterpriseInfoMap = projectEnterpriseService.queryPageList(new MapBuilder<String, Object>()
|
||||
.put("projectSn", projectSn)
|
||||
.build()).getRecords().stream().collect(Collectors.toMap(EnterpriseInfo::getEnterpriseName, Function.identity(), (enterpriseInfo, enterpriseInfo2) -> enterpriseInfo));
|
||||
Map<String, CarInfo> numMap = carInfoMapper.selectList(new LambdaQueryWrapper<CarInfo>()
|
||||
.in(CarInfo::getCarNumber, list.stream().map(o -> o.get("车牌号")).collect(Collectors.toList()))
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)).stream().collect(Collectors.toMap(CarInfo::getCarNumber, Function.identity()));
|
||||
Map<String, WorkerInfo> workerMap = workerInfoService.list(new LambdaQueryWrapper<WorkerInfo>()
|
||||
.eq(WorkerInfo::getProjectSn, projectSn)
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)).stream().collect(Collectors.toMap(WorkerInfo::getWorkerName, Function.identity(), (workerInfo, workerInfo2) -> workerInfo));
|
||||
Map<String, CarType> carTypeMap = carTypeService.list(new LambdaQueryWrapper<CarType>()
|
||||
.eq(CarType::getProjectSn, projectSn)
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
|
||||
).stream().collect(Collectors.toMap(CarType::getCarTypeName, Function.identity(), (o1, o2) -> o1));
|
||||
for (Map<String, String> importInfo : list) {
|
||||
String carModuleType = importInfo.get("车辆类型");
|
||||
CarInfo dataCar = numMap.get(importInfo.get("车牌号"));
|
||||
CarInfo excelCar = new CarInfo();
|
||||
excelCar.setCarNumber(importInfo.get("车牌号"));
|
||||
excelCar.setCarColor(importInfo.get("车辆颜色"));
|
||||
excelCar.setAddTime(new Date());
|
||||
excelCar.setProjectSn(projectSn);
|
||||
if (!"临时车辆".equals(carModuleType)) {
|
||||
excelCar.setDriverWorkerId(Optional.ofNullable(workerMap.get(importInfo.get("司机姓名"))).map(o -> String.valueOf(o.getId())).orElse(null));
|
||||
}
|
||||
excelCar.setDriverWorkerName(importInfo.get("司机姓名"));
|
||||
excelCar.setDriverTelephone(importInfo.get("司机电话"));
|
||||
excelCar.setIsBlack(Objects.equals(importInfo.get("是否黑名单"), "是") ? 1 : 0);
|
||||
excelCar.setCarType(Optional.ofNullable(carTypeMap.get(importInfo.get("车种类型"))).map(CarType::getId).orElse(null));
|
||||
excelCar.setCarModuleType("固定车辆".equals(carModuleType) ? 1 : ("长期车辆".equals(carModuleType) ? 2 : 3));
|
||||
excelCar.setReserveStartTime(DateUtil.parse(importInfo.get("预约开始时间")));
|
||||
excelCar.setReserveEndTime(DateUtil.parse(importInfo.get("预约结束时间")));
|
||||
excelCar.setEntryAndExitPermit("单次".equals(importInfo.get("允许进出次数")) ? 0 : 1);
|
||||
excelCar.setEnterpriseId(Optional.ofNullable(enterpriseInfoMap.get(importInfo.get("单位"))).map(EnterpriseInfo::getId).orElse(null));
|
||||
if (dataCar == null) {
|
||||
this.addCarInfo(excelCar);
|
||||
} else {
|
||||
//存在车辆
|
||||
if (dataCar.toExistString().equals(excelCar.toExistString())) {
|
||||
existName.append(excelCar.getCarNumber());
|
||||
existName.append("、");
|
||||
log.info("忽略批量导入已存在完全一样车辆:{}", excelCar.getCarNumber());
|
||||
continue;
|
||||
}
|
||||
excelCar.setId(dataCar.getId());
|
||||
this.editCarInfo(excelCar);
|
||||
}
|
||||
}
|
||||
if (!"".equals(existName.toString())) {
|
||||
existName.deleteCharAt(existName.lastIndexOf("、"));
|
||||
existMsg = "车牌号为:" + existName + "的车辆已存在对应信息(车牌号等信息一致)";
|
||||
}
|
||||
String errIdCardMsg = "";
|
||||
if (CollUtil.isNotEmpty(errIdCards)) {
|
||||
if (StrUtil.isNotBlank(existMsg)) {
|
||||
errIdCardMsg += ",";
|
||||
}
|
||||
}
|
||||
rtMsg = StrUtil.format("导入成功。{}{}", existMsg, errIdCardMsg);
|
||||
result.successMsg(rtMsg);
|
||||
} catch (OpenAlertException e) {
|
||||
log.error("error:", e);
|
||||
rtMsg = e.getMessage();
|
||||
result.error500(rtMsg);
|
||||
} catch (Exception e) {
|
||||
log.error("error:", e);
|
||||
rtMsg = MessageUtil.get("failErr");
|
||||
result.error500(rtMsg);
|
||||
}
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
if (user != null) {
|
||||
noticeService.addUserNotice(user.getUserId(), "批量导入提醒", rtMsg, "10");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void checkParams(List<Map<String, String>> list, String projectSn) {
|
||||
for (Map<String, String> importInfo : list) {
|
||||
if (StringUtils.isBlank(importInfo.get("单位"))) {
|
||||
throw new OpenAlertException("有单位未填写");
|
||||
}
|
||||
if (StringUtils.isBlank(importInfo.get("车辆类型"))) {
|
||||
throw new OpenAlertException("有车辆类型未填写");
|
||||
}
|
||||
if (StringUtils.isBlank(importInfo.get("车牌号"))) {
|
||||
throw new OpenAlertException("有车牌号未填写");
|
||||
}
|
||||
if (StringUtils.isBlank(importInfo.get("车辆颜色"))) {
|
||||
throw new OpenAlertException("有车辆颜色未填写");
|
||||
}
|
||||
if (StringUtils.isBlank(importInfo.get("车种类型"))) {
|
||||
throw new OpenAlertException("有车种类型未填写");
|
||||
}
|
||||
if (StringUtils.isBlank(importInfo.get("司机姓名"))) {
|
||||
throw new OpenAlertException("有司机姓名未填写");
|
||||
}
|
||||
if (StringUtils.isBlank(importInfo.get("司机电话"))) {
|
||||
throw new OpenAlertException("有司机电话未填写");
|
||||
}
|
||||
if (StringUtils.isBlank(importInfo.get("司机电话"))) {
|
||||
throw new OpenAlertException("有司机电话未填写");
|
||||
}
|
||||
if (!"固定车辆".equals(importInfo.get("车辆类型")) && DateUtil.compare(DateUtil.parse(importInfo.get("预约结束时间")), new Date()) < 0) {
|
||||
throw new OpenAlertException("预约时间已失效,车辆" + importInfo.get("车牌号") + "无法下发,请重新提交");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validTime(CarInfo c) {
|
||||
if (isReservationType(c) && DateUtil.compare(c.getReserveEndTime(), new Date()) < 0) {
|
||||
throw new OpenAlertException("预约时间已失效,车辆无法下发,请重新提交");
|
||||
|
||||
@ -92,7 +92,7 @@ public class ProjectEnterpriseController {
|
||||
})
|
||||
@PostMapping(value = "/list")
|
||||
public Result<IPage<EnterpriseInfo>> queryPageList(@RequestBody Map<String, Object> map) {
|
||||
IPage<EnterpriseInfo> pageList = projectEnterpriseService.selectProjectEnterprisePage(map);
|
||||
IPage<EnterpriseInfo> pageList = projectEnterpriseService.queryPageList(map);
|
||||
return Result.success(pageList);
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class ProjectEnterpriseController {
|
||||
public Result<List<Map<String, Object>>> selectDetailList(@RequestBody Map<String, Object> map) {
|
||||
map.put("pageNo", -1);
|
||||
map.put("pageSize", 10);
|
||||
IPage<EnterpriseInfo> pageList = projectEnterpriseService.selectProjectEnterprisePage(map);
|
||||
IPage<EnterpriseInfo> pageList = projectEnterpriseService.queryPageList(map);
|
||||
List<Long> enterpriseIds = pageList.getRecords().stream().map(e -> e.getId()).collect(Collectors.toList());
|
||||
Map<String, Object> userMap = new HashMap<>(16);
|
||||
userMap.put("projectSn", map.get("projectSn").toString());
|
||||
|
||||
@ -24,7 +24,7 @@ public interface IProjectEnterpriseService extends IService<ProjectEnterprise> {
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
IPage<EnterpriseInfo> selectProjectEnterprisePage(Map<String, Object> map);
|
||||
IPage<EnterpriseInfo> queryPageList(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 添加项目劳务公司关联信息
|
||||
|
||||
@ -52,7 +52,7 @@ public class ProjectEnterpriseServiceImpl extends ServiceImpl<ProjectEnterpriseM
|
||||
private IProjectService projectService;
|
||||
|
||||
@Override
|
||||
public IPage<EnterpriseInfo> selectProjectEnterprisePage(Map<String, Object> map) {
|
||||
public IPage<EnterpriseInfo> queryPageList(Map<String, Object> map) {
|
||||
int pageNo = Integer.parseInt(map.getOrDefault("pageNo", 1).toString());
|
||||
int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString());
|
||||
Page<EnterpriseInfo> page = new Page<>(pageNo, pageSize);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.zhgd.xmgl.modules.worker.service;
|
||||
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerType;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
@ -36,7 +36,6 @@ import com.zhgd.xmgl.modules.baotou.entity.WorkerAdmissionDetail;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IDeviceUnitService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IWorkerAdmissionDetailService;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.enums.CompanyTypeEnum;
|
||||
import com.zhgd.xmgl.modules.basicdata.enums.SystemUserAccountTypeEnum;
|
||||
@ -133,6 +132,8 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
public static final String ID_CARD_BIG_PHOTO_URL = "idCardBigPhotoUrl";
|
||||
public static final String ID_CARD_DOWN_PHOTO_URL = "idCardDownPhotoUrl";
|
||||
public static final String ID_CARD_UP_PHOTO_URL = "idCardUpPhotoUrl";
|
||||
//岗位或工种id
|
||||
public static final String DEPARTMENT_TYPE_ID = "dtId";
|
||||
@Lazy
|
||||
@Autowired
|
||||
public XzHikvisionSyncMapper xzHikvisionSyncMapper;
|
||||
@ -1897,12 +1898,14 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
@Override
|
||||
public void exporExcelWorkerTemplate(HttpServletResponse response, String projectSn) {
|
||||
// List<EntityMap> teamList = teamInfoMapper.selectTeamInfoBySnList(projectSn);
|
||||
// List<EntityMap> departmentList = departmentInfoMapper.selectDepartmentInfoBySnList(projectSn);
|
||||
List<DictionaryItem> workerTypeList = dictionaryItemService.getDictList("bt_worker_type", projectSn);
|
||||
List<EntityMap> departmentList = departmentInfoMapper.selectDepartmentInfoBySnList(projectSn);
|
||||
//List<DictionaryItem> workerTypeList = dictionaryItemService.getDictList("bt_worker_type", projectSn);
|
||||
List<DeviceUnit> deviceUnitList = deviceUnitService.list(new LambdaQueryWrapper<DeviceUnit>()
|
||||
.eq(DeviceUnit::getProjectSn, projectSn));
|
||||
List<WorkerType> workerTypeList = workerTypeService.list(new LambdaQueryWrapper<WorkerType>()
|
||||
.eq(WorkerType::getProjectSn, projectSn));
|
||||
List<EntityMap> enterpriseInfoList = projectEnterpriseService.selectProjectEnterpriseList(new MapBuilder<String, Object>().put("sn", projectSn).build());
|
||||
ExcelUtils.exporExcelWorkerTemplate(response, workerTypeList, deviceUnitList, enterpriseInfoList);
|
||||
ExcelUtils.exporExcelWorkerTemplate(response, deviceUnitList, enterpriseInfoList, departmentList, workerTypeList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1951,7 +1954,6 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
}
|
||||
Map<String, DeviceUnit> unitMap = deviceUnitService.list(new LambdaQueryWrapper<DeviceUnit>()
|
||||
.eq(DeviceUnit::getProjectSn, projectSn)).stream().collect(Collectors.toMap(DeviceUnit::getDeviceUnitName, Function.identity(), (deviceUnit, deviceUnit2) -> deviceUnit));
|
||||
Map<String, Long> enterpriseNameMap = projectEnterpriseService.selectProjectEnterpriseList(new MapBuilder<String, Object>().put("sn", projectSn).build()).stream().collect(Collectors.toMap(o -> MapUtils.getString(o, "enterpriseName"), o -> MapUtils.getLong(o, "id"), (aLong, aLong2) -> aLong));
|
||||
for (Map<String, String> importInfo : list) {
|
||||
WorkerInfo workerInfo = new WorkerInfo();
|
||||
workerInfo.setProjectSn(projectSn);
|
||||
@ -1983,7 +1985,7 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
workerInfo.setLongTerm(1);
|
||||
}
|
||||
workerInfo.setEnterpriseId(MapUtils.getLong(importInfo, "enterpriseId"));
|
||||
Long dtId = MapUtils.getLong(importInfo, "dtId");
|
||||
Long dtId = MapUtils.getLong(importInfo, DEPARTMENT_TYPE_ID);
|
||||
if (workerInfo.getPersonType() == 2) {
|
||||
workerInfo.setDepartmentId(dtId);
|
||||
} else {
|
||||
@ -2092,33 +2094,41 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入excel前,list添加班组和部门名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void addTeamAndDepartmentName(List<Map<String, String>> list, String projectSn) {
|
||||
List<DictionaryItem> workerTypeList = dictionaryItemService.getDictList("bt_worker_type", projectSn);
|
||||
Map<String, DictionaryItem> typeMap = workerTypeList.stream().collect(Collectors.toMap(DictionaryItem::getName, Function.identity(), (dictionaryItem, dictionaryItem2) -> dictionaryItem));
|
||||
//List<DictionaryItem> workerTypeList = dictionaryItemService.getDictList("bt_worker_type", projectSn);
|
||||
List<WorkerType> workerTypeList = workerTypeService.list(new LambdaQueryWrapper<WorkerType>()
|
||||
.eq(WorkerType::getProjectSn, projectSn));
|
||||
//Map<String, DictionaryItem> typeMap = workerTypeList.stream().collect(Collectors.toMap(DictionaryItem::getName, Function.identity(), (dictionaryItem, dictionaryItem2) -> dictionaryItem));
|
||||
Map<String, WorkerType> typeMap = workerTypeList.stream().collect(Collectors.toMap(WorkerType::getTypeName, Function.identity(), (dictionaryItem, dictionaryItem2) -> dictionaryItem));
|
||||
Map<String, Object> teamMap = teamInfoMapper.getTeamInfoMapBySn(projectSn);
|
||||
Map<String, Object> departmentMap = departmentInfoMapper.getDepartmentInfoMapBySn(projectSn);
|
||||
List<WorkerType> typeList = workerTypeService.list(new LambdaQueryWrapper<WorkerType>()
|
||||
.eq(WorkerType::getProjectSn, projectSn));
|
||||
List<EntityMap> enterpriseList = projectEnterpriseService.selectProjectEnterpriseList(new MapBuilder<String, Object>().put("sn", projectSn).build());
|
||||
List<WorkerType> addTypeList = new ArrayList<>();
|
||||
for (DictionaryItem item : workerTypeList) {
|
||||
Optional<WorkerType> op = typeList.stream().filter(o -> Objects.equals(o.getTypeName(), item.getName())).findAny();
|
||||
if (!op.isPresent()) {
|
||||
WorkerType type = new WorkerType();
|
||||
type.setTypeName(item.getName());
|
||||
type.setProjectSn(projectSn);
|
||||
addTypeList.add(type);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(addTypeList)) {
|
||||
workerTypeService.saveBatch(addTypeList);
|
||||
typeList = workerTypeService.list(new LambdaQueryWrapper<WorkerType>()
|
||||
.eq(WorkerType::getProjectSn, projectSn));
|
||||
}
|
||||
//List<WorkerType> addTypeList = new ArrayList<>();
|
||||
//for (DictionaryItem item : workerTypeList) {
|
||||
// Optional<WorkerType> op = typeList.stream().filter(o -> Objects.equals(o.getTypeName(), item.getName())).findAny();
|
||||
// if (!op.isPresent()) {
|
||||
// WorkerType type = new WorkerType();
|
||||
// type.setTypeName(item.getName());
|
||||
// type.setProjectSn(projectSn);
|
||||
// addTypeList.add(type);
|
||||
// }
|
||||
//}
|
||||
//if (CollUtil.isNotEmpty(addTypeList)) {
|
||||
// workerTypeService.saveBatch(addTypeList);
|
||||
// typeList = workerTypeService.list(new LambdaQueryWrapper<WorkerType>()
|
||||
// .eq(WorkerType::getProjectSn, projectSn));
|
||||
//}
|
||||
for (Map<String, String> map : list) {
|
||||
String name = MapUtils.getString(map, "*单位名称");
|
||||
String typeName = MapUtils.getString(map, "*岗位(工种)");
|
||||
Integer personType = getPersonType(typeMap, typeName);
|
||||
Integer personType = typeMap.get(typeName) != null ? 1 : 2;
|
||||
Long dtId = null;
|
||||
Optional<EntityMap> enterpriseNameOp = enterpriseList.stream().filter(o -> Objects.equals(MapUtils.getString(((Map) o), "enterpriseName"), name)).findFirst();
|
||||
Long enterpriseId = null;
|
||||
@ -2163,29 +2173,12 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
dtId = Convert.toLong(o1.get("id"));
|
||||
}
|
||||
}
|
||||
map.put("dtId", dtId.toString());
|
||||
map.put(DEPARTMENT_TYPE_ID, dtId.toString());
|
||||
map.put("personType", personType.toString());
|
||||
map.put("enterpriseId", enterpriseId.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Integer getPersonType(Map<String, DictionaryItem> typeMap, String typeName) {
|
||||
Integer personType = 1;
|
||||
DictionaryItem di = typeMap.get(typeName);
|
||||
if (di != null) {
|
||||
Integer i = Convert.toInt(di.getData());
|
||||
if (i != null) {
|
||||
if (i >= 200) {
|
||||
personType = 1;
|
||||
} else {
|
||||
personType = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return personType;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void editWorkerForUploadExcel(WorkerInfo workerInfo) {
|
||||
xzHikvisionSyncMapper.delete(new LambdaQueryWrapper<XzHikvisionSync>()
|
||||
@ -2230,21 +2223,23 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
throw new OpenAlertException("身份证号码有重复,重复的号码为:" + StringUtils.join(repeatList));
|
||||
}
|
||||
//编号判重
|
||||
List<String> numList = list.stream().collect(Collectors.groupingBy(m -> m.get("编号"), Collectors.counting())).entrySet().stream().filter(key -> key.getValue() > 1).map(o -> o.getKey()).collect(Collectors.toList());
|
||||
List<String> numList = list.stream().filter(m -> StrUtil.isNotBlank(m.get("编号"))).collect(Collectors.groupingBy(m -> m.get("编号"), Collectors.counting())).entrySet().stream().filter(key -> key.getValue() > 1).map(o -> o.getKey()).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(numList)) {
|
||||
throw new OpenAlertException("编号有重复,重复的号码为:" + StringUtils.join(numList));
|
||||
}
|
||||
|
||||
List<String> numList1 = list.stream().map(o -> o.get("编号")).collect(Collectors.toList());
|
||||
List<String> numList1 = list.stream().filter(m -> StrUtil.isNotBlank(m.get("编号"))).map(o -> o.get("编号")).collect(Collectors.toList());
|
||||
List<String> cardList1 = list.stream().map(o -> o.get("*身份证号码")).collect(Collectors.toList());
|
||||
List<WorkerInfo> infos = workerInfoMapper.selectList(new LambdaQueryWrapper<WorkerInfo>()
|
||||
.eq(WorkerInfo::getProjectSn, projectSn)
|
||||
.in(WorkerInfo::getNum, numList1)
|
||||
.notIn(WorkerInfo::getIdCard, cardList1)
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(infos)) {
|
||||
throw new OpenAlertException("人员编号已存在,重复的人员和编号为:" + StringUtils.join(infos.stream().map(o -> o.getWorkerName() + "(" + o.getNum() + ")").collect(Collectors.toList())));
|
||||
if (CollUtil.isNotEmpty(numList1)) {
|
||||
List<WorkerInfo> infos = workerInfoMapper.selectList(new LambdaQueryWrapper<WorkerInfo>()
|
||||
.eq(WorkerInfo::getProjectSn, projectSn)
|
||||
.in(WorkerInfo::getNum, numList1)
|
||||
.notIn(WorkerInfo::getIdCard, cardList1)
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(infos)) {
|
||||
throw new OpenAlertException("人员编号已存在,重复的人员和编号为:" + StringUtils.join(infos.stream().map(o -> o.getWorkerName() + "(" + o.getNum() + ")").collect(Collectors.toList())));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -80,6 +80,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
http.authorizeRequests()
|
||||
//请求路径允许访问
|
||||
.antMatchers("/xmgl/carInfo/exportExcelCarTemplate").permitAll()
|
||||
.antMatchers("/xmgl/weeklyMonthlyRiskIdentification/flow/add").permitAll()
|
||||
.antMatchers("/xmgl/projectHomeNotice/flow/add").permitAll()
|
||||
.antMatchers("/xmgl/promotionalVideo/flow/add").permitAll()
|
||||
|
||||
@ -33,7 +33,6 @@ import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -837,7 +836,7 @@ public class JzgTask {
|
||||
eMap.put("projectSn", projectSn);
|
||||
eMap.put("pageNo", "1");
|
||||
eMap.put("pageSize", "9999999");
|
||||
List<EnterpriseInfo> records = projectEnterpriseService.selectProjectEnterprisePage(eMap).getRecords();
|
||||
List<EnterpriseInfo> records = projectEnterpriseService.queryPageList(eMap).getRecords();
|
||||
Map<String, JzgEnterpriseInfo> jzgEnterpriseInfoMap = new HashMap<>(16);
|
||||
if (jzgRt != null) {
|
||||
String data = jzgRt.getData();
|
||||
|
||||
@ -2,7 +2,7 @@ package com.zhgd.xmgl.util;
|
||||
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.DeviceUnit;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarType;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamSubject;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerSafeEducationWorker;
|
||||
@ -229,22 +229,32 @@ public class ExcelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void exporExcelWorkerTemplate(HttpServletResponse response, List<DictionaryItem> workerTypeList, List<DeviceUnit> deviceUnitList, List<EntityMap> enterpriseInfoList) {
|
||||
public static void exporExcelWorkerTemplate(HttpServletResponse response, List<DeviceUnit> deviceUnitList, List<EntityMap> enterpriseInfoList, List<EntityMap> departmentList, List<WorkerType> typeList) {
|
||||
try {
|
||||
ClassPathResource classPathResource = new ClassPathResource("excel/人员导入模板.xlsx");
|
||||
InputStream inputStream = classPathResource.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||
//*岗位(工种)下拉列
|
||||
XSSFSheet sheet1 = workbook.getSheet("岗位(班组)");
|
||||
if (workerTypeList.size() > 0) {
|
||||
for (int i = 0; i < workerTypeList.size(); i++) {
|
||||
XSSFSheet sheet1 = workbook.getSheet("岗位(工种)");
|
||||
if (departmentList.size() > 0) {
|
||||
for (int i = 0; i < departmentList.size(); i++) {
|
||||
XSSFRow row1 = sheet1.createRow(i);
|
||||
XSSFCell cell1 = row1.createCell(0);
|
||||
DictionaryItem obj = workerTypeList.get(i);
|
||||
EntityMap obj = departmentList.get(i);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
cell1.setCellValue(obj.getName());
|
||||
cell1.setCellValue(MapUtils.getString(obj, "enterpriseDepartmentName"));
|
||||
}
|
||||
}
|
||||
if (typeList.size() > 0) {
|
||||
for (int i = departmentList.size(); i < typeList.size() + departmentList.size(); i++) {
|
||||
XSSFRow row1 = sheet1.createRow(i);
|
||||
XSSFCell cell1 = row1.createCell(0);
|
||||
WorkerType obj = typeList.get(i - departmentList.size());
|
||||
cell1.setCellType(CellType.STRING);
|
||||
cell1.setCellValue(obj.getTypeName());
|
||||
}
|
||||
}
|
||||
|
||||
//工作区域下拉
|
||||
XSSFSheet sheet2 = workbook.getSheet("工作区域");
|
||||
if (deviceUnitList.size() > 0) {
|
||||
@ -264,7 +274,8 @@ public class ExcelUtils {
|
||||
XSSFCell cell1 = row1.createCell(0);
|
||||
EntityMap obj = enterpriseInfoList.get(i);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
cell1.setCellValue(MapUtils.getString(obj, "enterpriseName")); }
|
||||
cell1.setCellValue(MapUtils.getString(obj, "enterpriseName"));
|
||||
}
|
||||
}
|
||||
downLoadExcel("人员导入模板.xlsx", response, workbook);
|
||||
} catch (IOException e) {
|
||||
@ -418,4 +429,38 @@ public class ExcelUtils {
|
||||
return cell.getStringCellValue();
|
||||
}
|
||||
|
||||
public static void exportExcelCarTemplate(HttpServletResponse response, List<EnterpriseInfo> enterpriseInfos, List<CarType> carTypes) {
|
||||
try {
|
||||
ClassPathResource classPathResource = new ClassPathResource("excel/车辆导入模板.xlsx");
|
||||
InputStream inputStream = classPathResource.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||
//单位
|
||||
XSSFSheet sheet1 = workbook.getSheet("单位");
|
||||
if (enterpriseInfos.size() > 0) {
|
||||
for (int i = 0; i < enterpriseInfos.size(); i++) {
|
||||
XSSFRow row1 = sheet1.createRow(i);
|
||||
XSSFCell cell1 = row1.createCell(0);
|
||||
EnterpriseInfo obj = enterpriseInfos.get(i);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
cell1.setCellValue(obj.getEnterpriseName());
|
||||
}
|
||||
}
|
||||
|
||||
//车种类型
|
||||
XSSFSheet sheet2 = workbook.getSheet("车种类型");
|
||||
if (carTypes.size() > 0) {
|
||||
for (int i = 0; i < carTypes.size(); i++) {
|
||||
XSSFRow row1 = sheet2.createRow(i);
|
||||
XSSFCell cell1 = row1.createCell(0);
|
||||
CarType obj = carTypes.get(i);
|
||||
cell1.setCellType(CellType.STRING);
|
||||
cell1.setCellValue(obj.getCarTypeName());
|
||||
}
|
||||
}
|
||||
|
||||
downLoadExcel("车辆导入模板.xlsx", response, workbook);
|
||||
} catch (IOException e) {
|
||||
log.error("error:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
src/main/resources/excel/车辆导入模板.xlsx
Normal file
BIN
src/main/resources/excel/车辆导入模板.xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user