Browse Source

Merge branch 'master' of http://121.42.41.42:7070/r/epmet-cloud into dev_party_helper

master
yinzuomei 3 years ago
parent
commit
fafc05dfdf
  1. 103
      epmet-cloud-generator/src/main/resources/template/index.vue.vm
  2. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java
  3. 16
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  4. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java
  5. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java
  6. 1
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerGridDao.java
  7. 77
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java
  8. 102
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java
  9. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  10. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  11. 48
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  12. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  13. 18
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  14. 22
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java
  15. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml
  16. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java
  17. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java
  18. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java
  19. 9
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  20. 7
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
  21. 19
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java
  22. 11
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java
  23. 19
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java
  24. 46
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/enums/ProjectOriginEnum.java
  25. 11
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectService.java
  26. 28
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java
  27. 12
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java
  28. 6
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataOrgChangeEventListener.java
  29. 6
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java
  30. 6
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java
  31. 8
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataStaffChangeEventListener.java
  32. 3
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/EventreportPingyinServiceImpl.java
  33. 11
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridInfoPingyinServiceImpl.java
  34. 9
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffInfoPingyinServiceImpl.java
  35. 6
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java
  36. 4
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/EventreportPingyinDao.xml
  37. 9
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/GridInfoPingyinDao.xml
  38. 4
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/GridstaffInfoPingyinDao.xml
  39. 4
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/GridstaffWorkInfoPingyinDao.xml
  40. 40
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java
  41. 7
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java
  42. 39
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/DhTokenDTO.java
  43. 184
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccinePrarmeterDTO.java
  44. 8
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/SaveCollectVisitorFormDTO.java
  45. 27
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhAuthFormDTO.java
  46. 29
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhCardPageFormDTO.java
  47. 23
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhChannelFormDTO.java
  48. 25
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhChannelPageFormDTO.java
  49. 25
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhDeptFormDTO.java
  50. 29
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhIdentityFormDTO.java
  51. 23
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhLoginPassFormDTO.java
  52. 23
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhNodeFormDTO.java
  53. 39
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonCardFormDTO.java
  54. 22
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonCardListFormDTO.java
  55. 22
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonDelFormDTO.java
  56. 39
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonFormDTO.java
  57. 23
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonImgFormDTO.java
  58. 25
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonPageFormDTO.java
  59. 27
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPlanFormDTO.java
  60. 25
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPlanPageFormDTO.java
  61. 21
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPublicKeyFormDTO.java
  62. 14
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitListFormDTO.java
  63. 24
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitVisitorChartFormDTO.java
  64. 51
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitVisitorFormDTO.java
  65. 14
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitorInfoFormDTO.java
  66. 23
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DhChannelResultDTO.java
  67. 30
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VisitVisitorChartResultDTO.java
  68. 80
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectVisitorController.java
  69. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  70. 82
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccinePrarmeterController.java
  71. 27
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectVisitorDao.java
  72. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccinePrarmeterDao.java
  73. 154
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccinePrarmeterEntity.java
  74. 117
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterExcel.java
  75. 30
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/IcVaccinePrarmeterRedis.java
  76. 53
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiCollectVisitorService.java
  77. 78
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccinePrarmeterService.java
  78. 1
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  79. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java
  80. 56
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectVisitorServiceImpl.java
  81. 87
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccinePrarmeterServiceImpl.java
  82. 768
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/Base64Util.java
  83. 521
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/BaseNCodec.java
  84. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/Cities.java
  85. 60
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/DhCloudProperties.java
  86. 904
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/DhDeviceUtil.java
  87. 141
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/DhResult.java
  88. 85
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/IDUtils.java
  89. 316
      epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/RSAUtils.java
  90. 1
      epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.65__resi_collect_alter.sql
  91. 56
      epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.66__chart_hour.sql
  92. 88
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectVisitorDao.xml
  93. 43
      epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccinePrarmeterDao.xml
  94. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/UserDao.xml

103
epmet-cloud-generator/src/main/resources/template/index.vue.vm

@ -1,52 +1,52 @@
<template>
<el-card shadow="never" class="aui-card--fill">
<div class="mod-${moduleName}__${pathName}}">
<div class="mod-${moduleName}__${pathName}} resi-container">
<el-card ref="searchCard" class="search-card">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.${pk.attrname}" placeholder="${pk.attrname}" clearable></el-input>
<el-input size="small" v-model="dataForm.${pk.attrname}" placeholder="${pk.attrname}" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">{{ $t('query') }}</el-button>
</el-form-item>
<el-form-item>
<el-button v-if="$hasPermission('${moduleName}:${pathName}:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
</el-form-item>
<el-form-item>
<el-button v-if="$hasPermission('${moduleName}:${pathName}:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
<el-button type="primary" size="small" @click="getDataList()">{{ $t('query') }}</el-button>
</el-form-item>
</el-form>
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
</el-card>
<el-card class="resi-card-table">
<div class="resi-row-btn">
<el-button class="diy-button--add" type="primary" size="small" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
<el-button class="diy-button--add" type="danger" size="small" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
</div>
<el-table v-loading="dataListLoading" class="resi-table" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%" :height="tableHeight">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
#foreach($column in $columns)
<el-table-column prop="${column.attrname}" label="${column.comments}" header-align="center" align="center"></el-table-column>
#end
#foreach($column in $columns)
<el-table-column prop="${column.attrname}" label="${column.comments}" header-align="center" align="center"></el-table-column>
#end
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
<template slot-scope="scope">
<el-button v-if="$hasPermission('${moduleName}:${pathName}:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
<el-button v-if="$hasPermission('${moduleName}:${pathName}:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="limit"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="pageSizeChangeHandle"
@current-change="pageCurrentChangeHandle">
:current-page="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="limit"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="pageSizeChangeHandle"
@current-change="pageCurrentChangeHandle">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</el-card>
</el-card>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './'
export default {
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './${pathName}-add-or-update'
import { mapGetters } from 'vuex'
export default {
mixins: [mixinViewModule],
data () {
return {
@ -56,13 +56,52 @@
deleteURL: '/${moduleName}/${pathName}',
deleteIsBatch: true
},
dataForm: {;
dataForm: {
${pk.attrname}: ''
}
}
},
components: {
AddOrUpdate
},
computed: {
...mapGetters(["clientHeight", "iframeHeight"]),
tableHeight() {
const h = this.clientHeight - 360 + this.iframeHeight;
const _h = this.clientHeight - 360;
return this.$store.state.inIframe ? h : _h;
},
}
}
</script>
<style lang="scss" scoped>
@import "@/assets/scss/buttonstyle.scss";
.resi-container .resi-card-table {
::v-deep .el-table th {
color: #fff;
background-color: rgba(33, 149, 254, 1);
}
}
.resi-table {
::v-deep .el-button--text {
text-decoration: underline;
}
}
.search-card {
.el-card__body {
padding: 20px 20px 0 20px;
}
}
.resi-row-btn {
margin-bottom: 13px;
.upload-btn {
display: inline-block;
margin: 0 10px;
}
}
</style>

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java

@ -18,7 +18,9 @@ public enum CoveragePlaceTypeEnum {
VOLUNTEER("volunteer", "志愿者"),
GROUP_RENT("group_rent", "群租房"),
EVENT("event", "城市管理事件"),
ZHZL_RQ("zhzl_rq", "综合治理人群");
ZHZL_RQ("zhzl_rq", "综合治理人群"),
NUCLEIC_POINT("nucleic_point", "核酸检测点"),
VACCINE_POINT("vaccine_point", "疫苗接种点");
private final String code;
private final String name;

16
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -856,4 +856,20 @@ public class RedisKeys {
}
return rootPrefix.concat("staffbaseinfo:")+userId;
}
/**
* 大华publicKey
*/
public static String getDhPublicKey() {
return rootPrefix.concat("dh:public");
}
/**
* 大华token
*/
public static String getDhToken() {
return rootPrefix.concat("dh:token");
}
}

17
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java

@ -0,0 +1,17 @@
package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 核酸监测点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Mapper
public interface IcPointNucleicMonitoringDao extends BaseDao<IcPointNucleicMonitoringEntity> {
}

17
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java

@ -0,0 +1,17 @@
package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 疫苗接种点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Mapper
public interface IcPointVaccinesInoculationDao extends BaseDao<IcPointVaccinesInoculationEntity> {
}

1
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerGridDao.java

@ -86,4 +86,5 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
CustomerGridDTO getGridInfo(@Param("gridId") String gridId);
List<ScreenCustomerGridDTO> getSubGridList(@Param("customerId") String customerId, @Param("agencyId") String agencyId);
List<ScreenCustomerGridDTO> getAllSubGridList(@Param("customerId") String customerId, @Param("agencyId") String agencyId);
}

77
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java

@ -0,0 +1,77 @@
package com.epmet.dataaggre.entity.epmetuser;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 核酸监测点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ic_point_nucleic_monitoring")
public class IcPointNucleicMonitoringEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 所属组织ID
*/
private String orgId;
/**
* 所属组织名称
*/
private String orgName;
/**
* 组织ID上级
*/
private String pid;
/**
* 组织ID所有上级
*/
private String pids;
/**
* 核酸监测点名称
*/
private String name;
/**
* 服务时间
*/
private String serveTime;
/**
* 咨询电话
*/
private String mobile;
/**
* 监测点地址
*/
private String address;
/**
* 经度
*/
private String longitude;
/**
* 纬度
*/
private String latitude;
}

102
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java

@ -0,0 +1,102 @@
package com.epmet.dataaggre.entity.epmetuser;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 疫苗接种点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ic_point_vaccines_inoculation")
public class IcPointVaccinesInoculationEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 所属组织ID
*/
private String orgId;
/**
* 所属组织名称
*/
private String orgName;
/**
* 组织ID上级
*/
private String pid;
/**
* 组织ID所有上级
*/
private String pids;
/**
* 疫苗接种点名称
*/
private String name;
/**
* 接种日期
*/
private String inoculationDate;
/**
* 接种上午开始时间
*/
private String moStartTime;
/**
* 接种上午结束时间
*/
private String moEndTime;
/**
* 接种下午开始时间
*/
private String afStartTime;
/**
* 接种下午结束时间
*/
private String afEndTime;
/**
* 暂无疫苗12
*/
private String noAvailableVaccines;
/**
* 咨询电话
*/
private String mobile;
/**
* 接种点地址
*/
private String address;
/**
* 经度
*/
private String longitude;
/**
* 纬度
*/
private String latitude;
}

9
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -2011,10 +2011,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
//2.查询组织信息,判断查询下级组织还是网格数据
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId(), formDTO.isExport());
//2022.8.17 屏蔽查询组织、网格逻辑,直接以org库的组织网格为准
ScreenAgencyOrGridListDTO agencyGrid = govOrgService.getSubAgencyOrGridList(formDTO.getCustomerId(), formDTO.getAgencyId(), formDTO.isExport());
if (null == agencyGrid) {
return new CustomerDataManageResultDTO();
}
/*ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId(), formDTO.isExport());
if (null == agencyGrid) {
return new CustomerDataManageResultDTO();
}*/
//组织或网格Id集合
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList());
formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode());
@ -2329,7 +2334,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
//2.查询组织信息,判断要查询下级是组织还是网格数据
ScreenAgencyOrGridListDTO agencyGrid = govOrgService.getSubAgencyOrGridList(formDTO.getCustomerId(), formDTO.getAgencyId());
ScreenAgencyOrGridListDTO agencyGrid = govOrgService.getSubAgencyOrGridList(formDTO.getCustomerId(), formDTO.getAgencyId(), false);
if (null == agencyGrid) {
return new ArrayList<>();
}

10
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java

@ -15,6 +15,8 @@ import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.dto.govorg.result.MemberProjectInfoResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectAnalysisResultDTO;
import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity;
import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity;
import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity;
import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity;
import com.epmet.dto.IcResiUserDTO;
import com.epmet.dto.UserBaseInfoDTO;
@ -240,4 +242,12 @@ public interface EpmetUserService {
List<IcResiUserEntity> listVolunteers(String customerId, String agencyId, String staffOrgIds, String search, String resiCategory);
List<NowStatsDataResultDTO> getNowResiUser(NowStatsDataFormDTO formDTO);
Integer countVaccinePoint(String customerId, String agencyId, String staffOrgIds, String search);
Integer countNucleicPoint(String customerId, String agencyId, String staffOrgIds, String search);
List<IcPointVaccinesInoculationEntity> listVaccinePoints(String customerId, String agencyId, String staffOrgIds, String search);
List<IcPointNucleicMonitoringEntity> listNucleicPoints(String customerId, String agencyId,String staffOrgIds, String search);
}

48
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -94,6 +94,10 @@ public class EpmetUserServiceImpl implements EpmetUserService {
private CustomerFootBarService customerFootBarService;
@Resource
private RegisterRelationDao registerRelationDao;
@Resource
private IcPointVaccinesInoculationDao pointVaccinesInoculationDao;
@Resource
private IcPointNucleicMonitoringDao pointNucleicMonitoringDao;
/**
* @Description 根据UserIds查询
@ -923,4 +927,48 @@ public class EpmetUserServiceImpl implements EpmetUserService {
List<NowStatsDataResultDTO> list = registerRelationDao.selectNowResiUser(formDTO);
return list;
}
@Override
public Integer countVaccinePoint(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointVaccinesInoculationEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointVaccinesInoculationEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointVaccinesInoculationEntity::getPids, staffOrgIds)
.or()
.eq(IcPointVaccinesInoculationEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointVaccinesInoculationEntity::getName, search);
return pointVaccinesInoculationDao.selectCount(query);
}
@Override
public Integer countNucleicPoint(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointNucleicMonitoringEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointNucleicMonitoringEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointNucleicMonitoringEntity::getPids, staffOrgIds)
.or()
.eq(IcPointNucleicMonitoringEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointNucleicMonitoringEntity::getName, search);
return pointNucleicMonitoringDao.selectCount(query);
}
@Override
public List<IcPointVaccinesInoculationEntity> listVaccinePoints(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointVaccinesInoculationEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointVaccinesInoculationEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointVaccinesInoculationEntity::getPids, staffOrgIds)
.or()
.eq(IcPointVaccinesInoculationEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointVaccinesInoculationEntity::getName, search);
return pointVaccinesInoculationDao.selectList(query);
}
@Override
public List<IcPointNucleicMonitoringEntity> listNucleicPoints(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointNucleicMonitoringEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointNucleicMonitoringEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointNucleicMonitoringEntity::getPids, staffOrgIds)
.or()
.eq(IcPointNucleicMonitoringEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointNucleicMonitoringEntity::getName, search);
return pointNucleicMonitoringDao.selectList(query);
}
}

2
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -290,6 +290,6 @@ public interface GovOrgService {
List<ResourceInfoResultDTO> getEnterpriseInfos(CoverageHomeSearchFormDTO formDTO);
Integer getEnterpriseInfosCount(CoverageHomeSearchFormDTO formDTO);
ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String customerId, String agencyId);
ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String customerId, String agencyId, Boolean isGetSubAllGrid);
}

18
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -1473,7 +1473,7 @@ public class GovOrgServiceImpl implements GovOrgService {
}
@Override
public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String customerId, String agencyId) {
public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String customerId, String agencyId, Boolean isGetSubAllGrid) {
ScreenAgencyOrGridListDTO resultDTO = new ScreenAgencyOrGridListDTO();
List<ScreenAgencyOrGridListDTO.AgencyGrid> agencyGridList = new ArrayList<>();
//1.查询组织信息
@ -1485,10 +1485,22 @@ public class GovOrgServiceImpl implements GovOrgService {
//2.根据组织级别判断查询直属组织或网格列表
List<ScreenCustomerAgencyDTO> agencyList = new ArrayList<>();
List<ScreenCustomerGridDTO> gridList = new ArrayList<>();
//组织级别为街道的查询下级所有网格
if (isGetSubAllGrid && (OrgLevelEnum.STREET.getCode().equals(dto.getLevel()))) {
gridList = customerGridDao.getAllSubGridList(customerId, agencyId);
List<ScreenAgencyOrGridListDTO.AgencyGrid> allGridList = new ArrayList<>();
gridList.forEach(gr -> {
ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid();
org.setOrgId(gr.getGridId());
org.setOrgName(gr.getGridName());
allGridList.add(org);
});
resultDTO.setAllGridList(allGridList);
}
if (!"community".equals(dto.getLevel())) {
//2-1.直属下级组织列表
agencyList = customerAgencyDao.getSubAgencyListByAgency(customerId, agencyId);
agencyList.forEach(gr->{
agencyList.forEach(gr -> {
ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid();
org.setOrgId(gr.getAgencyId());
org.setOrgName(gr.getAgencyName());
@ -1497,7 +1509,7 @@ public class GovOrgServiceImpl implements GovOrgService {
} else {
//2-2.直属下级网格列表
gridList = customerGridDao.getSubGridList(customerId, agencyId);
gridList.forEach(gr->{
gridList.forEach(gr -> {
ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid();
org.setOrgId(gr.getGridId());
org.setOrgName(gr.getGridName());

22
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java

@ -30,6 +30,8 @@ import com.epmet.dataaggre.dto.govorg.form.DataListLeftSubTotalFormDTO;
import com.epmet.dataaggre.dto.govorg.form.SearchDetailFormDTO;
import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity;
import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity;
import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity;
import com.epmet.dataaggre.entity.govorg.*;
import com.epmet.dataaggre.entity.govproject.IcEventEntity;
@ -628,6 +630,12 @@ public class CoverageServiceImpl implements CoverageService {
// 志愿者
String[] parts = categoryKey.split("_");
return epmetUserService.countVolunteers(customerId, agencyId, staffOrgIds, search, parts[1]);
} else if (CoveragePlaceTypeEnum.VACCINE_POINT.getCode().equals(placeType)) {
// 疫苗接种点
return epmetUserService.countVaccinePoint(customerId, agencyId, staffOrgIds, search);
} else if (CoveragePlaceTypeEnum.NUCLEIC_POINT.getCode().equals(placeType)) {
// 核酸检测点
return epmetUserService.countNucleicPoint(customerId, agencyId, staffOrgIds, search);
}
return 0;
@ -805,6 +813,20 @@ public class CoverageServiceImpl implements CoverageService {
coordinates[1], coordinates[0]);
}).collect(Collectors.toList());
} else if (CoveragePlaceTypeEnum.VACCINE_POINT.getCode().equals(placeType)) {
// 疫苗接种点
List<IcPointVaccinesInoculationEntity> vps = epmetUserService.listVaccinePoints(customerId, agencyId, staffOrgIds, search);
return vps.stream()
.map(vp -> new CoverageAnalisisDataListResultDTO(vp.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null,
placeType, vp.getName(), vp.getLatitude(), vp.getLongitude()))
.collect(Collectors.toList());
} else if (CoveragePlaceTypeEnum.NUCLEIC_POINT.getCode().equals(placeType)) {
// 核酸检测点
List<IcPointNucleicMonitoringEntity> nps = epmetUserService.listNucleicPoints(customerId, agencyId, staffOrgIds, search);
return nps.stream()
.map(np -> new CoverageAnalisisDataListResultDTO(np.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null,
placeType, np.getName(), np.getLatitude(), np.getLongitude()))
.collect(Collectors.toList());
}
return new ArrayList<>();
}

17
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml

@ -194,6 +194,23 @@
del_flag = '0'
AND customer_id = #{customerId}
AND pid = #{agencyId}
ORDER BY pid, grid_name
</select>
<select id="getAllSubGridList" resultType="com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO">
SELECT
customer_id AS customerId,
id AS gridId,
grid_name AS gridName,
pid AS parentAgencyId,
pids AS allParentIds
FROM
customer_grid
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND pids LIKE concat('%',#{agencyId},'%')
ORDER BY pid, grid_name
</select>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java

@ -244,7 +244,7 @@ public class DataReportingServiceImpl implements DataReportingService {
if (CollectionUtils.isNotEmpty(formDTO.getProjectId())) {
list = projectList.stream().map(project -> {
EventInfoResultDTO dto = getEventInfoResultDTO(project, finalEpmetCodeMap, codeMap);
ScreenCustomerGridDTO grid = screenCustomerGridService.getGridById(project.getOrgId());
CustomerGridDTO grid = customerGridService.getGridById(project.getOrgId());
dto.setOrgId(project.getOrgId());
if (null != grid) {
dto.setOrgCode(grid.getCode());
@ -255,10 +255,10 @@ public class DataReportingServiceImpl implements DataReportingService {
} else {
//项目ID不为空时,提前取出客户下的组织和网格
Map<String, ScreenCustomerAgencyEntity> agencyMap = screenCustomerAgencyService.getAgencyList(formDTO.getCustomerId());
Map<String, ScreenCustomerGridDTO> gridMap = screenCustomerGridService.getGridList(formDTO.getCustomerId());
Map<String, CustomerGridDTO> gridMap = customerGridService.getGridMap(PingYinConstant.PROD_PING_YIN_CUSTOMER_ID);
list = projectList.stream().map(project -> {
EventInfoResultDTO dto = getEventInfoResultDTO(project, finalEpmetCodeMap, codeMap);
ScreenCustomerGridDTO grid = gridMap.get(project.getOrgId());
CustomerGridDTO grid = gridMap.get(project.getOrgId());
dto.setOrgId(project.getOrgId());
if (null != grid) {
dto.setOrgCode(grid.getCode());

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java

@ -15,6 +15,7 @@ import com.epmet.entity.org.CustomerGridEntity;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface CustomerGridService extends BaseService<CustomerGridEntity> {
/**
@ -106,4 +107,9 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
* @Description 查询客户下有效网格列表
**/
List<DimGridDTO> gridListByCustomerId(String customerId);
CustomerGridDTO getGridById(String gridId);
Map<String, CustomerGridDTO> getGridMap(String customerId);
}

