screen-api/src/main/java/com/moral/api/controller/RectifyController.java
New file @@ -0,0 +1,89 @@ package com.moral.api.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; 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 java.util.Map; import javax.servlet.http.HttpServletRequest; import com.moral.api.entity.Rectify; import com.moral.api.service.RectifyService; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; import com.moral.util.WebUtils; @Slf4j @Api(tags = {"企业整顿"}) @RestController @CrossOrigin(origins = "*", maxAge = 3600) @RequestMapping("rectify") public class RectifyController { @Autowired private RectifyService rectifyService; @PostMapping("addRectify") public ResultMessage addRectify(@RequestBody Rectify rectify) { if (rectify.getCityCode() == null || rectify.getCityName() == null) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } int count = rectifyService.addRectify(rectify); if (count > 0) { return ResultMessage.ok(); } return ResultMessage.fail(); } @ApiOperation(value = "分页整顿清单", notes = "分页整顿清单") @ApiImplicitParams({ @ApiImplicitParam(name = "cityCode", value = "城市编码", required = false, paramType = "query", dataType = "int"), @ApiImplicitParam(name = "time", value = "时间,例:2022", required = false, paramType = "query", dataType = "String"), @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "int"), @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "int") }) @GetMapping("queryRectify") public ResultMessage queryRectify(HttpServletRequest request) { Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); if (params.get("cityCode") == null || params.get("time") == null) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } Map<String, Object> response = rectifyService.queryRectifyByCityCode(params); return ResultMessage.ok(response); } @PostMapping("updateRectify") public ResultMessage updateRectify(@RequestBody Rectify rectify) { if (rectify.getId() == null) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } int count = rectifyService.updateRectify(rectify); if (count > 0) { return ResultMessage.ok(); } return ResultMessage.fail(); } @GetMapping("deleteRectify") public ResultMessage deleteRectify(Integer id) { if (id == null) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } int count = rectifyService.deleteRectify(id); if (count > 0) { return ResultMessage.ok(); } return ResultMessage.fail(); } } screen-api/src/main/java/com/moral/api/entity/Rectify.java
New file @@ -0,0 +1,156 @@ package com.moral.api.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import java.time.LocalDateTime; import java.io.Serializable; import java.util.Date; import lombok.Data; import lombok.EqualsAndHashCode; /** * <p> * 企业整顿清单 * </p> * * @author moral * @since 2022-04-13 */ @Data @EqualsAndHashCode(callSuper = false) public class Rectify extends Model<Rectify> { private static final long serialVersionUID = 1L; /** * 主键 */ @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 地区编码 */ private Integer cityCode; /** * 地区名称 */ private String cityName; /** * 县市区名称 */ private String areaName; /** * 乡镇名称 */ private String townName; /** * 组织机构代码 */ private String institutionCode; /** * 企业名称 */ private String enterpriseName; /** * 企业地址 */ private String enterpriseAddress; /** * 经度 */ private Double longitude; /** * 纬度 */ private Double latitude; /** * 企业规模 */ private String enterpriseScale; /** * 主要原料,多个逗号隔开 */ private String material; /** * 主要燃料,多个逗号隔开 */ private String fuel; /** * 主要产品,多个逗号隔开 */ private String product; /** * 完成时间 */ @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date completeTime; /** * 责任单位 */ private String responsibleUnit; /** * 责任人 */ private String responsiblePerson; /** * 是否完成 */ private String isComplete; /** * 整顿类别 */ private String rectifyCategory; /** * 备注 */ private String remarks; /** * 创建时间 */ @JsonIgnore private Date createTime; /** * 更新时间 */ @JsonIgnore private Date updateTime; /** * 是否删除,0:不删除,1:删除 */ @JsonIgnore private String isDelete; @Override protected Serializable pkVal() { return this.id; } } screen-api/src/main/java/com/moral/api/mapper/RectifyMapper.java
New file @@ -0,0 +1,16 @@ package com.moral.api.mapper; import com.moral.api.entity.Rectify; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * 企业整顿清单 Mapper 接口 * </p> * * @author moral * @since 2022-04-13 */ public interface RectifyMapper extends BaseMapper<Rectify> { } screen-api/src/main/java/com/moral/api/service/RectifyService.java
New file @@ -0,0 +1,31 @@ package com.moral.api.service; import java.util.Date; import java.util.List; import java.util.Map; import com.moral.api.entity.Rectify; import com.baomidou.mybatisplus.extension.service.IService; /** * <p> * 企业整顿清单 服务类 * </p> * * @author moral * @since 2022-04-13 */ public interface RectifyService extends IService<Rectify> { //企业整顿清单新增 int addRectify(Rectify rectify); //分页获取企业整顿清单 Map<String, Object> queryRectifyByCityCode(Map<String, Object> params); //根据id修改清单 int updateRectify(Rectify rectify); //根据id删除 int deleteRectify(Integer id); } screen-api/src/main/java/com/moral/api/service/impl/RectifyServiceImpl.java
New file @@ -0,0 +1,79 @@ package com.moral.api.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.moral.api.entity.Rectify; import com.moral.api.mapper.RectifyMapper; import com.moral.api.service.RectifyService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.moral.constant.Constants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * <p> * 企业整顿清单 服务实现类 * </p> * * @author moral * @since 2022-04-13 */ @Service public class RectifyServiceImpl extends ServiceImpl<RectifyMapper, Rectify> implements RectifyService { @Autowired private RectifyMapper rectifyMapper; @Override public int addRectify(Rectify rectify) { return rectifyMapper.insert(rectify); } @Override public Map<String, Object> queryRectifyByCityCode(Map<String, Object> params) { //获取请求参数 Integer cityCode = Integer.parseInt(params.get("cityCode").toString()); String time = params.get("time").toString(); int page = Integer.parseInt(params.get("page").toString()); int size = Integer.parseInt(params.get("size").toString()); QueryWrapper<Rectify> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("city_code", cityCode) .eq("is_delete", Constants.NOT_DELETE) .likeRight("complete_time", time); Page<Rectify> rectifyPage = new Page<>(page, size); rectifyMapper.selectPage(rectifyPage, queryWrapper); List<Rectify> rectifyList = rectifyPage.getRecords(); Map<String, Object> result = new LinkedHashMap<>(); result.put("total", rectifyPage.getTotal()); result.put("totalPage", rectifyPage.getPages()); result.put("current", rectifyPage.getCurrent()); result.put("pageSize", rectifyPage.getSize()); result.put("item", rectifyList); return result; } @Override public int updateRectify(Rectify rectify) { UpdateWrapper<Rectify> wrapper = new UpdateWrapper<>(); wrapper.eq("id", rectify.getId()); return rectifyMapper.updateById(rectify); } @Override public int deleteRectify(Integer id) { Rectify rectify = new Rectify(); rectify.setId(id); rectify.setIsDelete(Constants.DELETE); return rectifyMapper.updateById(rectify); } } screen-api/src/main/resources/application-specialCity.yml
@@ -276,8 +276,8 @@ areaName: 洛阳市 - areaCode: 411200 areaName: 三门峡市 - areaCode: 220403 areaName: 西安区 - areaCode: 610100 areaName: 西安市 - areaCode: 610400 areaName: 咸阳市 - areaCode: 610300 @@ -304,8 +304,8 @@ areaName: 内江市 - areaCode: 511100 areaName: 乐山市 - areaCode: 511181 areaName: 峨眉山市 - areaCode: 511400 areaName: 眉山市 - areaCode: 511500 areaName: 宜宾市 - areaCode: 511800 screen-job/src/main/java/com/moral/api/service/impl/CityAqiServiceImpl.java
@@ -60,6 +60,7 @@ @Autowired private RedisTemplate redisTemplate; //城市aqi数据来源于,阿里云市场:墨迹天气(基础版CityID)全国历史天气预报接口 @Override public void insertCityAqi() { //pubtime=08的数据,是07-08之间的数据,存入数据库时的时间为07点 screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java
@@ -40,6 +40,8 @@ @Autowired private CityWeatherForecastMapper cityWeatherForecastMapper; //城市预测气象数据来源于,和风天气,逐小时天气预报(未来72小时)商业版 @Override public void insertCityWeatherForecast() { Date nextDay = DateUtils.addDays(new Date(), 1); @@ -71,4 +73,16 @@ } cityWeatherForecastMapper.insertCityWeatherForecast(cityWeatherForecasts); } public static void main(String[] args) { String time = "20221231"; long currentMils = DateUtils.getDate(time, DateUtils.yyyyMMdd_EN).getTime(); long startMils = DateUtils.getDate("2022", DateUtils.yyyy).getTime(); long mss = currentMils - startMils; long days = mss / (1000 * 60 * 60 * 24); System.out.println(days + 1); } } screen-job/src/main/java/com/moral/api/service/impl/CityWeatherServiceImpl.java
@@ -45,6 +45,7 @@ @Autowired private RedisTemplate redisTemplate; //城市气象数据来源于,和风天气,实时天气商业版 @Override public void insertCityWeather() { //获取城市配置 screen-job/src/main/java/com/moral/api/service/impl/HistoryAqiServiceImpl.java
@@ -55,6 +55,8 @@ @Autowired private RedisTemplate redisTemplate; //国控站aqi数据来自阿里云市场,大中华地区空气质量API--单站点接口 @Override @Transactional public void insertHistoryAqi() {