| | |
| | | package com.panzhihua.applets.api; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.panzhihua.applets.config.WxMaConfiguration; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.constants.FtpConstants; |
| | | import com.panzhihua.common.constants.UserConstants; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.WeatherVO; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.HttpUtils; |
| | | import com.panzhihua.common.utlis.SFTPUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.apache.commons.lang3.RandomUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | |
| | | return R.ok(nextInt); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取天气",response = WeatherVO.class) |
| | | @GetMapping(value = "/getWeather/noToken") |
| | | public R getWeather(){ |
| | | //获取请求url |
| | | String url = Constants.G_D_WEATHER_URL; |
| | | //获取请求参数 |
| | | String param = "key=" + Constants.G_D_WEATHER_KEY + "&city=510400"; |
| | | String result = HttpUtils.sendGet(url,param); |
| | | return R.ok(JSON.parseObject(result)); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // int nextInt = RandomUtils.nextInt(99999, 1000000); |
| | |
| | | public static final String PROFIT_EXPLAIN = "<p>一、简介</p><p>活动期间内,居民发布随手拍内容可获得一定现金奖励,具体奖励金额以社区设置为准,最终由对应社区统一结算。</p><p>二、如何使用</p><p>居民获得收益后由对应社区结算,具体结算方式由社区根据实际情况进行处理。</p><p>三、如何获得</p><p>1.参与活动</p><p>活动期间内,用户可以在西区社区通“随手拍”板块,用照片和视频记录展示社区生活;</p><p>活动由所在社区添加管理,社区发布活动后居民可进行参与。</p><p>2. 社区审核</p><p>社区通过对用户发布内容的质量(优质、精良、普通内容)和价值进行审核,酌情对相关用户进行奖励;</p><p>3. 获得奖励</p><p>审核完成后,根据社区设置的内容质量奖励金额下发奖励。</p><p>若内容被工作人员驳回将不可获得奖励。</p><p> </p><p><br></p>"; |
| | | |
| | | public static final String INTEGRAL_EXPLAIN = "积分说明"; |
| | | |
| | | public static final String POPULATION_ERROR_LIST = "POPULATION_ERROR_LIST_"; |
| | | |
| | | /** |
| | | * 高德地图获取天气url |
| | | */ |
| | | public static final String G_D_WEATHER_URL = "https://restapi.amap.com/v3/weather/weatherInfo"; |
| | | |
| | | /** |
| | | * 高德地图获取天气key |
| | | */ |
| | | public static final String G_D_WEATHER_KEY = "02019a956b118ac7956c8539ab02b0f5"; |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.google.common.collect.Lists; |
| | | import com.panzhihua.common.constants.BcDictionaryConstants; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.enums.*; |
| | | import com.panzhihua.common.excel.CustomSheetWriteHandler; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private int port; |
| | | private String excelUrl; |
| | | |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | public static String loadUrl; |
| | | |
| | | public ComMngPopulationServeExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl) { |
| | | public ComMngPopulationServeExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl,StringRedisTemplate stringRedisTemplate) { |
| | | this.communityService = communityService; |
| | | this.communityId = communityId; |
| | | this.userName = userName; |
| | |
| | | this.host = host; |
| | | this.port = port; |
| | | this.excelUrl = excelUrl; |
| | | this.stringRedisTemplate = stringRedisTemplate; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void saveData() { |
| | | R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); |
| | | ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); |
| | | String key = Constants.POPULATION_ERROR_LIST + communityId; |
| | | |
| | | Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); |
| | | // Map<String,Integer> dictMap = new HashMap<>(); |
| | |
| | | // populationImportErrorVOList.addAll(errorList); |
| | | // } |
| | | mistakes.addAll(list); |
| | | throw new ServiceException("500", JSON.toJSONString(mistakes)); |
| | | valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); |
| | | throw new ServiceException("500", key); |
| | | }else{ |
| | | if(!mistakes.isEmpty()){ |
| | | throw new ServiceException("500", JSON.toJSONString(mistakes)); |
| | | valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); |
| | | throw new ServiceException("500", key); |
| | | } |
| | | } |
| | | } catch (NumberFormatException e) { |
| | |
| | | @ApiModelProperty("指派人员") |
| | | private String assignPerson; |
| | | |
| | | @ApiModelProperty("指派人员名称") |
| | | private String assignPersonName; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | |
| | | @ApiModelProperty("创建人") |
| | | private Long createBy; |
| | | |
| | | @ApiModelProperty("创建人姓名") |
| | | private String createName; |
| | | |
| | | @ApiModelProperty("巡查人姓名") |
| | | private String personName; |
| | | |
| | | /** |
| | | * 是否指派 |
| | | */ |
| | | @ApiModelProperty("是否指派(1.是 0.否)") |
| | | private Integer isAssign; |
| | | |
| | | @ApiModelProperty("巡查人员名称") |
| | | private String patrolName; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * 巡查时间 |
| | | */ |
| | | @ApiModelProperty("巡查时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date PatrolTime; |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private Date patrolTime; |
| | | |
| | | /** |
| | | * (取字典表国家标准编码)巡查类型(1.防火巡查2.防汛巡查3.防疫巡查) |
| | |
| | | @ApiModelProperty("创建人") |
| | | private Long createBy; |
| | | |
| | | @ApiModelProperty("填报人名字") |
| | | private String createName; |
| | | |
| | | /** |
| | | * 巡查人员名字,多个以逗号隔开 |
| | | */ |
| | | @ApiModelProperty("巡查人员名字,多个以逗号隔开") |
| | | private String personName; |
| | | |
| | | /** |
| | | * 巡查类型 |
| | | */ |
New file |
| | |
| | | package com.panzhihua.common.model.vos.community; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel("天气返回参数") |
| | | public class WeatherVO { |
| | | |
| | | @ApiModelProperty("省份名") |
| | | private String province; |
| | | |
| | | @ApiModelProperty("城市名") |
| | | private String city; |
| | | |
| | | @ApiModelProperty("区域编码") |
| | | private String adcode; |
| | | |
| | | @ApiModelProperty("天气现象(汉字描述)") |
| | | private String weather; |
| | | |
| | | @ApiModelProperty("实时气温,单位:摄氏度") |
| | | private String reporttime; |
| | | |
| | | @ApiModelProperty("风向描述") |
| | | private String temperature; |
| | | |
| | | @ApiModelProperty("风力级别,单位:级") |
| | | private String winddirection; |
| | | |
| | | @ApiModelProperty("空气湿度") |
| | | private String windpower; |
| | | |
| | | @ApiModelProperty("数据发布的时间") |
| | | private String humidity; |
| | | } |
| | |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.enums.*; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | private int port; |
| | | @Value("${excel.userurl}") |
| | | private String excelUrl; |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | @ApiOperation(value = "分页查询实有人口列表", response = ComMngPopulationVO.class) |
| | | @PostMapping("/pagePopulation") |
| | |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl); |
| | | ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl,stringRedisTemplate); |
| | | EasyExcel.read(inputStream, null, comMngPopulationServeExcelListen).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
| | |
| | | try { |
| | | Long communityId = Long.valueOf(request.getParameter("communityId")); |
| | | inputStream = file.getInputStream(); |
| | | ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, communityId,userName,password,host,port,excelUrl); |
| | | ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, communityId,userName,password,host,port,excelUrl,stringRedisTemplate); |
| | | EasyExcel.read(inputStream, null, comMngPopulationServeExcelListen).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
| | |
| | | |
| | | @ApiOperation(value = "下载导入失败实有人口数据") |
| | | @PostMapping("/download/error/population") |
| | | public R downloadErrorPopulation(@RequestBody String mistakes) { |
| | | List<ComMngPopulationMistakeExcelVO> list = JSON.parseArray(mistakes,ComMngPopulationMistakeExcelVO.class); |
| | | public R downloadErrorPopulation(@RequestParam(value = "key") String key) { |
| | | List<ComMngPopulationMistakeExcelVO> list = new ArrayList<>(); |
| | | Boolean isExits = stringRedisTemplate.hasKey(key); |
| | | ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); |
| | | if(isExits){ |
| | | String json = valueOperations.get(key); |
| | | list= JSONArray.parseArray(json,ComMngPopulationMistakeExcelVO.class); |
| | | } |
| | | // List<ComMngPopulationMistakeExcelVO> list = JSON.parseArray(mistakes,ComMngPopulationMistakeExcelVO.class); |
| | | //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | String nowDate = DateUtils.getCurrentDateStr(); |
| | | String name = nowDate + "实有人口错误数据.xlsx"; |
| | | String nowDate = DateUtils.getCurrentDateString(); |
| | | String name = "实有人口错误数据" + nowDate +".xlsx"; |
| | | try { |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(fileName, ComMngPopulationMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new com.panzhihua.common.excel.CustomSheetWriteHandler()).build(); |
| | | excelWriter = EasyExcel.write(fileName, ComMngPopulationMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet("实有人口错误数据").build(); |
| | | excelWriter.write(list, writeSheet); |
| | | excelWriter.finish(); |
| | |
| | | Map<String,String> getPbServiceTeamById(@Param("teamId") String teamId); |
| | | |
| | | String getCreateName(@Param("userId") Long userId); |
| | | |
| | | Map<String,String> getPatrolPersonName(@Param("dangerId") Long dangerId); |
| | | } |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @auther txb |
| | |
| | | BeanUtils.copyProperties(comSwPatrolRecordDO, comSwDangerReportVO); |
| | | } |
| | | BeanUtils.copyProperties(comSwDangerReportDO, comSwDangerReportVO); |
| | | |
| | | //组装巡查类型 |
| | | if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolType())){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | String patrolTypes[] = comSwDangerReportVO.getPatrolType().split(","); |
| | | for (int i = 0; i < patrolTypes.length; i++) { |
| | | if(i != 0){ |
| | | sb.append(","); |
| | | } |
| | | if(patrolTypes[i].equals("1")){ |
| | | sb.append("防火巡查"); |
| | | }else if(patrolTypes[i].equals("2")){ |
| | | sb.append("防汛巡查"); |
| | | }else if(patrolTypes[i].equals("3")){ |
| | | sb.append("防疫巡查"); |
| | | } |
| | | } |
| | | comSwDangerReportVO.setPatrolType(sb.toString()); |
| | | } |
| | | |
| | | //查询人员信息 |
| | | if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | String personIds[] = comSwDangerReportVO.getRectifyPerson().split(","); |
| | | for (int i = 0; i < personIds.length; i++) { |
| | | if(i != 0){ |
| | | sb.append(","); |
| | | } |
| | | Map<String,String> personMap = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]); |
| | | if(personMap != null){ |
| | | sb.append(personMap.get("name")); |
| | | } |
| | | } |
| | | comSwDangerReportVO.setPersonName(sb.toString()); |
| | | } |
| | | |
| | | //查询填报人名称 |
| | | if(comSwDangerReportVO.getCreateBy() != null){ |
| | | comSwDangerReportVO.setCreateName(comSwPatrolRecordDAO.getCreateName(comSwDangerReportVO.getCreateBy())); |
| | | } |
| | | |
| | | //查询指派人名称 |
| | | if(StringUtils.isNotEmpty(comSwDangerReportVO.getAssignPerson())){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | String personIds[] = comSwDangerReportVO.getAssignPerson().split(","); |
| | | for (int i = 0; i < personIds.length; i++) { |
| | | if(i != 0){ |
| | | sb.append(","); |
| | | } |
| | | Map<String,String> personMap = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]); |
| | | if(personMap != null){ |
| | | sb.append(personMap.get("name")); |
| | | } |
| | | } |
| | | comSwDangerReportVO.setAssignPersonName(sb.toString()); |
| | | } |
| | | |
| | | //查询巡查人员 |
| | | Map<String,String> map = comSwPatrolRecordDAO.getPatrolPersonName(comSwDangerReportVO.getId()); |
| | | if(map != null){ |
| | | comSwDangerReportVO.setPatrolName(map.get("person_name")); |
| | | } |
| | | |
| | | return R.ok(comSwDangerReportVO); |
| | | } |
| | | |
| | | @Override |
| | | public R detailDangerReportByPrId(Long patrolRecordId) { |
| | | ComSwPatrolRecordDO comSwPatrolRecordDO = comSwPatrolRecordDAO.selectById(patrolRecordId); |
| | | if(comSwPatrolRecordDO == null){ |
| | | return R.fail("该隐患报告不存在"); |
| | | } |
| | | ComSwDangerReportVO comSwDangerReportVO = new ComSwDangerReportVO(); |
| | | ComSwPatrolRecordReportDO comSwPatrolRecordReportDO = comSwPatrolRecordReportDAO.selectOne(new QueryWrapper<ComSwPatrolRecordReportDO>().lambda().eq(ComSwPatrolRecordReportDO::getPatrolRecordId, patrolRecordId)); |
| | | if (null != comSwPatrolRecordReportDO) { |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @auther txb |
| | |
| | | page.setCurrent(pageNum); |
| | | |
| | | IPage<ComSwSafetyWorkRecordVO> iPage = comSwSafetyWorkRecordDAO.pageSafetyWorkRecord(page, comSwPatrolRecordPageDTO); |
| | | if(!iPage.getRecords().isEmpty()){ |
| | | iPage.getRecords().forEach(work -> { |
| | | //查询人员信息 |
| | | if(StringUtils.isNotEmpty(work.getPatrolPerson())){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | String personIds[] = work.getPatrolPerson().split(","); |
| | | for (int i = 0; i < personIds.length; i++) { |
| | | if(i != 0){ |
| | | sb.append(","); |
| | | } |
| | | Map<String,String> personMap = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]); |
| | | if(personMap != null){ |
| | | sb.append(personMap.get("name")); |
| | | } |
| | | } |
| | | work.setPersonName(sb.toString()); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | |
| | | ComSwPatrolRecordDO comSwPatrolRecordDO = comSwPatrolRecordDAO.selectById(comSwPatrolRecordReportDO.getPatrolRecordId()); |
| | | BeanUtils.copyProperties(comSwPatrolRecordDO, comSwSafetyWorkRecordVO); |
| | | } |
| | | |
| | | //组装巡查类型 |
| | | if(StringUtils.isNotEmpty(comSwSafetyWorkRecordVO.getPatrolType())){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | String patrolTypes[] = comSwSafetyWorkRecordVO.getPatrolType().split(","); |
| | | for (int i = 0; i < patrolTypes.length; i++) { |
| | | if(i != 0){ |
| | | sb.append(","); |
| | | } |
| | | if(patrolTypes[i].equals("1")){ |
| | | sb.append("防火巡查"); |
| | | }else if(patrolTypes[i].equals("2")){ |
| | | sb.append("防汛巡查"); |
| | | }else if(patrolTypes[i].equals("3")){ |
| | | sb.append("防疫巡查"); |
| | | } |
| | | } |
| | | comSwSafetyWorkRecordVO.setPatrolType(sb.toString()); |
| | | } |
| | | |
| | | //查询人员信息 |
| | | if(StringUtils.isNotEmpty(comSwSafetyWorkRecordVO.getPatrolPerson())){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | String personIds[] = comSwSafetyWorkRecordVO.getPatrolPerson().split(","); |
| | | for (int i = 0; i < personIds.length; i++) { |
| | | if(i != 0){ |
| | | sb.append(","); |
| | | } |
| | | Map<String,String> personMap = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]); |
| | | if(personMap != null){ |
| | | sb.append(personMap.get("name")); |
| | | } |
| | | } |
| | | comSwSafetyWorkRecordVO.setPersonName(sb.toString()); |
| | | } |
| | | |
| | | //查询填报人名称 |
| | | if(comSwSafetyWorkRecordVO.getCreateBy() != null){ |
| | | comSwSafetyWorkRecordVO.setCreateName(comSwPatrolRecordDAO.getCreateName(comSwSafetyWorkRecordVO.getCreateBy())); |
| | | } |
| | | |
| | | return R.ok(comSwSafetyWorkRecordVO); |
| | | } |
| | | |
| | |
| | | select `name` from sys_user where user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="getPatrolPersonName" resultType="Map"> |
| | | select cspr.person_name from com_sw_patrol_record_report as csprr |
| | | left join com_sw_patrol_record as cspr on cspr.id = csprr.patrol_record_id |
| | | where csprr.report_id = #{dangerId} |
| | | </select> |
| | | |
| | | </mapper> |