25
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java

@ -1,8 +1,10 @@
package com.epmet.service.org.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.org.CustomerGridDao;
import com.epmet.dto.group.AgencyDTO;
@ -18,12 +20,13 @@ import com.epmet.dto.user.result.GridUserInfoDTO;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.Issue.IssueService;
import com.epmet.service.org.CustomerGridService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
@DataSource(DataSourceConstant.GOV_ORG)
@ -157,4 +160,20 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
return customerGridDao.gridListByCustomerId(customerId);
}
@Override
public CustomerGridDTO getGridById(String gridId) {
return ConvertUtils.sourceToTarget(baseDao.selectById(gridId), CustomerGridDTO.class);
}
@Override
public Map<String, CustomerGridDTO> getGridMap(String customerId) {
LambdaQueryWrapper<CustomerGridEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CustomerGridEntity::getCustomerId, customerId);
List<CustomerGridEntity> list = baseDao.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyMap();
}
return ConvertUtils.sourceToTarget(list, CustomerGridDTO.class).stream().collect(Collectors.toMap(CustomerGridDTO::getId, Function.identity()));
}
}

9
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java

@ -171,4 +171,13 @@ public interface EpmetHeartOpenFeignClient {
@PostMapping("/heart/icpartyunit/editpartyorcommunity")
Result editPartyOrCommunity(@RequestBody CheckStaffInfoResultDTO formDTO);
/**
* desc:根据来源id 删除需求 只删主表
* @param originId
* @param origin
* @return
*/
@PostMapping("/heart/userdemand/deleteByOriginId/{originId}/{origin}")
Result<Integer> deleteUserDemandByOriginId(@PathVariable("originId") String originId, @PathVariable("origin")String origin);
}

7
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java

@ -13,7 +13,6 @@ import com.epmet.dto.form.IcDemandFormDTO;
import com.epmet.dto.form.PartyUnitListFormDTO;
import com.epmet.dto.form.demand.DemandRecId;
import com.epmet.dto.form.demand.IcEventCommentToDemandFromDTO;
import com.epmet.dto.form.demand.ServiceItemSelectFormDTO;
import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO;
import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO;
import com.epmet.dto.form.resi.ResisByPolicyRulesFormDTO;
@ -21,7 +20,6 @@ import com.epmet.dto.form.resi.VolunteerCommonFormDTO;
import com.epmet.dto.result.CheckStaffInfoResultDTO;
import com.epmet.dto.result.PartyUnitListResultDTO;
import com.epmet.dto.result.demand.IcResiDemandDictDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO;
import com.epmet.feign.EpmetHeartOpenFeignClient;
@ -172,4 +170,9 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli
public Result editPartyOrCommunity(CheckStaffInfoResultDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "editPartyOrCommunity", formDTO);
}
@Override
public Result<Integer> deleteUserDemandByOriginId(String originId, String origin) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "deleteUserDemandByOriginId", originId,origin);
}
}

19
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java

@ -47,10 +47,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
@ -399,5 +396,17 @@ public class IcUserDemandRecController implements ResultDataResolver {
return new Result();
}
/**
* desc:根据来源id 删除需求 只删主表
* @param originId
* @param origin
* @return
*/
@PostMapping("deleteByOriginId/{originId}/{origin}")
public Result<Integer> deleteByOriginId(@PathVariable("originId") String originId, @PathVariable("origin")String origin) {
Integer effectRow = icUserDemandRecService.deleteByOriginId(originId,origin);
return new Result().ok(effectRow);
}
}
}

11
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java

@ -265,4 +265,13 @@ public interface IcUserDemandRecService extends BaseService<IcUserDemandRecEntit
Integer selectCountByServerId(String serverId);
ServerInfoDTO queryServiceName(String serverId, String serviceType);
}
/**
* desc:根据来源id 删除需求 只删主表
* @param originId
* @param origin
* @return
*/
Integer deleteByOriginId(String originId, String origin);
}

19
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java

@ -19,6 +19,7 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.NumConstant;
@ -38,6 +39,7 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.scan.param.TextScanParamDTO;
import com.epmet.commons.tools.scan.param.TextTaskDTO;
import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
@ -113,6 +115,8 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
private String textSyncScanMethod;
@Autowired
private GovProjectOpenFeignClient govProjectOpenFeignClient;
@Autowired
private LoginUserUtil loginUserUtil;
@Override
@ -467,6 +471,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
* @param serviceType
* @return
*/
@Override
public ServerInfoDTO queryServiceName(String serverId, String serviceType) {
String serviceName="";
String mobile="";
@ -515,6 +520,20 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl<IcUserDemandRecD
return serverInfoDTO;
}
@Override
public Integer deleteByOriginId(String originId, String origin) {
if(StringUtils.isBlank(originId) || StringUtils.isBlank(origin)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误","参数错误");
}
LambdaUpdateWrapper<IcUserDemandRecEntity> wrapper = new LambdaUpdateWrapper();
wrapper.eq(IcUserDemandRecEntity::getOriginId, originId)
.eq(IcUserDemandRecEntity::getOrigin,origin)
.set(IcUserDemandRecEntity::getUpdatedTime,new Date())
.set(IcUserDemandRecEntity::getCreatedBy,loginUserUtil.getLoginUserId())
.set(IcUserDemandRecEntity::getDelFlag,NumConstant.ONE_STR);
return baseDao.update(null, wrapper);
}
/**
* 完成并评价
*

46
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/enums/ProjectOriginEnum.java

@ -0,0 +1,46 @@
package com.epmet.enums;
/**
* 项目来源枚举
* @author liujianjun
*/
public enum ProjectOriginEnum {
/**
* 项目来源
*/
ISSUE("issue", "议题上报"),
AGENCY("agency", "直接立项"),
WORK_EVENT("work_event", "巡查上报"),
IC_EVENT("ic_event", "居民上报"),
RESI_EVENT("resi_event", "旧的居民上报(已废弃)");
private String code;
private String name;
ProjectOriginEnum(String code, String name) {
this.code = code;
this.name = name;
}
/**
* 根据sourceType查询对应的枚举对象
* @param code
* @return
*/
public static ProjectOriginEnum getEnumByCode(String code) {
for (ProjectOriginEnum e : ProjectOriginEnum.values()) {
if (e.getCode().equals(code)) {
return e;
}
}
return null;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
}

11
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectService.java

@ -397,4 +397,13 @@ public interface ProjectService extends BaseService<ProjectEntity> {
List<ProjectDTO> staffPendingProject(ProjectListFromDTO fromDTO);
PageData<OrgProjectListResultDTO> orgProjectList(OrgProjectListFormDTO formDTO);
}
/**
* desc:根据来源id和类型 删除项目 只删了主表
* @param originId
* @param origin
* @return
*/
Integer deleteByOriginId(String originId, String origin);
}

28
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.*;
@ -19,6 +20,7 @@ import com.epmet.commons.tools.scan.param.ImgTaskDTO;
import com.epmet.commons.tools.scan.param.TextScanParamDTO;
import com.epmet.commons.tools.scan.param.TextTaskDTO;
import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.*;
import com.epmet.constant.*;
import com.epmet.dao.IcEventDao;
@ -29,6 +31,7 @@ import com.epmet.dto.form.demand.IcEventCommentToDemandFromDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.*;
import com.epmet.enums.EcEventProcessStatusEnum;
import com.epmet.enums.ProjectOriginEnum;
import com.epmet.feign.*;
import com.epmet.resi.group.constant.TopicConstant;
import com.epmet.service.*;
@ -94,6 +97,8 @@ public class IcEventServiceImpl extends BaseServiceImpl<IcEventDao, IcEventEntit
private EpmetMessageOpenFeignClient messageOpenFeignClient;
@Autowired
private ProjectSatisfactionDetailService projectSatisfactionDetailService;
@Autowired
private LoginUserUtil loginUserUtil;
public CustomerStaffInfoCacheResult getStaffInfo(String customerId,String staffId){
@ -407,8 +412,27 @@ public class IcEventServiceImpl extends BaseServiceImpl<IcEventDao, IcEventEntit
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
//已立项、已转服务的事件删除时,同时删除关联的服务和项目
for (String id : ids) {
IcEventEntity entity = baseDao.selectById(id);
if (null == entity){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"数据不存在","数据不存在");
}
//1:已转项目 2:已转需求
if (NumConstant.ONE_STR.equals(entity.getOperationType())){
ProjectService projectService = SpringContextUtils.getBean(ProjectService.class);
Integer effectRow = projectService.deleteByOriginId(entity.getId(), ProjectOriginEnum.IC_EVENT.getCode());
log.info("delete project effectRow:{},eventId:{}", effectRow, id);
} else if (NumConstant.TWO_STR.equals(entity.getOperationType())){
Result<Integer> effectRow = epmetHeartOpenFeignClient.deleteUserDemandByOriginId(entity.getId(), ProjectOriginEnum.IC_EVENT.getCode());
log.info("delete userDemand result:{},eventId:{}", effectRow, id);
}
LambdaUpdateWrapper<IcEventEntity> wrapper = new LambdaUpdateWrapper();
wrapper.eq(IcEventEntity::getId,id).set(IcEventEntity::getUpdatedTime,new Date())
.set(IcEventEntity::getCreatedBy,loginUserUtil.getLoginUserId())
.set(IcEventEntity::getDelFlag,NumConstant.ONE_STR);
baseDao.update(null,wrapper);
}
}
/**

12
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

@ -20,6 +20,7 @@ package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg;
@ -3562,5 +3563,16 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
return new PageData<>(list, pageInfo.getTotal());
}
@Override
public Integer deleteByOriginId(String originId, String origin) {
LambdaUpdateWrapper<ProjectEntity> wrapper = new LambdaUpdateWrapper();
wrapper.eq(ProjectEntity::getOriginId, originId)
.eq(ProjectEntity::getOrigin,origin)
.set(ProjectEntity::getUpdatedTime,new Date())
.set(ProjectEntity::getCreatedBy,loginUserUtil.getLoginUserId())
.set(ProjectEntity::getDelFlag,NumConstant.ONE_STR);
return baseDao.update(null, wrapper);
}
}

6
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataOrgChangeEventListener.java

@ -6,7 +6,6 @@ import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils;
@ -106,12 +105,9 @@ public class OpenDataOrgChangeEventListener implements MessageListenerConcurrent
SpringContextUtils.getBean(GridInfoPingyinService.class).exractGrid(extractFormDto);
}
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
logger.warn("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e;
} finally {
distributedLock.unLock(lock);

6
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java

@ -9,7 +9,6 @@ import com.epmet.commons.tools.distributedlock.DistributedLock;
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.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils;
@ -109,12 +108,9 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"消费失败!");
}
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-巡查记录信息变更-失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-巡查记录信息变更-失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
logger.warn("【开放数据事件监听器】-巡查记录信息变更-失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e;
} finally {
distributedLock.unLock(lock);

6
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java

@ -5,7 +5,6 @@ import com.epmet.commons.rocketmq.constants.MQUserPropertys;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -77,12 +76,9 @@ public class OpenDataProjectChangeEventListener implements MessageListenerConcur
30L, 30L, TimeUnit.SECONDS);
//SpringContextUtils.getBean(BaseDisputeProcessService.class).getEventinfo(formDTO);
SpringContextUtils.getBean(EventreportPingyinService.class).getEventInfo(formDTO);
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
logger.warn("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e;
} finally {
distributedLock.unLock(lock);

8
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataStaffChangeEventListener.java

@ -6,12 +6,10 @@ import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO;
import com.epmet.opendata.service.ExUserService;
import com.epmet.opendata.service.GridstaffInfoPingyinService;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
@ -22,7 +20,6 @@ import org.redisson.api.RLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -90,12 +87,9 @@ public class OpenDataStaffChangeEventListener implements MessageListenerConcurre
SpringContextUtils.getBean(ExUserService.class).getStaffBaseInfo(dto);*/
dto.setStaffIdList(obj.getStaffIdList());
SpringContextUtils.getBean(GridstaffInfoPingyinService.class).getStaffBaseInfo(dto);
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
logger.warn("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e;
} finally {
distributedLock.unLock(lock);

3
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/EventreportPingyinServiceImpl.java

@ -21,7 +21,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -135,7 +134,7 @@ public class EventreportPingyinServiceImpl extends BaseServiceImpl<EventreportPi
entity.setLng(item.getLng());
entity.setLat(item.getLat());
entity.setIsDel("N");
entity.setUpdateTime(new Date());
entity.setUpdateTime(null);
//业务不包含 一级分类里 如果是03 矛盾纠纷 则涉及人数写2(目前业务不支持 所以应产品需求 填2)
if ("03".equals(item.getParentEventCategory())) {

11
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridInfoPingyinServiceImpl.java

@ -32,7 +32,6 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -187,7 +186,7 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD
entity.setGridName(ag.getGridName());
entity.setGridLevel("07");
entity.setIsDel("N");
entity.setUpdateTime(new Date());
entity.setUpdateTime(null);
if (ag.getLatitude().length() > 10) {
entity.setLat(new BigDecimal(ag.getLatitude().substring(0, 10)));
} else {
@ -256,7 +255,7 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD
if (StringUtils.isNotBlank(formDTO.getOldCode()) && !formDTO.getOldCode().equals(entity.getGridCode())){
GridInfoPingyinEntity gridInfoEntity = new GridInfoPingyinEntity();
gridInfoEntity.setGridCode(entity.getGridCode());
gridInfoEntity.setUpdateTime(new Date());
gridInfoEntity.setUpdateTime(null);
LambdaUpdateWrapper<GridInfoPingyinEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(GridInfoPingyinEntity::getGridCode,formDTO.getOldCode());
int update = baseDao.update(gridInfoEntity, updateWrapper);
@ -265,7 +264,7 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD
GridstaffInfoPingyinEntity staffInfo = new GridstaffInfoPingyinEntity();
staffInfo.setGridCode(entity.getGridCode());
staffInfo.setUpdateTime(new Date());
staffInfo.setUpdateTime(null);
LambdaUpdateWrapper<GridstaffInfoPingyinEntity> staffInfoWrapper = new LambdaUpdateWrapper<>();
staffInfoWrapper.eq(GridstaffInfoPingyinEntity::getGridCode,formDTO.getOldCode());
@ -274,7 +273,7 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD
GridstaffWorkInfoPingyinEntity workInfo = new GridstaffWorkInfoPingyinEntity();
workInfo.setGridCode(entity.getGridCode());
workInfo.setUpdateTime(new Date());
workInfo.setUpdateTime(null);
LambdaUpdateWrapper<GridstaffWorkInfoPingyinEntity> workInfoWrapper = new LambdaUpdateWrapper<>();
workInfoWrapper.eq(GridstaffWorkInfoPingyinEntity::getGridCode,formDTO.getOldCode());
@ -283,7 +282,7 @@ public class GridInfoPingyinServiceImpl extends BaseServiceImpl<GridInfoPingyinD
EventreportPingyinEntity eventEntity = new EventreportPingyinEntity();
eventEntity.setGridCode(entity.getGridCode());
eventEntity.setUpdateTime(new Date());
eventEntity.setUpdateTime(null);
LambdaUpdateWrapper<EventreportPingyinEntity> eventWrapper = new LambdaUpdateWrapper<>();
eventWrapper.eq(EventreportPingyinEntity::getGridCode,formDTO.getOldCode());

9
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffInfoPingyinServiceImpl.java

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CustomerGridStaffListFormDTO;
import com.epmet.dto.form.GridStaffUploadtFormDTO;
@ -21,12 +20,12 @@ import com.epmet.opendata.entity.GridstaffInfoPingyinEntity;
import com.epmet.opendata.service.GridstaffInfoPingyinService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -130,11 +129,15 @@ public class GridstaffInfoPingyinServiceImpl extends BaseServiceImpl<GridstaffIn
entity.setLeaveDate(r.getLeaveDate());
entity.setGridUserId(r.getStaffId());
entity.setCardNum(r.getIdCard());
if (StringUtils.isBlank(r.getIdCard())){
log.warn("getStaffBaseInfo 身份证号是空的,{}", JSON.toJSONString(entity));
return;
}
//按网格查询人员是否存在,存在更新否则新增
GridstaffInfoPingyinEntity gs = baseDao.selectByCodeAndStaffId(r.getCode(), r.getStaffId());
log.info(String.format("网格工作人员信息同步,当前操作人员信息,姓名:%s staffId:%s", entity.getNickName(), entity.getGridUserId()));
if (null != gs) {
entity.setUpdateTime(new Date());
entity.setUpdateTime(null);
baseDao.edit(entity);
} else {
insert(entity);

6
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java

@ -73,6 +73,10 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl<Gridsta
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode());
}
data.forEach(d -> {
if (StringUtils.isBlank(d.getGridId())){
log.warn("data is null string:{}",JSON.toJSONString(d));
return;
}
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(d.getGridId());
if (null == gridInfo) {
log.warn("未查询到网格信息:" + d.getGridId());
@ -131,7 +135,7 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl<Gridsta
entity.setWorkResult(NumConstant.ONE == record.getIsNormal() ? "Y" : "N");
entity.setWorkType(record.getWorkTypeSecondCode());
entity.setRecoredInsertTime(record.getCreatedTime());
entity.setUpdateTime(record.getUpdatedTime());
entity.setUpdateTime(null);
entity.setId(null);
entity.setIsDel("N");
return entity;

4
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/EventreportPingyinDao.xml

@ -40,8 +40,8 @@
<result property="recoredInsertTime" column="recored_insert_time"/>
</resultMap>
<delete id="deleteAllData">
DELETE FROM eventreport_pingyin
update eventreport_pingyin SET is_del = 'Y'
</delete>
</mapper>
</mapper>

9
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/GridInfoPingyinDao.xml

@ -4,12 +4,12 @@
<mapper namespace="com.epmet.opendata.dao.GridInfoPingyinDao">
<delete id="deleteAllAgencyData">
delete from grid_info_pingyin where grid_level !='07'
update grid_info_pingyin set is_del = 'Y' where grid_level !='07'
</delete>
<delete id="deleteAllGridData">
delete from grid_info_pingyin where grid_level ='07'
update grid_info_pingyin set is_del = 'Y' where grid_level ='07'
</delete>
<select id="selectByGridCode" parameterType="java.lang.String" resultType="com.epmet.opendata.entity.GridInfoPingyinEntity">
@ -22,13 +22,12 @@
set grid_name = #{gridName},
grid_level = #{gridLevel},
lng = #{lng},
lat = #{lat},
update_time = now()
lat = #{lat}
where grid_code = #{gridCode} and is_del = 'N'
</update>
<update id="deleteByCode">
update grid_info_pingyin set is_del = 'Y',update_time = now()
update grid_info_pingyin set is_del = 'Y'
where grid_code = #{gridCode}
</update>
</mapper>

4
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/GridstaffInfoPingyinDao.xml

@ -16,7 +16,7 @@
</update>
<delete id="del">
delete from gridstaff_info_pingyin
UPDATE gridstaff_info_pingyin set IS_LEAVE = 'Y'
</delete>
<select id="selectByCodeAndStaffId" resultType="com.epmet.opendata.entity.GridstaffInfoPingyinEntity">
@ -35,4 +35,4 @@
LIMIT 1
</select>
</mapper>
</mapper>

4
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/GridstaffWorkInfoPingyinDao.xml

@ -19,8 +19,8 @@
<result property="recoredInsertTime" column="recored_insert_time"/>
</resultMap>
<delete id="delAllGridStaffWorkInfoPY">
delete from gridstaff_work_info_pingyin LIMIT 1000
update gridstaff_work_info_pingyin SET is_del = 'Y' LIMIT 1000
</delete>
</mapper>
</mapper>

40
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java

@ -55,6 +55,8 @@ import java.nio.file.Path;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -390,21 +392,20 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
List<List<String>> idParts = ListUtils.partition(idList, 100);
// 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了)
//CountDownLatch cdl = new CountDownLatch(idParts.size());
CountDownLatch cdl = new CountDownLatch(idParts.size());
for (List<String> idPart : idParts) {
downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files);
//CompletableFuture.runAsync(() -> {
// downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl);
//}, executorService);
CompletableFuture.runAsync(() -> {
downloadXlsByBatchByBizId(reportId, idPart, param, xlsxStorePath, files, cdl);
}, executorService);
}
// 等待多线程执行完成,再执行打包
//try {
// cdl.await();
//} catch (InterruptedException e) {
// log.error(ExceptionUtils.getErrorStackTrace(e));
// throw new EpmetException("【报表批量导出】CountDownLatch等待被中断");
//}
try {
cdl.await();
} catch (InterruptedException e) {
log.error(ExceptionUtils.getErrorStackTrace(e));
throw new EpmetException("【报表批量导出】CountDownLatch等待被中断");
}
// 2,打包
Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip");
@ -472,20 +473,9 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
* @param xlsxStorePath
* @param files
*/
public void downloadXlsByBatchByBizId(String reportId, List<String> bizIds, Map<String, String> idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map<String, File> files) {
public void downloadXlsByBatchByBizId(String reportId, List<String> bizIds, JimuReportExportRequestDTO param,
Path xlsxStorePath, Map<String, File> files, CountDownLatch cdl) {
for (String id : bizIds) {
try {
Thread.sleep(200l);
} catch (InterruptedException e) {
final String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【报表批量导出】循环导出-请求jmreport,等待过程中睡眠发生意外:{}", errorMsg);
}
//if (!Arrays.asList("1501821697823608834","1501821694665297922","1501821695114088450","1501821695177003009","1501821695269277697","1501821695344775169","1501821695579656193","1501821695676125186","1501821695755816962","1501821695843897346","1501821695978115074","1501821696108138497","1501821696179441665","1501821696229773313","1501821696284299266","1501821696334630913","1501821696393351170","1501821696452071426","1501821696502403073","1501821696582094849","1501821696645009409","1501821696758255617","1501821696871501826","1501821696917639169","1501821696955387906","1501821696993136641","1501821697135742977","1501821697181880321","1501821697232211969","1501821697274155009").contains(id)) {
// continue;
//}
param.getQueryParam().setId(id);
final Response response = jiMuReportOpenFeignClient.exportAllExcelStream(param);
// 取出文件后缀
@ -506,7 +496,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
}
}
//cdl.countDown();
cdl.countDown();
}
/**

7
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

@ -158,6 +158,12 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
IcPartymemberStyleEntity entity = baseDao.selectById(id);
IcPartymemberStyleDTO dto = ConvertUtils.sourceToTarget(entity, IcPartymemberStyleDTO.class);
dto.setImageList(icPartymemberStyleImageService.getByStyleId(id));
GridInfoCache gridInfoCache = CustomerOrgRedis.getGridInfo(dto.getGridId());
if (null != gridInfoCache) {
dto.setGridName(gridInfoCache.getGridName());
}
IcPartymemberStyleCategoryDictEntity dict = icPartymemberStyleCategoryDictService.get(dto.getCategoryId());
dto.setCategoryName(null == dict ? StrConstant.EPMETY_STR : dict.getCategoryName());
return dto;
}
@ -240,6 +246,7 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
item.setGridName(gridInfo.getGridName());
IcPartymemberStyleCategoryDictEntity dict = icPartymemberStyleCategoryDictService.get(item.getCategoryId());
item.setCategoryName(null == dict ? StrConstant.EPMETY_STR : dict.getCategoryName());
item.setImageList(icPartymemberStyleImageService.getByStyleId(item.getId()));
}
});
return new PageData<>(dtoList, pageInfo.getTotal());

39
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/DhTokenDTO.java

@ -0,0 +1,39 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 大华设备鉴权信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-04-22
*/
@Data
public class DhTokenDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* loginName
*/
private String loginName;
/**
* token
*/
private String token;
/**
* publicKey
*/
private String publicKey;
}

184
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccinePrarmeterDTO.java

@ -0,0 +1,184 @@
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-08-22
*/
@Data
public class IcVaccinePrarmeterDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 客户Id customer.id
*/
private String customerId;
/**
* 网格ID
*/
private String gridId;
/**
* 网格名称
*/
private String gridName;
/**
* 组织Id
*/
private String agencyId;
/**
* 组织的pids
*/
private String pids;
/**
* 所属小区ID
*/
private String villageId;
/**
* 所属小区名称
*/
private String villageName;
/**
* 所属楼宇Id
*/
private String buildId;
/**
* 所属楼宇名称
*/
private String buildName;
/**
* 单元id
*/
private String unitId;
/**
* 单元名
*/
private String unitName;
/**
* 所属家庭Id
*/
private String homeId;
/**
* 房间名
*/
private String homeName;
/**
* 户口性质0户籍 1外来
*/
private String householdType;
/**
* 姓名
*/
private String name;
/**
* 联系电话
*/
private String mobile;
/**
* 身份证号
*/
private String idCard;
/**
* 是否接种0否1是
*/
private String isVaccination;
/**
* 第一次接种时间
*/
private String firstVacTime;
/**
* 第一次接种地点
*/
private String firstVacSite;
/**
* 第二次接种时间
*/
private String secondVacTime;
/**
* 第二次接种地点
*/
private String secondVacSite;
/**
* 第三次接种时间
*/
private String thirdVacTime;
/**
* 第三次接种地点
*/
private String thirdVacSite;
/**
* 原因禁忌症/拒绝接种/其他原因
*/
private String reason;
/**
* 备注
*/
private String note;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

8
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/SaveCollectVisitorFormDTO.java

@ -52,43 +52,36 @@ public class SaveCollectVisitorFormDTO implements Serializable {
/**
* 所属楼宇Id
*/
@NotBlank(message = "楼宇Id不能为空")
private String buildId;
/**
* 所属楼宇名称
*/
@NotBlank(message = "楼宇名称不能为空")
private String buildName;
/**
* 单元id
*/
@NotBlank(message = "单元id不能为空")
private String unitId;
/**
* 单元名
*/
@NotBlank(message = "单元名不能为空")
private String unitName;
/**
* 所属家庭Id
*/
@NotBlank(message = "家庭Id不能为空")
private String homeId;
/**
* 房间名
*/
@NotBlank(message = "房间名不能为空")
private String homeName;
/**
* 详细地址
*/
@NotBlank(message = "家庭地址不能为空")
private String address;
/**
@ -106,6 +99,7 @@ public class SaveCollectVisitorFormDTO implements Serializable {
/**
* 身份证号
*/
@NotBlank(message = "身份证号不能为空")
private String idCard;
/**

27
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhAuthFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.form;
import com.epmet.dto.result.DhChannelResultDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhAuthFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String cardNumber;
private String timeQuantumId;
private List<DhChannelResultDTO> cardPrivilegeDetails;
}

29
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhCardPageFormDTO.java

@ -0,0 +1,29 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhCardPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private String personCode;
private String cardNumber;
private String cardStatus;
}

23
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhChannelFormDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhChannelFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String interfaceId;
private String jsonParam;
}

25
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhChannelPageFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhChannelPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private String deviceGenre;
}

25
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhDeptFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhDeptFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String description;
private Long parentId;
}

29
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhIdentityFormDTO.java

@ -0,0 +1,29 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhIdentityFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private Double subsidyAmount;
private Integer isCashRecharge;
private Integer isMachineRecharge;
private String description;
}

23
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhLoginPassFormDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhLoginPassFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String loginName;
private String loginPass;
}

23
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhNodeFormDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhNodeFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String typeCode;
private String nodeId;
}

39
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonCardFormDTO.java

@ -0,0 +1,39 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonCardFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long personId;
private String personName;
private String cardNumber;
private String cardType;
private String category;
private String cardStatus;
private String startDate;
private String endDate;
private String cardPassword;
private String subSystems;
}

22
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonCardListFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonCardListFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private List<DhPersonCardFormDTO> objectList;
}

22
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonDelFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonDelFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private List<Integer> personIds;
}

39
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonFormDTO.java

@ -0,0 +1,39 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String paperType;
private String paperNumber;
private String name;
private String code;
private Long deptId;
private String sex;
private String birthday;
private String phone;
private String status;
private String personIdentityId;
}

23
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonImgFormDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonImgFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String personCode;
private String base64file;
}

25
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPersonPageFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private String code;
}

27
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPlanFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPlanFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String detail;
private String memo;
private String name;
private Integer type;
}

25
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPlanPageFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPlanPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private String singleCondition;
}

21
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DhPublicKeyFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPublicKeyFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String loginName;
}

14
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitListFormDTO.java

@ -23,4 +23,18 @@ public class VisitListFormDTO extends PageFormDTO {
private String orgId;
private String idCard;
private String name;
private String villageId;
private String buildId;
private String unitId;
private String homeId;
private String mobile;
}

24
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitVisitorChartFormDTO.java

@ -0,0 +1,24 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 租客表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-07-26
*/
@Data
public class VisitVisitorChartFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 时间
*/
private String date;
}

51
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitVisitorFormDTO.java

@ -0,0 +1,51 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 租客表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-07-26
*/
@Data
public class VisitVisitorFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 姓名
*/
@NotBlank(message = "姓名不能为空",groups = {AddGroup.class, DefaultGroup.class})
private String name;
/**
* 身份证
*/
@NotBlank(message = "身份证号不能为空",groups = {AddGroup.class, DefaultGroup.class})
private String idCard;
/**
* 手机号
*/
@NotBlank(message = "联系方式不能为空",groups = {AddGroup.class, DefaultGroup.class})
private String mobile;
/**
* 头像
*/
private String faceImg;
/**
* 节点
*/
private String node;
}

14
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VisitorInfoFormDTO.java

@ -0,0 +1,14 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
@Data
public class VisitorInfoFormDTO implements Serializable {
private String userId;
private String customerId;
}

23
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/DhChannelResultDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhChannelResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String privilegeType;
private String resouceCode;
}

30
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VisitVisitorChartResultDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 租客表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-07-26
*/
@Data
public class VisitVisitorChartResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 时间
*/
private String hour;
/**
* 数量
*/
private String num;
}

80
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectVisitorController.java

@ -1,7 +1,6 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.MaskResponse;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -14,10 +13,8 @@ import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IcResiCollectVisitorDTO;
import com.epmet.dto.SaveCollectVisitorFormDTO;
import com.epmet.dto.form.CollectDetailFormDTO;
import com.epmet.dto.form.CollectListFormDTO;
import com.epmet.dto.form.VisitListFormDTO;
import com.epmet.dto.result.CollectListResultDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.VisitVisitorChartResultDTO;
import com.epmet.excel.IcResiCollectVisitorExcel;
import com.epmet.service.IcResiCollectVisitorService;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,7 +39,7 @@ public class IcResiCollectVisitorController {
private IcResiCollectVisitorService icResiCollectVisitorService;
@RequestMapping("page")
public Result<PageData<IcResiCollectVisitorDTO>> page(@RequestParam Map<String, Object> params){
public Result<PageData<IcResiCollectVisitorDTO>> page(@RequestParam Map<String, Object> params) {
// PageData<IcResiCollectVisitorDTO> page = icResiCollectVisitorService.page(params);
PageData<IcResiCollectVisitorDTO> page = icResiCollectVisitorService.getPhrasePage(params);
return new Result<PageData<IcResiCollectVisitorDTO>>().ok(page);
@ -52,6 +49,7 @@ public class IcResiCollectVisitorController {
/**
* Desc: 访客记录列表
*
* @param formDTO
* @param tokenDto
* @author wgf
@ -60,22 +58,22 @@ public class IcResiCollectVisitorController {
@PostMapping("list")
// @MaskResponse(fieldNames = { "memberIdNum", "memberMobile" },
// fieldsMaskType = { MaskResponse.MASK_TYPE_ID_CARD, MaskResponse.MASK_TYPE_MOBILE })
public Result<PageData<IcResiCollectVisitorDTO>> getVisitorList(@RequestBody VisitListFormDTO formDTO, @LoginUser TokenDto tokenDto){
ValidatorUtils.validateEntity(formDTO,CollectListFormDTO.CollectListForm.class);
public Result<PageData<IcResiCollectVisitorDTO>> getVisitorList(@RequestBody VisitListFormDTO formDTO, @LoginUser TokenDto tokenDto) {
ValidatorUtils.validateEntity(formDTO, CollectListFormDTO.CollectListForm.class);
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCustomerId(tokenDto.getCustomerId());
return new Result<PageData<IcResiCollectVisitorDTO>>().ok(icResiCollectVisitorService.getVisitorList(formDTO));
}
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET})
public Result<IcResiCollectVisitorDTO> get(@PathVariable("id") String id){
@RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET})
public Result<IcResiCollectVisitorDTO> get(@PathVariable("id") String id) {
IcResiCollectVisitorDTO data = icResiCollectVisitorService.get(id);
return new Result<IcResiCollectVisitorDTO>().ok(data);
}
@NoRepeatSubmit
@PostMapping("save")
public Result save(@RequestBody IcResiCollectVisitorDTO dto){
public Result save(@RequestBody IcResiCollectVisitorDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
icResiCollectVisitorService.save(dto);
@ -84,7 +82,7 @@ public class IcResiCollectVisitorController {
@NoRepeatSubmit
@PostMapping("update")
public Result update(@RequestBody IcResiCollectVisitorDTO dto){
public Result update(@RequestBody IcResiCollectVisitorDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
icResiCollectVisitorService.update(dto);
@ -92,7 +90,7 @@ public class IcResiCollectVisitorController {
}
@PostMapping("delete")
public Result delete(@RequestBody String[] ids){
public Result delete(@RequestBody String[] ids) {
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
icResiCollectVisitorService.delete(ids);
@ -106,32 +104,62 @@ public class IcResiCollectVisitorController {
}
/**
* @describe: 保存访客信息
* @author wangtong
* @date 2022/8/3 10:33
* @params [dto]
* @return com.epmet.commons.tools.utils.Result
*/
* @return com.epmet.commons.tools.utils.Result
* @describe: 保存访客信息
* @author wangtong
* @date 2022/8/3 10:33
* @params [dto]
*/
@NoRepeatSubmit
@PostMapping("saveInfo")
public Result saveInfo(@RequestBody SaveCollectVisitorFormDTO dto){
public Result saveInfo(@RequestBody SaveCollectVisitorFormDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto);
return icResiCollectVisitorService.saveInfo(dto);
}
/**
* @describe: 访客信息详情
* @author wangtong
* @date 2022/8/3 15:41
* @params [dto]
* @return com.epmet.commons.tools.utils.Result
*/
* @return com.epmet.commons.tools.utils.Result
* @describe: 访客信息详情
* @author wangtong
* @date 2022/8/3 15:41
* @params [dto]
*/
@PostMapping("getVisitorDetail")
public Result getVisitorDetail(@RequestBody CollectDetailFormDTO dto) {
ValidatorUtils.validateEntity(dto);
return icResiCollectVisitorService.getVisitorDetail(dto);
}
/**
* 登陆访客用户信息
*
* @param tokenDto
* @param dto
* @return com.epmet.commons.tools.utils.Result
* @author zhy
* @date 2022/8/19 15:24
*/
@PostMapping("visitorinfo")
public Result getVisitorInfo(@LoginUser TokenDto tokenDto, @RequestBody VisitorInfoFormDTO dto) {
ValidatorUtils.validateEntity(dto);
return icResiCollectVisitorService.getVisitorInfo(tokenDto, dto);
}
/**
* 访客折线图
*
* @param dto
* @return com.epmet.commons.tools.utils.Result<java.util.List<VisitVisitorChartResultDTO>>
* @author zhy
* @date 2022/8/22 9:56
*/
@NoRepeatSubmit
@PostMapping("chart/traffic")
public Result<List<VisitVisitorChartResultDTO>> getTraffic(@RequestBody VisitVisitorChartFormDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
return new Result<List<VisitVisitorChartResultDTO>>().ok(icResiCollectVisitorService.getTraffic(dto));
}
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -560,7 +560,7 @@ public class IcResiUserController implements ResultDataResolver {
* @remark 用于报表调用的接口 试试
*/
@ReportRequest
@NoRepeatSubmit
//@NoRepeatSubmit
@RequestMapping(value = "/exportExcelCustomData")
public Map<String, Object> exportExcelCustomData(@LoginUser TokenDto tokenDto, @RequestParam("templateId") String templateId,
@RequestBody ExportResiUserFormDTO pageFormDTO) throws Exception {

82
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccinePrarmeterController.java

@ -0,0 +1,82 @@
package com.epmet.controller;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.IcVaccinePrarmeterDTO;
import com.epmet.excel.IcVaccinePrarmeterExcel;
import com.epmet.service.IcVaccinePrarmeterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 新冠病毒疫苗接种人员信息台账
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-08-22
*/
@RestController
@RequestMapping("icVaccinePrarmeter")
public class IcVaccinePrarmeterController {
@Autowired
private IcVaccinePrarmeterService icVaccinePrarmeterService;
@RequestMapping("page")
public Result<PageData<IcVaccinePrarmeterDTO>> page(@RequestParam Map<String, Object> params){
PageData<IcVaccinePrarmeterDTO> page = icVaccinePrarmeterService.page(params);
return new Result<PageData<IcVaccinePrarmeterDTO>>().ok(page);
}
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET})
public Result<IcVaccinePrarmeterDTO> get(@PathVariable("id") String id){
IcVaccinePrarmeterDTO data = icVaccinePrarmeterService.get(id);
return new Result<IcVaccinePrarmeterDTO>().ok(data);
}
@NoRepeatSubmit
@PostMapping("save")
public Result save(@RequestBody IcVaccinePrarmeterDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
icVaccinePrarmeterService.save(dto);
return new Result();
}
@NoRepeatSubmit
@PutMapping("update")
public Result update(@RequestBody IcVaccinePrarmeterDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
icVaccinePrarmeterService.update(dto);
return new Result();
}
@PostMapping("delete")
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
icVaccinePrarmeterService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<IcVaccinePrarmeterDTO> list = icVaccinePrarmeterService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, IcVaccinePrarmeterExcel.class);
}
}

27
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectVisitorDao.java

@ -2,9 +2,10 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IcResiCollectVisitorDTO;
import com.epmet.dto.form.CollectListFormDTO;
import com.epmet.dto.form.VisitListFormDTO;
import com.epmet.dto.result.CollectListResultDTO;
import com.epmet.dto.form.VisitVisitorChartFormDTO;
import com.epmet.dto.form.VisitorInfoFormDTO;
import com.epmet.dto.result.VisitVisitorChartResultDTO;
import com.epmet.entity.IcResiCollectVisitorEntity;
import org.apache.ibatis.annotations.Mapper;
@ -22,6 +23,7 @@ public interface IcResiCollectVisitorDao extends BaseDao<IcResiCollectVisitorEnt
/**
* 条件查询
*
* @param params
* @return
*/
@ -29,10 +31,31 @@ public interface IcResiCollectVisitorDao extends BaseDao<IcResiCollectVisitorEnt
/**
* Desc: 查询访客信息
*
* @param formDTO
* @author wgf
* @date 2022/8/5 8:41
*/
List<IcResiCollectVisitorDTO> getCollectList(VisitListFormDTO formDTO);
/**
* 最新一条访客信息
*
* @param formDTO
* @return com.epmet.entity.IcResiCollectVisitorEntity
* @author zhy
* @date 2022/8/19 15:33
*/
IcResiCollectVisitorEntity getLastInfo(VisitorInfoFormDTO formDTO);
/**
* 人流量
*
* @param dto
* @return void
* @author generator
* @date 2022-07-26
*/
List<VisitVisitorChartResultDTO> getTraffic(VisitVisitorChartFormDTO dto);
}

16
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccinePrarmeterDao.java

@ -0,0 +1,16 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.IcVaccinePrarmeterEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 新冠病毒疫苗接种人员信息台账
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-08-22
*/
@Mapper
public interface IcVaccinePrarmeterDao extends BaseDao<IcVaccinePrarmeterEntity> {
}

154
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccinePrarmeterEntity.java

@ -0,0 +1,154 @@
package com.epmet.entity;
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-08-22
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ic_vaccine_prarmeter")
public class IcVaccinePrarmeterEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id customer.id
*/
private String customerId;
/**
* 网格ID
*/
private String gridId;
/**
* 网格名称
*/
private String gridName;
/**
* 组织Id
*/
private String agencyId;
/**
* 组织的pids
*/
private String pids;
/**
* 所属小区ID
*/
private String villageId;
/**
* 所属小区名称
*/
private String villageName;
/**
* 所属楼宇Id
*/
private String buildId;
/**
* 所属楼宇名称
*/
private String buildName;
/**
* 单元id
*/
private String unitId;
/**
* 单元名
*/
private String unitName;
/**
* 所属家庭Id
*/
private String homeId;
/**
* 房间名
*/
private String homeName;
/**
* 户口性质0户籍 1外来
*/
private String householdType;
/**
* 姓名
*/
private String name;
/**
* 联系电话
*/
private String mobile;
/**
* 身份证号
*/
private String idCard;
/**
* 是否接种0否1是
*/
private String isVaccination;
/**
* 第一次接种时间
*/
private String firstVacTime;
/**
* 第一次接种地点
*/
private String firstVacSite;
/**
* 第二次接种时间
*/
private String secondVacTime;
/**
* 第二次接种地点
*/
private String secondVacSite;
/**
* 第三次接种时间
*/
private String thirdVacTime;
/**
* 第三次接种地点
*/
private String thirdVacSite;
/**
* 原因禁忌症/拒绝接种/其他原因
*/
private String reason;
/**
* 备注
*/
private String note;
}

117
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcVaccinePrarmeterExcel.java

@ -0,0 +1,117 @@
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 新冠病毒疫苗接种人员信息台账
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-08-22
*/
@Data
public class IcVaccinePrarmeterExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "客户Id customer.id")
private String customerId;
@Excel(name = "网格ID")
private String gridId;
@Excel(name = "网格名称")
private String gridName;
@Excel(name = "组织Id")
private String agencyId;
@Excel(name = "组织的pids")
private String pids;
@Excel(name = "所属小区ID;")
private String villageId;
@Excel(name = "所属小区名称")
private String villageName;
@Excel(name = "所属楼宇Id")
private String buildId;
@Excel(name = "所属楼宇名称")
private String buildName;
@Excel(name = "单元id")
private String unitId;
@Excel(name = "单元名")
private String unitName;
@Excel(name = "所属家庭Id")
private String homeId;
@Excel(name = "房间名")
private String homeName;
@Excel(name = "户口性质:0户籍 1外来")
private String householdType;
@Excel(name = "姓名")
private String name;
@Excel(name = "联系电话")
private String mobile;
@Excel(name = "身份证号")
private String idCard;
@Excel(name = "是否接种:0否1是")
private String isVaccination;
@Excel(name = "第一次接种时间")
private String firstVacTime;
@Excel(name = "第一次接种地点")
private String firstVacSite;
@Excel(name = "第二次接种时间")
private String secondVacTime;
@Excel(name = "第二次接种地点")
private String secondVacSite;
@Excel(name = "第三次接种时间")
private String thirdVacTime;
@Excel(name = "第三次接种地点")
private String thirdVacSite;
@Excel(name = "原因:禁忌症/拒绝接种/其他原因")
private String reason;
@Excel(name = "备注")
private String note;
@Excel(name = "删除标识 0.未删除 1.已删除")
private Integer delFlag;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
}

30
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/IcVaccinePrarmeterRedis.java

@ -0,0 +1,30 @@
package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 新冠病毒疫苗接种人员信息台账
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-08-22
*/
@Component
public class IcVaccinePrarmeterRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

53
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiCollectVisitorService.java

@ -2,13 +2,15 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcResiCollectVisitorDTO;
import com.epmet.dto.SaveCollectVisitorFormDTO;
import com.epmet.dto.form.CollectDetailFormDTO;
import com.epmet.dto.form.CollectListFormDTO;
import com.epmet.dto.form.VisitListFormDTO;
import com.epmet.dto.result.CollectListResultDTO;
import com.epmet.dto.form.VisitVisitorChartFormDTO;
import com.epmet.dto.form.VisitorInfoFormDTO;
import com.epmet.dto.result.VisitVisitorChartResultDTO;
import com.epmet.entity.IcResiCollectVisitorEntity;
import java.util.List;
@ -34,6 +36,7 @@ public interface IcResiCollectVisitorService extends BaseService<IcResiCollectVi
/**
* 分页条件查询
*
* @param params
* @return
*/
@ -92,20 +95,42 @@ public interface IcResiCollectVisitorService extends BaseService<IcResiCollectVi
void delete(String[] ids);
/**
* @describe: 保存访客信息
* @author wangtong
* @date 2022/8/3 10:44
* @params [dto]
* @return com.epmet.commons.tools.utils.Result
*/
* @return com.epmet.commons.tools.utils.Result
* @describe: 保存访客信息
* @author wangtong
* @date 2022/8/3 10:44
* @params [dto]
*/
Result saveInfo(SaveCollectVisitorFormDTO dto);
/**
* @describe: 访客信息详情
* @author wangtong
* @date 2022/8/3 15:43
* @params [dto]
* @return com.epmet.commons.tools.utils.Result
*/
* @return com.epmet.commons.tools.utils.Result
* @describe: 访客信息详情
* @author wangtong
* @date 2022/8/3 15:43
* @params [dto]
*/
Result getVisitorDetail(CollectDetailFormDTO dto);
/**
* 登陆访客用户信息
*
* @param tokenDto
* @param dto
* @return com.epmet.commons.tools.utils.Result
* @author zhy
* @date 2022/8/19 15:24
*/
Result getVisitorInfo(TokenDto tokenDto, VisitorInfoFormDTO dto);
/**
* 人流量
*
* @param dto
* @return void
* @author generator
* @date 2022-07-26
*/
List<VisitVisitorChartResultDTO> getTraffic(VisitVisitorChartFormDTO dto);
}

78
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccinePrarmeterService.java

@ -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.IcVaccinePrarmeterDTO;
import com.epmet.entity.IcVaccinePrarmeterEntity;
import java.util.List;
import java.util.Map;
/**
* 新冠病毒疫苗接种人员信息台账
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-08-22
*/
public interface IcVaccinePrarmeterService extends BaseService<IcVaccinePrarmeterEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<IcVaccinePrarmeterDTO>
* @author generator
* @date 2022-08-22
*/
PageData<IcVaccinePrarmeterDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<IcVaccinePrarmeterDTO>
* @author generator
* @date 2022-08-22
*/
List<IcVaccinePrarmeterDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return IcVaccinePrarmeterDTO
* @author generator
* @date 2022-08-22
*/
IcVaccinePrarmeterDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2022-08-22
*/
void save(IcVaccinePrarmeterDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2022-08-22
*/
void update(IcVaccinePrarmeterDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2022-08-22
*/
void delete(String[] ids);
}

1
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -794,6 +794,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
resultDTO.setCustomerName(customerResult.getData().getCustomerName());
}
}
redisUtils.delete(userBaseInfoKey);
redisUtils.set(userBaseInfoKey,resultDTO);
return resultDTO;
}

20
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java

@ -31,6 +31,7 @@ import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.IcResiCollectService;
import com.epmet.service.IcUserChangeRecordService;
import com.epmet.util.dh.DhDeviceUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
@ -71,6 +72,8 @@ public class IcResiCollectServiceImpl extends BaseServiceImpl<IcResiCollectDao,
@Autowired
private IcUserChangeRecordService icUserChangeRecordService;
@Autowired
private DhDeviceUtil dhDeviceUtil;
@Override
@Transactional(rollbackFor = Exception.class)
@ -175,7 +178,7 @@ public class IcResiCollectServiceImpl extends BaseServiceImpl<IcResiCollectDao,
}
});
} else {
IcResiCollectEntity collectInfo = baseDao.selectByAddress(formDTO.getAddress());
IcResiCollectEntity collectInfo = baseDao.selectById(formDTO.getId());
//更新主表
baseDao.updateRec(collectInfo.getId(), formDTO.getHouseType(), formDTO.getHouseHolderName(), formDTO.getTotalResi(),null);
List<IcResiMemberEntity> newMemberList = ConvertUtils.sourceToTarget(formDTO.getMemberList(), IcResiMemberEntity.class);
@ -183,6 +186,21 @@ public class IcResiCollectServiceImpl extends BaseServiceImpl<IcResiCollectDao,
Map<String, IcResiMemberEntity> memMap = queryOriginMem(collectInfo.getId());
saveOrUpdateMem(newMemberList, memMap,collectInfo);
}
// 如果是顺德居小区的人还要下放门禁
if (formDTO.getVillageName().contains("顺德居")) {
formDTO.getMemberList().forEach(item -> {
if (StringUtils.isNotBlank(item.getFaceImg())) {
VisitVisitorFormDTO visitor = new VisitVisitorFormDTO();
visitor.setIdCard(item.getIdNum());
visitor.setMobile(item.getMobile());
visitor.setName(item.getName());
visitor.setFaceImg(item.getFaceImg());
dhDeviceUtil.sendAuth(visitor);
}
});
}
return new Result().ok("提交成功");
}

56
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectVisitorServiceImpl.java

@ -8,19 +8,20 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcResiCollectVisitorDao;
import com.epmet.dto.IcNeighborHoodDTO;
import com.epmet.dto.IcResiCollectVisitorDTO;
import com.epmet.dto.SaveCollectVisitorFormDTO;
import com.epmet.dto.form.CollectDetailFormDTO;
import com.epmet.dto.form.CollectListFormDTO;
import com.epmet.dto.form.VisitListFormDTO;
import com.epmet.dto.result.CollectListResultDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.VisitVisitorChartResultDTO;
import com.epmet.entity.IcResiCollectVisitorEntity;
import com.epmet.redis.IcResiCollectVisitorRedis;
import com.epmet.service.IcResiCollectVisitorService;
import com.epmet.util.dh.DhDeviceUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -48,6 +50,12 @@ public class IcResiCollectVisitorServiceImpl extends BaseServiceImpl<IcResiColle
@Autowired
private IcResiCollectServiceImpl icResiCollectServiceImpl;
@Autowired
private LoginUserUtil loginUserUtil;
@Autowired
private DhDeviceUtil dhDeviceUtil;
@Override
public PageData<IcResiCollectVisitorDTO> page(Map<String, Object> params) {
IPage<IcResiCollectVisitorEntity> page = baseDao.selectPage(
@ -59,11 +67,13 @@ public class IcResiCollectVisitorServiceImpl extends BaseServiceImpl<IcResiColle
/**
* 条件查询
*
* @param params
* @return
*/
@Override
public PageData<IcResiCollectVisitorDTO> getPhrasePage(Map<String, Object> params) {
params.put("customerId", loginUserUtil.getLoginUserCustomerId());
IPage<IcResiCollectVisitorDTO> page = getPage(params);
List<IcResiCollectVisitorDTO> list = baseDao.getPhrasePage(params);
return new PageData<>(list, page.getTotal());
@ -71,6 +81,7 @@ public class IcResiCollectVisitorServiceImpl extends BaseServiceImpl<IcResiColle
/**
* Desc: 查询访客信息
*
* @param formDTO
* @author wgf
* @date 2022/8/5 8:23
@ -78,10 +89,10 @@ public class IcResiCollectVisitorServiceImpl extends BaseServiceImpl<IcResiColle
@Override
public PageData<IcResiCollectVisitorDTO> getVisitorList(VisitListFormDTO formDTO) {
PageData<IcResiCollectVisitorDTO> result = new PageData<>(new ArrayList<>(), 0);
if (StringUtils.isBlank(formDTO.getStartTime()) && StringUtils.isBlank(formDTO.getEndTime()) ){
if (StringUtils.isBlank(formDTO.getStartTime()) && StringUtils.isBlank(formDTO.getEndTime())) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId());
if (null == staffInfo){
throw new EpmetException("查询人员信息失败"+formDTO.getUserId());
if (null == staffInfo) {
throw new EpmetException("查询人员信息失败" + formDTO.getUserId());
}
formDTO.setOrgId(staffInfo.getAgencyId());
}
@ -98,8 +109,8 @@ public class IcResiCollectVisitorServiceImpl extends BaseServiceImpl<IcResiColle
return ConvertUtils.sourceToTarget(entityList, IcResiCollectVisitorDTO.class);
}
private QueryWrapper<IcResiCollectVisitorEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<IcResiCollectVisitorEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<IcResiCollectVisitorEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -146,6 +157,16 @@ public class IcResiCollectVisitorServiceImpl extends BaseServiceImpl<IcResiColle
entity.setPids(neighborHoodDTO.getAgencyPids());
entity.setCustomerId(neighborHoodDTO.getCustomerId());
insert(entity);
// 如果是顺德居小区的人还要下放门禁
if (dto.getVillageName().contains("顺德居") && StringUtils.isNotBlank(dto.getFaceImg())) {
VisitVisitorFormDTO visitor = new VisitVisitorFormDTO();
visitor.setMobile(dto.getMobile());
visitor.setName(dto.getName());
visitor.setIdCard(dto.getIdCard());
visitor.setFaceImg(dto.getFaceImg());
dhDeviceUtil.sendAuth(visitor);
}
return new Result().ok("提交成功");
}
@ -155,4 +176,21 @@ public class IcResiCollectVisitorServiceImpl extends BaseServiceImpl<IcResiColle
return new Result().ok(entity);
}
@Override
public Result getVisitorInfo(TokenDto tokenDto, VisitorInfoFormDTO dto) {
dto.setUserId(tokenDto.getUserId());
dto.setCustomerId(tokenDto.getCustomerId());
IcResiCollectVisitorEntity entity = baseDao.getLastInfo(dto);
return new Result().ok(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public List<VisitVisitorChartResultDTO> getTraffic(VisitVisitorChartFormDTO dto) {
if (StringUtils.isBlank(dto.getDate())) {
dto.setDate(LocalDate.now().toString());
}
return baseDao.getTraffic(dto);
}
}

87
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccinePrarmeterServiceImpl.java

@ -0,0 +1,87 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.IcVaccinePrarmeterDao;
import com.epmet.dto.IcVaccinePrarmeterDTO;
import com.epmet.entity.IcVaccinePrarmeterEntity;
import com.epmet.redis.IcVaccinePrarmeterRedis;
import com.epmet.service.IcVaccinePrarmeterService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 新冠病毒疫苗接种人员信息台账
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-08-22
*/
@Service
public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl<IcVaccinePrarmeterDao, IcVaccinePrarmeterEntity> implements IcVaccinePrarmeterService {
@Autowired
private IcVaccinePrarmeterRedis icVaccinePrarmeterRedis;
@Override
public PageData<IcVaccinePrarmeterDTO> page(Map<String, Object> params) {
IPage<IcVaccinePrarmeterEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, IcVaccinePrarmeterDTO.class);
}
@Override
public List<IcVaccinePrarmeterDTO> list(Map<String, Object> params) {
List<IcVaccinePrarmeterEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, IcVaccinePrarmeterDTO.class);
}
private QueryWrapper<IcVaccinePrarmeterEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<IcVaccinePrarmeterEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public IcVaccinePrarmeterDTO get(String id) {
IcVaccinePrarmeterEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, IcVaccinePrarmeterDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(IcVaccinePrarmeterDTO dto) {
IcVaccinePrarmeterEntity entity = ConvertUtils.sourceToTarget(dto, IcVaccinePrarmeterEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(IcVaccinePrarmeterDTO dto) {
IcVaccinePrarmeterEntity entity = ConvertUtils.sourceToTarget(dto, IcVaccinePrarmeterEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

768
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/Base64Util.java

@ -0,0 +1,768 @@
package com.epmet.util.dh;
import java.math.BigInteger;
/**
* Provides Base64 encoding and decoding as defined by <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>.
*
* <p>
* This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite> from RFC 2045 <cite>Multipurpose
* Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</cite> by Freed and Borenstein.
* </p>
* <p>
* The class can be parameterized in the following manner with various constructors:
* </p>
* <ul>
* <li>URL-safe mode: Default off.</li>
* <li>Line length: Default 76. Line length that aren't multiples of 4 will still essentially end up being multiples of
* 4 in the encoded data.
* <li>Line separator: Default is CRLF ("\r\n")</li>
* </ul>
* <p>
* The URL-safe parameter is only applied to encode operations. Decoding seamlessly handles both modes.
* </p>
* <p>
* Since this class operates directly on byte streams, and not character streams, it is hard-coded to only
* encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252,
* UTF-8, etc).
* </p>
* <p>
* This class is thread-safe.
* </p>
*
* @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
* @since 1.0
* @version $Id: Base64.java 1635986 2014-11-01 16:27:52Z tn $
*/
public class Base64Util extends BaseNCodec {
/**
* BASE32 characters are 6 bits in length.
* They are formed by taking a block of 3 octets to form a 24-bit string,
* which is converted into 4 BASE64 characters.
*/
private static final int BITS_PER_ENCODED_BYTE = 6;
private static final int BYTES_PER_UNENCODED_BLOCK = 3;
private static final int BYTES_PER_ENCODED_BLOCK = 4;
/**
* Chunk separator per RFC 2045 section 2.1.
*
* <p>
* N.B. The next major release may break compatibility and make this field private.
* </p>
*
* @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 2.1</a>
*/
static final byte[] CHUNK_SEPARATOR = {'\r', '\n'};
/**
* This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet"
* equivalents as specified in Table 1 of RFC 2045.
*
* Thanks to "commons" project in ws.apache.org for this code.
* http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/
*/
private static final byte[] STANDARD_ENCODE_TABLE = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
};
/**
* This is a copy of the STANDARD_ENCODE_TABLE above, but with + and /
* changed to - and _ to make the encoded Base64 results more URL-SAFE.
* This table is only used when the Base64's mode is set to URL-SAFE.
*/
private static final byte[] URL_SAFE_ENCODE_TABLE = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_'
};
/**
* This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified
* in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64
* alphabet but fall within the bounds of the array are translated to -1.
*
* Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both
* URL_SAFE and STANDARD base64. (The encoder, on the other hand, needs to know ahead of time what to emit).
*
* Thanks to "commons" project in ws.apache.org for this code.
* http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/
*/
private static final byte[] DECODE_TABLE = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
};
/**
* Base64 uses 6-bit fields.
*/
/** Mask used to extract 6 bits, used when encoding */
private static final int MASK_6BITS = 0x3f;
// The static final fields above are used for the original static byte[] methods on Base64.
// The private member fields below are used with the new streaming approach, which requires
// some state be preserved between calls of encode() and decode().
/**
* Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE above remains static because it is able
* to decode both STANDARD and URL_SAFE streams, but the encodeTable must be a member variable so we can switch
* between the two modes.
*/
private final byte[] encodeTable;
// Only one decode table currently; keep for consistency with Base32 code
private final byte[] decodeTable = DECODE_TABLE;
/**
* Line separator for encoding. Not used when decoding. Only used if lineLength &gt; 0.
*/
private final byte[] lineSeparator;
/**
* Convenience variable to help us determine when our buffer is going to run out of room and needs resizing.
* <code>decodeSize = 3 + lineSeparator.length;</code>
*/
private final int decodeSize;
/**
* Convenience variable to help us determine when our buffer is going to run out of room and needs resizing.
* <code>encodeSize = 4 + lineSeparator.length;</code>
*/
private final int encodeSize;
/**
* Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.
* <p>
* When encoding the line length is 0 (no chunking), and the encoding table is STANDARD_ENCODE_TABLE.
* </p>
*
* <p>
* When decoding all variants are supported.
* </p>
*/
public Base64Util() {
this(0);
}
/**
* Creates a Base64 codec used for decoding (all modes) and encoding in the given URL-safe mode.
* <p>
* When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE.
* </p>
*
* <p>
* When decoding all variants are supported.
* </p>
*
* @param urlSafe
* if <code>true</code>, URL-safe encoding is used. In most cases this should be set to
* <code>false</code>.
* @since 1.4
*/
public Base64Util(final boolean urlSafe) {
this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe);
}
/**
* Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.
* <p>
* When encoding the line length is given in the constructor, the line separator is CRLF, and the encoding table is
* STANDARD_ENCODE_TABLE.
* </p>
* <p>
* Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.
* </p>
* <p>
* When decoding all variants are supported.
* </p>
*
* @param lineLength
* Each line of encoded data will be at most of the given length (rounded down to nearest multiple of
* 4). If lineLength &lt;= 0, then the output will not be divided into lines (chunks). Ignored when
* decoding.
* @since 1.4
*/
public Base64Util(final int lineLength) {
this(lineLength, CHUNK_SEPARATOR);
}
/**
* Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.
* <p>
* When encoding the line length and line separator are given in the constructor, and the encoding table is
* STANDARD_ENCODE_TABLE.
* </p>
* <p>
* Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.
* </p>
* <p>
* When decoding all variants are supported.
* </p>
*
* @param lineLength
* Each line of encoded data will be at most of the given length (rounded down to nearest multiple of
* 4). If lineLength &lt;= 0, then the output will not be divided into lines (chunks). Ignored when
* decoding.
* @param lineSeparator
* Each line of encoded data will end with this sequence of bytes.
* @throws IllegalArgumentException
* Thrown when the provided lineSeparator included some base64 characters.
* @since 1.4
*/
public Base64Util(final int lineLength, final byte[] lineSeparator) {
this(lineLength, lineSeparator, false);
}
/**
* Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.
* <p>
* When encoding the line length and line separator are given in the constructor, and the encoding table is
* STANDARD_ENCODE_TABLE.
* </p>
* <p>
* Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.
* </p>
* <p>
* When decoding all variants are supported.
* </p>
*
* @param lineLength
* Each line of encoded data will be at most of the given length (rounded down to nearest multiple of
* 4). If lineLength &lt;= 0, then the output will not be divided into lines (chunks). Ignored when
* decoding.
* @param lineSeparator
* Each line of encoded data will end with this sequence of bytes.
* @param urlSafe
* Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode
* operations. Decoding seamlessly handles both modes.
* <b>Note: no padding is added when using the URL-safe alphabet.</b>
* @throws IllegalArgumentException
* The provided lineSeparator included some base64 characters. That's not going to work!
* @since 1.4
*/
public Base64Util(final int lineLength, final byte[] lineSeparator, final boolean urlSafe) {
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK,
lineLength,
lineSeparator == null ? 0 : lineSeparator.length);
// TODO could be simplified if there is no requirement to reject invalid line sep when length <=0
// @see test case Base64Test.testConstructors()
if (lineSeparator != null) {
if (containsAlphabetOrPad(lineSeparator)) {
final String sep = newStringUtf8(lineSeparator);
throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]");
}
if (lineLength > 0){ // null line-sep forces no chunking rather than throwing IAE
this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length;
this.lineSeparator = new byte[lineSeparator.length];
System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length);
} else {
this.encodeSize = BYTES_PER_ENCODED_BLOCK;
this.lineSeparator = null;
}
} else {
this.encodeSize = BYTES_PER_ENCODED_BLOCK;
this.lineSeparator = null;
}
this.decodeSize = this.encodeSize - 1;
this.encodeTable = urlSafe ? URL_SAFE_ENCODE_TABLE : STANDARD_ENCODE_TABLE;
}
/**
* Returns our current encode mode. True if we're URL-SAFE, false otherwise.
*
* @return true if we're in URL-SAFE mode, false otherwise.
* @since 1.4
*/
public boolean isUrlSafe() {
return this.encodeTable == URL_SAFE_ENCODE_TABLE;
}
/**
* <p>
* Encodes all of the provided data, starting at inPos, for inAvail bytes. Must be called at least twice: once with
* the data to encode, and once with inAvail set to "-1" to alert encoder that EOF has been reached, to flush last
* remaining bytes (if not multiple of 3).
* </p>
* <p><b>Note: no padding is added when encoding using the URL-safe alphabet.</b></p>
* <p>
* Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach.
* http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/
* </p>
*
* @param in
* byte[] array of binary data to base64 encode.
* @param inPos
* Position to start reading data from.
* @param inAvail
* Amount of bytes available from input for encoding.
* @param context
* the context to be used
*/
@Override
void encode(final byte[] in, int inPos, final int inAvail, final Context context) {
if (context.eof) {
return;
}
// inAvail < 0 is how we're informed of EOF in the underlying data we're
// encoding.
if (inAvail < 0) {
context.eof = true;
if (0 == context.modulus && lineLength == 0) {
return; // no leftovers to process and not using chunking
}
final byte[] buffer = ensureBufferSize(encodeSize, context);
final int savedPos = context.pos;
switch (context.modulus) { // 0-2
case 0 : // nothing to do here
break;
case 1 : // 8 bits = 6 + 2
// top 6 bits:
buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS];
// remaining 2:
buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4) & MASK_6BITS];
// URL-SAFE skips the padding to further reduce size.
if (encodeTable == STANDARD_ENCODE_TABLE) {
buffer[context.pos++] = pad;
buffer[context.pos++] = pad;
}
break;
case 2 : // 16 bits = 6 + 6 + 4
buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 10) & MASK_6BITS];
buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 4) & MASK_6BITS];
buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 2) & MASK_6BITS];
// URL-SAFE skips the padding to further reduce size.
if (encodeTable == STANDARD_ENCODE_TABLE) {
buffer[context.pos++] = pad;
}
break;
default:
throw new IllegalStateException("Impossible modulus "+context.modulus);
}
context.currentLinePos += context.pos - savedPos; // keep track of current line position
// if currentPos == 0 we are at the start of a line, so don't add CRLF
if (lineLength > 0 && context.currentLinePos > 0) {
System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);
context.pos += lineSeparator.length;
}
} else {
for (int i = 0; i < inAvail; i++) {
final byte[] buffer = ensureBufferSize(encodeSize, context);
context.modulus = (context.modulus+1) % BYTES_PER_UNENCODED_BLOCK;
int b = in[inPos++];
if (b < 0) {
b += 256;
}
context.ibitWorkArea = (context.ibitWorkArea << 8) + b; // BITS_PER_BYTE
if (0 == context.modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract
buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 18) & MASK_6BITS];
buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 12) & MASK_6BITS];
buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 6) & MASK_6BITS];
buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6BITS];
context.currentLinePos += BYTES_PER_ENCODED_BLOCK;
if (lineLength > 0 && lineLength <= context.currentLinePos) {
System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);
context.pos += lineSeparator.length;
context.currentLinePos = 0;
}
}
}
}
}
/**
* <p>
* Decodes all of the provided data, starting at inPos, for inAvail bytes. Should be called at least twice: once
* with the data to decode, and once with inAvail set to "-1" to alert decoder that EOF has been reached. The "-1"
* call is not necessary when decoding, but it doesn't hurt, either.
* </p>
* <p>
* Ignores all non-base64 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are
* silently ignored, but has implications for other bytes, too. This method subscribes to the garbage-in,
* garbage-out philosophy: it will not check the provided data for validity.
* </p>
* <p>
* Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach.
* http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/
* </p>
*
* @param in
* byte[] array of ascii data to base64 decode.
* @param inPos
* Position to start reading data from.
* @param inAvail
* Amount of bytes available from input for encoding.
* @param context
* the context to be used
*/
@Override
void decode(final byte[] in, int inPos, final int inAvail, final Context context) {
if (context.eof) {
return;
}
if (inAvail < 0) {
context.eof = true;
}
for (int i = 0; i < inAvail; i++) {
final byte[] buffer = ensureBufferSize(decodeSize, context);
final byte b = in[inPos++];
if (b == pad) {
// We're done.
context.eof = true;
break;
} else {
if (b >= 0 && b < DECODE_TABLE.length) {
final int result = DECODE_TABLE[b];
if (result >= 0) {
context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK;
context.ibitWorkArea = (context.ibitWorkArea << BITS_PER_ENCODED_BYTE) + result;
if (context.modulus == 0) {
buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 16) & MASK_8BITS);
buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS);
buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS);
}
}
}
}
}
// Two forms of EOF as far as base64 decoder is concerned: actual
// EOF (-1) and first time '=' character is encountered in stream.
// This approach makes the '=' padding characters completely optional.
if (context.eof && context.modulus != 0) {
final byte[] buffer = ensureBufferSize(decodeSize, context);
// We have some spare bits remaining
// Output all whole multiples of 8 bits and ignore the rest
switch (context.modulus) {
// case 0 : // impossible, as excluded above
case 1 : // 6 bits - ignore entirely
// TODO not currently tested; perhaps it is impossible?
break;
case 2 : // 12 bits = 8 + 4
context.ibitWorkArea = context.ibitWorkArea >> 4; // dump the extra 4 bits
buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS);
break;
case 3 : // 18 bits = 8 + 8 + 2
context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 2 bits
buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS);
buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS);
break;
default:
throw new IllegalStateException("Impossible modulus "+context.modulus);
}
}
}
/**
* Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the
* method treats whitespace as valid.
*
* @param arrayOctet
* byte array to test
* @return <code>true</code> if all bytes are valid characters in the Base64 alphabet or if the byte array is empty;
* <code>false</code>, otherwise
* @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0.
*/
@Deprecated
public static boolean isArrayByteBase64(final byte[] arrayOctet) {
return isBase64(arrayOctet);
}
/**
* Returns whether or not the <code>octet</code> is in the base 64 alphabet.
*
* @param octet
* The value to test
* @return <code>true</code> if the value is defined in the the base 64 alphabet, <code>false</code> otherwise.
* @since 1.4
*/
public static boolean isBase64(final byte octet) {
return octet == PAD_DEFAULT || (octet >= 0 && octet < DECODE_TABLE.length && DECODE_TABLE[octet] != -1);
}
/**
* Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the
* method treats whitespace as valid.
*
* @param base64
* String to test
* @return <code>true</code> if all characters in the String are valid characters in the Base64 alphabet or if
* the String is empty; <code>false</code>, otherwise
* @since 1.5
*/
public static boolean isBase64(final String base64) {
return isBase64(getBytesUtf8(base64));
}
/**
* Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the
* method treats whitespace as valid.
*
* @param arrayOctet
* byte array to test
* @return <code>true</code> if all bytes are valid characters in the Base64 alphabet or if the byte array is empty;
* <code>false</code>, otherwise
* @since 1.5
*/
public static boolean isBase64(final byte[] arrayOctet) {
for (int i = 0; i < arrayOctet.length; i++) {
if (!isBase64(arrayOctet[i]) && !isWhiteSpace(arrayOctet[i])) {
return false;
}
}
return true;
}
/**
* Encodes binary data using the base64 algorithm but does not chunk the output.
*
* @param binaryData
* binary data to encode
* @return byte[] containing Base64 characters in their UTF-8 representation.
*/
public static byte[] encodeBase64(final byte[] binaryData) {
return encodeBase64(binaryData, false);
}
/**
* Encodes binary data using the base64 algorithm but does not chunk the output.
*
* NOTE: We changed the behaviour of this method from multi-line chunking (commons-codec-1.4) to
* single-line non-chunking (commons-codec-1.5).
*
* @param binaryData
* binary data to encode
* @return String containing Base64 characters.
* @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not).
*/
public static String encodeBase64String(final byte[] binaryData) {
return newStringUtf8(encodeBase64(binaryData, false));
}
/**
* Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The
* url-safe variation emits - and _ instead of + and / characters.
* <b>Note: no padding is added.</b>
* @param binaryData
* binary data to encode
* @return byte[] containing Base64 characters in their UTF-8 representation.
* @since 1.4
*/
public static byte[] encodeBase64URLSafe(final byte[] binaryData) {
return encodeBase64(binaryData, false, true);
}
/**
* Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The
* url-safe variation emits - and _ instead of + and / characters.
* <b>Note: no padding is added.</b>
* @param binaryData
* binary data to encode
* @return String containing Base64 characters
* @since 1.4
*/
public static String encodeBase64URLSafeString(final byte[] binaryData) {
return newStringUtf8(encodeBase64(binaryData, false, true));
}
/**
* Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks
*
* @param binaryData
* binary data to encode
* @return Base64 characters chunked in 76 character blocks
*/
public static byte[] encodeBase64Chunked(final byte[] binaryData) {
return encodeBase64(binaryData, true);
}
/**
* Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
*
* @param binaryData
* Array containing binary data to encode.
* @param isChunked
* if <code>true</code> this encoder will chunk the base64 output into 76 character blocks
* @return Base64-encoded data.
* @throws IllegalArgumentException
* Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE}
*/
public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) {
return encodeBase64(binaryData, isChunked, false);
}
/**
* Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
*
* @param binaryData
* Array containing binary data to encode.
* @param isChunked
* if <code>true</code> this encoder will chunk the base64 output into 76 character blocks
* @param urlSafe
* if <code>true</code> this encoder will emit - and _ instead of the usual + and / characters.
* <b>Note: no padding is added when encoding using the URL-safe alphabet.</b>
* @return Base64-encoded data.
* @throws IllegalArgumentException
* Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE}
* @since 1.4
*/
public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) {
return encodeBase64(binaryData, isChunked, urlSafe, Integer.MAX_VALUE);
}
/**
* Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
*
* @param binaryData
* Array containing binary data to encode.
* @param isChunked
* if <code>true</code> this encoder will chunk the base64 output into 76 character blocks
* @param urlSafe
* if <code>true</code> this encoder will emit - and _ instead of the usual + and / characters.
* <b>Note: no padding is added when encoding using the URL-safe alphabet.</b>
* @param maxResultSize
* The maximum result size to accept.
* @return Base64-encoded data.
* @throws IllegalArgumentException
* Thrown when the input array needs an output array bigger than maxResultSize
* @since 1.4
*/
public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked,
final boolean urlSafe, final int maxResultSize) {
if (binaryData == null || binaryData.length == 0) {
return binaryData;
}
// Create this so can use the super-class method
// Also ensures that the same roundings are performed by the ctor and the code
final Base64Util b64 = isChunked ? new Base64Util(urlSafe) : new Base64Util(0, CHUNK_SEPARATOR, urlSafe);
final long len = b64.getEncodedLength(binaryData);
if (len > maxResultSize) {
throw new IllegalArgumentException("Input array too big, the output array would be bigger (" +
len +
") than the specified maximum size of " +
maxResultSize);
}
return b64.encode(binaryData);
}
/**
* Decodes a Base64 String into octets.
* <p>
* <b>Note:</b> this method seamlessly handles data encoded in URL-safe or normal mode.
* </p>
*
* @param base64String
* String containing Base64 data
* @return Array containing decoded data.
* @since 1.4
*/
public static byte[] decodeBase64(final String base64String) {
return new Base64Util().decode(base64String);
}
/**
* Decodes Base64 data into octets.
* <p>
* <b>Note:</b> this method seamlessly handles data encoded in URL-safe or normal mode.
* </p>
*
* @param base64Data
* Byte array containing Base64 data
* @return Array containing decoded data.
*/
public static byte[] decodeBase64(final byte[] base64Data) {
return new Base64Util().decode(base64Data);
}
// Implementation of the Encoder Interface
// Implementation of integer encoding used for crypto
/**
* Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature.
*
* @param pArray
* a byte array containing base64 character data
* @return A BigInteger
* @since 1.4
*/
public static BigInteger decodeInteger(final byte[] pArray) {
return new BigInteger(1, decodeBase64(pArray));
}
/**
* Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature.
*
* @param bigInt
* a BigInteger
* @return A byte array containing base64 character data
* @throws NullPointerException
* if null is passed in
* @since 1.4
*/
public static byte[] encodeInteger(final BigInteger bigInt) {
if (bigInt == null) {
throw new NullPointerException("encodeInteger called with null parameter");
}
return encodeBase64(toIntegerBytes(bigInt), false);
}
/**
* Returns a byte-array representation of a <code>BigInteger</code> without sign bit.
*
* @param bigInt
* <code>BigInteger</code> to be converted
* @return a byte array representation of the BigInteger parameter
*/
static byte[] toIntegerBytes(final BigInteger bigInt) {
int bitlen = bigInt.bitLength();
// round bitlen
bitlen = ((bitlen + 7) >> 3) << 3;
final byte[] bigBytes = bigInt.toByteArray();
if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) {
return bigBytes;
}
// set up params for copying everything but sign bit
int startSrc = 0;
int len = bigBytes.length;
// if bigInt is exactly byte-aligned, just skip signbit in copy
if ((bigInt.bitLength() % 8) == 0) {
startSrc = 1;
len--;
}
final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec
final byte[] resizedBytes = new byte[bitlen / 8];
System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len);
return resizedBytes;
}
/**
* Returns whether or not the <code>octet</code> is in the Base64 alphabet.
*
* @param octet
* The value to test
* @return <code>true</code> if the value is defined in the the Base64 alphabet <code>false</code> otherwise.
*/
@Override
protected boolean isInAlphabet(final byte octet) {
return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1;
}
}

521
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/BaseNCodec.java

@ -0,0 +1,521 @@
package com.epmet.util.dh;
import java.nio.charset.Charset;
import java.util.Arrays;
/**
* Abstract superclass for Base-N encoders and decoders.
*
* <p>
* This class is thread-safe.
* </p>
*
* @version $Id: BaseNCodec.java 1634404 2014-10-26 23:06:10Z ggregory $
*/
public abstract class BaseNCodec {
/**
* Holds thread context so classes can be thread-safe.
*
* This class is not itself thread-safe; each thread must allocate its own copy.
*
* @since 1.7
*/
static class Context {
/**
* Place holder for the bytes we're dealing with for our based logic.
* Bitwise operations store and extract the encoding or decoding from this variable.
*/
int ibitWorkArea;
/**
* Place holder for the bytes we're dealing with for our based logic.
* Bitwise operations store and extract the encoding or decoding from this variable.
*/
long lbitWorkArea;
/**
* Buffer for streaming.
*/
byte[] buffer;
/**
* Position where next character should be written in the buffer.
*/
int pos;
/**
* Position where next character should be read from the buffer.
*/
int readPos;
/**
* Boolean flag to indicate the EOF has been reached. Once EOF has been reached, this object becomes useless,
* and must be thrown away.
*/
boolean eof;
/**
* Variable tracks how many characters have been written to the current line. Only used when encoding. We use
* it to make sure each encoded line never goes beyond lineLength (if lineLength &gt; 0).
*/
int currentLinePos;
/**
* Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. This
* variable helps track that.
*/
int modulus;
Context() {
}
/**
* Returns a String useful for debugging (especially within a debugger.)
*
* @return a String useful for debugging.
*/
@SuppressWarnings("boxing") // OK to ignore boxing here
public String toString() {
return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " +
"modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer),
currentLinePos, eof, ibitWorkArea, lbitWorkArea, modulus, pos, readPos);
}
}
/**
* EOF
*
* @since 1.7
*/
static final int EOF = -1;
/**
* MIME chunk size per RFC 2045 section 6.8.
*
* <p>
* The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any
* equal signs.
* </p>
*
* @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
*/
public static final int MIME_CHUNK_SIZE = 76;
/**
* PEM chunk size per RFC 1421 section 4.3.2.4.
*
* <p>
* The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any
* equal signs.
* </p>
*
* @see <a href="http://tools.ietf.org/html/rfc1421">RFC 1421 section 4.3.2.4</a>
*/
public static final int PEM_CHUNK_SIZE = 64;
private static final int DEFAULT_BUFFER_RESIZE_FACTOR = 2;
/**
* Defines the default buffer size - currently {@value}
* - must be large enough for at least one encoded block+separator
*/
private static final int DEFAULT_BUFFER_SIZE = 8192;
/** Mask used to extract 8 bits, used in decoding bytes */
protected static final int MASK_8BITS = 0xff;
/**
* Byte used to pad output.
*/
protected static final byte PAD_DEFAULT = '='; // Allow static access to default
/**
* @deprecated Use {@link #pad}. Will be removed in 2.0.
*/
@Deprecated
protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later
protected final byte pad; // instance variable just in case it needs to vary later
/** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 */
private final int unencodedBlockSize;
/** Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 */
private final int encodedBlockSize;
/**
* Chunksize for encoding. Not used when decoding.
* A value of zero or less implies no chunking of the encoded data.
* Rounded down to nearest multiple of encodedBlockSize.
*/
protected final int lineLength;
/**
* Size of chunk separator. Not used unless {@link #lineLength} &gt; 0.
*/
private final int chunkSeparatorLength;
/**
* Note <code>lineLength</code> is rounded down to the nearest multiple of {@link #encodedBlockSize}
* If <code>chunkSeparatorLength</code> is zero, then chunking is disabled.
* @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3)
* @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4)
* @param lineLength if &gt; 0, use chunking with a length <code>lineLength</code>
* @param chunkSeparatorLength the chunk separator length, if relevant
*/
protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize,
final int lineLength, final int chunkSeparatorLength) {
this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, PAD_DEFAULT);
}
/**
* Note <code>lineLength</code> is rounded down to the nearest multiple of {@link #encodedBlockSize}
* If <code>chunkSeparatorLength</code> is zero, then chunking is disabled.
* @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3)
* @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4)
* @param lineLength if &gt; 0, use chunking with a length <code>lineLength</code>
* @param chunkSeparatorLength the chunk separator length, if relevant
* @param pad byte used as padding byte.
*/
protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize,
final int lineLength, final int chunkSeparatorLength, final byte pad) {
this.unencodedBlockSize = unencodedBlockSize;
this.encodedBlockSize = encodedBlockSize;
final boolean useChunking = lineLength > 0 && chunkSeparatorLength > 0;
this.lineLength = useChunking ? (lineLength / encodedBlockSize) * encodedBlockSize : 0;
this.chunkSeparatorLength = chunkSeparatorLength;
this.pad = pad;
}
/**
* Returns true if this object has buffered data for reading.
*
* @param context the context to be used
* @return true if there is data still available for reading.
*/
boolean hasData(final Context context) { // package protected for access from I/O streams
return context.buffer != null;
}
/**
* Returns the amount of buffered data available for reading.
*
* @param context the context to be used
* @return The amount of buffered data available for reading.
*/
int available(final Context context) { // package protected for access from I/O streams
return context.buffer != null ? context.pos - context.readPos : 0;
}
/**
* Get the default buffer size. Can be overridden.
*
* @return {@link #DEFAULT_BUFFER_SIZE}
*/
protected int getDefaultBufferSize() {
return DEFAULT_BUFFER_SIZE;
}
/**
* Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}.
* @param context the context to be used
*/
private byte[] resizeBuffer(final Context context) {
if (context.buffer == null) {
context.buffer = new byte[getDefaultBufferSize()];
context.pos = 0;
context.readPos = 0;
} else {
final byte[] b = new byte[context.buffer.length * DEFAULT_BUFFER_RESIZE_FACTOR];
System.arraycopy(context.buffer, 0, b, 0, context.buffer.length);
context.buffer = b;
}
return context.buffer;
}
/**
* Ensure that the buffer has room for <code>size</code> bytes
*
* @param size minimum spare space required
* @param context the context to be used
* @return the buffer
*/
protected byte[] ensureBufferSize(final int size, final Context context){
if ((context.buffer == null) || (context.buffer.length < context.pos + size)){
return resizeBuffer(context);
}
return context.buffer;
}
/**
* Extracts buffered data into the provided byte[] array, starting at position bPos, up to a maximum of bAvail
* bytes. Returns how many bytes were actually extracted.
* <p>
* Package protected for access from I/O streams.
*
* @param b
* byte[] array to extract the buffered data into.
* @param bPos
* position in byte[] array to start extraction at.
* @param bAvail
* amount of bytes we're allowed to extract. We may extract fewer (if fewer are available).
* @param context
* the context to be used
* @return The number of bytes successfully extracted into the provided byte[] array.
*/
int readResults(final byte[] b, final int bPos, final int bAvail, final Context context) {
if (context.buffer != null) {
final int len = Math.min(available(context), bAvail);
System.arraycopy(context.buffer, context.readPos, b, bPos, len);
context.readPos += len;
if (context.readPos >= context.pos) {
context.buffer = null; // so hasData() will return false, and this method can return -1
}
return len;
}
return context.eof ? EOF : 0;
}
/**
* Checks if a byte value is whitespace or not.
* Whitespace is taken to mean: space, tab, CR, LF
* @param byteToCheck
* the byte to check
* @return true if byte is whitespace, false otherwise
*/
protected static boolean isWhiteSpace(final byte byteToCheck) {
switch (byteToCheck) {
case ' ' :
case '\n' :
case '\r' :
case '\t' :
return true;
default :
return false;
}
}
/**
* Encodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of
* the Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[].
*
* @param obj
* Object to encode
* @return An object (of type byte[]) containing the Base-N encoded data which corresponds to the byte[] supplied.
* @throws Exception
* if the parameter supplied is not of type byte[]
*/
public Object encode(final Object obj) throws Exception {
if (!(obj instanceof byte[])) {
throw new Exception("Parameter supplied to Base-N encode is not a byte[]");
}
return encode((byte[]) obj);
}
/**
* Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet.
* Uses UTF8 encoding.
*
* @param pArray
* a byte array containing binary data
* @return A String containing only Base-N character data
*/
public String encodeToString(final byte[] pArray) {
return newStringUtf8(encode(pArray));
}
/**
* Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet.
* Uses UTF8 encoding.
*
* @param pArray a byte array containing binary data
* @return String containing only character data in the appropriate alphabet.
*/
public String encodeAsString(final byte[] pArray){
return newStringUtf8(encode(pArray));
}
/**
* Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of
* the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String.
*
* @param obj
* Object to decode
* @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String
* supplied.
* @throws Exception
* if the parameter supplied is not of type byte[]
*/
public Object decode(final Object obj) throws Exception {
if (obj instanceof byte[]) {
return decode((byte[]) obj);
} else if (obj instanceof String) {
return decode((String) obj);
} else {
throw new Exception("Parameter supplied to Base-N decode is not a byte[] or a String");
}
}
/**
* Decodes a String containing characters in the Base-N alphabet.
*
* @param pArray
* A String containing Base-N character data
* @return a byte array containing binary data
*/
public byte[] decode(final String pArray) {
return decode(getBytesUtf8(pArray));
}
/**
* Decodes a byte[] containing characters in the Base-N alphabet.
*
* @param pArray
* A byte array containing Base-N character data
* @return a byte array containing binary data
*/
public byte[] decode(final byte[] pArray) {
if (pArray == null || pArray.length == 0) {
return pArray;
}
final Context context = new Context();
decode(pArray, 0, pArray.length, context);
decode(pArray, 0, EOF, context); // Notify decoder of EOF.
final byte[] result = new byte[context.pos];
readResults(result, 0, result.length, context);
return result;
}
/**
* Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet.
*
* @param pArray
* a byte array containing binary data
* @return A byte array containing only the basen alphabetic character data
*/
public byte[] encode(final byte[] pArray) {
if (pArray == null || pArray.length == 0) {
return pArray;
}
final Context context = new Context();
encode(pArray, 0, pArray.length, context);
encode(pArray, 0, EOF, context); // Notify encoder of EOF.
final byte[] buf = new byte[context.pos - context.readPos];
readResults(buf, 0, buf.length, context);
return buf;
}
// package protected for access from I/O streams
abstract void encode(byte[] pArray, int i, int length, Context context);
// package protected for access from I/O streams
abstract void decode(byte[] pArray, int i, int length, Context context);
/**
* Returns whether or not the <code>octet</code> is in the current alphabet.
* Does not allow whitespace or pad.
*
* @param value The value to test
*
* @return <code>true</code> if the value is defined in the current alphabet, <code>false</code> otherwise.
*/
protected abstract boolean isInAlphabet(byte value);
/**
* Tests a given byte array to see if it contains only valid characters within the alphabet.
* The method optionally treats whitespace and pad as valid.
*
* @param arrayOctet byte array to test
* @param allowWSPad if <code>true</code>, then whitespace and PAD are also allowed
*
* @return <code>true</code> if all bytes are valid characters in the alphabet or if the byte array is empty;
* <code>false</code>, otherwise
*/
public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) {
for (int i = 0; i < arrayOctet.length; i++) {
if (!isInAlphabet(arrayOctet[i]) &&
(!allowWSPad || (arrayOctet[i] != pad) && !isWhiteSpace(arrayOctet[i]))) {
return false;
}
}
return true;
}
/**
* Tests a given String to see if it contains only valid characters within the alphabet.
* The method treats whitespace and PAD as valid.
*
* @param basen String to test
* @return <code>true</code> if all characters in the String are valid characters in the alphabet or if
* the String is empty; <code>false</code>, otherwise
* @see #isInAlphabet(byte[], boolean)
*/
public boolean isInAlphabet(final String basen) {
return isInAlphabet(getBytesUtf8(basen), true);
}
/**
* Tests a given byte array to see if it contains any characters within the alphabet or PAD.
*
* Intended for use in checking line-ending arrays
*
* @param arrayOctet
* byte array to test
* @return <code>true</code> if any byte is a valid character in the alphabet or PAD; <code>false</code> otherwise
*/
protected boolean containsAlphabetOrPad(final byte[] arrayOctet) {
if (arrayOctet == null) {
return false;
}
for (final byte element : arrayOctet) {
if (pad == element || isInAlphabet(element)) {
return true;
}
}
return false;
}
/**
* Calculates the amount of space needed to encode the supplied array.
*
* @param pArray byte[] array which will later be encoded
*
* @return amount of space needed to encoded the supplied array.
* Returns a long since a max-len array will require &gt; Integer.MAX_VALUE
*/
public long getEncodedLength(final byte[] pArray) {
// Calculate non-chunked size - rounded up to allow for padding
// cast to long is needed to avoid possibility of overflow
long len = ((pArray.length + unencodedBlockSize-1) / unencodedBlockSize) * (long) encodedBlockSize;
if (lineLength > 0) { // We're using chunking
// Round up to nearest multiple
len += ((len + lineLength-1) / lineLength) * chunkSeparatorLength;
}
return len;
}
public static Charset UTF8 = Charset.forName("UTF-8");
public static String newStringUtf8(byte[] bytes) {
return newString(bytes, UTF8);
}
private static String newString(final byte[] bytes, final Charset charset) {
return bytes == null ? null : new String(bytes, charset);
}
public static byte[] getBytesUtf8(final String string) {
return getBytes(string, UTF8);
}
private static byte[] getBytes(final String string, final Charset charset) {
if (string == null) {
return null;
}
return string.getBytes(charset);
}
}

7
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/Cities.java

File diff suppressed because one or more lines are too long

60
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/DhCloudProperties.java

@ -0,0 +1,60 @@
package com.epmet.util.dh;
import org.springframework.stereotype.Component;
/**
* 海康设备参数
*
* @author zhy
* @date 2022/5/20 14:59
*/
@Component
public class DhCloudProperties {
/**
* URL
*/
private String url;
/**
* 账号
*/
private String loginName;
/**
* 账号密码
*/
private String loginPass;
public DhCloudProperties() {
url = "http://112.6.213.175:8314";
loginName = "shundeju";
loginPass = "hg123456";
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getLoginPass() {
return loginPass;
}
public void setLoginPass(String loginPass) {
this.loginPass = loginPass;
}
}

904
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/DhDeviceUtil.java

@ -0,0 +1,904 @@
package com.epmet.util.dh;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.dto.DhTokenDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.DhChannelResultDTO;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.imageio.ImageIO;
import javax.xml.bind.DatatypeConverter;
import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
/**
* 海康设备下放命令
*
* @author zhy
* @date 2022/5/20 9:36
*/
@Component
public class DhDeviceUtil {
private static Logger logger = LoggerFactory.getLogger(DhDeviceUtil.class);
@Autowired
private DhCloudProperties dhCloudProperties;
@Autowired
private RedisUtils redisUtils;
private final String GET_PUBLIC_KEY = "/WPMS/getPublicKey";
private final String GET_LOGIN_PASS = "/WPMS/login";
private final String GET_DEPARTMENT = "/CardSolution/card/department";
private final String GET_NODE = "/CardSolution/resource/tree/nodeList";
private final String GET_CHANNEL = "/admin/rest/api";
private final String GET_PERSON_IDENTITY = "/CardSolution/card/person/personidentity";
private final String GET_DOOR_PLAN = "/CardSolution/card/accessControl/timeQuantum/1/page";
private final String GET_DOOR_CHANNEL = "/CardSolution/card/accessControl/channel/bycondition/combined";
private final String ADD_PERSON = "/CardSolution/card/person";
private final String LIST_PERSON = "/CardSolution/card/person/bycondition/combined";
private final String DEL_PERSON = "/CardSolution/card/person/delete";
private final String ADD_PERSON_IMG = "/CardSolution/common/saveMobileBase64ImageToByte";
private final String ADD_AUTH = "/CardSolution/card/accessControl/doorAuthority/update";
private final String LIST_CARD = "/CardSolution/card/card/bycondition/combined";
private final String DEL_CARD = "/CardSolution/card/card/returnByNumber/";
private final String OPEN_CARD = "/CardSolution/card/card/open/batch";
/**
* 主方法准备下发开门权限
*
* @param dto
* @return void
* @author zhy
* @date 2022/8/17 15:24
*/
public void sendAuth(VisitVisitorFormDTO dto) {
if (StringUtils.isBlank(dto.getIdCard())) {
dto.setIdCard(IDUtils.getIdNo(new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD).format(new Date()), true));
}
DhPersonFormDTO formDTO = new DhPersonFormDTO();
formDTO.setPaperType("身份证");
formDTO.setPaperNumber(dto.getIdCard());
formDTO.setName(dto.getName());
formDTO.setCode(dto.getIdCard().substring(dto.getIdCard().length() - 10));
formDTO.setSex(IDUtils.getSex(dto.getIdCard()));
formDTO.setBirthday(dto.getIdCard().substring(6, 10) + "-" + dto.getIdCard().substring(10, 12) + "-" + dto.getIdCard().substring(12, 14));
formDTO.setPhone(dto.getMobile());
formDTO.setStatus("在职");
addPersonAuth(formDTO, dto.getFaceImg(), dto.getNode());
}
/**
* 获取publicKey
*
* @param
* @return void
* @author zhy
* @date 2022/5/20 16:40
*/
private String getPublicKey() {
String key = RedisKeys.getDhPublicKey();
Object obj = redisUtils.get(key);
if (null != obj) {
return (String) obj;
}
String url = dhCloudProperties.getUrl().concat(GET_PUBLIC_KEY);
Map<String, String> paramsMap = new HashMap<>(4);
DhPublicKeyFormDTO dto = new DhPublicKeyFormDTO();
dto.setLoginName(dhCloudProperties.getLoginName());
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "publicKey获取失败");
}
JSONObject toResult = JSON.parseObject(data);
if (!toResult.containsKey("publicKey")) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "publicKey获取失败");
}
String publicKey = toResult.get("publicKey").toString();
redisUtils.set(key, publicKey, RedisUtils.MINUTE_THIRTY_EXPIRE);
return publicKey;
}
/**
* 获取loginPass
*
* @param
* @return void
* @author zhy
* @date 2022/5/20 16:40
*/
private DhTokenDTO getLoginPass(String publicKey) {
String key = RedisKeys.getDhToken();
Object obj = redisUtils.get(key);
if (null != obj) {
return (DhTokenDTO) obj;
}
String url = dhCloudProperties.getUrl().concat(GET_LOGIN_PASS);
Map<String, String> paramsMap = new HashMap<>(4);
DhLoginPassFormDTO dto = new DhLoginPassFormDTO();
dto.setLoginName(dhCloudProperties.getLoginName());
String pwd;
try {
pwd = RSAUtils.getPwdByRsa(publicKey, dhCloudProperties.getLoginPass());
} catch (Exception e) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass加密失败");
}
dto.setLoginPass(pwd);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass获取失败");
}
JSONObject toResult = JSON.parseObject(data);
if (!toResult.containsKey("token")) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass获取失败");
}
DhTokenDTO token = new DhTokenDTO();
token.setId(toResult.get("id").toString());
token.setLoginName(toResult.get("loginName").toString());
token.setPublicKey(toResult.get("publicKey").toString());
token.setToken(toResult.get("token").toString());
redisUtils.set(key, token, RedisUtils.MINUTE_THIRTY_EXPIRE);
return token;
}
/**
* 新增部门
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
private Long getDept() {
String url = dhCloudProperties.getUrl().concat(GET_DEPARTMENT);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, Object> paramsMap = new HashMap<>(4);
// DhDeptFormDTO dto = new DhDeptFormDTO();
// dto.setName("访客部门");
// dto.setParentId(1L);
String data = HttpClientManager.getInstance().sendGet(url, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
for (int i = 0; i < jsonArray.size(); i++) {
if ("临时人员".equals(jsonArray.getJSONObject(i).get("name").toString())) {
return Long.parseLong(jsonArray.getJSONObject(i).get("id").toString());
}
}
return null;
}
/**
* 查询节点
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
private String getNode(String nodeName) {
String url = dhCloudProperties.getUrl().concat(GET_NODE);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhNodeFormDTO dto = new DhNodeFormDTO();
dto.setNodeId("ORG_001");
dto.setTypeCode("01;0;8;7");
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询节点列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询节点列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
for (int i = 0; i < jsonArray.size(); i++) {
if (nodeName.equals(jsonArray.getJSONObject(i).get("name").toString())) {
return jsonArray.getJSONObject(i).get("id").toString();
}
}
return null;
}
/**
* 人员预处理
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
private void personHandle(String code) {
String url = dhCloudProperties.getUrl().concat(LIST_PERSON);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhPersonPageFormDTO dto = new DhPersonPageFormDTO();
dto.setPageNum(1);
dto.setPageSize(100);
dto.setCode(code);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询人员列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询人员列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
List<Integer> ids = new ArrayList<>();
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
for (int i = 0; i < jsonArray.size(); i++) {
ids.add(Integer.parseInt(jsonArray.getJSONObject(i).get("id").toString()));
}
if (!ids.isEmpty()) {
DhPersonDelFormDTO del = new DhPersonDelFormDTO();
del.setPersonIds(ids);
delPerson(del);
}
}
/**
* 卡片预处理
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
private void cardHandle(String code) {
String url = dhCloudProperties.getUrl().concat(LIST_CARD);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhCardPageFormDTO dto = new DhCardPageFormDTO();
dto.setPageNum(1);
dto.setPageSize(100);
dto.setPersonCode(code);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询卡片列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询卡片列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
for (int i = 0; i < jsonArray.size(); i++) {
delCard(jsonArray.getJSONObject(i).get("cardNumber").toString());
}
}
/**
* 删除人员
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
private void delPerson(DhPersonDelFormDTO dto) {
String url = dhCloudProperties.getUrl().concat(DEL_PERSON);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "删除人员失败");
}
}
/**
* 退卡
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
private void delCard(String cardNum) {
String url = dhCloudProperties.getUrl().concat(DEL_CARD);
url = url + cardNum;
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "删除卡片失败");
}
}
/**
* 获取身份
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private String getIdentity() {
String url = dhCloudProperties.getUrl().concat(GET_PERSON_IDENTITY);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, Object> paramsMap = new HashMap<>(4);
// DhIdentityFormDTO dto = new DhIdentityFormDTO();
// dto.setName("访客");
// dto.setSubsidyAmount(0D);
// dto.setIsCashRecharge(1);
// dto.setIsMachineRecharge(1);
String data = HttpClientManager.getInstance().sendGet(url, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
for (int i = 0; i < jsonArray.size(); i++) {
if ("默认身份".equals(jsonArray.getJSONObject(i).get("name").toString())) {
return jsonArray.getJSONObject(i).get("id").toString();
}
}
return "";
}
/**
* 获取开门计划
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private Long getPlan() {
String url = dhCloudProperties.getUrl().concat(GET_DOOR_PLAN);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhPlanPageFormDTO dto = new DhPlanPageFormDTO();
dto.setPageNum(1);
dto.setPageSize(100);
dto.setSingleCondition("默认");
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
if (jsonArray.size() > 0) {
return Long.parseLong(jsonArray.getJSONObject(0).get("id").toString());
}
return null;
}
/**
* 查询通道
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private List<DhChannelResultDTO> getChannel() {
String url = dhCloudProperties.getUrl().concat(GET_DOOR_CHANNEL);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhChannelPageFormDTO dto = new DhChannelPageFormDTO();
dto.setPageSize(100);
dto.setPageNum(1);
dto.setDeviceGenre("0");
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
List<DhChannelResultDTO> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonItem = jsonArray.getJSONObject(i);
DhChannelResultDTO channel = new DhChannelResultDTO();
channel.setPrivilegeType("1");
channel.setResouceCode(jsonItem.get("channelCode").toString());
list.add(channel);
}
return list;
}
/**
* 查询通道-从全部设备中获取
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private List<DhChannelResultDTO> getAllChannel(String nodeName) {
String nodeId = getNode(nodeName);
if (StringUtils.isBlank(nodeId)) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询节点失败");
}
nodeId = nodeId.replaceAll("ORG_", "");
String url = dhCloudProperties.getUrl().concat(GET_CHANNEL);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhChannelFormDTO dto = new DhChannelFormDTO();
dto.setInterfaceId("admin_001_006");
dto.setJsonParam("{\"param\":{\"unitType\":7,\"orgCode\":\"" + nodeId + "\"}}");
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
List<DhChannelResultDTO> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonItem = jsonArray.getJSONObject(i);
DhChannelResultDTO channel = new DhChannelResultDTO();
channel.setPrivilegeType("1");
channel.setResouceCode(jsonItem.get("channelId").toString());
list.add(channel);
}
return list;
}
/**
* 新增人员
*
* @param dto
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private Long addPerson(DhPersonFormDTO dto) {
// 数据预处理
dataHandle(dto.getCode());
String url = dhCloudProperties.getUrl().concat(ADD_PERSON);
String urlParam = getDhUrlParams();
url = url + urlParam;
Long deptId = getDept();
if (null == deptId) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询临时人员部门失败");
}
String identity = getIdentity();
if (StringUtils.isBlank(identity)) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份失败");
}
dto.setDeptId(deptId);
dto.setPersonIdentityId(identity);
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "新增人员失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "新增人员失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
if (null != registerResult) {
return Long.parseLong(registerResult.toString());
}
return null;
}
/**
* 下发人员头像
*
* @param dto
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private String addPersonImg(DhPersonFormDTO dto, String imgUrl) {
DhPersonImgFormDTO imgFormDTO = new DhPersonImgFormDTO();
String url = dhCloudProperties.getUrl().concat(ADD_PERSON_IMG);
String urlParam = getDhUrlParams();
url = url + urlParam;
imgFormDTO.setPersonCode(dto.getCode());
imgFormDTO.setBase64file(getBase64ByUrl(imgUrl));
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(imgFormDTO), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员头像失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员头像失败!" + result.getErrMsg());
} else {
return "success";
}
}
/**
* 人员开卡
*
* @param dto
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private String addPersonCard(DhPersonFormDTO dto) {
Long personId = addPerson(dto);
if (personId == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "添加人员信息失败");
}
DhPersonCardListFormDTO cardListFormDTO = new DhPersonCardListFormDTO();
List<DhPersonCardFormDTO> cardList = new ArrayList<>();
DhPersonCardFormDTO cardFormDTO = new DhPersonCardFormDTO();
String url = dhCloudProperties.getUrl().concat(OPEN_CARD);
String urlParam = getDhUrlParams();
url = url + urlParam;
cardFormDTO.setPersonId(personId);
cardFormDTO.setPersonName(dto.getName());
cardFormDTO.setCardNumber(generateNiceString(8));
cardFormDTO.setCardType("0");
cardFormDTO.setCategory("0");
cardFormDTO.setCardStatus("ACTIVE");
cardFormDTO.setStartDate(LocalDate.now().minusDays(1L).toString());
cardFormDTO.setEndDate(LocalDate.now().plusDays(1L).toString());
String pwd;
try {
pwd = RSAUtils.getPwdByRsa(getPublicKey(), "123456");
} catch (Exception e) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "密码加密失败");
}
cardFormDTO.setCardPassword(pwd);
cardFormDTO.setSubSystems("1");
cardList.add(cardFormDTO);
cardListFormDTO.setObjectList(cardList);
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(cardListFormDTO), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败!" + result.getErrMsg());
} else {
return cardFormDTO.getCardNumber();
}
}
/**
* 下发人员权限
*
* @param dto
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
private String addPersonAuth(DhPersonFormDTO dto, String imgUrl, String node) {
String personCard = addPersonCard(dto);
if (StringUtils.isBlank(personCard)) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "开卡失败");
} else if (StringUtils.isNotBlank(imgUrl)) {
addPersonImg(dto, imgUrl);
}
// List<DhChannelResultDTO> channel = getAllChannel(node);
List<DhChannelResultDTO> channel = getChannel();
if (channel.isEmpty()) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取通道失败");
}
Long plan = getPlan();
if (plan == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取开门计划失败");
}
DhAuthFormDTO authFormDTO = new DhAuthFormDTO();
String url = dhCloudProperties.getUrl().concat(ADD_AUTH);
String urlParam = getDhUrlParams();
url = url + urlParam;
authFormDTO.setCardNumber(personCard);
authFormDTO.setTimeQuantumId(plan.toString());
authFormDTO.setCardPrivilegeDetails(channel);
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(authFormDTO), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员权限失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员权限失败!" + result.getErrMsg());
} else {
return "success";
}
}
/**
* 拼接url固定参数
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/7/28 16:09
*/
private String getDhUrlParams() {
DhTokenDTO token = getLoginPass(getPublicKey());
return "?userId=" + token.getId() + "&username=" + token.getLoginName() + "&token=" + token.getToken();
}
private String getBase64ByUrl(String imgUrl) {
String ossDomain;
byte[] fileBytes;
try {
URL url = new URL(imgUrl);
DataInputStream dataInputStream = new DataInputStream(url.openStream());
byte[] originBytes = toByteArray(dataInputStream);
fileBytes = compressPicCycle(originBytes, 100L, 0.3);
} catch (IOException e) {
logger.error("图片上传异常", e);
throw new RenException("图片上传异常");
}
return DatatypeConverter.printBase64Binary(fileBytes);
}
/**
* @param bytes 原图片字节数组
* @param desFileSize 指定图片大小,单位 kb
* @param accuracy 精度,递归压缩的比率,建议小于0.9
* @return
*/
private byte[] compressPicCycle(byte[] bytes, long desFileSize, double accuracy) throws IOException {
// 获取目标图片
long fileSize = bytes.length;
System.out.println("=====fileSize======== " + fileSize);
// 判断图片大小是否小于指定图片大小
if (fileSize <= desFileSize * 1024) {
return bytes;
}
//计算宽高
BufferedImage bim = ImageIO.read(new ByteArrayInputStream(bytes));
int imgWidth = bim.getWidth();
System.out.println(imgWidth + "====imgWidth=====");
int imgHeight = bim.getHeight();
int desWidth = new BigDecimal(imgWidth).multiply(new BigDecimal(accuracy)).intValue();
System.out.println(desWidth + "====desWidth=====");
int desHeight = new BigDecimal(imgHeight).multiply(new BigDecimal(accuracy)).intValue();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); //字节输出流(写入到内存)
Thumbnails.of(new ByteArrayInputStream(bytes)).size(desWidth, desHeight).outputQuality(accuracy).toOutputStream(baos);
//如果不满足要求,递归直至满足要求
return compressPicCycle(baos.toByteArray(), desFileSize, accuracy);
}
/**
* inputstream输入流转换成byte[]字节数组
*
* @param input
* @return byte[]
* @author yinzuomei
* @date 2020/2/27 16:09
*/
private byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024 * 4];
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
return output.toByteArray();
}
/**
* 随机生成16进制字符串
*
* @param len
* @return java.lang.String
* @author zhy
* @date 2022/7/29 9:47
*/
private String generateNiceString(int len) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i++) {
sb.append(Integer.toHexString(new Random().nextInt(16)));
}
return sb.toString().toUpperCase();
}
/**
* 退卡然后删除人员
*
* @param code
* @return void
* @author zhy
* @date 2022/8/3 10:48
*/
private void dataHandle(String code) {
// 先退卡
cardHandle(code);
// 再删人员
personHandle(code);
}
}

