124 changed files with 2679 additions and 510 deletions
@ -0,0 +1,93 @@ |
|||
package com.epmet.commons.tools.utils.poi.excel; |
|||
|
|||
|
|||
import cn.afterturn.easypoi.excel.export.styler.AbstractExcelExportStyler; |
|||
import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler; |
|||
import org.apache.poi.ss.usermodel.*; |
|||
|
|||
|
|||
/** |
|||
* desc:easypoi自定义表头颜色 |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2022/4/8 4:39 下午 |
|||
* @version: 1.0 |
|||
*/ |
|||
public class EasyPoiExcelExportStylerImpl extends AbstractExcelExportStyler |
|||
implements IExcelExportStyler { |
|||
public EasyPoiExcelExportStylerImpl(Workbook workbook) { |
|||
super.createStyles(workbook); |
|||
} |
|||
|
|||
@Override |
|||
public CellStyle getTitleStyle(short color) { |
|||
CellStyle titleStyle = workbook.createCellStyle(); |
|||
Font font = this.workbook.createFont(); |
|||
// 字体加粗
|
|||
font.setBold(true); |
|||
font.setFontHeightInPoints((short) 12); |
|||
titleStyle.setFont(font); |
|||
//居中
|
|||
titleStyle.setAlignment(HorizontalAlignment.CENTER); |
|||
//垂直居中
|
|||
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
|||
//设置颜色
|
|||
titleStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); |
|||
titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|||
titleStyle.setBorderRight(BorderStyle.THIN); |
|||
titleStyle.setBorderLeft(BorderStyle.THIN); |
|||
titleStyle.setBorderBottom(BorderStyle.THIN); |
|||
titleStyle.setBorderTop(BorderStyle.THIN); |
|||
titleStyle.setWrapText(true); |
|||
return titleStyle; |
|||
} |
|||
|
|||
@Override |
|||
public CellStyle getHeaderStyle(short color) { |
|||
CellStyle titleStyle = workbook.createCellStyle(); |
|||
Font font = workbook.createFont(); |
|||
font.setFontHeightInPoints((short) 12); |
|||
titleStyle.setFont(font); |
|||
titleStyle.setAlignment(HorizontalAlignment.CENTER); |
|||
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* desc:隔行样式 |
|||
* @param workbook |
|||
* @param isWarp |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { |
|||
CellStyle style = workbook.createCellStyle(); |
|||
//style.setAlignment(HorizontalAlignment.CENTER);
|
|||
style.setVerticalAlignment(VerticalAlignment.CENTER); |
|||
style.setDataFormat(STRING_FORMAT); |
|||
if (isWarp) { |
|||
style.setWrapText(true); |
|||
} |
|||
|
|||
return style; |
|||
} |
|||
|
|||
/** |
|||
* desc:隔行样式 |
|||
* @param workbook |
|||
* @param isWarp |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { |
|||
CellStyle style = workbook.createCellStyle(); |
|||
//style.setAlignment(HorizontalAlignment.CENTER);
|
|||
style.setVerticalAlignment(VerticalAlignment.CENTER); |
|||
style.setDataFormat(STRING_FORMAT); |
|||
if (isWarp) { |
|||
style.setWrapText(true); |
|||
} |
|||
return style; |
|||
} |
|||
|
|||
} |
@ -1,4 +1,4 @@ |
|||
package com.epmet.commons.tools.utils.excel; |
|||
package com.epmet.commons.tools.utils.poi.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|||
import lombok.AllArgsConstructor; |
@ -0,0 +1,46 @@ |
|||
package com.epmet.commons.tools.utils.poi.excel; |
|||
|
|||
/** |
|||
* desc:easyExcel 冻结标题 |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2022/4/11 10:27 上午 |
|||
* @version: 1.0 |
|||
*/ |
|||
|
|||
import com.alibaba.excel.write.handler.SheetWriteHandler; |
|||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
|||
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; |
|||
import org.apache.poi.ss.usermodel.Sheet; |
|||
import org.apache.poi.ss.util.CellRangeAddress; |
|||
|
|||
|
|||
public class FreezeAndFilter implements SheetWriteHandler { |
|||
|
|||
public int colSplit = 0, rowSplit = 1, leftmostColumn = 0, topRow = 1; |
|||
public String autoFilterRange = "1:1"; |
|||
private boolean isFilter; |
|||
|
|||
public FreezeAndFilter() { |
|||
|
|||
} |
|||
public FreezeAndFilter(boolean isFilter) { |
|||
this.isFilter = isFilter; |
|||
} |
|||
|
|||
@Override |
|||
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
|||
Sheet sheet = writeSheetHolder.getSheet(); |
|||
sheet.createFreezePane(colSplit, rowSplit, leftmostColumn, topRow); |
|||
//不让他筛选
|
|||
if (isFilter){ |
|||
sheet.setAutoFilter(CellRangeAddress.valueOf(autoFilterRange)); |
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.opendata.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.opendata.entity.GriderOnlineNumEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 在线网格员人数 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-14 |
|||
*/ |
|||
@Mapper |
|||
public interface GriderOnlineNumDao extends BaseDao<GriderOnlineNumEntity> { |
|||
|
|||
} |
@ -0,0 +1,61 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.opendata.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 用户巡查主记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-14 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("grider_online_num") |
|||
public class GriderOnlineNumEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
private String qxGridId; |
|||
|
|||
/** |
|||
* 推送时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date pushTime; |
|||
|
|||
/** |
|||
* 在线数 |
|||
*/ |
|||
private Integer onlineNum; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,38 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.opendata.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.opendata.entity.GriderOnlineNumEntity; |
|||
|
|||
/** |
|||
* 用户巡查主记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-14 |
|||
*/ |
|||
public interface GriderOnlineNumService extends BaseService<GriderOnlineNumEntity> { |
|||
|
|||
/** |
|||
* desc:插入巡查中的网格员数据 |
|||
* @return boolean |
|||
*/ |
|||
Boolean insertData(String agencyId); |
|||
|
|||
|
|||
} |
@ -0,0 +1,69 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.opendata.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.constant.StrConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.PatrolCountFormDTO; |
|||
import com.epmet.dto.result.PatrolCountResultDTO; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.opendata.dao.GriderOnlineNumDao; |
|||
import com.epmet.opendata.entity.GriderOnlineNumEntity; |
|||
import com.epmet.opendata.service.GriderOnlineNumService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 用户巡查主记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-14 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class GriderOnlineNumServiceImpl extends BaseServiceImpl<GriderOnlineNumDao, GriderOnlineNumEntity> implements GriderOnlineNumService { |
|||
@Autowired |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
@Override |
|||
public Boolean insertData(String agencyId) { |
|||
PatrolCountFormDTO param = new PatrolCountFormDTO(); |
|||
param.setAgencyId(agencyId); |
|||
Result<PatrolCountResultDTO> patrolCountResult = epmetUserOpenFeignClient.patrolCount(param); |
|||
|
|||
log.debug("insertData patrolCountResult return:{}", JSON.toJSONString(patrolCountResult)); |
|||
if (patrolCountResult == null || !patrolCountResult.success()) { |
|||
log.warn("insertData patrolCount fail,return null"); |
|||
return false; |
|||
} |
|||
PatrolCountResultDTO data = patrolCountResult.getData(); |
|||
int count = data.getPatrollingCount() == null ? NumConstant.ZERO : data.getPatrollingCount(); |
|||
GriderOnlineNumEntity entity = new GriderOnlineNumEntity(); |
|||
entity.setCustomerId(StrConstant.PY_CUSTOMER); |
|||
entity.setPushTime(new Date()); |
|||
entity.setOnlineNum(count); |
|||
baseDao.insert(entity); |
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,71 @@ |
|||
package com.epmet.opendata.task; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.constant.StrConstant; |
|||
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.opendata.service.GriderOnlineNumService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.redisson.api.RLock; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* desc: |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2022/4/12 4:21 下午 |
|||
* @version: 1.0 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class ExtractBizDataToOpenData { |
|||
|
|||
@Autowired |
|||
private DistributedLock distributedLock; |
|||
|
|||
@Autowired |
|||
private GriderOnlineNumService griderOnlineNumService; |
|||
|
|||
@Scheduled(cron = "0 30 */2 * * *") |
|||
//@Scheduled(cron = "0/15 * * * * *")
|
|||
public void extractGridMemberPatrollingCount() { |
|||
String currentTime = DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN); |
|||
log.info("extractGridMemberPatrollingCount start,date:{}", currentTime); |
|||
RLock rLock = null; |
|||
try { |
|||
rLock = distributedLock.tryLock(RedisKeys.getLockByMethodName("extractGridMemberPatrollingCount")); |
|||
if (rLock == null || !rLock.isLocked()) { |
|||
log.warn("tryLock method extractGridMemberPatrollingCount fail"); |
|||
return; |
|||
} |
|||
boolean patrolCountResult; |
|||
int retryTime = NumConstant.THREE; |
|||
do { |
|||
//StrConstant.PY_ROOT_AGENCY
|
|||
patrolCountResult = griderOnlineNumService.insertData(StrConstant.PY_ROOT_AGENCY); |
|||
if (!patrolCountResult) { |
|||
break; |
|||
} |
|||
//如果 重试次数为1了 就让歇个 5分钟
|
|||
if (retryTime == 1) { |
|||
Thread.sleep(NumConstant.FIVE * NumConstant.SIXTY * NumConstant.ONE_THOUSAND); |
|||
} |
|||
} while (retryTime-- > 0); |
|||
if (!patrolCountResult) { |
|||
log.error("插入网格员在线人数失败,请检查原因,时间:{}", currentTime); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
log.warn("tryLock method extractGridMemberPatrollingCount fail"); |
|||
} finally { |
|||
distributedLock.unLock(rLock); |
|||
} |
|||
log.info("extractGridMemberPatrollingCount end"); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
CREATE TABLE `grider_online_num` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '主键', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', |
|||
`ONLINE_NUM` int(11) NOT NULL COMMENT '在线人数', |
|||
`PUSH_TIME` datetime NOT NULL COMMENT '推送时间', |
|||
`DEL_FLAG` bigint(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', |
|||
`REVISION` int(11) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='网格员在线人数'; |
@ -0,0 +1,6 @@ |
|||
<?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.epmet.opendata.dao.GriderOnlineNumDao"> |
|||
|
|||
</mapper> |
@ -0,0 +1,119 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Data |
|||
public class IcVaccineDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 唯一标识 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户Id customer.id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
private String isResiUser; |
|||
|
|||
/** |
|||
* 数据来源【导入的:import;】 |
|||
*/ |
|||
private String userType; |
|||
|
|||
/** |
|||
* 接种时间 |
|||
*/ |
|||
private Date inoculateTime; |
|||
|
|||
/** |
|||
* 接种地点 |
|||
*/ |
|||
private String inoculateAddress; |
|||
|
|||
/** |
|||
* 疫苗厂家 |
|||
*/ |
|||
private String manufacturer; |
|||
|
|||
/** |
|||
* 预留字段1 |
|||
*/ |
|||
private String field1; |
|||
|
|||
/** |
|||
* 预留字段2 |
|||
*/ |
|||
private String field2; |
|||
|
|||
/** |
|||
* 预留字段3 |
|||
*/ |
|||
private String field3; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remaek; |
|||
|
|||
/** |
|||
* 删除标识 0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Data |
|||
public class IcVaccineRelationDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 组织pids,包含当前agencyId值 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 疫苗记录表Id(ic_vaccine.id) |
|||
*/ |
|||
private String icVaccineId; |
|||
|
|||
/** |
|||
* 关系数据的绑定途径【 |
|||
数字社区录入:icresi; |
|||
导入的:import; |
|||
同步的:synchro】 |
|||
*/ |
|||
private String userType; |
|||
|
|||
/** |
|||
* 删除标识 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* @Description 疫苗接种信息查询 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class VaccineListFormDTO extends PageFormDTO { |
|||
|
|||
private static final long serialVersionUID = -6809065476616323072L; |
|||
|
|||
public interface Detail extends CustomerClientShowGroup { |
|||
} |
|||
public interface Del extends CustomerClientShowGroup { |
|||
} |
|||
public interface Synchro extends CustomerClientShowGroup { |
|||
} |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
private String idCard; |
|||
/** |
|||
* 当前组织:current 根组织:all |
|||
*/ |
|||
private String searchType; |
|||
private String agencyId; |
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
private String isResiUser; |
|||
/** |
|||
* 检测开始时间yyyy-MM-dd HH:mm |
|||
*/ |
|||
private String startTime; |
|||
/** |
|||
* 检测结束时间yyyy-MM-dd HH:mm间yy-mm-dd |
|||
*/ |
|||
private String endTime; |
|||
|
|||
/** |
|||
* 核酸记录Id |
|||
*/ |
|||
@NotBlank(message = "疫苗接种记录Id不能为空", groups = { Detail.class, Del.class, Synchro.class}) |
|||
private String icVaccineId; |
|||
|
|||
/** |
|||
* token里设置 |
|||
*/ |
|||
private String customerId; |
|||
private String userId; |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
|||
import com.alibaba.excel.annotation.write.style.HeadStyle; |
|||
import com.alibaba.excel.enums.poi.FillPatternTypeEnum; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 疫苗接种-全局导出 |
|||
* @Author sun |
|||
*/ |
|||
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) |
|||
@Data |
|||
public class IcVaccineListCommonExcelResultDTO extends IcVaccineListResultDTO{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "本辖区居民",order = 6) |
|||
private String isResiUser; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,89 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelIgnore; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
|||
import com.alibaba.excel.annotation.write.style.HeadStyle; |
|||
import com.alibaba.excel.enums.poi.FillPatternTypeEnum; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Description 核酸检测-我的上报记录 |
|||
* @Author sun |
|||
*/ |
|||
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) |
|||
@Data |
|||
public class IcVaccineListResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 组织Id |
|||
*/ |
|||
@ExcelIgnore |
|||
private String agencyId; |
|||
@ExcelIgnore |
|||
private String vaccineId; |
|||
@ExcelIgnore |
|||
private String userId; |
|||
|
|||
/** |
|||
* 居民端小程序的人:resi;数字社区的居民:icresi;未关联上的:other |
|||
*/ |
|||
@ExcelIgnore |
|||
private String userType; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "姓名",order = 1) |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "手机号",order = 2) |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
@ColumnWidth(25) |
|||
@ExcelProperty(value = "身份证号",order = 3) |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 检测时间,yyyy-MM-dd HH:mm |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
|||
@ColumnWidth(25) |
|||
@ExcelProperty(value = "接种时间",order = 4) |
|||
private Date inoculateTime; |
|||
|
|||
/** |
|||
* 检测结果 |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "接种地点",order = 5) |
|||
private String inoculateAddress; |
|||
|
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
@ExcelIgnore |
|||
private String isResiUser; |
|||
|
|||
/** |
|||
* 检测地点 |
|||
*/ |
|||
@ColumnWidth(30) |
|||
@ExcelProperty(value = "疫苗厂家",order = 7) |
|||
private String manufacturer; |
|||
|
|||
|
|||
} |
@ -0,0 +1,230 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.alibaba.excel.EasyExcel; |
|||
import com.alibaba.excel.ExcelWriter; |
|||
import com.alibaba.excel.write.metadata.WriteSheet; |
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.*; |
|||
import com.epmet.commons.tools.utils.poi.excel.FreezeAndFilter; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.constants.ImportTaskConstants; |
|||
import com.epmet.dto.form.ImportTaskCommonFormDTO; |
|||
import com.epmet.dto.form.VaccineListFormDTO; |
|||
import com.epmet.dto.result.IcVaccineListCommonExcelResultDTO; |
|||
import com.epmet.dto.result.IcVaccineListResultDTO; |
|||
import com.epmet.dto.result.ImportTaskCommonResultDTO; |
|||
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|||
import com.epmet.service.IcVaccineService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.apache.commons.io.IOUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.ServletOutputStream; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.FileOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.net.URLEncoder; |
|||
import java.nio.file.Path; |
|||
import java.util.List; |
|||
import java.util.UUID; |
|||
|
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("icVaccine") |
|||
public class IcVaccineController implements ResultDataResolver { |
|||
|
|||
@Autowired |
|||
private IcVaccineService icVaccineService; |
|||
|
|||
@Autowired |
|||
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【疫苗】疫苗接种信息列表 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("vaccine-list") |
|||
public Result<PageData<IcVaccineListResultDTO>> vaccineList(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
return new Result<PageData<IcVaccineListResultDTO>>().ok(icVaccineService.icVaccineList(formDTO)); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息同步 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("synchro") |
|||
public Result synchro(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, VaccineListFormDTO.Synchro.class); |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
icVaccineService.synchro(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息取消同步 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("cancelsynchro") |
|||
public Result cancelSynchro(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, VaccineListFormDTO.Synchro.class); |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
icVaccineService.cancelSynchro(formDTO); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
/** |
|||
* 导入excel |
|||
* @return |
|||
*/ |
|||
@PostMapping("import") |
|||
public Result importExcel(MultipartFile file) { |
|||
String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); |
|||
|
|||
// 1.暂存文件
|
|||
String originalFilename = file.getOriginalFilename(); |
|||
String extName = originalFilename.substring(originalFilename.lastIndexOf(".")); |
|||
|
|||
Path fileSavePath; |
|||
try { |
|||
Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_vaccine", "import"); |
|||
fileSavePath = importPath.resolve(UUID.randomUUID().toString().concat(extName)); |
|||
} catch (IOException e) { |
|||
String errorMsg = ExceptionUtils.getErrorStackTrace(e); |
|||
log.error("【疫苗接种导入】创建临时存储文件失败:{}", errorMsg); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "文件上传失败", "文件上传失败"); |
|||
} |
|||
|
|||
InputStream is = null; |
|||
FileOutputStream os = null; |
|||
|
|||
try { |
|||
is = file.getInputStream(); |
|||
os = new FileOutputStream(fileSavePath.toString()); |
|||
IOUtils.copy(is, os); |
|||
} catch (Exception e) { |
|||
log.error("importExcel exception", e); |
|||
} finally { |
|||
org.apache.poi.util.IOUtils.closeQuietly(is); |
|||
org.apache.poi.util.IOUtils.closeQuietly(os); |
|||
} |
|||
|
|||
// 2.生成导入任务记录
|
|||
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); |
|||
importTaskForm.setOperatorId(userId); |
|||
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_IC_VACCINE); |
|||
importTaskForm.setOriginFileName(originalFilename); |
|||
|
|||
ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException(commonServiceOpenFeignClient.createImportTask(importTaskForm), |
|||
ServiceConstant.EPMET_COMMON_SERVICE, |
|||
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), |
|||
"excel导入疫苗接种信息错误", |
|||
"导入居民疫苗接种信息失败"); |
|||
|
|||
// 3.执行导入
|
|||
icVaccineService.execAsyncExcelImport(fileSavePath, rstData.getTaskId()); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息下载模板 |
|||
**/ |
|||
@RequestMapping(value = "import-template-download", method = {RequestMethod.GET, RequestMethod.POST}) |
|||
public void downloadTemplate(HttpServletResponse response) throws IOException { |
|||
response.setCharacterEncoding("UTF-8"); |
|||
response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition"); |
|||
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("疫苗接种导入模板", "UTF-8") + ".xlsx"); |
|||
|
|||
InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/ic_vaccine.xlsx"); |
|||
try { |
|||
ServletOutputStream os = response.getOutputStream(); |
|||
IOUtils.copy(is, os); |
|||
} finally { |
|||
if (is != null) { |
|||
is.close(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【疫苗】疫苗接种信息列表 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("export") |
|||
public void export(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO, HttpServletResponse response) { |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
formDTO.setIsPage(false); |
|||
ExcelWriter excelWriter = null; |
|||
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|||
int pageNo = formDTO.getPageNo(); |
|||
try { |
|||
// 这里 需要指定写用哪个class去写
|
|||
String fileName = "疫苗接种信息.xlsx"; |
|||
if ("all".equals(formDTO.getSearchType())) { |
|||
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcVaccineListResultDTO.class).build(); |
|||
}else { |
|||
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcVaccineListCommonExcelResultDTO.class).build(); |
|||
} |
|||
|
|||
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); |
|||
PageData<IcVaccineListResultDTO> data = null; |
|||
do { |
|||
data = icVaccineService.icVaccineList(formDTO); |
|||
data.getList().forEach(o-> { |
|||
o.setIsResiUser(NumConstant.ONE_STR.equals(o.getIsResiUser()) ? "是" : "否"); |
|||
}); |
|||
formDTO.setPageNo(++pageNo); |
|||
if ("current".equals(formDTO.getSearchType())) { |
|||
List<IcVaccineListResultDTO> list = ConvertUtils.sourceToTarget(data.getList(), IcVaccineListResultDTO.class); |
|||
excelWriter.write(list, writeSheet); |
|||
}else{ |
|||
excelWriter.write(data.getList(), writeSheet); |
|||
} |
|||
} while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize()); |
|||
|
|||
}catch (Exception e){ |
|||
log.error("export exception", e); |
|||
}finally { |
|||
// 千万别忘记finish 会帮忙关闭流
|
|||
if (excelWriter != null) { |
|||
excelWriter.finish(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -1,16 +0,0 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.IcResiVaccineEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 居民疫苗情况 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-03-28 |
|||
*/ |
|||
@Mapper |
|||
public interface IcResiVaccineDao extends BaseDao<IcResiVaccineEntity> { |
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.IcNatDTO; |
|||
import com.epmet.dto.form.MyNatListFormDTO; |
|||
import com.epmet.dto.form.VaccineListFormDTO; |
|||
import com.epmet.dto.result.IcVaccineListResultDTO; |
|||
import com.epmet.dto.result.MyNatListResultDTO; |
|||
import com.epmet.dto.result.NatListResultDTO; |
|||
import com.epmet.entity.IcVaccineEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Mapper |
|||
public interface IcVaccineDao extends BaseDao<IcVaccineEntity> { |
|||
/** |
|||
* @Author sun |
|||
* @Description 核酸检测-按条件查询核酸记录 |
|||
**/ |
|||
List<MyNatListResultDTO> getMyNatList(MyNatListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【核酸】本辖区核酸检测信息列表 |
|||
* |
|||
* @param formDTO*/ |
|||
List<IcVaccineListResultDTO> getIcVaccineList(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【核酸】客户下核酸检测信息列表 |
|||
* |
|||
* @param formDTO*/ |
|||
List<IcVaccineListResultDTO> getCustomerIcVaccineList(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 删除操作--物理删除业务数据 |
|||
**/ |
|||
int delById(@Param("icNatId") String icNatId); |
|||
|
|||
/** |
|||
* 插入或者更新 |
|||
* |
|||
* @param e |
|||
*/ |
|||
void insertOrUpdate(IcVaccineEntity e); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 按条件查询业务数据 |
|||
**/ |
|||
IcNatDTO getNatDTO(@Param("customerId") String customerId, @Param("icNatId") String icNatId, @Param("idCard") String idCard, @Param("natTime") String natTime, @Param("natResult") String natResult); |
|||
|
|||
/** |
|||
* desc:根据客户id 更新是否居民状态 |
|||
* |
|||
* @param customerId |
|||
* @param icResiUserId 如果为空则更新全部 |
|||
* @return |
|||
*/ |
|||
int updateIsResiFlag(@Param("customerId") String customerId, @Param("icResiUserId") String icResiUserId); |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.IcVaccineRelationEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Mapper |
|||
public interface IcVaccineRelationDao extends BaseDao<IcVaccineRelationEntity> { |
|||
int delRelation(@Param("icVaccineId") String icNatId, @Param("agencyId") String agencyId); |
|||
} |
@ -0,0 +1,55 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.FieldFill; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_vaccine_relation") |
|||
public class IcVaccineRelationEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
@TableField(fill = FieldFill.INSERT) |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 组织pids,包含当前agencyId值 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 疫苗记录表Id(ic_vaccine.id) |
|||
*/ |
|||
private String icVaccineId; |
|||
|
|||
/** |
|||
* 关系数据的绑定途径【 |
|||
数字社区录入:icresi; |
|||
导入的:import; |
|||
同步的:synchro】 |
|||
*/ |
|||
private String userType; |
|||
|
|||
} |
@ -0,0 +1,65 @@ |
|||
package com.epmet.excel.data; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 疫苗接种信息导入excel数据 |
|||
*/ |
|||
@Data |
|||
public class IcVaccineImportExcelData implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -700535059296633797L; |
|||
@NotBlank(message = "姓名为必填项") |
|||
@ExcelProperty("姓名") |
|||
private String name; |
|||
|
|||
@NotBlank(message = "手机号为必填项") |
|||
@ExcelProperty("手机号") |
|||
@Length(max = 15, message = "手机号长度不正确") |
|||
private String mobile; |
|||
|
|||
@NotBlank(message = "身份证号为必填项") |
|||
@ExcelProperty("身份证号") |
|||
@Length(max = 18, message = "身份证号长度不正确") |
|||
private String idCard; |
|||
|
|||
@NotNull(message = "接种时间为必填项") |
|||
@ExcelProperty("接种时间") |
|||
private Date inoculateTime; |
|||
|
|||
@NotBlank(message = "接种地点为必填项") |
|||
@ExcelProperty("接种地点") |
|||
private String inoculateAddress; |
|||
|
|||
@NotBlank(message = "疫苗厂家为必填项") |
|||
@ExcelProperty("疫苗厂家") |
|||
private String manufacturer; |
|||
|
|||
@Data |
|||
public static class RowRemarkMessage { |
|||
|
|||
@ExcelProperty("姓名") |
|||
@ColumnWidth(20) |
|||
private String name; |
|||
|
|||
@ExcelProperty("手机号") |
|||
@ColumnWidth(20) |
|||
private String mobile; |
|||
|
|||
@ColumnWidth(20) |
|||
@ExcelProperty("身份证号") |
|||
private String idCard; |
|||
|
|||
@ColumnWidth(60) |
|||
@ExcelProperty("错误信息") |
|||
private String errorInfo; |
|||
} |
|||
} |
@ -0,0 +1,136 @@ |
|||
package com.epmet.excel.handler; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.read.listener.ReadListener; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.exception.ValidateException; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.entity.IcVaccineEntity; |
|||
import com.epmet.excel.data.IcNatImportExcelData; |
|||
import com.epmet.excel.data.IcVaccineImportExcelData; |
|||
import com.epmet.service.impl.IcNatServiceImpl; |
|||
import com.epmet.service.impl.IcVaccineServiceImpl; |
|||
import lombok.Data; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 核酸检测excel导入监听器 |
|||
*/ |
|||
@Data |
|||
@Slf4j |
|||
public class IcVaccineExcelImportListener implements ReadListener<IcVaccineImportExcelData> { |
|||
|
|||
/** |
|||
* 最大条数阈值 |
|||
*/ |
|||
public static final int MAX_THRESHOLD = 200; |
|||
|
|||
private String currentUserId; |
|||
/** |
|||
* 当前组织ID |
|||
*/ |
|||
private String currentAgencyId; |
|||
|
|||
private String currentAgencyPids; |
|||
|
|||
/** |
|||
* 数据 |
|||
*/ |
|||
private List<IcVaccineEntity> datas = new ArrayList<>(); |
|||
|
|||
/** |
|||
* 错误项列表 |
|||
*/ |
|||
private List<IcVaccineImportExcelData.RowRemarkMessage> errorRows = new ArrayList<>(); |
|||
/** |
|||
* 其他被标记出来的列表列表 |
|||
*/ |
|||
private List<IcVaccineImportExcelData.RowRemarkMessage> otherRows = new ArrayList<>(); |
|||
|
|||
private IcVaccineServiceImpl icVaccineService; |
|||
|
|||
public IcVaccineExcelImportListener(String currentUserId, String currentAgencyId, String currentAgencyPids, IcVaccineServiceImpl icVaccineService) { |
|||
this.currentUserId = currentUserId; |
|||
this.currentAgencyId = currentAgencyId; |
|||
this.currentAgencyPids = currentAgencyPids; |
|||
this.icVaccineService = icVaccineService; |
|||
} |
|||
|
|||
@Override |
|||
public void invoke(IcVaccineImportExcelData data, AnalysisContext context) { |
|||
|
|||
try { |
|||
// 先校验数据
|
|||
ValidatorUtils.validateEntity(data); |
|||
|
|||
// 取出前后空格
|
|||
if (StringUtils.isNotBlank(data.getName())) { |
|||
data.setName(data.getName().trim()); |
|||
} |
|||
if (StringUtils.isNotBlank(data.getMobile())) { |
|||
data.setMobile(data.getMobile().trim()); |
|||
} |
|||
if (StringUtils.isNotBlank(data.getInoculateAddress())) { |
|||
data.setInoculateAddress(data.getInoculateAddress().trim()); |
|||
} |
|||
if (StringUtils.isNotBlank(data.getIdCard())) { |
|||
data.setIdCard(data.getIdCard().trim()); |
|||
} |
|||
|
|||
IcVaccineEntity icVaccineEntity = ConvertUtils.sourceToTarget(data, IcVaccineEntity.class); |
|||
icVaccineEntity.setUserType("import"); |
|||
datas.add(icVaccineEntity); |
|||
|
|||
if (datas.size() == MAX_THRESHOLD) { |
|||
execPersist(); |
|||
} |
|||
} catch (Exception e) { |
|||
String errorMsg = null; |
|||
if (e instanceof ValidateException) { |
|||
errorMsg = ((ValidateException) e).getMsg(); |
|||
} else { |
|||
errorMsg = "未知错误"; |
|||
log.error("【疫苗接种信息导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); |
|||
} |
|||
|
|||
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|||
errorRow.setName(data.getName()); |
|||
errorRow.setMobile(data.getMobile()); |
|||
errorRow.setIdCard(data.getIdCard()); |
|||
errorRow.setErrorInfo(errorMsg); |
|||
errorRows.add(errorRow); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
// 最后几条达不到阈值,这里必须再调用一次
|
|||
execPersist(); |
|||
} |
|||
|
|||
/** |
|||
* 执行持久化 |
|||
*/ |
|||
private void execPersist() { |
|||
try { |
|||
if (datas != null && datas.size() > 0) { |
|||
icVaccineService.batchPersist(datas, this); |
|||
} |
|||
} finally { |
|||
datas.clear(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获取错误行 |
|||
* @return |
|||
*/ |
|||
public List<IcVaccineImportExcelData.RowRemarkMessage> getErrorRows() { |
|||
return errorRows; |
|||
} |
|||
} |
@ -1,89 +0,0 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.IcResiVaccineDTO; |
|||
import com.epmet.dto.result.VaccineListDTO; |
|||
import com.epmet.entity.IcResiVaccineEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 居民疫苗情况 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-03-28 |
|||
*/ |
|||
public interface IcResiVaccineService extends BaseService<IcResiVaccineEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<IcResiVaccineDTO> |
|||
* @author generator |
|||
* @date 2022-03-28 |
|||
*/ |
|||
PageData<IcResiVaccineDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<IcResiVaccineDTO> |
|||
* @author generator |
|||
* @date 2022-03-28 |
|||
*/ |
|||
List<IcResiVaccineDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return IcResiVaccineDTO |
|||
* @author generator |
|||
* @date 2022-03-28 |
|||
*/ |
|||
IcResiVaccineDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-03-28 |
|||
*/ |
|||
void save(IcResiVaccineDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-03-28 |
|||
*/ |
|||
void update(IcResiVaccineDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-03-28 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* 获取居民疫苗接种信息 |
|||
* |
|||
* @Param idCard |
|||
* @Return {@link List< VaccineListDTO>} |
|||
* @Author zhaoqifeng |
|||
* @Date 2022/3/30 10:24 |
|||
*/ |
|||
List<VaccineListDTO> getVaccineList(String customerId, String idCard); |
|||
} |
@ -0,0 +1,78 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.IcVaccineRelationDTO; |
|||
import com.epmet.entity.IcVaccineRelationEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
public interface IcVaccineRelationService extends BaseService<IcVaccineRelationEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<IcVaccineRelationDTO> |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
PageData<IcVaccineRelationDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<IcVaccineRelationDTO> |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
List<IcVaccineRelationDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return IcVaccineRelationDTO |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
IcVaccineRelationDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
void save(IcVaccineRelationDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
void update(IcVaccineRelationDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
void delete(String[] ids); |
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.form.VaccineListFormDTO; |
|||
import com.epmet.dto.result.IcVaccineListResultDTO; |
|||
import com.epmet.dto.result.VaccineListDTO; |
|||
import com.epmet.entity.IcVaccineEntity; |
|||
|
|||
import java.nio.file.Path; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
public interface IcVaccineService extends BaseService<IcVaccineEntity> { |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【核酸】核酸检测信息列表 |
|||
* |
|||
* @param formDTO |
|||
* @return*/ |
|||
PageData<IcVaccineListResultDTO> icVaccineList(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【核酸】核酸检测信息同步 |
|||
**/ |
|||
void synchro(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【核酸】核酸检测信息取消同步 |
|||
**/ |
|||
void cancelSynchro(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* 执行Excel导入 |
|||
* @param filePath |
|||
*/ |
|||
void execAsyncExcelImport(Path filePath, String importTaskId); |
|||
|
|||
/** |
|||
* 获取居民疫苗接种信息 |
|||
* |
|||
* @Param idCard |
|||
* @Return {@link List <VaccineListDTO>} |
|||
* @Author zhaoqifeng |
|||
* @Date 2022/3/30 10:24 |
|||
*/ |
|||
List<VaccineListDTO> getVaccineList(String customerId, String idCard); |
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue