From 1798ef91a15805bbe6032805edcd662473ac7c08 Mon Sep 17 00:00:00 2001 From: zhuxinyu <1799009482@qq.com> Date: Mon, 10 Apr 2023 14:13:28 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BB=88=E7=AB=AF=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E7=AE=A1=E7=90=86bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/pq/pojo/param/RunManageParam.java | 2 ++ .../com/njcn/device/pq/pojo/vo/RunTimeVO.java | 1 - .../njcn/device/pq/mapper/DeviceMapper.java | 13 ++++++- .../device/pq/mapper/mapping/DeviceMapper.xml | 35 ++++++++++++++++--- .../pq/service/impl/RunManageServiceImpl.java | 23 ++++++------ 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/param/RunManageParam.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/param/RunManageParam.java index 0cbfbdec3..101d0c0c5 100644 --- a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/param/RunManageParam.java +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/param/RunManageParam.java @@ -72,4 +72,6 @@ public class RunManageParam extends BaseParam implements Serializable { @ApiModelProperty(name = "runFlag", value = "终端状态") private List runFlag; + @ApiModelProperty(name = "searchValue", value = "篩選數據") + private String searchValue; } diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/RunTimeVO.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/RunTimeVO.java index adf9ccd1d..99c583483 100644 --- a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/RunTimeVO.java +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/RunTimeVO.java @@ -42,7 +42,6 @@ public class RunTimeVO implements Serializable { @ApiModelProperty(name = "loginTime",value = "投运时间") private String loginTime; - @ApiModelProperty(name = "devType",value = "终端型号") private String devType; diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java index 10bd0a7d3..f5f283b7f 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java @@ -3,6 +3,7 @@ package com.njcn.device.pq.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.njcn.device.pq.pojo.po.Device; +import com.njcn.device.pq.pojo.vo.LineInfluxDbOnlineVO; import com.njcn.device.pq.pojo.vo.RunManageVO; import com.njcn.device.pq.pojo.vo.RunTimeVO; import org.apache.ibatis.annotations.Param; @@ -46,9 +47,15 @@ public interface DeviceMapper extends BaseMapper { * @param list 终端集合 * @param comFlag 状态 * @param runFlag 状态 + * @param manufacturer + * @param searchValue * @return 结果 */ - List getRunManageDevList(@Param("list") List list, @Param("comFlag")List comFlag, @Param("runFlag")List runFlag); + List getRunManageDevList(@Param("list") List list, + @Param("comFlag") List comFlag, + @Param("runFlag") List runFlag, + @Param("manufacturers") List manufacturer, + @Param("searchValue") String searchValue); /** * 获取指定等级的装置 @@ -56,4 +63,8 @@ public interface DeviceMapper extends BaseMapper { * @date 2023/2/10 */ List getDevByGrade(@Param("devId")List devIds,@Param("lineGrade") String lineGrade); + + List getOnlineEvaluate(@Param("list") List devIndexes, + @Param("begin") String searchBeginTime, + @Param("end") String searchEndTime); } diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml index b803a40fe..a019471aa 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml @@ -160,19 +160,46 @@ #{item} - + and device.Run_Flag in - + #{item1} - + and device.Com_Flag in - + #{item2} + + and device.Manufacturer in + + #{item3} + + + + + AND sub.NAME LIKE #{searchValueLike} + OR dev.NAME LIKE #{searchValueLike} + OR devT.Name LIKE #{searchValueLike} + OR device.IP LIKE #{searchValueLike} + ORDER BY areaId.NAME + diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java index d85058e10..a228c5ec8 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java @@ -93,19 +93,22 @@ public class RunManageServiceImpl implements RunManageService { if (!CollectionUtils.isEmpty(generalDeviceDTOList)) { List devIndexes = generalDeviceDTOList.stream().flatMap(list->list.getDeviceIndexes().stream()).collect(Collectors.toList()); DateFormat bf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - runManageParam.setSearchBeginTime(DateUtil.beginOfMonth(new Date()).toString(bf)); - runManageParam.setSearchEndTime(DateUtil.endOfMonth(new Date()).toString(bf)); + runManageParam.setSearchBeginTime(bf.format(DateUtil.beginOfDay(DateUtil.parse(runManageParam.getSearchBeginTime())))); + runManageParam.setSearchEndTime(bf.format(DateUtil.beginOfDay(DateUtil.parse(runManageParam.getSearchEndTime())))); + List manuList = runManageParam.getManufacturer().stream().map(SimpleDTO::getId).collect(Collectors.toList()); if(CollectionUtil.isNotEmpty(devIndexes)){ - runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag()); + runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag(),manuList,runManageParam.getSearchValue()); - StringBuilder devSql = InfluxDBCommUtils.assToInfluxParamDev(devIndexes); - String stringBuilder = "time >= '" + runManageParam.getSearchBeginTime() + "' and " + "time <= '" + runManageParam.getSearchEndTime()+"' and "+devSql+" group by dev_id"; - //sql语句 - String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE; - QueryResult queryResult = influxDbUtils.query(sql); + List lineInfluxDbOnlineVOList = deviceMapper.getOnlineEvaluate(devIndexes,runManageParam.getSearchBeginTime(),runManageParam.getSearchEndTime()); - InfluxDBResultMapper inCn = new InfluxDBResultMapper(); - List lineInfluxDbOnlineVOList = inCn.toPOJO(queryResult,LineInfluxDbOnlineVO.class); +// StringBuilder devSql = InfluxDBCommUtils.assToInfluxParamDev(devIndexes); +// String stringBuilder = "time >= '" + runManageParam.getSearchBeginTime() + "' and " + "time <= '" + runManageParam.getSearchEndTime()+"' and "+devSql+" group by dev_id"; +// //sql语句 +// String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE; +// QueryResult queryResult = influxDbUtils.query(sql); +// +// InfluxDBResultMapper inCn = new InfluxDBResultMapper(); +// List lineInfluxDbOnlineVOList = inCn.toPOJO(queryResult,LineInfluxDbOnlineVO.class); runManageDevList = runManageDevList.stream().peek(item-> lineInfluxDbOnlineVOList.stream().filter(it-> Objects.equals(item.getId(),it.getDevIndex())).findFirst().ifPresent(i->item.setOnlineEvaluate(i.getOnlineRate()))).collect(Collectors.toList()); } } From bd533be859b2542336b55c340441fad738e25b73 Mon Sep 17 00:00:00 2001 From: zhuxinyu <1799009482@qq.com> Date: Mon, 10 Apr 2023 14:43:32 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E7=9B=91=E6=B5=8B=E7=82=B9=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6=E4=BF=A1=E6=81=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/device/pq/mapper/DeviceMapper.java | 12 +- .../device/pq/mapper/mapping/DeviceMapper.xml | 145 +++++++++--------- .../pq/service/impl/RunManageServiceImpl.java | 6 +- 3 files changed, 78 insertions(+), 85 deletions(-) diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java index f5f283b7f..fae5c7785 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/DeviceMapper.java @@ -37,10 +37,12 @@ public interface DeviceMapper extends BaseMapper { * 获取监测点台账信息 * @param list 监测点集合 * @param comFlag 状态 - * @param runFlag 状态 + * @param searchValue * @return 结果 */ - List getRunManageList(@Param("list") List list, @Param("comFlag")List comFlag, @Param("runFlag")List runFlag); + List getRunManageList(@Param("list") List list, + @Param("comFlag") List comFlag, + @Param("searchValue") String searchValue); /** * 获取监测点台账信息 @@ -57,12 +59,6 @@ public interface DeviceMapper extends BaseMapper { @Param("manufacturers") List manufacturer, @Param("searchValue") String searchValue); - /** - * 获取指定等级的装置 - * @author cdf - * @date 2023/2/10 - */ - List getDevByGrade(@Param("devId")List devIds,@Param("lineGrade") String lineGrade); List getOnlineEvaluate(@Param("list") List devIndexes, @Param("begin") String searchBeginTime, diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml index a019471aa..6a1ba250f 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml @@ -18,72 +18,71 @@ diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java index a228c5ec8..5bd425928 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RunManageServiceImpl.java @@ -68,8 +68,6 @@ public class RunManageServiceImpl implements RunManageService { private final LineDetailMapper lineDetailMapper; - private final InfluxDbUtils influxDbUtils; - @Override public List getLineLedger(RunManageParam runManageParam) { DeviceInfoParam deviceInfoParam = new DeviceInfoParam(); @@ -77,8 +75,8 @@ public class RunManageServiceImpl implements RunManageService { List generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList())); List lineIndexes = generalDeviceDTOList.stream().flatMap(list->list.getLineIndexes().stream()).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(lineIndexes)) { - return deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag()); - }else { + return deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(),runManageParam.getSearchValue()); + } else { throw new BusinessException(CommonResponseEnum.FAIL); } } From b1bc826e734be3aff9c673df1e7ae5b9e6aa664b Mon Sep 17 00:00:00 2001 From: zhangbaojian <1065122561@qq.com> Date: Mon, 10 Apr 2023 14:45:34 +0800 Subject: [PATCH 3/6] =?UTF-8?q?zbj//1.=E7=81=BF=E8=83=BD=E4=BA=91=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=A7=84=E6=A8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/device/pq/pojo/vo/UserScaleVO.java | 36 ++++++ .../controller/LargeScreenController.java | 52 +++++++++ .../njcn/user/mapper/LargeScreenMapper.java | 18 +++ .../user/mapper/mapping/LargeScreenMapper.xml | 18 +++ .../njcn/user/service/LargeScreenService.java | 18 +++ .../service/impl/LargeScreenServiceImpl.java | 106 ++++++++++++++++++ 6 files changed, 248 insertions(+) create mode 100644 pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/UserScaleVO.java create mode 100644 pqs-user/user-boot/src/main/java/com/njcn/user/controller/LargeScreenController.java create mode 100644 pqs-user/user-boot/src/main/java/com/njcn/user/mapper/LargeScreenMapper.java create mode 100644 pqs-user/user-boot/src/main/java/com/njcn/user/mapper/mapping/LargeScreenMapper.xml create mode 100644 pqs-user/user-boot/src/main/java/com/njcn/user/service/LargeScreenService.java create mode 100644 pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/LargeScreenServiceImpl.java diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/UserScaleVO.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/UserScaleVO.java new file mode 100644 index 000000000..418695604 --- /dev/null +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/UserScaleVO.java @@ -0,0 +1,36 @@ +package com.njcn.device.pq.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @version 1.0.0 + * @author: zbj + * @date: 2023/04/10 + */ +@Data +public class UserScaleVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 月份 + */ + @ApiModelProperty("月份") + private String timeId; + + /** + * 累计增量 + */ + @ApiModelProperty("累计增量") + private Integer incrementNum; + + /** + * 当月增量 + */ + @ApiModelProperty("当月增量") + private Integer monthIncrementNum; + +} diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/controller/LargeScreenController.java b/pqs-user/user-boot/src/main/java/com/njcn/user/controller/LargeScreenController.java new file mode 100644 index 000000000..86c1ab0bc --- /dev/null +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/controller/LargeScreenController.java @@ -0,0 +1,52 @@ +package com.njcn.user.controller; + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.device.pq.pojo.param.LargeScreenParam; +import com.njcn.device.pq.pojo.vo.HomeostasisAreaVO; +import com.njcn.device.pq.pojo.vo.UserScaleVO; +import com.njcn.user.service.LargeScreenService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +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.List; + +/** + * @version 1.0.0 + * @author: zbj + * @date: 2023/04/10 + */ +@Slf4j +@Api(tags = "大屏") +@RestController +@RequestMapping("/largeScreen") +@RequiredArgsConstructor +public class LargeScreenController extends BaseController { + + private final LargeScreenService largeScreenService; + + /** + * 灿能云用户规模 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getUserScale") + @ApiOperation("灿能云用户规模") + @ApiImplicitParam(name = "largeScreenParam", value = "灿能云用户规模", required = true) + public HttpResult> getUserScale(@RequestBody @Validated LargeScreenParam largeScreenParam) { + String methodDescribe = getMethodDescribe("getUserScale"); + List result = largeScreenService.getUserScale(largeScreenParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } +} diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/mapper/LargeScreenMapper.java b/pqs-user/user-boot/src/main/java/com/njcn/user/mapper/LargeScreenMapper.java new file mode 100644 index 000000000..4d3666d47 --- /dev/null +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/mapper/LargeScreenMapper.java @@ -0,0 +1,18 @@ +package com.njcn.user.mapper; + + +import com.njcn.device.pq.pojo.param.LargeScreenParam; +import com.njcn.device.pq.pojo.vo.UserScaleVO; + +import java.util.List; + +/** + * @version 1.0.0 + * @author: zbj + * @date: 2023/04/10 + */ +public interface LargeScreenMapper { + + List getUserScale (LargeScreenParam largeScreenParam); + +} diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/mapper/mapping/LargeScreenMapper.xml b/pqs-user/user-boot/src/main/java/com/njcn/user/mapper/mapping/LargeScreenMapper.xml new file mode 100644 index 000000000..8ec0b0fca --- /dev/null +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/mapper/mapping/LargeScreenMapper.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/LargeScreenService.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/LargeScreenService.java new file mode 100644 index 000000000..c23a18e8c --- /dev/null +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/LargeScreenService.java @@ -0,0 +1,18 @@ +package com.njcn.user.service; + +import com.njcn.device.pq.pojo.param.LargeScreenParam; +import com.njcn.device.pq.pojo.vo.UserScaleVO; + +import java.util.List; + + +/** + * @version 1.0.0 + * @author: zbj + * @date: 2023/04/10 + */ +public interface LargeScreenService { + + List getUserScale(LargeScreenParam largeScreenParam); + +} diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/LargeScreenServiceImpl.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/LargeScreenServiceImpl.java new file mode 100644 index 000000000..d7df2ed2d --- /dev/null +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/LargeScreenServiceImpl.java @@ -0,0 +1,106 @@ +package com.njcn.user.service.impl; + +import com.njcn.device.pq.pojo.param.LargeScreenParam; +import com.njcn.device.pq.pojo.vo.HomeostasisAreaVO; +import com.njcn.device.pq.pojo.vo.UserScaleVO; +import com.njcn.user.mapper.LargeScreenMapper; +import com.njcn.user.service.LargeScreenService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.Year; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @version 1.0.0 + * @author: zbj + * @date: 2023/04/10 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class LargeScreenServiceImpl implements LargeScreenService { + + private final LargeScreenMapper largeScreenMapper; + + /** + * 灿能云用户规模 + */ + @Override + public List getUserScale(LargeScreenParam largeScreenParam) { + //创建返回VO + List result = new ArrayList<>(); + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + //获取当前年第一天日期 + Year year = Year.now(); + String firstDay = year.atDay(1).format(formatter); + //获取当前天字符串日期 + LocalDate today = LocalDate.now(); + String endDay = today.format(formatter); + //替换属性 + largeScreenParam.setSearchBeginTime(firstDay); + largeScreenParam.setSearchEndTime(endDay); + List list = largeScreenMapper.getUserScale(largeScreenParam); + //获取传入起始月结束月中所有月份 + List monthList = selectDate(largeScreenParam.getSearchBeginTime(), + largeScreenParam.getSearchEndTime()); + + for (String s : monthList) { + UserScaleVO vo = new UserScaleVO(); + vo.setTimeId(s); + result.add(vo); + } + //集合不为空 + if (list.size()>0){ + for (UserScaleVO userScaleVO : result) { + for (UserScaleVO scaleVO : list) { + if (Objects.equals(scaleVO.getTimeId(),userScaleVO.getTimeId())){ + userScaleVO.setMonthIncrementNum(scaleVO.getMonthIncrementNum()); + } + } + } + for (UserScaleVO vo : result) { + if (vo.getMonthIncrementNum()==null){ + vo.setMonthIncrementNum(0); + } + } + int count = 0; + for (int i = 0; i < result.size(); i++) { + count = count + result.get(i).getMonthIncrementNum(); + result.get(i).setIncrementNum(count); + } + return result; + }else{ + return result; + } + } + + + /** + * 获取传入起始月结束月中所有月份 + * @param startDate + * @param endDate + * @return + */ + public List selectDate(String startDate, String endDate) { + LocalDate start = LocalDate.parse(startDate, DateTimeFormatter.ISO_LOCAL_DATE); + LocalDate end = LocalDate.parse(endDate, DateTimeFormatter.ISO_LOCAL_DATE); + + List allMonths = new ArrayList<>(); + YearMonth current = YearMonth.from(start); + + while (!current.isAfter(YearMonth.from(end))) { + allMonths.add(current.format(DateTimeFormatter.ofPattern("yyyy-MM"))); + current = current.plusMonths(1); + } + return allMonths; + } +} From 4169a51ba28c25cd1732cdeb0834953157d50f29 Mon Sep 17 00:00:00 2001 From: zhuxinyu <1799009482@qq.com> Date: Mon, 10 Apr 2023 14:45:54 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=9B=91=E6=B5=8B=E7=82=B9=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml index 6a1ba250f..c2bfe7fcc 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/DeviceMapper.xml @@ -113,8 +113,7 @@ OR dev.name LIKE #{searchValueLike} OR line.NAME LIKE #{searchValueLike} - ORDER BY - areaId.NAME + ORDER BY areaId.NAME + SELECT a.*, + b.code as devName + FROM cs_dev_model a + LEFT JOIN sys_dict_data b ON a.dev_type = b.id + WHERE + 1 = 1 + + AND a.version_date >= #{csDevModelQueryParm.versionStartDate } + + + AND a.version_date <= #{csDevModelQueryParm.versionendDate } + + + + AND b.CODE LIKE concat('%',#{csDevModelQueryParm.devName},'%') + + + AND a.dev_type = #{csDevModelQueryParm.devType} + + + \ No newline at end of file diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/CsDevModelService.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/CsDevModelService.java new file mode 100644 index 000000000..28d180f54 --- /dev/null +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/CsDevModelService.java @@ -0,0 +1,55 @@ +package com.njcn.algorithm.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.njcn.algorithm.pojo.param.*; +import com.njcn.algorithm.pojo.po.CsDevModelPO; +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.algorithm.pojo.vo.CsDevModelPageVO; + +import java.util.List; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/4/10 11:28【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +public interface CsDevModelService extends IService{ + + /** + * @Description: addDevModel + * @Param: [csDevModelAddParm] + * @return: java.lang.Boolean + * @Author: clam + * @Date: 2023/4/10 + */ + Boolean addDevModel(CsDevModelAddParm csDevModelAddParm); + /** + * @Description: AuditDevModel + * @Param: [csDevModelAuditParm] + * @return: java.lang.Boolean + * @Author: clam + * @Date: 2023/4/10 + */ + Boolean AuditDevModel(CsDevModelAuditParm csDevModelAuditParm); + /** + * @Description: 设备模板 + * @Param: [csDevModelQueryParm] + * @return: com.baomidou.mybatisplus.core.metadata.IPage + * @Author: clam + * @Date: 2023/4/10 + */ + IPage queryPage(CsDevModelQueryParm csDevModelQueryParm); + /** + * @Description: queryList + * @Param: [projectEquipmentQueryParm] + * @return: java.util.List + * @Author: clam + * @Date: 2023/4/10 + * @param projectEquipmentQueryParm + */ + List queryList(CsDevModelQueryListParm projectEquipmentQueryParm); +} diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/impl/CsDevModelServiceImpl.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/impl/CsDevModelServiceImpl.java new file mode 100644 index 000000000..ab044db6f --- /dev/null +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/impl/CsDevModelServiceImpl.java @@ -0,0 +1,62 @@ +package com.njcn.algorithm.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.algorithm.mapper.CsDevModelMapper; +import com.njcn.algorithm.pojo.param.*; +import com.njcn.algorithm.pojo.po.CsDevModelPO; +import com.njcn.algorithm.pojo.vo.CsDevModelPageVO; +import com.njcn.algorithm.service.CsDevModelService; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/4/10 11:28【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Service +public class CsDevModelServiceImpl extends ServiceImpl implements CsDevModelService{ + + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean addDevModel(CsDevModelAddParm csDevModelAddParm) { + CsDevModelPO csDevModelPO = new CsDevModelPO (); + BeanUtils.copyProperties (csDevModelAddParm, csDevModelPO); + csDevModelPO.setStatus ("1"); + boolean save = this.save (csDevModelPO); + + return save; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean AuditDevModel(CsDevModelAuditParm csDevModelAuditParm) { + CsDevModelPO csDevModelPO = new CsDevModelPO (); + BeanUtils.copyProperties (csDevModelAuditParm, csDevModelPO); + boolean b = this.updateById (csDevModelPO); + return b; + } + + @Override + public IPage queryPage(CsDevModelQueryParm csDevModelQueryParm) { + Page returnpage = new Page<> (csDevModelQueryParm.getCurrentPage ( ), csDevModelQueryParm.getPageSize ( )); + + returnpage = this.getBaseMapper ().getPage(returnpage,csDevModelQueryParm); + return returnpage; + } + + @Override + public List queryList(CsDevModelQueryListParm csDevModelQueryListParm) { + List list = this.getBaseMapper ().queryList(csDevModelQueryListParm); + return list; + } +} From ff27f42ae2602855274096864fbf19416460eceb Mon Sep 17 00:00:00 2001 From: xuyang <748613696@qq.com> Date: Mon, 10 Apr 2023 15:19:45 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B2=BB=E7=90=86?= =?UTF-8?q?=E5=AF=B9=E5=A4=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pqs-algorithm/algorithm-api/pom.xml | 5 ++ .../algorithm/api/EquipmentFeignClient.java | 21 +++++ .../EquipmentFeignClientFallbackFactory.java | 36 +++++++++ pqs-algorithm/algorithm-boot/pom.xml | 76 +++++++++---------- .../EquipmentDeliveryController.java | 2 +- .../njcn/common/pojo/constant/ServerInfo.java | 1 + 6 files changed, 102 insertions(+), 39 deletions(-) create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java diff --git a/pqs-algorithm/algorithm-api/pom.xml b/pqs-algorithm/algorithm-api/pom.xml index ea461c39d..2a9f51a6a 100644 --- a/pqs-algorithm/algorithm-api/pom.xml +++ b/pqs-algorithm/algorithm-api/pom.xml @@ -38,6 +38,11 @@ org.projectlombok lombok + + com.njcn + common-microservice + ${project.version} + diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java new file mode 100644 index 000000000..61f192864 --- /dev/null +++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java @@ -0,0 +1,21 @@ +package com.njcn.algorithm.api; + +import com.njcn.algorithm.api.fallback.EquipmentFeignClientFallbackFactory; +import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO; +import com.njcn.common.pojo.constant.ServerInfo; +import com.njcn.common.pojo.response.HttpResult; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author xy + */ +@FeignClient(value = ServerInfo.ALGORITHM_BOOT, path = "/EquipmentDelivery", fallbackFactory = EquipmentFeignClientFallbackFactory.class,contextId = "EquipmentDelivery") +public interface EquipmentFeignClient { + + @PostMapping("/queryEquipmentByndid") + HttpResult queryEquipmentByndid(@RequestParam("ndid") String ndid); + +} diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java new file mode 100644 index 000000000..d204e56fc --- /dev/null +++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java @@ -0,0 +1,36 @@ +package com.njcn.algorithm.api.fallback; + +import com.njcn.algorithm.api.EquipmentFeignClient; +import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.pojo.response.HttpResult; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * @author xy + */ +@Slf4j +@Component +public class EquipmentFeignClientFallbackFactory implements FallbackFactory { + @Override + public EquipmentFeignClient create(Throwable cause) { + //判断抛出异常是否为解码器抛出的业务异常 + Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; + if (cause.getCause() instanceof BusinessException) { + BusinessException businessException = (BusinessException) cause.getCause(); +// exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult()); + } + Enum finalExceptionEnum = exceptionEnum; + return new EquipmentFeignClient() { + + @Override + public HttpResult queryEquipmentByndid(String ndid) { + log.error("{}异常,降级处理,异常为:{}","通过ndid查询出厂设备异常",cause.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + } +} diff --git a/pqs-algorithm/algorithm-boot/pom.xml b/pqs-algorithm/algorithm-boot/pom.xml index 7070ec2bc..2fe984f3b 100644 --- a/pqs-algorithm/algorithm-boot/pom.xml +++ b/pqs-algorithm/algorithm-boot/pom.xml @@ -101,44 +101,44 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + com.spotify + docker-maven-plugin + 1.0.0 + + + + build-image + ${docker.operate} + + build + + + + + + http://${docker.repostory} + + ${docker.repostory}/${docker.registry.name}/${project.artifactId} + + + latest + + + ${docker.url} + ${basedir}/ + + + + /ROOT + + ${project.build.directory} + + ${project.build.finalName}.jar + + + + diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java index 9021a65e1..629dfcfd1 100644 --- a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java @@ -62,7 +62,7 @@ public class EquipmentDeliveryController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @PostMapping("/queryEquipmentByndid") + @PostMapping("/queryEquipmentByndid") @ApiOperation("通过ndid查询出厂设备") @ApiImplicitParam(name = "ndid", value = "网关识别码", required = true) public HttpResult queryEquipmentByndid(@RequestParam("ndid")String ndid){ diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java index 71a6315db..70b1641ea 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java @@ -25,6 +25,7 @@ public interface ServerInfo { String QUALITY = "quality-boot"; String PROCESS = "process-boot"; String PREPARE_BOOT = "prepare-boot"; + String ALGORITHM_BOOT = "algorithm-boot"; }