141
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/DhResult.java

@ -0,0 +1,141 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.util.dh;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ErrorCode;
import com.epmet.commons.tools.utils.MessageUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
/**
* 响应数据
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
public class DhResult<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 编码0表示成功其他值表示失败
*/
private Integer code = 0;
/**
* 消息内容
*/
private String errMsg = "success";
/**
* 内部信息
*/
private Boolean success = true;
/**
* 响应数据
*/
private T data;
public DhResult<T> ok(T data) {
this.setData(data);
return this;
}
public boolean success(){
return code == 0;
}
/**
* 返回
* "code": 8000,
* "msg": "服务器开小差了...",
*/
public DhResult<T> error() {
this.code = EpmetErrorCode.SERVER_ERROR.getCode();
this.errMsg = EpmetErrorCode.getMsg(code);
if (StringUtils.isBlank(this.errMsg)) {
this.errMsg = MessageUtils.getMessage(this.code);
}
return this;
}
/**
* 根据错误编码查询msg返回
*/
public DhResult<T> error(int code) {
this.code = code;
this.errMsg = EpmetErrorCode.getMsg(code);
if (StringUtils.isBlank(this.errMsg)) {
this.errMsg = MessageUtils.getMessage(this.code);
}
return this;
}
/**
* 传入错误编码+msg返回
*/
public DhResult<T> error(int code, String msg) {
this.code = code;
this.errMsg = msg;
return this;
}
/**
*
* @param msg
* @return 此方法废弃统一使用
* logger.error(XXXX);
* throw new RenException(XXXX);
* XXXX定义常量里
*/
@Deprecated
public DhResult<T> error(String msg) {
this.code = ErrorCode.INTERNAL_SERVER_ERROR;
this.errMsg = msg;
return this;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
}

85
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/IDUtils.java

@ -0,0 +1,85 @@
package com.epmet.util.dh;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class IDUtils {
public static String getIdNo(boolean male) {
//随机生成生日 1~99岁
long begin = System.currentTimeMillis() - 3153600000000L;//100年内
long end = System.currentTimeMillis() - 31536000000L; //1年内
long rtn = begin + (long) (Math.random() * (end - begin));
Date date = new Date(rtn);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
String birth = simpleDateFormat.format(date);
return getIdNo(birth, male);
}
public static String getIdNo(String birth, boolean male) {
StringBuilder sb = new StringBuilder();
Random random = new Random();
int value = random.nextInt(Cities.cities.length);
sb.append(Cities.cities[value]);
sb.append(birth);
value = random.nextInt(999) + 1;
if (male && value % 2 == 0) {
value++;
}
if (!male && value % 2 == 1) {
value++;
}
if (value >= 100) {
sb.append(value);
} else if (value >= 10) {
sb.append('0').append(value);
} else {
sb.append("00").append(value);
}
sb.append(calcTrailingNumber(sb));
return sb.toString();
}
private static final int[] calcC = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
private static final char[] calcR = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
private static char calcTrailingNumber(StringBuilder sb) {
int[] n = new int[17];
int result = 0;
for (int i = 0; i < n.length; i++) {
n[i] = Integer.parseInt(String.valueOf(sb.charAt(i)));
}
for (int i = 0; i < n.length; i++) {
result += calcC[i] * n[i];
}
return calcR[result % 11];
}
/**
* 根据身份证号判断用户性别
*
* @param cardNo
* @return
*/
public static String getSex(String cardNo) {
String sexStr = "0";
if (cardNo.length() == 15) {
sexStr = cardNo.substring(14, 15);
} else if (cardNo.length() == 18) {
sexStr = cardNo.substring(16, 17);
}
int sexNo = Integer.parseInt(sexStr);
return sexNo % 2 == 0 ? "女" : "男";
}
// public static void main(String[] args) {
// long a = System.currentTimeMillis();
// System.out.println(getIdNo("19790306", true));
// System.out.println(getIdNo("20100112", false));
// System.out.println(getIdNo(true));
// System.out.println(getIdNo(false));
// a = System.currentTimeMillis() - a;
// System.out.println(a);
// }
}

316
epmet-user/epmet-user-server/src/main/java/com/epmet/util/dh/RSAUtils.java

@ -0,0 +1,316 @@
package com.epmet.util.dh;
import cn.hutool.core.codec.Base64;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.Cipher;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
/**
*
*<p>Title:RSAUtils</p>
*<p>Description:RSA工具类</p>
*<p>Company:浙江大华技术股份有限公司</p>
* @author 32174
* @date 2018年12月18日
*/
public class RSAUtils{
public static final String KEY_ALGORITHM = "RSA";
public static final String SIGNATURE_ALGORITHM = "MD5withRSA";
public static final String PADDING="RSA/None/PKCS1Padding";
private static final String PUBLIC_KEY = "RSAPublicKey";
private static final String PRIVATE_KEY = "RSAPrivateKey";
private static final int KEY_SIZE = 1024; // 秘钥长度1024,最长加密117字节明文
static{
Security.addProvider(new BouncyCastleProvider());
}
/**
* 用私钥对信息生成数字签名
*
* @param data
* 加密数据
* @param privateKey
* 私钥
*
* @return
* @throws Exception
*/
public static String sign(byte[] data, String privateKey) throws Exception {
// 解密由base64编码的私钥
byte[] keyBytes = decryptBASE64(privateKey);
// 构造PKCS8EncodedKeySpec对象
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
// KEY_ALGORITHM 指定的加密算法
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
// 取私钥匙对象
PrivateKey priKey = keyFactory.generatePrivate(pkcs8KeySpec);
// 用私钥对信息生成数字签名
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
signature.initSign(priKey);
signature.update(data);
return encryptBASE64(signature.sign());
}
/**
* BASE64加密
*
* @param key
* @return
* @throws Exception
*/
public static String encryptBASE64(byte[] key) throws Exception {
return Base64Util.encodeBase64String(key);
}
/**
* BASE64解密
*
* @param key
* @return
* @throws Exception
*/
public static byte[] decryptBASE64(String key) throws Exception {
return Base64Util.decodeBase64(key.getBytes());
}
/**
* 校验数字签名
*
* @param data
* 加密数据
* @param publicKey
* 公钥
* @param sign
* 数字签名
*
* @return 校验成功返回true 失败返回false
* @throws Exception
*
*/
public static boolean verify(byte[] data, String publicKey, String sign)
throws Exception {
// 解密由base64编码的公钥
byte[] keyBytes = decryptBASE64(publicKey);
// 构造X509EncodedKeySpec对象
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
// KEY_ALGORITHM 指定的加密算法
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
// 取公钥匙对象
PublicKey pubKey = keyFactory.generatePublic(keySpec);
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
signature.initVerify(pubKey);
signature.update(data);
// 验证签名是否正常
return signature.verify(decryptBASE64(sign));
}
/**
* 解密<br>
* 用私钥解密
*
* @param data
* @param key
* @return
* @throws Exception
*/
public static byte[] decryptByPrivateKey(byte[] data, String key)
throws Exception {
// 对密钥解密
byte[] keyBytes = decryptBASE64(key);
// 取得私钥
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
// 对数据解密
Cipher cipher = Cipher.getInstance(PADDING , BouncyCastleProvider.PROVIDER_NAME);
cipher.init(Cipher.DECRYPT_MODE, privateKey);
return cipher.doFinal(data);
}
/**
* 解密<br>
* 用公钥解密
*
* @param data
* @param key
* @return
* @throws Exception
*/
public static byte[] decryptByPublicKey(byte[] data, String key)
throws Exception {
// 对密钥解密
byte[] keyBytes = decryptBASE64(key);
// 取得公钥
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key publicKey = keyFactory.generatePublic(x509KeySpec);
// 对数据解密
Cipher cipher = Cipher.getInstance(PADDING , BouncyCastleProvider.PROVIDER_NAME);
cipher.init(Cipher.DECRYPT_MODE, publicKey);
return cipher.doFinal(data);
}
/**
* 加密<br>
* 用公钥加密
*
* @param data
* @param key
* @return
* @throws Exception
*/
public static byte[] encryptByPublicKey(byte[] data, String key)
throws Exception {
// 对公钥解密
byte[] keyBytes = decryptBASE64(key);
// 取得公钥
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key publicKey = keyFactory.generatePublic(x509KeySpec);
// 对数据加密
Cipher cipher = Cipher.getInstance(PADDING , BouncyCastleProvider.PROVIDER_NAME);
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return cipher.doFinal(data);
}
/**
* 加密<br>
* 用私钥加密
*
* @param data
* @param key
* @return
* @throws Exception
*/
public static byte[] encryptByPrivateKey(byte[] data, String key)
throws Exception {
// 对密钥解密
byte[] keyBytes = decryptBASE64(key);
// 取得私钥
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
// 对数据加密
Cipher cipher = Cipher.getInstance(PADDING , BouncyCastleProvider.PROVIDER_NAME);
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
return cipher.doFinal(data);
}
/**
* 取得私钥(BASE64编码)
*
* @param keyMap
* @return
* @throws Exception
*/
public static String getPrivateKey(Map<String, Object> keyMap)
throws Exception {
Key key = (Key) keyMap.get(PRIVATE_KEY);
return encryptBASE64(key.getEncoded());
}
/**
* 取得公钥(BASE64编码)
*
* @param keyMap
* @return
* @throws Exception
*/
public static String getPublicKey(Map<String, Object> keyMap)
throws Exception {
Key key = (Key) keyMap.get(PUBLIC_KEY);
return encryptBASE64(key.getEncoded());
}
/**
* 判断字符串是否被公钥加密
* @param text
* @param privateKey
* @return
*/
public static boolean isTextEncryptByPublicKey(String text , String privateKey){
boolean bol = true;
try{
byte[] encryBytes = RSAUtils.decryptBASE64(text);
RSAUtils.decryptByPrivateKey(encryBytes, privateKey);
}catch(Exception e){
bol = false;
}
return bol;
}
/**
* 初始化密钥
*
* @return
* @throws Exception
*/
public static Map<String, Object> initKey() throws Exception {
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM , BouncyCastleProvider.PROVIDER_NAME);
keyPairGen.initialize(KEY_SIZE , new SecureRandom());
KeyPair keyPair = keyPairGen.generateKeyPair();
// 公钥
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
// 私钥
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
Map<String, Object> keyMap = new HashMap<String, Object>(2);
keyMap.put(PUBLIC_KEY, publicKey);
keyMap.put(PRIVATE_KEY, privateKey);
return keyMap;
}
/**
* 密码加密
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/7/29 10:46
*/
public static String getPwdByRsa(String publicKey, String str) throws Exception {
byte[] decoded = Base64.decode(publicKey);
RSAPublicKey pubKey =(RSAPublicKey)KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));// RSA加密
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
return Base64.encode(cipher.doFinal(str.getBytes("UTF-8")));
}
}

1
epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.65__resi_collect_alter.sql

@ -0,0 +1 @@
ALTER TABLE epmet_user.ic_resi_collect_visitor MODIFY COLUMN ADDRESS varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '详细地址';

56
epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.66__chart_hour.sql

@ -0,0 +1,56 @@
/*
Navicat Premium Data Transfer
Source Server : epmet_cloud_dev_user
Source Server Type : MySQL
Source Server Version : 50726
Source Host : 192.168.1.140:3306
Source Schema : epmet_user
Target Server Type : MySQL
Target Server Version : 50726
File Encoding : 65001
Date: 22/08/2022 13:31:44
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for pli_chart_hour
-- ----------------------------
DROP TABLE IF EXISTS `pli_chart_hour`;
CREATE TABLE `pli_chart_hour` (
`hour` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '图表日期链表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of pli_chart_hour
-- ----------------------------
INSERT INTO `pli_chart_hour` VALUES ('01');
INSERT INTO `pli_chart_hour` VALUES ('02');
INSERT INTO `pli_chart_hour` VALUES ('03');
INSERT INTO `pli_chart_hour` VALUES ('04');
INSERT INTO `pli_chart_hour` VALUES ('05');
INSERT INTO `pli_chart_hour` VALUES ('06');
INSERT INTO `pli_chart_hour` VALUES ('07');
INSERT INTO `pli_chart_hour` VALUES ('08');
INSERT INTO `pli_chart_hour` VALUES ('09');
INSERT INTO `pli_chart_hour` VALUES ('10');
INSERT INTO `pli_chart_hour` VALUES ('11');
INSERT INTO `pli_chart_hour` VALUES ('12');
INSERT INTO `pli_chart_hour` VALUES ('13');
INSERT INTO `pli_chart_hour` VALUES ('14');
INSERT INTO `pli_chart_hour` VALUES ('15');
INSERT INTO `pli_chart_hour` VALUES ('16');
INSERT INTO `pli_chart_hour` VALUES ('17');
INSERT INTO `pli_chart_hour` VALUES ('18');
INSERT INTO `pli_chart_hour` VALUES ('19');
INSERT INTO `pli_chart_hour` VALUES ('20');
INSERT INTO `pli_chart_hour` VALUES ('21');
INSERT INTO `pli_chart_hour` VALUES ('22');
INSERT INTO `pli_chart_hour` VALUES ('23');
INSERT INTO `pli_chart_hour` VALUES ('00');
SET FOREIGN_KEY_CHECKS = 1;

88
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectVisitorDao.xml

@ -60,8 +60,33 @@
UPDATED_TIME
from ic_resi_collect_visitor
where DEL_FLAG = '0'
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( CREATED_TIME, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
AND CUSTOMER_ID = #{customerId}
<if test="idCard != null and idCard != ''">
AND ID_CARD = #{idCard}
</if>
<if test="name != null and name != ''">
AND NAME = #{name}
</if>
<if test="mobile != null and mobile != ''">
AND MOBILE = #{mobile}
</if>
<if test="villageId != null and villageId != ''">
AND VILLAGE_ID = #{villageId}
</if>
<if test="buildId != null and buildId != ''">
AND BUILD_ID = #{buildId}
</if>
<if test="unitId != null and unitId != ''">
AND UNIT_ID = #{unitId}
</if>
<if test="homeId != null and homeId != ''">
AND HOME_ID = #{homeId}
</if>
<if test="startTime != null and startTime != ''">
AND CREATED_TIME >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND CREATED_TIME &lt;= #{endTime}
</if>
order by CREATED_TIME desc
</select>
@ -95,14 +120,65 @@
UPDATED_TIME
from ic_resi_collect_visitor
where DEL_FLAG = '0'
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( CREATED_TIME, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
AND CUSTOMER_ID = #{customerId}
<if test="idCard != null and idCard != ''">
AND ID_CARD = #{idCard}
</if>
<if test="name != null and name != ''">
AND NAME = #{name}
</if>
<if test="mobile != null and mobile != ''">
AND MOBILE = #{mobile}
</if>
<if test="villageId != null and villageId != ''">
AND VILLAGE_ID = #{villageId}
</if>
<if test='orgId != null and orgId != "" '>
AND CONCAT(PIDS,':',AGENCY_ID) LIKE CONCAT('%',#{orgId},'%')
<if test="buildId != null and buildId != ''">
AND BUILD_ID = #{buildId}
</if>
<if test="unitId != null and unitId != ''">
AND UNIT_ID = #{unitId}
</if>
<if test="homeId != null and homeId != ''">
AND HOME_ID = #{homeId}
</if>
<if test="startTime != null and startTime != ''">
AND CREATED_TIME >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND CREATED_TIME &lt;= #{endTime}
</if>
order by CREATED_TIME desc
</select>
<select id="getLastInfo" resultType="com.epmet.entity.IcResiCollectVisitorEntity">
SELECT
NAME,
MOBILE,
ID_CARD,
FACE_IMG
FROM
ic_resi_collect_visitor
WHERE
DEL_FLAG = '0'
AND CREATED_BY = #{userId}
AND CUSTOMER_ID = #{customerId}
ORDER BY
CREATED_TIME DESC
LIMIT 1
</select>
<select id="getTraffic" resultType="com.epmet.dto.result.VisitVisitorChartResultDTO">
SELECT
CONCAT( h.`hour`, ':00' ) AS HOUR,
COUNT( v.id ) AS num
FROM
pli_chart_hour h
LEFT JOIN ic_resi_collect_visitor v ON h.`hour` = DATE_FORMAT( v.CREATED_TIME, '%H' )
AND DATE_FORMAT( v.CREATED_TIME, '%Y-%m-%d' ) = #{date}
GROUP BY
h.`hour`;
</select>
</mapper>

43
epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccinePrarmeterDao.xml

@ -0,0 +1,43 @@
<?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.dao.IcVaccinePrarmeterDao">
<resultMap type="com.epmet.entity.IcVaccinePrarmeterEntity" id="icVaccinePrarmeterMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="gridName" column="GRID_NAME"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="pids" column="PIDS"/>
<result property="villageId" column="VILLAGE_ID"/>
<result property="villageName" column="VILLAGE_NAME"/>
<result property="buildId" column="BUILD_ID"/>
<result property="buildName" column="BUILD_NAME"/>
<result property="unitId" column="UNIT_ID"/>
<result property="unitName" column="UNIT_NAME"/>
<result property="homeId" column="HOME_ID"/>
<result property="homeName" column="HOME_NAME"/>
<result property="householdType" column="HOUSEHOLD_TYPE"/>
<result property="name" column="NAME"/>
<result property="mobile" column="MOBILE"/>
<result property="idCard" column="ID_CARD"/>
<result property="isVaccination" column="IS_VACCINATION"/>
<result property="firstVacTime" column="FIRST_VAC_TIME"/>
<result property="firstVacSite" column="FIRST_VAC_SITE"/>
<result property="secondVacTime" column="SECOND_VAC_TIME"/>
<result property="secondVacSite" column="SECOND_VAC_SITE"/>
<result property="thirdVacTime" column="THIRD_VAC_TIME"/>
<result property="thirdVacSite" column="THIRD_VAC_SITE"/>
<result property="reason" column="REASON"/>
<result property="note" column="NOTE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

2
epmet-user/epmet-user-server/src/main/resources/mapper/UserDao.xml

@ -35,7 +35,7 @@
IFNULL(resi.ID,"") AS resiId,
IFNULL(CONCAT(resi.SURNAME,resi.NAME),"") AS userRealName,
IFNULL(relation.GRID_ID,"") AS gridId,
IFNULL(resi.id_num,'')AS idNum
IFNULL(wechat.id_num,'')AS idNum
FROM
USER user
LEFT JOIN

Loading…
Cancel
Save