Commit 675cdd1b authored by tangwei's avatar tangwei

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 5dc4c319 4b6f8dc1
......@@ -19,7 +19,7 @@
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]> #{endDate}
and s.app_Key = #{appKey}
GROUP BY s.duty_date
GROUP BY s.duty_date,s.shift_id <!--增添分组条件 根据班次分组技术 -->
) a) as maxDutyPersonNumDay,
(select
IFNULL(max(num),0)
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.yeejoin.amos.boot.module.common.api.mapper.FirefightersMapper">
namespace="com.yeejoin.amos.boot.module.common.api.mapper.FirefightersMapper">
<select id="getFirefightersJobTitleCount" resultType="com.yeejoin.amos.boot.biz.common.utils.FirefightersTreeDto">
select COUNT(a.sequence_nbr) num, a.job_title_code jobTitleCode
from cb_firefighters a
where a.is_delete = 0
GROUP BY a.job_title_code
</select>
<!--消防队员列表按时间倒叙排列add desc 2021-09-08 by kongfm -->
<select id="getFirefighters"
resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersZhDto">
select a.*,b.areas_expertise areasExpertise ,b.areas_expertise_code areasExpertiseCode from cb_firefighters a LEFT JOIN cb_firefighters_post b on
a.sequence_nbr=b.firefighters_id where a.is_delete=0
<if test='par.postQualification!=null'>and b.post_qualification_code = #{par.postQualification}</if>
<if test='par.areasExpertise!=null'>and b.areas_expertise_code= #{par.areasExpertise}</if>
<if test='par.name!=null'>and a.name like concat ('%',#{par.name},'%')</if>
<if test='par.state!=null'>and a.state_code= #{par.state}</if>
<if test='par.fireTeamId!=null'>and a.fire_team_id= #{par.fireTeamId}</if>
<if test='par.jobTitle!=null'>and a.job_title_code =#{par.jobTitle}</if>
<if test='par.areasExpertiseCode!=null and par.areasExpertiseCode!="0"'>and b.areas_expertise_code =#{par.areasExpertiseCode}</if>
<if test='par.areasExpertiseCode=="0"'>and b.areas_expertise_code is not null</if>
ORDER BY a.rec_date desc limit #{pageNum},#{pageSize}
</select>
<!--消防队员列表按时间倒叙排列add desc 2021-09-08 by kongfm -->
<select id="getFirefightersCount" resultType="Map">
select COUNT(a.sequence_nbr) num from cb_firefighters a LEFT JOIN
cb_firefighters_post b on a.sequence_nbr=b.firefighters_id where
a.is_delete=0
<if test='par.postQualification!=null'>and b.post_qualification_code = #{par.postQualification}</if>
<if test='par.areasExpertise!=null'>and b.areas_expertise_code= #{par.areasExpertise}</if>
<if test='par.name!=null'>and a.name like concat ('%',#{par.name},'%')</if>
<if test='par.state!=null'>and a.state_code= #{par.state}</if>
<if test='par.fireTeamId!=null'>and a.fire_team_id= #{par.fireTeamId}</if>
<if test='par.jobTitle!=null'>and a.job_title_code =#{par.jobTitle}</if>
<if test='par.areasExpertiseCode!=null and par.areasExpertiseCode!="0"'>and b.areas_expertise_code =#{par.areasExpertiseCode}</if>
<if test='par.areasExpertiseCode=="0"'>and b.areas_expertise_code is not null</if>
<select id="getFirefightersJobTitleCount"
resultType="com.yeejoin.amos.boot.biz.common.utils.FirefightersTreeDto">
select COUNT(a.sequence_nbr) num, a.job_title_code jobTitleCode
from cb_firefighters a
where a.is_delete = 0
GROUP BY a.job_title_code
</select>
<!--消防队员列表按时间倒叙排列add desc 2021-09-08 by kongfm -->
<select id="getFirefighters"
resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersZhDto">
select a.*,b.areas_expertise areasExpertise ,b.areas_expertise_code
areasExpertiseCode from cb_firefighters a LEFT JOIN
cb_firefighters_post b on
a.sequence_nbr=b.firefighters_id where a.is_delete=0
<if test='par.postQualification!=null'>and b.post_qualification_code = #{par.postQualification}</if>
<if test='par.areasExpertise!=null'>and b.areas_expertise_code= #{par.areasExpertise}</if>
<if test='par.name!=null'>and a.name like concat ('%',#{par.name},'%')</if>
<if test='par.state!=null'>and a.state_code= #{par.state}</if>
<if test='par.fireTeamId!=null'>and a.fire_team_id= #{par.fireTeamId}</if>
<if test='par.jobTitle!=null'>and a.job_title_code =#{par.jobTitle}</if>
<if
test='par.areasExpertiseCode!=null and par.areasExpertiseCode!="0"'>and b.areas_expertise_code =#{par.areasExpertiseCode}</if>
<if test='par.areasExpertiseCode=="0"'>and b.areas_expertise_code is not null</if>
ORDER BY a.rec_date desc limit #{pageNum},#{pageSize}
</select>
<!--消防队员列表按时间倒叙排列add desc 2021-09-08 by kongfm -->
<select id="getFirefightersCount" resultType="Map">
select COUNT(a.sequence_nbr) num from cb_firefighters a LEFT JOIN
cb_firefighters_post b on a.sequence_nbr=b.firefighters_id where
a.is_delete=0
<if test='par.postQualification!=null'>and b.post_qualification_code = #{par.postQualification}</if>
<if test='par.areasExpertise!=null'>and b.areas_expertise_code= #{par.areasExpertise}</if>
<if test='par.name!=null'>and a.name like concat ('%',#{par.name},'%')</if>
<if test='par.state!=null'>and a.state_code= #{par.state}</if>
<if test='par.fireTeamId!=null'>and a.fire_team_id= #{par.fireTeamId}</if>
<if test='par.jobTitle!=null'>and a.job_title_code =#{par.jobTitle}</if>
<if
test='par.areasExpertiseCode!=null and par.areasExpertiseCode!="0"'>and b.areas_expertise_code =#{par.areasExpertiseCode}</if>
<if test='par.areasExpertiseCode=="0"'>and b.areas_expertise_code is not null</if>
ORDER BY a.rec_date desc
</select>
ORDER BY a.rec_date desc
</select>
<select id="listToSelectById" resultType="Map">
SELECT IFNULL(a.personnel_photos, '') personnelPhotos,
a.sequence_nbr
sequenceNbr,
IFNULL(a.`name`, '无') `name`,
IFNULL(a.job_title, '无')
jobTitle,
IFNULL(b.administrative_position, '无')
administrativePosition,
IFNULL(c.`name`, '无') fireTeamName,
IFNULL(a.state, '无') state,
IFNULL(b.employee_hierarchy, '无')
employeeHierarchy,
IFNULL(b.areas_expertise, '无') areasExpertise,
IFNULL(a.gender, '无') gender,
IFNULL(b.post_qualification, '无')
postQualification, year ( from_days( datediff( now( ),
a.birthday_time))) age
FROM cb_firefighters a LEFT JOIN cb_firefighters_post b
ON a.sequence_nbr
= b.firefighters_id LEFT JOIN cb_fire_team c on
c.sequence_nbr=a.fire_team_id
WHERE a.is_delete =0
and a.sequence_nbr=#{id}
</select>
<select id="listToSelectById" resultType="Map">
SELECT IFNULL(a.personnel_photos, '') personnelPhotos,
a.sequence_nbr
sequenceNbr,
IFNULL(a.`name`, '无') `name`,
IFNULL(a.job_title, '无')
jobTitle,
IFNULL(b.administrative_position, '无')
administrativePosition,
IFNULL(c.`name`, '无') fireTeamName,
IFNULL(a.state, '无') state,
IFNULL(b.employee_hierarchy, '无')
employeeHierarchy,
IFNULL(b.areas_expertise, '无') areasExpertise,
IFNULL(a.gender, '无') gender,
IFNULL(b.post_qualification, '无')
postQualification, year ( from_days( datediff( now( ),
a.birthday_time))) age
FROM cb_firefighters a LEFT JOIN cb_firefighters_post b
ON a.sequence_nbr
= b.firefighters_id LEFT JOIN cb_fire_team c on
c.sequence_nbr=a.fire_team_id
WHERE a.is_delete =0
and a.sequence_nbr=#{id}
</select>
<!-- BUG3553 BY kongfm 人员关系显示汉字-->
<select id="exportToExcel" resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersExcelDto">
select f.*,
(select cb_fire_team.name from cb_fire_team where cb_fire_team.sequence_nbr=f.fire_team_id) fireTeam,
emergency_contact, (select da.name from cb_data_dictionary da where da.code = fc.relationship) as relationship , emergency_contact_phone
from cb_firefighters f
left join cb_firefighters_contacts fc on f.sequence_nbr = fc.firefighters_id
where f.is_delete = #{isDelete}
</select>
<!-- BUG3553 BY kongfm 人员关系显示汉字 -->
<select id="exportToExcel"
resultType="com.yeejoin.amos.boot.module.common.api.dto.FirefightersExcelDto">
SELECT
f.*,
( SELECT cb_fire_team.NAME FROM cb_fire_team WHERE
cb_fire_team.sequence_nbr = f.fire_team_id ) fireTeam,
emergency_contact,
da.NAME AS relationship,
emergency_contact_phone
FROM
cb_firefighters f
LEFT JOIN cb_firefighters_contacts fc ON f.sequence_nbr =
fc.firefighters_id
left join cb_data_dictionary da on da.CODE = fc.relationship
where f.is_delete = #{isDelete}
</select>
</mapper>
......@@ -79,7 +79,7 @@ public class OrgPersonController {
@ApiOperation(httpMethod = "PUT", value = "更新单位数据", notes = "更新单位数据")
public ResponseModel<?> updateByIdOrgUsr(HttpServletRequest request, @RequestBody OrgPersonDto OrgPersonVo,
@PathVariable Long id) throws Exception {
//OrgPersonVo.setBizOrgType(CommonConstant.BIZ_ORG_TYPE_PERSON);
OrgPersonVo.setBizOrgType(CommonConstant.BIZ_ORG_TYPE_PERSON);
iOrgUsrService.updateByIdOrgPerson(OrgPersonVo, id);
return ResponseHelper.buildResponse(null);
}
......
......@@ -87,7 +87,10 @@ public class OrgUsrController extends BaseController {
return ResponseHelper.buildResponse("-1");
}
}
iOrgUsrService.update(new UpdateWrapper<OrgUsr>().eq("sequence_nbr", id).set("is_delete", CommonConstant.IS_DELETE_01));
// iOrgUsrService.update(new UpdateWrapper<OrgUsr>().eq("sequence_nbr", id).set("is_delete", CommonConstant.IS_DELETE_01));
/*bug 2812 一次删除多条数据 传入类型修改为string 问题解决 2021-09-09 陈召 开始*/
iOrgUsrService.update(new UpdateWrapper<OrgUsr>().eq("sequence_nbr", String.valueOf(id)).set("is_delete", CommonConstant.IS_DELETE_01));
/*bug 2812 一次删除多条数据 传入类型修改为string 问题解决 2021-09-09 陈召 结束*/
try {
eSOrgUsrService.deleteById(id);
emqKeeper.getMqttClient().publish(airportDeleteTopic, JSON.toJSONString(id).getBytes(), 2, false);
......@@ -108,6 +111,7 @@ public class OrgUsrController extends BaseController {
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "更新单位数据", notes = "更新单位数据")
public ResponseModel<?> updateByIdOrgUsr(HttpServletRequest request, @RequestBody OrgUsrDto OrgUsrVo, @PathVariable Long id) throws Exception {
OrgUsrVo.setBizOrgType(CommonConstant.BIZ_ORG_TYPE_COMPANY);
iOrgUsrService.updateByIdOrgUsr(OrgUsrVo, id);
return ResponseHelper.buildResponse(null);
......
......@@ -100,7 +100,6 @@ public class WaterResourceController extends BaseController {
model.setLongitude(Double.valueOf(address.getString(BizConstant.LONGITUDE)));
model.setLatitude(Double.valueOf(address.getString(BizConstant.LATITUDE)));
}*/
if (!StringUtils.isEmpty(resourceType)) {
switch (resourceType) {
case "hydrant":
......@@ -176,8 +175,6 @@ public class WaterResourceController extends BaseController {
model.setLongitude(Double.valueOf(address.getString(BizConstant.LONGITUDE)));
model.setLatitude(Double.valueOf(address.getString(BizConstant.LATITUDE)));
}*/
// 更新基本信息
model.setSequenceNbr(sequenceNbr);
model.setRealityImg(JSONArray.toJSONString(model.getRealityImgList()));
......
......@@ -85,16 +85,43 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
}
private void fillDutyShiftData(String beginDate, String endDate, Map<String, Object> m) throws ParseException {
// 获取值班的实例id
String instanceId = m.get("instanceId").toString();
// 根据appkey 获取未删除的值班班次
List<DutyShift> dutyShifts = dutyShiftService.list(new LambdaQueryWrapper<DutyShift>()
.eq(BaseEntity::getIsDelete, false).eq(DutyShift::getAppKey, RequestContext.getAppKey()));
// 根据id 保存成key -value
Map<Long, DutyShift> keyNameMap = dutyShifts.stream()
.collect(Collectors.toMap(BaseEntity::getSequenceNbr, Function.identity()));
// 根据时间 查询值班关系表
// BUG 2806 获取月份第一天和最后一天 2021-09-09 by kongfm
if(beginDate != null ) {
Calendar c = Calendar.getInstance();
c.setTime(DateUtils.longStr2Date(beginDate));
c.set(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR_OF_DAY,0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
beginDate = DateUtils.date2LongStr(c.getTime());
}
if(endDate != null ) {
Calendar c = Calendar.getInstance();
c.setTime(DateUtils.longStr2Date(beginDate));
c.add(Calendar.MONTH, 1);
c.set(Calendar.DAY_OF_MONTH, 1);
c.add(Calendar.DATE, -1);
c.set(Calendar.HOUR_OF_DAY,23);
c.set(Calendar.MINUTE,59);
c.set(Calendar.SECOND,59);
endDate = DateUtils.date2LongStr(c.getTime());
}
List<DutyPersonShiftDto> personShiftList = dutyPersonShiftService
.list(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId, instanceId)
.ge(beginDate != null, DutyPersonShift::getDutyDate, beginDate)
.le(endDate != null, DutyPersonShift::getDutyDate, endDate))
.stream().map(e -> {
// 值班关系查询到以后 重新封装
DutyPersonShiftDto dto = new DutyPersonShiftDto();
Bean.copyExistPropertis(e, dto);
// 没值班信息,默认休
......@@ -152,6 +179,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
public List<Map<String, Object>> list(Long teamId, String beginDate, String endDate) throws ParseException {
// 1.已column为准 进行返回
String groupCode = this.getGroupCode();
// 动态表单查询所有值班信息
List<Map<String, Object>> list = dynamicFormInstanceService.listAll(groupCode);
// 2.组织值班数据
......@@ -299,6 +327,9 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
@Override
public Boolean deleteDutyData(Long instanceId) {
// 一个人共用一个 instanceId
dynamicFormInstanceService.remove(
new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
dutyPersonShiftService
......
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -8,7 +33,24 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.dto.CheckObjectDto;
import com.yeejoin.amos.boot.module.common.api.dto.CompanyDto;
import com.yeejoin.amos.boot.module.common.api.dto.CompanyPerson;
import com.yeejoin.amos.boot.module.common.api.dto.DynamicFormInstanceDto;
import com.yeejoin.amos.boot.module.common.api.dto.ESOrgUsrDto;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentFormDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonExcelDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonFormDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrExcelDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrFormDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrzhDto;
import com.yeejoin.amos.boot.module.common.api.dto.RequestData;
import com.yeejoin.amos.boot.module.common.api.dto.UserUnitDto;
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.MaintenanceCompany;
......@@ -23,24 +65,6 @@ import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.component.emq.EmqKeeper;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 机构/部门/人员表 服务实现类
*
......@@ -169,13 +193,11 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return resultList;
}
@SuppressWarnings("unchecked")
@Override
public List<OrgMenuDto> getSub(Long topId, @SuppressWarnings("rawtypes") Collection entityList, String packageURL,
String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName,
String OrgTypeMethodName) throws Exception {
List<OrgMenuDto> childList = new ArrayList<>();
@SuppressWarnings("rawtypes")
Class clazz = Class.forName(packageURL);
Method IDMethodNameme = null;
switch (IDHierarchy) {
......@@ -239,7 +261,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return childList;
}
@Override
public List<Map<String, Object>> returnCompanyPersonMsg(List<Long> ids) throws Exception {
List<Map<String, Object>> companyPersonMsg = new ArrayList<>();
......@@ -413,13 +435,12 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
private void updateChildOrgCode(String oriOrgCode, String targetOrgCode) {
List<OrgUsr> list = queryOrgUsrList(oriOrgCode);
if (ObjectUtils.isEmpty(list)) {
return;
}
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
action.setBizOrgCode(action.getBizOrgCode().replace(oriOrgCode, targetOrgCode));
updateById(action);
});
}
}
public List<OrgUsr> queryOrgUsrList(String bizOrgCode) {
......@@ -621,6 +642,13 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
OrgUsr orgUsr = new OrgUsr();
OrgUsr oriOrgUsr = getById(id);
BeanUtils.copyProperties(OrgUsrVo, orgUsr);
/*单位编辑后 code值也应做出修改 2021-09-09 陈召 开始 */
OrgUsr parent = getById(OrgUsrVo.getParentId());
if (parent != null){
orgUsr.setBizOrgCode(parent.getBizOrgCode() + getOrgCodeStr());
}
orgUsr.setSequenceNbr(id);
/*单位编辑后 code值也应做出修改 2021-09-09 陈召 结束 */
saveOrgUsr(orgUsr, oriOrgUsr);
// 保存动态表单数据
updateDynamicFormInstance(orgUsr.getSequenceNbr(), OrgUsrVo.getDynamicFormValue());
......@@ -636,13 +664,13 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
OrgUsr orgUsr = new OrgUsr();
OrgUsr oriOrgUsr = getById(id);
BeanUtils.copyProperties(OrgPersonVo, orgUsr);
/* Bug 2647 编辑用户所属单位后按单位筛选人员结果错误 增加了 638 639 两行代码 根据修改的部门调整部门code 2021-09-03 陈召 开始*/
OrgUsr parent = getById(OrgPersonVo.getParentId());
if (parent != null){
orgUsr.setBizOrgCode(parent.getBizOrgCode() + getOrgCodeStr());
}
/* Bug 2647 编辑用户所属单位后按单位筛选人员结果错误 增加了 638 639 两行代码 根据修改的部门调整部门code 2021-09-03 陈召 结束*/
orgUsr.setSequenceNbr(id);
/* Bug 2647 编辑用户所属单位后按单位筛选人员结果错误 增加了 638 639 两行代码 根据修改的部门调整部门code 2021-09-03 陈召 开始*/
OrgUsr parent = getById(OrgPersonVo.getParentId());
if (!ObjectUtils.isEmpty(parent)){
orgUsr.setBizOrgCode(parent.getBizOrgCode() + getOrgCodeStr());
}
/* Bug 2647 编辑用户所属单位后按单位筛选人员结果错误 增加了 638 639 两行代码 根据修改的部门调整部门code 2021-09-03 陈召 结束*/
if (!ObjectUtils.isEmpty(OrgPersonVo.getAmosOrgId())) {
AgencyUserModel user = Privilege.agencyUserClient.queryByUserId(OrgPersonVo.getAmosOrgId()).getResult();
oriOrgUsr.setAmosOrgCode(user.getRealName());
......@@ -776,6 +804,14 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
OrgUsr orgUsr = new OrgUsr();
OrgUsr oriOrgUsr = getById(id);
BeanUtils.copyProperties(OrgDepartmentVo, orgUsr);
/*部门编辑后 code值也应做出修改 2021-09-09 陈召 开始 */
OrgUsr parent = getById(OrgDepartmentVo.getParentId());
if (parent != null){
orgUsr.setBizOrgCode(parent.getBizOrgCode() + getOrgCodeStr());
}
orgUsr.setSequenceNbr(id);
/*部门编辑后 code值也应做出修改 2021-09-09 陈召 结束 */
saveOrgUsr(orgUsr, oriOrgUsr);
// 保存动态表单数据
updateDynamicFormInstance(orgUsr.getSequenceNbr(), OrgDepartmentVo.getDynamicFormValue());
......@@ -961,7 +997,8 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return null;
}
return ids.stream().map(m -> {
OrgUsr org = getById(m);
// BUG 2740 机场单位主键varchar 导致 通过主键搜索返回多条数据 2021 - 09 - 09by kongfm
OrgUsr org = getById(m.toString());
if (ObjectUtils.isEmpty(org)) {
return null;
}
......@@ -978,6 +1015,10 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
public List<OrgUsrDto> queryForListByParentIdAndOrgType(Long parentId, String bizOrgType, Boolean isDelete) {
return this.queryForList(null, false, parentId, bizOrgType, isDelete);
}
public List<OrgUsrDto> queryForListByParentIdAndOrgType(Long parentId, String bizOrgType) {
return Bean.toModels(this.list(new LambdaQueryWrapper<OrgUsr>().eq(OrgUsr::getIsDelete,false).eq(OrgUsr::getParentId,parentId).eq(OrgUsr::getBizOrgType,bizOrgType)), this.getModelClass());
}
public OrgUsrDto getOrg(String amosUserId) {
OrgUsrDto person = queryForListByParentIdAndOrgType(amosUserId);
......@@ -1383,7 +1424,6 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
List<OrgUsr> orgUsrList = this.baseMapper.selectList(wrapper);
return orgUsrList;
}
}
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.collect.Lists;
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
......@@ -26,6 +32,10 @@ import com.yeejoin.amos.boot.module.common.biz.service.impl.*;
import com.yeejoin.amos.boot.module.jcs.api.dto.AircraftDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.Aircraft;
import com.yeejoin.amos.boot.module.jcs.api.enums.ExcelEnums;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import ch.qos.logback.core.subst.Token;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.ibatis.annotations.Case;
import org.apache.poi.ss.usermodel.Cell;
......@@ -38,6 +48,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -60,1083 +71,1069 @@ import java.util.concurrent.atomic.AtomicInteger;
@Service
public class ExcelServiceImpl {
private static final String NOT_DUTY = "休班";
private static final String PERSON = "PERSON";
private static final String MAINTENANCE_PERSON = "maintenancePerson";
@Autowired
DataSourcesImpl dataSourcesImpl;
@Autowired
FireChemicalServiceImpl fireChemicalServiceImpl;
@Autowired
FireExpertsServiceImpl fireExpertsServiceImpl;
@Autowired
WaterResourceServiceImpl waterResourceServiceImpl;
@Autowired
AircraftServiceImpl aircraftServiceImpl;
@Autowired
FireTeamServiceImpl fireTeamService;
@Autowired
FireStationServiceImpl fireStationService;
@Autowired
FirefightersServiceImpl firefightersService;
@Autowired
IMaintenanceCompanyService maintenanceCompanyService;
@Autowired
IKeySiteService keySiteService;
@Autowired
DutyCarServiceImpl dutyCarService;
@Autowired
DutyPersonServiceImpl dutyPersonService;
@Autowired
Sequence sequence;
@Autowired
DynamicFormColumnServiceImpl dynamicFormColumnService;
@Autowired
DutyPersonShiftServiceImpl dutyPersonShiftService;
@Autowired
OrgUsrServiceImpl orgUsrService;
@Autowired
DutyShiftServiceImpl dutyShiftService;
@Autowired
IDutyPersonService iDutyPersonService;
@Autowired
DynamicFormColumnServiceImpl dynamicFormColumnServiceImpl;
@Autowired
LinkageUnitServiceImpl linkageUnitServiceImpl;
@Autowired
SpecialPositionStaffServiceImpl specialPositionStaffServiceImpl;
@Autowired
RescueEquipmentServiceImpl rescueEquipmentServiceImpl;
public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException {
String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), null, clz,
dataSourcesImpl, true);
}
public void commonExport(HttpServletResponse response, ExcelDto excelDto) {
switch (excelDto.getType()) {
case "WHP":
List<FireChemicalDto> data = fireChemicalServiceImpl.queryForFireChemicalList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
FireChemicalDto.class, dataSourcesImpl, false);
break;
case "XFZJ":
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
fireExpertsDtoList, FireExpertsDto.class, dataSourcesImpl, false);
break;
case "SYXX":
List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
waterResourceDtoList, WaterResourceDto.class, dataSourcesImpl, false);
break;
case "HKQ":
List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
aircraftDtoList, AircraftDto.class, dataSourcesImpl, false);
break;
case "XFDW":
List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireTeamDtoList,
FireTeamDto.class, dataSourcesImpl, false);
break;
case "WXXFZ":
List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
fireStationDtoList, FireStationDto.class, null, false);
break;
case "XFRY":
List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
firefightersExcelDtoList, FirefightersExcelDto.class, null, false);
break;
case "WBRY":
List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList =
maintenanceCompanyService.exportToMaintenancePersonExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false);
break;
case "KEYSITE":
List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
keySiteDtoList, KeySiteExcleDto.class, null, false);
break;
case "JCDWRY":
List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
orgUsrList, OrgUsrExcelDto.class, null, false);
break;
case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
LinkageUnitDtoList, LinkageUnitDto.class, null, false);
break;
default:
break;
}
}
public void commonUpload(MultipartFile multipartFile, ExcelDto excelDto) throws Exception {
switch (excelDto.getType()) {
case "WHP":
excelImportFireChemical(multipartFile);
break;
case "XFZJ":
excelImportFireExperts(multipartFile);
break;
case "SYXX":
excelImportWaterResource(multipartFile);
break;
case "HKQ":
excelImportAircraft(multipartFile);
break;
case "XFDW":
excelImportFireTeam(multipartFile);
break;
case "WXXFZ":
excelImportFireStation(multipartFile);
break;
case "XFRY":
excelImportFirefighters(multipartFile);
break;
case "CLZQ":
excelImportDutyPerson(multipartFile, "CLZQ");
break;
case "RYZB":
excelImportDutyPerson(multipartFile, "RYZB");
break;
case "WBRY":
excelImportMaintenancePerson(multipartFile);
break;
case "KEYSITE":
excelImportKeySite(multipartFile);
break;
case "JCDWRY":
excelImportOrgUsrExcelDto(multipartFile);
break;
case "LDDW":
excelImportLinkageUnitZhDto(multipartFile);
break;
// BUG 2455 相关代码 bykongfm
case "TGRY":
excelImportLinkageUnitTGRYDto(multipartFile);
break;
case "JYZB":
excelImportLinkageUnitJYZBDto(multipartFile);
break;
}
return;
}
private void excelImportLinkageUnitTGRYDto(MultipartFile multipartFile) throws Exception {
List<SpecialPositionStaffDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
SpecialPositionStaffDto.class, 1);
if(excelDtoList!=null&&excelDtoList.size()>0){
outer : for(SpecialPositionStaffDto positionStaffDto : excelDtoList) {
String code = "";
if(positionStaffDto.getPositionName()!=null){
String[] certificates = positionStaffDto.getPositionName().split("@");
positionStaffDto.setPositionName(certificates[0]);
positionStaffDto.setPositionNameCode(certificates[1]);
code = certificates[1];
} else {
continue;
}
if(positionStaffDto.getCompany()!=null){
String[] certificates = positionStaffDto.getCompany().split("@");
positionStaffDto.setCompany(certificates[0]);
positionStaffDto.setCompanyId(Long.parseLong(certificates[1]));
// 获取特岗人员已经存在的岗位 如果存在则不导入
LambdaQueryWrapper<SpecialPositionStaff> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SpecialPositionStaff::getCompanyId,Long.parseLong(certificates[1])).eq(SpecialPositionStaff::getIsDelete,false);
List<SpecialPositionStaff> tempList = specialPositionStaffServiceImpl.list(queryWrapper);
for(SpecialPositionStaff temp : tempList) {
if(temp.getPositionNameCode().equals(code)) {
continue outer; // 已经存在则不导入继续循环
}
}
} else {
continue;
}
specialPositionStaffServiceImpl.createWithModel(positionStaffDto);
}
}
}
private void excelImportLinkageUnitJYZBDto(MultipartFile multipartFile) throws Exception {
List<RescueEquipmentDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
RescueEquipmentDto.class, 1);
if(excelDtoList!=null&&excelDtoList.size()>0){
outer : for(RescueEquipmentDto rescueEquipmentDto : excelDtoList ) {
String code = "";
if(rescueEquipmentDto.getVehicleType()!=null){
String[] certificates = rescueEquipmentDto.getVehicleType().split("@");
rescueEquipmentDto.setVehicleType(certificates[0]);
rescueEquipmentDto.setVehicleTypeCode(certificates[1]);
code = certificates[1];
} else {
continue;
}
if(rescueEquipmentDto.getCompany()!=null){
String[] certificates = rescueEquipmentDto.getCompany().split("@");
rescueEquipmentDto.setCompany(certificates[0]);
rescueEquipmentDto.setCompanyId(Long.parseLong(certificates[1]));
// 获取救援装备已经存在的装备 如果存在则不导入
LambdaQueryWrapper<RescueEquipment> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueEquipment::getCompanyId,Long.parseLong(certificates[1])).eq(RescueEquipment::getIsDelete,false);
List<RescueEquipment> tempList = rescueEquipmentServiceImpl.list(queryWrapper);
for(RescueEquipment temp : tempList) {
if(temp.getVehicleTypeCode().equals(code)) {
continue outer; // 已经存在则不导入继续循环
}
}
} else {
continue ;
}
rescueEquipmentServiceImpl.createWithModel(rescueEquipmentDto);
}
}
}
private void excelImportLinkageUnitZhDto(MultipartFile multipartFile) throws Exception {
List<LinkageUnitDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
LinkageUnitDto.class, 1);
if(excelDtoList!=null&&excelDtoList.size()>0){
excelDtoList.forEach(linkageUnitDto->{
if(linkageUnitDto.getLinkageUnitType()!=null){
String[] certificates = linkageUnitDto.getLinkageUnitType().split("@");
linkageUnitDto.setLinkageUnitType(certificates[0]);
linkageUnitDto.setLinkageUnitTypeCode(certificates[1]);
}
if(linkageUnitDto.getEmergencyLinkageUnit()!=null){
String[] certificates = linkageUnitDto.getEmergencyLinkageUnit().split("@");
linkageUnitDto.setEmergencyLinkageUnit(certificates[0]);
linkageUnitDto.setEmergencyLinkageUnitCode(certificates[1]);
}
linkageUnitServiceImpl.saveLinkageModel(linkageUnitDto);
});
}
}
private void excelImportOrgUsrExcelDto(MultipartFile multipartFile) throws Exception {
List<OrgUsrExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
OrgUsrExcelDto.class, 1);
if(excelDtoList!=null&&excelDtoList.size()>0){
excelDtoList.forEach(orgUsrExcelDto->{
if(orgUsrExcelDto.getParentId()!=null){
String[] certificates = orgUsrExcelDto.getParentId().split("@");
orgUsrExcelDto.setParentId(certificates[1]);
}
// 动态字段填充
List<DynamicFormInitDto> dynamicFormColumn = dynamicFormColumnServiceImpl.getFormlist("246");
List<DynamicFormInstanceDto> dynamicFormValue =new ArrayList<>();
List<DynamicFormInstance> dynamicFormInstancelist =new ArrayList<>();
dynamicFormColumn.forEach(DynamicFormInitDto->{
dynamicFormValue.add(DynamicFormInitDto.getFormItemDescr());
});
dynamicFormValue.forEach(dynamicFormInstanceDto->{
switch (dynamicFormInstanceDto.getFieldCode()) {
case "administrativePositionCode":
if(orgUsrExcelDto.getAdministrativePositionCode()!=null){
String[] certificates = orgUsrExcelDto.getAdministrativePositionCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "auditCycle":
if(orgUsrExcelDto.getAuditCycle()!=null){
String[] certificates = orgUsrExcelDto.getAuditCycle().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "certificatesNumber":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getCertificatesNumber());
break;
case "certificatesTypeCode":
if(orgUsrExcelDto.getCertificatesTypeCode()!=null){
String[] certificates = orgUsrExcelDto.getCertificatesTypeCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "certificateType":
if(orgUsrExcelDto.getCertificateType()!=null){
String[] certificates = orgUsrExcelDto.getCertificateType().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
case "fireManagementPostCode":
if(orgUsrExcelDto.getFireManagementPostCode()!=null){
String[] certificates = orgUsrExcelDto.getFireManagementPostCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "gender":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getGender());
break;
case "internalPositionCode":
if(orgUsrExcelDto.getInternalPositionCode()!=null){
String[] certificates = orgUsrExcelDto.getInternalPositionCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "personNumber":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getPersonNumber());
break;
case "positionType":
if(orgUsrExcelDto.getPositionType()!=null){
String[] certificates = orgUsrExcelDto.getPositionType().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "safetyTraining":
if(orgUsrExcelDto.getSafetyTraining()!=null){
String[] certificates = orgUsrExcelDto.getSafetyTraining().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "stateCode":
if(orgUsrExcelDto.getStateCode()!=null){
String[] certificates = orgUsrExcelDto.getStateCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "telephone":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getTelephone());
break;
}
DynamicFormInstance dynamicFormInstance=new DynamicFormInstance();
BeanUtils.copyProperties(dynamicFormInstanceDto, dynamicFormInstance);
dynamicFormInstancelist.add(dynamicFormInstance);
});
orgUsrExcelDto.setDynamicFormValue(dynamicFormInstancelist);
try {
orgUsrService.saveOrgPersonExcel(orgUsrExcelDto);
} catch (Exception e) {
throw new RuntimeException("导入失败!");
}
});
}
}
private void excelImportFirefighters(MultipartFile multipartFile) throws Exception {
List<FirefightersExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
FirefightersExcelDto.class, 1);
excelDtoList.forEach(
item -> {
Firefighters firefighters = new Firefighters();
FirefightersContacts firefightersContacts = new FirefightersContacts();
firefighters = Bean.toPo(item, firefighters);
firefightersContacts = Bean.toPo(item, firefightersContacts);
if (item.getFireTeam() != null) {
Long fireTeamId = Long.valueOf(item.getFireTeam().split("@")[1]);
firefighters.setFireTeamId(fireTeamId);
}
if (firefighters.getCertificatesType() != null) {
String[] certificates = firefighters.getCertificatesType().split("@");
firefighters.setCertificatesType(certificates[0]);
firefighters.setCertificatesTypeCode(certificates[1]);
}
if (firefighters.getState() != null) {
String[] state = firefighters.getState().split("@");
firefighters.setState(state[0]);
firefighters.setStateCode(state[1]);
}
if (firefighters.getJobTitle() != null) {
String[] jobTitle = firefighters.getJobTitle().split("@");
firefighters.setJobTitle(jobTitle[0]);
firefighters.setJobTitleCode(jobTitle[1]);
}
if (firefightersContacts.getRelationship() != null) {
String relationship = firefightersContacts.getRelationship().split("@")[1];
firefightersContacts.setRelationship(relationship);
}
if(firefighters.getCompanyName() != null) {
String[] tempCompany = firefighters.getCompanyName().split("@");
firefighters.setCompanyName(tempCompany[0]);
firefighters.setCompany(tempCompany[1]);
}
if(firefighters.getNativePlaceValue() != null) {
String[] tempCity = firefighters.getNativePlaceValue().split("@");
firefighters.setNativePlaceValue(tempCity[0]);
firefighters.setNativePlace(tempCity[1]);
}
if(firefighters.getResidence() != null) {
String[] tempCity = firefighters.getResidence().split("@");
firefighters.setResidence(tempCity[0]);
firefighters.setResidenceDetails(tempCity[1]);
}
// BUG 2760 修改消防人员导出模板和 导入问题 bykongfm
FirefightersInfoDto firefightersInfo = new FirefightersInfoDto(firefighters, firefightersContacts);
firefightersService.saveFirefighters(firefightersInfo);
}
);
}
private void excelImportFireStation(MultipartFile multipartFile) throws Exception {
List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1);
List<FireStation> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
FireStation fireStation = new FireStation();
fireStation = Bean.toPo(item, fireStation);
if (fireStation.getWhereBuilding() != null) {
String[] whereBuilding = fireStation.getWhereBuilding().split("@");
fireStation.setWhereBuilding(whereBuilding[0]);
fireStation.setWhereBuildingId(whereBuilding[1]);
}
if (fireStation.getBizCompany() != null) {
String[] bizCompany = fireStation.getBizCompany().split("@");
fireStation.setBizCompany(bizCompany[0]);
fireStation.setBizCompanyId(Long.valueOf(bizCompany[1]));
fireStation.setBizCompanyCode(bizCompany[2]);
}
excelEntityList.add(fireStation);
}
);
fireStationService.saveBatch(excelEntityList);
}
private void excelImportFireTeam(MultipartFile multipartFile) throws Exception {
List<FireTeamDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireTeamDto.class, 1);
List<FireTeam> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
FireTeam fireTeam = new FireTeam();
fireTeam = Bean.toPo(item, fireTeam);
if (fireTeam.getType() != null) {
String[] type = fireTeam.getType().split("@");
fireTeam.setType(type[0]);
fireTeam.setTypeCode(type[1]);
}
if (fireTeam.getContactUser() != null) {
String[] contactUser = fireTeam.getContactUser().split("@");
fireTeam.setContactUser(contactUser[0]);
fireTeam.setContactUserId(Long.valueOf(contactUser[1]));
}
if (item.getParentName() != null) {
String[] parentName = item.getParentName().split("@");
fireTeam.setParent(Long.valueOf(parentName[1]));
}
excelEntityList.add(fireTeam);
}
);
fireTeamService.saveBatch(excelEntityList);
}
private void excelImportAircraft(MultipartFile multipartFile) throws Exception {
List<AircraftDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, AircraftDto.class, 1);
List<Aircraft> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
Aircraft aircraft = new Aircraft();
aircraft = Bean.toPo(item, aircraft);
if (aircraft.getEngineType() != null) {
String[] engineType = aircraft.getEngineType().split("@");
aircraft.setEngineType(engineType[0]);
aircraft.setEngineTypeCode(engineType[1]);
}
if (aircraft.getFuelType() != null) {
String[] fuelType = aircraft.getFuelType().split("@");
aircraft.setFuelType(fuelType[0]);
aircraft.setFuelTypeCode(fuelType[1]);
}
excelEntityList.add(aircraft);
}
);
aircraftServiceImpl.saveBatch(excelEntityList);
}
private void excelImportFireChemical(MultipartFile multipartFile) throws Exception {
List<FireChemicalDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireChemicalDto.class, 1);
List<FireChemical> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
item -> {
FireChemical fireChemical = new FireChemical();
fireChemical = Bean.toPo(item, fireChemical);
if (fireChemical.getType() != null) {
String[] type = fireChemical.getType().split("@");
fireChemical.setType(type[0]);
fireChemical.setTypeCode(type[1]);
}
excelEntityList.add(fireChemical);
}
);
fireChemicalServiceImpl.saveBatch(excelEntityList);
}
private void excelImportWaterResource(MultipartFile multipartFile) throws Exception {
List<WaterResourceDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
WaterResourceDto.class, 1);
excelDtoList.forEach(
item -> {
if (item.getResourceTypeName() != null) {
String[] resourceTypeName = item.getResourceTypeName().split("@");
item.setResourceTypeName(resourceTypeName[0]);
item.setResourceType(resourceTypeName[1]);
}
if (item.getSystemType() != null) {
String[] systemType = item.getSystemType().split("@");
item.setSystemType(systemType[0]);
item.setSystemTypeCode(systemType[1]);
}
if (item.getPlaceForm() != null) {
String[] placeForm = item.getPlaceForm().split("@");
item.setPlaceForm(placeForm[0]);
item.setPlaceFormCode(placeForm[1]);
}
if (item.getBelongBuilding() != null) {
String[] belongBuilding = item.getBelongBuilding().split("@");
item.setBelongBuilding(belongBuilding[0]);
item.setBelongBuildingId(Long.valueOf(belongBuilding[1]));
}
if (item.getBelongFightingSystem() != null) {
String[] belongFightingSystem = item.getBelongFightingSystem().split("@");
item.setBelongFightingSystem(belongFightingSystem[0]);
item.setBelongFightingSystemId(Long.valueOf(belongFightingSystem[1]));
}
if (item.getManagementUnit() != null) {
String[] managementUnit = item.getManagementUnit().split("@");
item.setManagementUnit(managementUnit[0]);
item.setManagementUnitId(Long.valueOf(managementUnit[1]));
}
if (item.getMaintenanceUnit() != null) {
String[] maintenanceUnit = item.getMaintenanceUnit().split("@");
item.setMaintenanceUnit(maintenanceUnit[0]);
item.setMaintenanceUnitId(Long.valueOf(maintenanceUnit[1]));
}
if (item.getHoseConnection() != null) {
String[] hoseConnection = item.getHoseConnection().split("@");
item.setHoseConnection(hoseConnection[0]);
item.setHoseConnectionCode(hoseConnection[1]);
}
if (item.getIntakeForm() != null) {
String[] intakeForm = item.getIntakeForm().split("@");
item.setIntakeForm(intakeForm[0]);
}
if (item.getPipeTypeName() != null) {
String[] pipeTypeName = item.getPipeTypeName().split("@");
item.setPipeTypeName(pipeTypeName[0]);
item.setPipeTypeCode(pipeTypeName[1]);
}
if (item.getStatus() != null) {
String[] status = item.getStatus().split("@");
item.setStatus(status[0]);
item.setStatusCode(status[1]);
}
if (item.getType() != null) {
String[] type = item.getType().split("@");
item.setType(type[0]);
item.setTypeCode(type[1]);
}
waterResourceServiceImpl.importByExcel(item);
}
);
}
private void excelImportFireExperts(MultipartFile multipartFile) throws Exception {
List<FireExpertsDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
FireExpertsDto.class, 1);
List<FireExperts> excelEntityList = new ArrayList<>();
excelDtoList.forEach(
fireExpertsDto -> {
FireExperts fireExperts = new FireExperts();
fireExperts = Bean.toPo(fireExpertsDto, fireExperts);
if (fireExperts.getCertificatesType() != null) {
String[] certificates = fireExperts.getCertificatesType().split("@");
fireExperts.setCertificatesType(certificates[0]);
fireExperts.setCertificatesTypeCode(certificates[1]);
}
if (fireExperts.getJobs() != null) {
String[] jobs = fireExperts.getJobs().split("@");
fireExperts.setJobs(jobs[0]);
fireExperts.setJobsCode(jobs[1]);
}
if (fireExperts.getExpert() != null) {
String[] expert = fireExperts.getExpert().split("@");
fireExperts.setExpert(expert[0]);
fireExperts.setExpertCode(expert[1]);
}
if (fireExperts.getHighestEducation() != null) {
String[] highestEducation = fireExperts.getHighestEducation().split("@");
fireExperts.setHighestEducation(highestEducation[0]);
}
excelEntityList.add(fireExperts);
}
);
fireExpertsServiceImpl.saveBatch(excelEntityList);
}
private void excelImportDutyPerson(MultipartFile multipartFile, String dutyType) 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();
XSSFWorkbook workbook = new XSSFWorkbook(input);
XSSFSheet sheet = workbook.getSheetAt(0);
List<Map<String, Object>> dataList = new ArrayList<>();
if (sheet != null) {
//获取表头月份
Row titleRow = sheet.getRow(0);
Cell monthCell = titleRow.getCell(5);
String dateStr = monthCell == null ? "" : monthCell.toString();
List<Date> dayByMonth = DateUtils.getDayByMonth(dateStr);
if (ExcelEnums.CLZQ.getType().equals(dutyType)) {
initDutyCarData(sheet, dataList, dayByMonth);
dutyCarService.saveImportData(dataList);
} else if (ExcelEnums.RYZB.getType().equals(dutyType)) {
initDutyPersonData(sheet, dataList, dayByMonth);
dutyPersonService.saveImportData(dataList);
}
}
}
private void initDutyCarData(XSSFSheet 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 = 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[] userName = cell.toString().split("@");
dutyCarDto.setUserName(userName[0]);
dutyCarDto.setUserId(userName[1]);
cell = row.getCell(3);
if (cell != null) {
String[] postType = cell.toString().split("@");
dutyCarDto.setPostTypeName(postType[0]);
dutyCarDto.setPostType(postType[1]);
}
cell = row.getCell(4);
if (cell != null) {
String[] carName = cell.toString().split("@");
dutyCarDto.setCarName(carName[0]);
dutyCarDto.setCarId(carName[1]);
}
List<DutyPersonShiftDto> dutyShift = dutyCarDto.getDutyShift();
for (int j = 0; j < dayByMonth.size(); j++) {
cell = row.getCell(5 + 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 initDutyPersonData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
//遍历行,i = 1,从第二行开始,第一行是表头跳过。
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
DutyPersonDto dutyPersonDto = new DutyPersonDto();
//row是一行数据,row.getCell(i),代表拿到这一行,第i列数据
Row row = sheet.getRow(i);
if (row == null) {
continue;
}
Cell cell = row.getCell(1);
if (cell != null) {
dutyPersonDto.setUserId(cell.toString());
cell = row.getCell(2);
if (cell != null) {
dutyPersonDto.setUserName(cell.toString());
}
cell = row.getCell(3);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyPersonDto.setDeptName(split[0]);
dutyPersonDto.setDeptId(split[1]);
}
cell = row.getCell(4);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyPersonDto.setPostTypeName(split[0]);
dutyPersonDto.setPostType(split[1]);
}
List<DutyPersonShiftDto> dutyShift = new ArrayList<>();
for (int j = 0; j < dayByMonth.size(); j++) {
cell = row.getCell(5 + 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);
}
}
dutyPersonDto.setDutyShift(dutyShift);
Map<String, Object> dutyPersonDtoMap = Bean.BeantoMap(dutyPersonDto);
dataList.add(dutyPersonDtoMap);
}
}
}
private void excelImportMaintenancePerson(MultipartFile multipartFile) throws Exception {
List<MaintenancePersonExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
MaintenancePersonExcleDto.class, 1);
List<DynamicFormColumn> columns =
dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, MAINTENANCE_PERSON));
List<MaintenanceCompany> maintenanceCompanyList = new ArrayList<MaintenanceCompany>();
List<DynamicFormInstance> dynamicFormInstanceList = new ArrayList<DynamicFormInstance>();
for (MaintenancePersonExcleDto maintenancePersonExcleDto : excelDtoList) {
Long instanceId = sequence.nextId();
// 先填充主表的属性
MaintenanceCompany maintenanceCompany = new MaintenanceCompany();
maintenanceCompany = Bean.toPo(maintenancePersonExcleDto, maintenanceCompany);
maintenanceCompany.setType(PERSON);
if (maintenanceCompany.getParentId() != null) {
long getParentId = Long.valueOf(maintenancePersonExcleDto.getParentName().split("@")[1]);
maintenanceCompany.setParentId(getParentId);
}
if (maintenanceCompanyService.checkPersonCodeExists(maintenancePersonExcleDto.getCode())) {
maintenanceCompany.setBizCode(maintenancePersonExcleDto.getCode());
} else {
maintenanceCompany.setCode(null);
}
maintenanceCompany.setOrgCode(null);
maintenanceCompany.setBizCode(sequence.nextId() + "");
maintenanceCompany.setInstanceId(instanceId);
maintenanceCompanyList.add(maintenanceCompany);
maintenanceCompanyService.maintenancePersonExcleDtoToDynamicFormInstanceList(columns,
maintenancePersonExcleDto, instanceId, dynamicFormInstanceList);
}
maintenanceCompanyService.saveMaintenanceCompanyBatch(maintenanceCompanyList, dynamicFormInstanceList);
}
private void excelImportKeySite(MultipartFile multipartFile) throws Exception {
List<KeySiteExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
KeySiteExcleDto.class, 1);
keySiteService.saveExcel(excelDtoList);
}
public void dutyTemplateExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto,
String ids) {
List<List<Object>> data = new ArrayList<>();
if (ExcelEnums.CLZQ.getType().equals(excelDto.getType())) {
data = initDutyCarTemplate(ids);
} else if (ExcelEnums.RYZB.getType().equals(excelDto.getType())) {
data = initDutyPersonTemplate(ids);
}
// 获取日期
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate,
endDate);
List<String> dayByMonth = new ArrayList<>();
rangeDate.forEach(item -> dayByMonth.add((String) item.get("date")));
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, true);
}
public void dutyInfoExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto) throws ParseException {
// 获取日期
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate,
endDate);
List<String> dayByMonth = new ArrayList<>();
rangeDate.forEach(item -> dayByMonth.add((String) item.get("date")));
List<List<Object>> data = new ArrayList<>();
if (ExcelEnums.CLZQ.getType().equals(excelDto.getType())) {
data = initDutyCarInfo(beginDate, endDate, dayByMonth);
} else if (ExcelEnums.RYZB.getType().equals(excelDto.getType())) {
data = initDutyPersonInfo(beginDate, endDate, dayByMonth);
}
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, false);
}
private List<List<Object>> initDutyCarTemplate(String teamIds) {
List<List<Object>> data = new ArrayList<>();
// 根据id列表获取队伍下的人
List<String> teamIdList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(teamIds)) {
teamIdList = Lists.newArrayList(teamIds.split(","));
}
List<FirefightersDto> firefightersDtoList = fireTeamService.getFighterByTeamId(teamIdList);
if (!firefightersDtoList.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
firefightersDtoList.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getFireTeamName() + "@" + o.getFireTeamId());
list.add(o.getName() + "@" + o.getSequenceNbr());
list.add(o.getJobTitle() + "@" + o.getJobTitleCode());
data.add(list);
});
}
return data;
}
private List<List<Object>> initDutyPersonTemplate(String ids) {
List<List<Object>> data = new ArrayList<>();
// 根据id列表获取部门下的人
List<Long> idList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(ids)) {
String[] strings = ids.split(",");
Long[] convert = (Long[]) ConvertUtils.convert(strings, Long.class);
idList = Arrays.asList(convert);
}
try {
List<CompanyPerson> companyPeople = orgUsrService.returnCompanyPerson(idList);
if (!companyPeople.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
companyPeople.forEach(item -> {
List<OrgUsrDto> persons = item.getPersons();
if (persons != null && !persons.isEmpty()) {
persons.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getSequenceNbr().toString());
list.add(o.getBizOrgName());
list.add(item.getBizOrgName() + "@" + item.getSequenceNbr());
data.add(list);
});
}
});
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
return data;
}
private void exportDutyTemplate(HttpServletResponse response, String classUrl, List<String> dayByMonth,
ExcelDto excelDto, List<? extends Object> data, Boolean flag) {
try {
// 获取排班类型
String[] dutyNameList = getDutyNameList();
Class<?> clz = Class.forName(classUrl);
ExcelUtil.createDutyTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
clz, dayByMonth, dutyNameList, dataSourcesImpl, flag);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
private String[] getDutyNameList() {
List<String> dutyShiftList = new ArrayList<>();
List<DutyShiftDto> dutyShiftDtoList = dutyShiftService.queryForDutyShiftList(null, false);
dutyShiftDtoList.forEach(item -> dutyShiftList.add(item.getName() + "@" + item.getSequenceNbr()));
return dutyShiftList.toArray(new String[dutyShiftList.size()]);
}
private List<List<Object>> initDutyCarInfo(String beginDate, String endDate, List<String> dayByMonth) throws ParseException {
// 查询已值班数据
List<DutyCarDto> contentList = dutyCarService.downloadList(beginDate, endDate);
List<List<Object>> data = new ArrayList<>();
// 组装导出数据
if (!contentList.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
contentList.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getTeamName());
list.add(o.getUserName());
list.add(o.getPostTypeName());
list.add(o.getCarName());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, list);
data.add(list);
});
}
return data;
}
private void initDutyShift(List<String> dayByMonth, List<DutyPersonShiftDto> dutyShift, ArrayList<Object> list) {
HashMap<String, String> dutyShiftMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
dutyShift.forEach(item -> dutyShiftMap.put(format.format(item.getDutyDate()), item.getShiftName()));
for (int i = 0; i < dayByMonth.size(); i++) {
if (dutyShiftMap.containsKey(dayByMonth.get(i))) {
list.add(dutyShiftMap.get(dayByMonth.get(i)));
} else {
list.add(NOT_DUTY);
}
}
}
private List<List<Object>> initDutyPersonInfo(String beginDate, String endDate, List<String> dayByMonth) throws ParseException {
// 查询已值班数据
List<DutyPersonDto> contentList = iDutyPersonService.downloadList(beginDate, endDate);
List<List<Object>> data = new ArrayList<>();
// 组装导出数据
if (!contentList.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
contentList.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getUserId());
list.add(o.getUserName());
list.add(o.getDeptName());
list.add(o.getPostTypeName());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, list);
data.add(list);
});
}
return data;
}
public void exportByParams(HttpServletResponse response, ExcelDto excelDto, String params) {
switch (excelDto.getType()) {
case "WHP":
List<FireChemicalDto> data = fireChemicalServiceImpl.queryForFireChemicalList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
FireChemicalDto.class, dataSourcesImpl, false);
break;
case "XFZJ":
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
fireExpertsDtoList, FireExpertsDto.class, dataSourcesImpl, false);
break;
case "SYXX":
List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
waterResourceDtoList, WaterResourceDto.class, dataSourcesImpl, false);
break;
case "HKQ":
List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
aircraftDtoList, AircraftDto.class, dataSourcesImpl, false);
break;
case "XFDW":
List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireTeamDtoList,
FireTeamDto.class, dataSourcesImpl, false);
break;
case "WXXFZ":
List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
fireStationDtoList, FireStationDto.class, null, false);
break;
case "XFRY":
List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
firefightersExcelDtoList, FirefightersExcelDto.class, null, false);
break;
case "WBRY":
List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList =
maintenanceCompanyService.exportToMaintenancePersonExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false);
break;
case "KEYSITE":
List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
keySiteDtoList, KeySiteExcleDto.class, null, false);
break;
case "JCDWRY":
// 机场单位人员参数传递为 parentId = xxxxxxx
String parentIdStr = params.split("=")[1];
Long parentId = -1l;
try {
parentId = Long.parseLong(parentIdStr);
} catch (NumberFormatException e) {
throw new BadRequest("导出机场单位时未传递正确parentId");
}
List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportPersonToExcelByParentId(parentId);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
orgUsrList, OrgUsrExcelDto.class, null, false);
break;
case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
LinkageUnitDtoList, LinkageUnitDto.class, null, false);
break;
default:
break;
}
}
private static final String NOT_DUTY = "休班";
private static final String PERSON = "PERSON";
private static final String MAINTENANCE_PERSON = "maintenancePerson";
@Autowired
private RedisUtils redisUtils;
@Autowired
DataSourcesImpl dataSourcesImpl;
@Autowired
FireChemicalServiceImpl fireChemicalServiceImpl;
@Autowired
FireExpertsServiceImpl fireExpertsServiceImpl;
@Autowired
WaterResourceServiceImpl waterResourceServiceImpl;
@Autowired
AircraftServiceImpl aircraftServiceImpl;
@Autowired
FireTeamServiceImpl fireTeamService;
@Autowired
FireStationServiceImpl fireStationService;
@Autowired
FirefightersServiceImpl firefightersService;
@Autowired
IMaintenanceCompanyService maintenanceCompanyService;
@Autowired
IKeySiteService keySiteService;
@Autowired
DutyCarServiceImpl dutyCarService;
@Autowired
DutyPersonServiceImpl dutyPersonService;
@Autowired
Sequence sequence;
@Autowired
DynamicFormColumnServiceImpl dynamicFormColumnService;
@Autowired
DutyPersonShiftServiceImpl dutyPersonShiftService;
@Autowired
OrgUsrServiceImpl orgUsrService;
@Autowired
DutyShiftServiceImpl dutyShiftService;
@Autowired
IDutyPersonService iDutyPersonService;
@Autowired
DynamicFormColumnServiceImpl dynamicFormColumnServiceImpl;
@Autowired
LinkageUnitServiceImpl linkageUnitServiceImpl;
@Autowired
SpecialPositionStaffServiceImpl specialPositionStaffServiceImpl;
@Autowired
RescueEquipmentServiceImpl rescueEquipmentServiceImpl;
public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException {
String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), null, clz, dataSourcesImpl,
true);
}
public void commonExport(HttpServletResponse response, ExcelDto excelDto) {
switch (excelDto.getType()) {
case "WHP":
List<FireChemicalDto> data = fireChemicalServiceImpl.queryForFireChemicalList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
FireChemicalDto.class, dataSourcesImpl, false);
break;
case "XFZJ":
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireExpertsDtoList,
FireExpertsDto.class, dataSourcesImpl, false);
break;
case "SYXX":
List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), waterResourceDtoList,
WaterResourceDto.class, dataSourcesImpl, false);
break;
case "HKQ":
List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), aircraftDtoList,
AircraftDto.class, dataSourcesImpl, false);
break;
case "XFDW":
List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireTeamDtoList,
FireTeamDto.class, dataSourcesImpl, false);
break;
case "WXXFZ":
List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireStationDtoList,
FireStationDto.class, null, false);
break;
case "XFRY":
List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
firefightersExcelDtoList, FirefightersExcelDto.class, null, false);
break;
case "WBRY":
List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList = maintenanceCompanyService
.exportToMaintenancePersonExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false);
break;
case "KEYSITE":
List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), keySiteDtoList,
KeySiteExcleDto.class, null, false);
break;
case "JCDWRY":
List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), orgUsrList,
OrgUsrExcelDto.class, null, false);
break;
case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), LinkageUnitDtoList,
LinkageUnitDto.class, null, false);
break;
default:
break;
}
}
public void commonUpload(MultipartFile multipartFile, ExcelDto excelDto) throws Exception {
switch (excelDto.getType()) {
case "WHP":
excelImportFireChemical(multipartFile);
break;
case "XFZJ":
excelImportFireExperts(multipartFile);
break;
case "SYXX":
excelImportWaterResource(multipartFile);
break;
case "HKQ":
excelImportAircraft(multipartFile);
break;
case "XFDW":
excelImportFireTeam(multipartFile);
break;
case "WXXFZ":
excelImportFireStation(multipartFile);
break;
case "XFRY":
excelImportFirefighters(multipartFile);
break;
case "CLZQ":
excelImportDutyPerson(multipartFile, "CLZQ");
break;
case "RYZB":
excelImportDutyPerson(multipartFile, "RYZB");
break;
case "WBRY":
excelImportMaintenancePerson(multipartFile);
break;
case "KEYSITE":
excelImportKeySite(multipartFile);
break;
case "JCDWRY":
excelImportOrgUsrExcelDto(multipartFile);
break;
case "LDDW":
excelImportLinkageUnitZhDto(multipartFile);
break;
// BUG 2455 相关代码 bykongfm
case "TGRY":
excelImportLinkageUnitTGRYDto(multipartFile);
break;
case "JYZB":
excelImportLinkageUnitJYZBDto(multipartFile);
break;
}
return;
}
private void excelImportLinkageUnitTGRYDto(MultipartFile multipartFile) throws Exception {
List<SpecialPositionStaffDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
SpecialPositionStaffDto.class, 1);
if (excelDtoList != null && excelDtoList.size() > 0) {
outer: for (SpecialPositionStaffDto positionStaffDto : excelDtoList) {
String code = "";
if (positionStaffDto.getPositionName() != null) {
String[] certificates = positionStaffDto.getPositionName().split("@");
positionStaffDto.setPositionName(certificates[0]);
positionStaffDto.setPositionNameCode(certificates[1]);
code = certificates[1];
} else {
continue;
}
if (positionStaffDto.getCompany() != null) {
String[] certificates = positionStaffDto.getCompany().split("@");
positionStaffDto.setCompany(certificates[0]);
positionStaffDto.setCompanyId(Long.parseLong(certificates[1]));
// 获取特岗人员已经存在的岗位 如果存在则不导入
LambdaQueryWrapper<SpecialPositionStaff> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SpecialPositionStaff::getCompanyId, Long.parseLong(certificates[1]))
.eq(SpecialPositionStaff::getIsDelete, false);
List<SpecialPositionStaff> tempList = specialPositionStaffServiceImpl.list(queryWrapper);
for (SpecialPositionStaff temp : tempList) {
if (temp.getPositionNameCode().equals(code)) {
continue outer; // 已经存在则不导入继续循环
}
}
} else {
continue;
}
specialPositionStaffServiceImpl.createWithModel(positionStaffDto);
}
}
}
private void excelImportLinkageUnitJYZBDto(MultipartFile multipartFile) throws Exception {
List<RescueEquipmentDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, RescueEquipmentDto.class,
1);
if (excelDtoList != null && excelDtoList.size() > 0) {
outer: for (RescueEquipmentDto rescueEquipmentDto : excelDtoList) {
String code = "";
if (rescueEquipmentDto.getVehicleType() != null) {
String[] certificates = rescueEquipmentDto.getVehicleType().split("@");
rescueEquipmentDto.setVehicleType(certificates[0]);
rescueEquipmentDto.setVehicleTypeCode(certificates[1]);
code = certificates[1];
} else {
continue;
}
if (rescueEquipmentDto.getCompany() != null) {
String[] certificates = rescueEquipmentDto.getCompany().split("@");
rescueEquipmentDto.setCompany(certificates[0]);
rescueEquipmentDto.setCompanyId(Long.parseLong(certificates[1]));
// 获取救援装备已经存在的装备 如果存在则不导入
LambdaQueryWrapper<RescueEquipment> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueEquipment::getCompanyId, Long.parseLong(certificates[1]))
.eq(RescueEquipment::getIsDelete, false);
List<RescueEquipment> tempList = rescueEquipmentServiceImpl.list(queryWrapper);
for (RescueEquipment temp : tempList) {
if (temp.getVehicleTypeCode().equals(code)) {
continue outer; // 已经存在则不导入继续循环
}
}
} else {
continue;
}
rescueEquipmentServiceImpl.createWithModel(rescueEquipmentDto);
}
}
}
private void excelImportLinkageUnitZhDto(MultipartFile multipartFile) throws Exception {
List<LinkageUnitDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, LinkageUnitDto.class, 1);
if (excelDtoList != null && excelDtoList.size() > 0) {
excelDtoList.forEach(linkageUnitDto -> {
if (linkageUnitDto.getLinkageUnitType() != null) {
String[] certificates = linkageUnitDto.getLinkageUnitType().split("@");
linkageUnitDto.setLinkageUnitType(certificates[0]);
linkageUnitDto.setLinkageUnitTypeCode(certificates[1]);
}
if (linkageUnitDto.getEmergencyLinkageUnit() != null) {
String[] certificates = linkageUnitDto.getEmergencyLinkageUnit().split("@");
linkageUnitDto.setEmergencyLinkageUnit(certificates[0]);
linkageUnitDto.setEmergencyLinkageUnitCode(certificates[1]);
}
linkageUnitServiceImpl.saveLinkageModel(linkageUnitDto);
});
}
}
private void excelImportOrgUsrExcelDto(MultipartFile multipartFile) throws Exception {
List<OrgUsrExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, OrgUsrExcelDto.class, 1);
if (excelDtoList != null && excelDtoList.size() > 0) {
excelDtoList.forEach(orgUsrExcelDto -> {
if (orgUsrExcelDto.getParentId() != null) {
String[] certificates = orgUsrExcelDto.getParentId().split("@");
orgUsrExcelDto.setParentId(certificates[1]);
}
// 动态字段填充
List<DynamicFormInitDto> dynamicFormColumn = dynamicFormColumnServiceImpl.getFormlist("246");
List<DynamicFormInstanceDto> dynamicFormValue = new ArrayList<>();
List<DynamicFormInstance> dynamicFormInstancelist = new ArrayList<>();
dynamicFormColumn.forEach(DynamicFormInitDto -> {
dynamicFormValue.add(DynamicFormInitDto.getFormItemDescr());
});
dynamicFormValue.forEach(dynamicFormInstanceDto -> {
switch (dynamicFormInstanceDto.getFieldCode()) {
case "administrativePositionCode":
if (orgUsrExcelDto.getAdministrativePositionCode() != null) {
String[] certificates = orgUsrExcelDto.getAdministrativePositionCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "auditCycle":
if (orgUsrExcelDto.getAuditCycle() != null) {
String[] certificates = orgUsrExcelDto.getAuditCycle().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "certificatesNumber":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getCertificatesNumber());
break;
case "certificatesTypeCode":
if (orgUsrExcelDto.getCertificatesTypeCode() != null) {
String[] certificates = orgUsrExcelDto.getCertificatesTypeCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "certificateType":
if (orgUsrExcelDto.getCertificateType() != null) {
String[] certificates = orgUsrExcelDto.getCertificateType().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
case "fireManagementPostCode":
if (orgUsrExcelDto.getFireManagementPostCode() != null) {
String[] certificates = orgUsrExcelDto.getFireManagementPostCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "gender":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getGender());
break;
case "internalPositionCode":
if (orgUsrExcelDto.getInternalPositionCode() != null) {
String[] certificates = orgUsrExcelDto.getInternalPositionCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "personNumber":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getPersonNumber());
break;
case "positionType":
if (orgUsrExcelDto.getPositionType() != null) {
String[] certificates = orgUsrExcelDto.getPositionType().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "safetyTraining":
if (orgUsrExcelDto.getSafetyTraining() != null) {
String[] certificates = orgUsrExcelDto.getSafetyTraining().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "stateCode":
if (orgUsrExcelDto.getStateCode() != null) {
String[] certificates = orgUsrExcelDto.getStateCode().split("@");
dynamicFormInstanceDto.setFieldValue(certificates[1]);
dynamicFormInstanceDto.setFieldValueLabel(certificates[0]);
}
break;
case "telephone":
dynamicFormInstanceDto.setFieldValue(orgUsrExcelDto.getTelephone());
break;
}
DynamicFormInstance dynamicFormInstance = new DynamicFormInstance();
BeanUtils.copyProperties(dynamicFormInstanceDto, dynamicFormInstance);
dynamicFormInstancelist.add(dynamicFormInstance);
});
orgUsrExcelDto.setDynamicFormValue(dynamicFormInstancelist);
try {
orgUsrService.saveOrgPersonExcel(orgUsrExcelDto);
} catch (Exception e) {
throw new RuntimeException("导入失败!");
}
});
}
}
private void excelImportFirefighters(MultipartFile multipartFile) throws Exception {
List<FirefightersExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
FirefightersExcelDto.class, 1);
excelDtoList.forEach(item -> {
Firefighters firefighters = new Firefighters();
FirefightersContacts firefightersContacts = new FirefightersContacts();
firefighters = Bean.toPo(item, firefighters);
firefighters = Bean.toPo(getCurrentInfo(), firefighters);
firefightersContacts = Bean.toPo(item, firefightersContacts);
if (item.getFireTeam() != null) {
Long fireTeamId = Long.valueOf(item.getFireTeam().split("@")[1]);
firefighters.setFireTeamId(fireTeamId);
}
if (firefighters.getCertificatesType() != null) {
String[] certificates = firefighters.getCertificatesType().split("@");
firefighters.setCertificatesType(certificates[0]);
firefighters.setCertificatesTypeCode(certificates[1]);
}
if (firefighters.getState() != null) {
String[] state = firefighters.getState().split("@");
firefighters.setState(state[0]);
firefighters.setStateCode(state[1]);
}
if (firefighters.getJobTitle() != null) {
String[] jobTitle = firefighters.getJobTitle().split("@");
firefighters.setJobTitle(jobTitle[0]);
firefighters.setJobTitleCode(jobTitle[1]);
}
if (firefightersContacts.getRelationship() != null) {
String relationship = firefightersContacts.getRelationship().split("@")[1];
firefightersContacts.setRelationship(relationship);
}
if (firefighters.getCompanyName() != null) {
String[] tempCompany = firefighters.getCompanyName().split("@");
firefighters.setCompanyName(tempCompany[0]);
firefighters.setCompany(tempCompany[1]);
}
if (firefighters.getNativePlaceValue() != null) {
String[] tempCity = firefighters.getNativePlaceValue().split("@");
firefighters.setNativePlaceValue(tempCity[0]);
firefighters.setNativePlace(tempCity[1]);
}
if (firefighters.getResidence() != null) {
String[] tempCity = firefighters.getResidence().split("@");
firefighters.setResidence(tempCity[0]);
firefighters.setResidenceDetails(tempCity[1]);
}
// BUG 2760 修改消防人员导出模板和 导入问题 bykongfm
FirefightersInfoDto firefightersInfo = new FirefightersInfoDto(firefighters, firefightersContacts);
firefightersService.saveFirefighters(firefightersInfo);
});
}
private void excelImportFireStation(MultipartFile multipartFile) throws Exception {
List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1);
List<FireStation> excelEntityList = new ArrayList<>();
excelDtoList.forEach(item -> {
FireStation fireStation = new FireStation();
fireStation = Bean.toPo(item, fireStation);
fireStation = Bean.toPo(getCurrentInfo(), fireStation);
if (fireStation.getWhereBuilding() != null) {
String[] whereBuilding = fireStation.getWhereBuilding().split("@");
fireStation.setWhereBuilding(whereBuilding[0]);
fireStation.setWhereBuildingId(whereBuilding[1]);
}
if (fireStation.getBizCompany() != null) {
String[] bizCompany = fireStation.getBizCompany().split("@");
fireStation.setBizCompany(bizCompany[0]);
fireStation.setBizCompanyId(Long.valueOf(bizCompany[1]));
fireStation.setBizCompanyCode(bizCompany[2]);
}
excelEntityList.add(fireStation);
});
fireStationService.saveBatch(excelEntityList);
}
private void excelImportFireTeam(MultipartFile multipartFile) throws Exception {
List<FireTeamDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireTeamDto.class, 1);
List<FireTeam> excelEntityList = new ArrayList<>();
excelDtoList.forEach(item -> {
FireTeam fireTeam = new FireTeam();
fireTeam = Bean.toPo(item, fireTeam);
fireTeam = Bean.toPo(getCurrentInfo(), fireTeam);
if (fireTeam.getType() != null) {
String[] type = fireTeam.getType().split("@");
fireTeam.setType(type[0]);
fireTeam.setTypeCode(type[1]);
}
if (fireTeam.getContactUser() != null) {
String[] contactUser = fireTeam.getContactUser().split("@");
fireTeam.setContactUser(contactUser[0]);
fireTeam.setContactUserId(Long.valueOf(contactUser[1]));
}
if (item.getParentName() != null) {
String[] parentName = item.getParentName().split("@");
fireTeam.setParent(Long.valueOf(parentName[1]));
}
excelEntityList.add(fireTeam);
});
fireTeamService.saveBatch(excelEntityList);
}
private void excelImportAircraft(MultipartFile multipartFile) throws Exception {
List<AircraftDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, AircraftDto.class, 1);
List<Aircraft> excelEntityList = new ArrayList<>();
excelDtoList.forEach(item -> {
Aircraft aircraft = new Aircraft();
aircraft = Bean.toPo(item, aircraft);
aircraft = Bean.toPo(getCurrentInfo(), aircraft);
if (aircraft.getEngineType() != null) {
String[] engineType = aircraft.getEngineType().split("@");
aircraft.setEngineType(engineType[0]);
aircraft.setEngineTypeCode(engineType[1]);
}
if (aircraft.getFuelType() != null) {
String[] fuelType = aircraft.getFuelType().split("@");
aircraft.setFuelType(fuelType[0]);
aircraft.setFuelTypeCode(fuelType[1]);
}
excelEntityList.add(aircraft);
});
aircraftServiceImpl.saveBatch(excelEntityList);
}
private void excelImportFireChemical(MultipartFile multipartFile) throws Exception {
List<FireChemicalDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireChemicalDto.class, 1);
List<FireChemical> excelEntityList = new ArrayList<>();
excelDtoList.forEach(item -> {
FireChemical fireChemical = new FireChemical();
fireChemical = Bean.toPo(item, fireChemical);
fireChemical = Bean.toPo(getCurrentInfo(), fireChemical);
if (fireChemical.getType() != null) {
String[] type = fireChemical.getType().split("@");
fireChemical.setType(type[0]);
fireChemical.setTypeCode(type[1]);
}
excelEntityList.add(fireChemical);
});
fireChemicalServiceImpl.saveBatch(excelEntityList);
}
private void excelImportWaterResource(MultipartFile multipartFile) throws Exception {
List<WaterResourceDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, WaterResourceDto.class, 1);
excelDtoList.forEach(item -> {
if (item.getResourceTypeName() != null) {
String[] resourceTypeName = item.getResourceTypeName().split("@");
item.setResourceTypeName(resourceTypeName[0]);
item.setResourceType(resourceTypeName[1]);
}
if (item.getSystemType() != null) {
String[] systemType = item.getSystemType().split("@");
item.setSystemType(systemType[0]);
item.setSystemTypeCode(systemType[1]);
}
if (item.getPlaceForm() != null) {
String[] placeForm = item.getPlaceForm().split("@");
item.setPlaceForm(placeForm[0]);
item.setPlaceFormCode(placeForm[1]);
}
if (item.getBelongBuilding() != null) {
String[] belongBuilding = item.getBelongBuilding().split("@");
item.setBelongBuilding(belongBuilding[0]);
item.setBelongBuildingId(Long.valueOf(belongBuilding[1]));
}
if (item.getBelongFightingSystem() != null) {
String[] belongFightingSystem = item.getBelongFightingSystem().split("@");
item.setBelongFightingSystem(belongFightingSystem[0]);
item.setBelongFightingSystemId(Long.valueOf(belongFightingSystem[1]));
}
if (item.getManagementUnit() != null) {
String[] managementUnit = item.getManagementUnit().split("@");
item.setManagementUnit(managementUnit[0]);
item.setManagementUnitId(Long.valueOf(managementUnit[1]));
}
if (item.getMaintenanceUnit() != null) {
String[] maintenanceUnit = item.getMaintenanceUnit().split("@");
item.setMaintenanceUnit(maintenanceUnit[0]);
item.setMaintenanceUnitId(Long.valueOf(maintenanceUnit[1]));
}
if (item.getHoseConnection() != null) {
String[] hoseConnection = item.getHoseConnection().split("@");
item.setHoseConnection(hoseConnection[0]);
item.setHoseConnectionCode(hoseConnection[1]);
}
if (item.getIntakeForm() != null) {
String[] intakeForm = item.getIntakeForm().split("@");
item.setIntakeForm(intakeForm[0]);
}
if (item.getPipeTypeName() != null) {
String[] pipeTypeName = item.getPipeTypeName().split("@");
item.setPipeTypeName(pipeTypeName[0]);
item.setPipeTypeCode(pipeTypeName[1]);
}
if (item.getStatus() != null) {
String[] status = item.getStatus().split("@");
item.setStatus(status[0]);
item.setStatusCode(status[1]);
}
if (item.getType() != null) {
String[] type = item.getType().split("@");
item.setType(type[0]);
item.setTypeCode(type[1]);
}
item = Bean.toPo(getCurrentInfo(), item);
waterResourceServiceImpl.importByExcel(item);
});
}
private void excelImportFireExperts(MultipartFile multipartFile) throws Exception {
List<FireExpertsDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireExpertsDto.class, 1);
List<FireExperts> excelEntityList = new ArrayList<>();
excelDtoList.forEach(fireExpertsDto -> {
FireExperts fireExperts = new FireExperts();
fireExperts = Bean.toPo(fireExpertsDto, fireExperts);
if (fireExperts.getCertificatesType() != null) {
String[] certificates = fireExperts.getCertificatesType().split("@");
fireExperts.setCertificatesType(certificates[0]);
fireExperts.setCertificatesTypeCode(certificates[1]);
}
if (fireExperts.getJobs() != null) {
String[] jobs = fireExperts.getJobs().split("@");
fireExperts.setJobs(jobs[0]);
fireExperts.setJobsCode(jobs[1]);
}
if (fireExperts.getExpert() != null) {
String[] expert = fireExperts.getExpert().split("@");
fireExperts.setExpert(expert[0]);
fireExperts.setExpertCode(expert[1]);
}
if (fireExperts.getHighestEducation() != null) {
String[] highestEducation = fireExperts.getHighestEducation().split("@");
fireExperts.setHighestEducation(highestEducation[0]);
}
excelEntityList.add(fireExperts);
});
fireExpertsServiceImpl.saveBatch(excelEntityList);
}
private void excelImportDutyPerson(MultipartFile multipartFile, String dutyType) 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();
XSSFWorkbook workbook = new XSSFWorkbook(input);
XSSFSheet sheet = workbook.getSheetAt(0);
List<Map<String, Object>> dataList = new ArrayList<>();
if (sheet != null) {
// 获取表头月份
Row titleRow = sheet.getRow(0);
Cell monthCell = titleRow.getCell(5);
String dateStr = monthCell == null ? "" : monthCell.toString();
List<Date> dayByMonth = DateUtils.getDayByMonth(dateStr);
if (ExcelEnums.CLZQ.getType().equals(dutyType)) {
initDutyCarData(sheet, dataList, dayByMonth);
dutyCarService.saveImportData(dataList);
} else if (ExcelEnums.RYZB.getType().equals(dutyType)) {
initDutyPersonData(sheet, dataList, dayByMonth);
dutyPersonService.saveImportData(dataList);
}
}
}
private void initDutyCarData(XSSFSheet 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 = 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[] userName = cell.toString().split("@");
dutyCarDto.setUserName(userName[0]);
dutyCarDto.setUserId(userName[1]);
cell = row.getCell(3);
if (cell != null) {
String[] postType = cell.toString().split("@");
dutyCarDto.setPostTypeName(postType[0]);
dutyCarDto.setPostType(postType[1]);
}
cell = row.getCell(4);
if (cell != null) {
String[] carName = cell.toString().split("@");
dutyCarDto.setCarName(carName[0]);
dutyCarDto.setCarId(carName[1]);
}
List<DutyPersonShiftDto> dutyShift = dutyCarDto.getDutyShift();
for (int j = 0; j < dayByMonth.size(); j++) {
cell = row.getCell(5 + 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 initDutyPersonData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
// 遍历行,i = 1,从第二行开始,第一行是表头跳过。
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
DutyPersonDto dutyPersonDto = new DutyPersonDto();
// row是一行数据,row.getCell(i),代表拿到这一行,第i列数据
Row row = sheet.getRow(i);
if (row == null) {
continue;
}
Cell cell = row.getCell(1);
if (cell != null) {
dutyPersonDto.setUserId(cell.toString());
cell = row.getCell(2);
if (cell != null) {
dutyPersonDto.setUserName(cell.toString());
}
cell = row.getCell(3);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyPersonDto.setDeptName(split[0]);
dutyPersonDto.setDeptId(split[1]);
}
cell = row.getCell(4);
if (cell != null) {
String[] split = cell.toString().split("@");
dutyPersonDto.setPostTypeName(split[0]);
dutyPersonDto.setPostType(split[1]);
}
List<DutyPersonShiftDto> dutyShift = new ArrayList<>();
for (int j = 0; j < dayByMonth.size(); j++) {
cell = row.getCell(5 + 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);
}
}
dutyPersonDto.setDutyShift(dutyShift);
Map<String, Object> dutyPersonDtoMap = Bean.BeantoMap(dutyPersonDto);
dataList.add(dutyPersonDtoMap);
}
}
}
private void excelImportMaintenancePerson(MultipartFile multipartFile) throws Exception {
List<MaintenancePersonExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
MaintenancePersonExcleDto.class, 1);
List<DynamicFormColumn> columns = dynamicFormColumnService.list(
new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, MAINTENANCE_PERSON));
List<MaintenanceCompany> maintenanceCompanyList = new ArrayList<MaintenanceCompany>();
List<DynamicFormInstance> dynamicFormInstanceList = new ArrayList<DynamicFormInstance>();
for (MaintenancePersonExcleDto maintenancePersonExcleDto : excelDtoList) {
Long instanceId = sequence.nextId();
// 先填充主表的属性
MaintenanceCompany maintenanceCompany = new MaintenanceCompany();
maintenanceCompany = Bean.toPo(maintenancePersonExcleDto, maintenanceCompany);
maintenanceCompany.setType(PERSON);
if (maintenanceCompany.getParentId() != null) {
long getParentId = Long.valueOf(maintenancePersonExcleDto.getParentName().split("@")[1]);
maintenanceCompany.setParentId(getParentId);
}
if (maintenanceCompanyService.checkPersonCodeExists(maintenancePersonExcleDto.getCode())) {
maintenanceCompany.setBizCode(maintenancePersonExcleDto.getCode());
} else {
maintenanceCompany.setCode(null);
}
maintenanceCompany.setOrgCode(null);
maintenanceCompany.setBizCode(sequence.nextId() + "");
maintenanceCompany.setInstanceId(instanceId);
maintenanceCompanyList.add(maintenanceCompany);
maintenanceCompanyService.maintenancePersonExcleDtoToDynamicFormInstanceList(columns,
maintenancePersonExcleDto, instanceId, dynamicFormInstanceList);
}
maintenanceCompanyService.saveMaintenanceCompanyBatch(maintenanceCompanyList, dynamicFormInstanceList);
}
private void excelImportKeySite(MultipartFile multipartFile) throws Exception {
List<KeySiteExcleDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, KeySiteExcleDto.class, 1);
keySiteService.saveExcel(excelDtoList);
}
public void dutyTemplateExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto,
String ids) {
List<List<Object>> data = new ArrayList<>();
if (ExcelEnums.CLZQ.getType().equals(excelDto.getType())) {
data = initDutyCarTemplate(ids);
} else if (ExcelEnums.RYZB.getType().equals(excelDto.getType())) {
data = initDutyPersonTemplate(ids);
}
// 获取日期
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, endDate);
List<String> dayByMonth = new ArrayList<>();
rangeDate.forEach(item -> dayByMonth.add((String) item.get("date")));
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, true);
}
public void dutyInfoExport(HttpServletResponse response, String beginDate, String endDate, ExcelDto excelDto)
throws ParseException {
// 获取日期
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, endDate);
List<String> dayByMonth = new ArrayList<>();
rangeDate.forEach(item -> dayByMonth.add((String) item.get("date")));
List<List<Object>> data = new ArrayList<>();
if (ExcelEnums.CLZQ.getType().equals(excelDto.getType())) {
data = initDutyCarInfo(beginDate, endDate, dayByMonth);
} else if (ExcelEnums.RYZB.getType().equals(excelDto.getType())) {
data = initDutyPersonInfo(beginDate, endDate, dayByMonth);
}
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, false);
}
private List<List<Object>> initDutyCarTemplate(String teamIds) {
List<List<Object>> data = new ArrayList<>();
// 根据id列表获取队伍下的人
List<String> teamIdList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(teamIds)) {
teamIdList = Lists.newArrayList(teamIds.split(","));
}
List<FirefightersDto> firefightersDtoList = fireTeamService.getFighterByTeamId(teamIdList);
if (!firefightersDtoList.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
firefightersDtoList.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getFireTeamName() + "@" + o.getFireTeamId());
list.add(o.getName() + "@" + o.getSequenceNbr());
list.add(o.getJobTitle() + "@" + o.getJobTitleCode());
data.add(list);
});
}
return data;
}
private List<List<Object>> initDutyPersonTemplate(String ids) {
List<List<Object>> data = new ArrayList<>();
// 根据id列表获取部门下的人
List<Long> idList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(ids)) {
String[] strings = ids.split(",");
Long[] convert = (Long[]) ConvertUtils.convert(strings, Long.class);
idList = Arrays.asList(convert);
}
try {
List<CompanyPerson> companyPeople = orgUsrService.returnCompanyPerson(idList);
if (!companyPeople.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
companyPeople.forEach(item -> {
List<OrgUsrDto> persons = item.getPersons();
if (persons != null && !persons.isEmpty()) {
persons.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getSequenceNbr().toString());
list.add(o.getBizOrgName());
list.add(item.getBizOrgName() + "@" + item.getSequenceNbr());
data.add(list);
});
}
});
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
return data;
}
private void exportDutyTemplate(HttpServletResponse response, String classUrl, List<String> dayByMonth,
ExcelDto excelDto, List<? extends Object> data, Boolean flag) {
try {
// 获取排班类型
String[] dutyNameList = getDutyNameList();
Class<?> clz = Class.forName(classUrl);
ExcelUtil.createDutyTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data, clz,
dayByMonth, dutyNameList, dataSourcesImpl, flag);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
private String[] getDutyNameList() {
List<String> dutyShiftList = new ArrayList<>();
List<DutyShiftDto> dutyShiftDtoList = dutyShiftService.queryForDutyShiftList(null, false);
dutyShiftDtoList.forEach(item -> dutyShiftList.add(item.getName() + "@" + item.getSequenceNbr()));
return dutyShiftList.toArray(new String[dutyShiftList.size()]);
}
private List<List<Object>> initDutyCarInfo(String beginDate, String endDate, List<String> dayByMonth)
throws ParseException {
// 查询已值班数据
List<DutyCarDto> contentList = dutyCarService.downloadList(beginDate, endDate);
List<List<Object>> data = new ArrayList<>();
// 组装导出数据
if (!contentList.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
contentList.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getTeamName());
list.add(o.getUserName());
list.add(o.getPostTypeName());
list.add(o.getCarName());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, list);
data.add(list);
});
}
return data;
}
private void initDutyShift(List<String> dayByMonth, List<DutyPersonShiftDto> dutyShift, ArrayList<Object> list) {
HashMap<String, String> dutyShiftMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
dutyShift.forEach(item -> dutyShiftMap.put(format.format(item.getDutyDate()), item.getShiftName()));
for (int i = 0; i < dayByMonth.size(); i++) {
if (dutyShiftMap.containsKey(dayByMonth.get(i))) {
list.add(dutyShiftMap.get(dayByMonth.get(i)));
} else {
list.add(NOT_DUTY);
}
}
}
private List<List<Object>> initDutyPersonInfo(String beginDate, String endDate, List<String> dayByMonth)
throws ParseException {
// 查询已值班数据
List<DutyPersonDto> contentList = iDutyPersonService.downloadList(beginDate, endDate);
List<List<Object>> data = new ArrayList<>();
// 组装导出数据
if (!contentList.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
contentList.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(o.getUserId());
list.add(o.getUserName());
list.add(o.getDeptName());
list.add(o.getPostTypeName());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, list);
data.add(list);
});
}
return data;
}
public void exportByParams(HttpServletResponse response, ExcelDto excelDto, String params) {
switch (excelDto.getType()) {
case "WHP":
List<FireChemicalDto> data = fireChemicalServiceImpl.queryForFireChemicalList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data,
FireChemicalDto.class, dataSourcesImpl, false);
break;
case "XFZJ":
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireExpertsDtoList,
FireExpertsDto.class, dataSourcesImpl, false);
break;
case "SYXX":
List<WaterResourceDto> waterResourceDtoList = waterResourceServiceImpl.exportToExcel(true);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), waterResourceDtoList,
WaterResourceDto.class, dataSourcesImpl, false);
break;
case "HKQ":
List<AircraftDto> aircraftDtoList = aircraftServiceImpl.queryAircraftDtoForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), aircraftDtoList,
AircraftDto.class, dataSourcesImpl, false);
break;
case "XFDW":
List<FireTeamDto> fireTeamDtoList = fireTeamService.queryFireTeamForList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireTeamDtoList,
FireTeamDto.class, dataSourcesImpl, false);
break;
case "WXXFZ":
List<FireStationDto> fireStationDtoList = fireStationService.queryForFireStationList(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), fireStationDtoList,
FireStationDto.class, null, false);
break;
case "XFRY":
List<FirefightersExcelDto> firefightersExcelDtoList = firefightersService.exportToExcel(false);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
firefightersExcelDtoList, FirefightersExcelDto.class, null, false);
break;
case "WBRY":
List<MaintenancePersonExcleDto> maintenancePersonExcelDtoList = maintenanceCompanyService
.exportToMaintenancePersonExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false);
break;
case "KEYSITE":
List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), keySiteDtoList,
KeySiteExcleDto.class, null, false);
break;
case "JCDWRY":
// 机场单位人员参数传递为 parentId = xxxxxxx
String parentIdStr = params.split("=")[1];
Long parentId = -1l;
try {
parentId = Long.parseLong(parentIdStr);
} catch (NumberFormatException e) {
throw new BadRequest("导出机场单位时未传递正确parentId");
}
List<OrgUsrExcelDto> orgUsrList = orgUsrService.exportPersonToExcelByParentId(parentId);
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), orgUsrList,
OrgUsrExcelDto.class, null, false);
break;
case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), LinkageUnitDtoList,
LinkageUnitDto.class, null, false);
break;
default:
break;
}
}
public BaseEntity getCurrentInfo() {
BaseEntity userModel= new BaseEntity();
/* String keyString= RequestContext.getExeUserId();
String token=RequestContext.getToken();
ReginParams params = JSONObject.parseObject(redisUtils
.get(RedisKey.buildReginKey(keyString, token)).toString(),
ReginParams.class);*/
userModel.setRecUserId("3141675");
userModel.setRecUserName("admin_jcs");
userModel.setRecDate( new Date());
userModel.setIsDelete(false);
return userModel;
}
}
spring.application.name=JCS-chenhao
spring.application.name=JCS
server.servlet.context-path=/jcs
server.port=11100
spring.profiles.active=dev
......@@ -7,10 +7,10 @@ spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
logging.config=classpath:logback-${spring.profiles.active}.xml
## mybatis-plus配置控制台打印完整带参数SQL语句
## mybatis-plus配置控制台打印完整带参数SQL语句
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
## redis失效时间
## redis失效时间
redis.cache.failure.time=10800
## unit(h)
......@@ -52,13 +52,13 @@ spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
#在重启服务的过程中是否清空缓存的标识符 --2021-09-09
my.spring.redis.cache.isclean=false
## mqtt-警情初报消息主题
## mqtt-警情初报消息主题
mqtt.topic.alert.reporting=alertReporting
## 实战指挥新警情�?�报主题
## 实战指挥新警情主题
mqtt.topic.command.alert.notice=alertNotice
## 跑马灯地震,天气预警信息
## 跑马灯地震、天气预警信息
mqtt.topic.command.meteorological.notice=meteorological
mqtt.topic.command.power.deployment=power
......@@ -72,8 +72,8 @@ iot.fegin.name=AMOS-API-IOT
equip.fegin.name=AMOS-EQUIPMANAGE
## 设备联动服务(车库门、广播、警铃)
## 设备联动服务(车库门、广播、警铃)
control.fegin.name=JCS-API-CONTROL
## 故障报修流程
## 故障报修流程
failure.work.flow.processDefinitionKey=malfunction_repair
\ No newline at end of file
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