From c6a5968dfaab373b6178670aa058f5525e6447ec Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期二, 04 三月 2025 17:49:43 +0800 Subject: [PATCH] 代码迁移bug解决 --- ruoyi-system/src/main/resources/mapper/system/InformationNotificationMapper.xml | 10 ++ inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderPlanController.java | 2 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/ReportServiceImpl.java | 129 +++++++++++++++++++++++++ inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsOrder.java | 4 ruoyi-system/src/main/java/com/ruoyi/system/mapper/InformationNotificationMapper.java | 11 ++ performance-server/src/main/java/com/ruoyi/performance/dto/AuxiliaryAllDto.java | 4 inspect-server/src/main/java/com/ruoyi/inspect/controller/InformationNotificationController.java | 40 ++++++++ inspect-server/src/main/java/com/ruoyi/inspect/controller/ReportController.java | 32 ++++++ inspect-server/src/main/java/com/ruoyi/inspect/service/ReportService.java | 13 ++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InformationNotificationServiceImpl.java | 11 ++ ruoyi-system/src/main/java/com/ruoyi/system/service/InformationNotificationService.java | 8 + 11 files changed, 262 insertions(+), 2 deletions(-) diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InformationNotificationController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InformationNotificationController.java new file mode 100644 index 0000000..d20b89b --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InformationNotificationController.java @@ -0,0 +1,40 @@ +package com.ruoyi.inspect.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.system.service.InformationNotificationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * <p> + * 娑堟伅閫氱煡 鍓嶇鎺у埗鍣� + * </p> + * + * @author 姹熻嫃榈烽洀缃戠粶绉戞妧鏈夐檺鍏徃 + * @since 2024-04-23 02:14:30 + */ +@Api(tags = "娑堟伅閫氱煡") +@RestController +@RequestMapping("/informationNotification") +public class InformationNotificationController { + + @Autowired + private InformationNotificationService informationNotificationService; + + @ApiOperation(value = "娑堟伅閫氱煡-婊氬姩鍒嗛〉鏌ヨ") + @GetMapping("page") + public Result<?> getPage(Long size, Long current, String messageType) { + return Result.success(informationNotificationService.getPage(new Page<>(current, size), messageType)); + } + + @ApiOperation(value = "娑堟伅閫氱煡-婊氬姩鏌ヨ") + @GetMapping("msgRoll") + public Result<?> msgRoll(Page page) { + return Result.success(informationNotificationService.msgRoll(page)); + } +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderPlanController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderPlanController.java index b1a1303..4e8624e 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderPlanController.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsOrderPlanController.java @@ -255,7 +255,7 @@ @ApiOperation(value = "鍒犻櫎鐗规畩妫�楠岄」缁戝畾淇℃伅") - @GetMapping("/delProductTreeByProductId") + @DeleteMapping("/delProductTreeByProductId") public Result<?> delProductTreeByProductId(Integer productId) { return Result.success(insProductService.removeBindingProductTree(productId)); } diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/ReportController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/ReportController.java new file mode 100644 index 0000000..cbe00da --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/ReportController.java @@ -0,0 +1,32 @@ +package com.ruoyi.inspect.controller; + + +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.inspect.service.ReportService; +import com.ruoyi.performance.dto.AuxiliaryOriginalHoursLookDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +@RestController +@AllArgsConstructor +@RequestMapping("/report") +@Api(tags = "鎶ヨ〃妯″潡") +public class ReportController { + + private ReportService reportService; + + @ApiOperation(value = "鏌ヨ鏃ュ巻浠诲姟鍥�") + @GetMapping("/calendarWorkByWeek") + public Result calendarWorkByWeek(){ + return Result.success(reportService.calendarWorkByWeek()); + } + + @ApiOperation(value = "褰撳墠鐢ㄦ埛宸ユ椂缁熻") + @GetMapping("/currentUserWorkHourCount") + public Result currentUserWorkHourCount(AuxiliaryOriginalHoursLookDto dto){ + return Result.success(reportService.currentUserWorkHourCount(dto)); + } + +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsOrder.java b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsOrder.java index 629ed12..0725899 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsOrder.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsOrder.java @@ -211,4 +211,8 @@ @ApiModelProperty("绗竴娆℃彁浜ゆ椂闂�") private LocalDateTime firstSubmitDate; + @ApiModelProperty("鏍锋満鍛�(闄や簡鍏朵粬鎴愬搧澶栬繖涓瓧娈靛繀閫�,鐢ㄤ簬浼佷笟寰俊鎺ㄩ��)") + @TableField(exist = false) + private Integer issueUser; + } diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/ReportService.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/ReportService.java new file mode 100644 index 0000000..57e2fc5 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/ReportService.java @@ -0,0 +1,13 @@ +package com.ruoyi.inspect.service; + +import com.ruoyi.performance.dto.AuxiliaryAllDto; +import com.ruoyi.performance.dto.AuxiliaryOriginalHoursLookDto; + +import java.util.Map; + +public interface ReportService { + //棣栭〉-->鏃ュ巻浠诲姟鍥� + Map<String, Object> calendarWorkByWeek(); + + AuxiliaryAllDto currentUserWorkHourCount(AuxiliaryOriginalHoursLookDto dto); +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/ReportServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/ReportServiceImpl.java new file mode 100644 index 0000000..fd69315 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/ReportServiceImpl.java @@ -0,0 +1,129 @@ +package com.ruoyi.inspect.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.User; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.inspect.mapper.*; +import com.ruoyi.inspect.pojo.InsOrder; +import com.ruoyi.inspect.pojo.InsSample; +import com.ruoyi.inspect.pojo.InsSampleUser; +import com.ruoyi.inspect.service.ReportService; +import com.ruoyi.performance.dto.AuxiliaryAllDto; +import com.ruoyi.performance.dto.AuxiliaryOriginalHoursLookDto; +import com.ruoyi.performance.service.AuxiliaryOriginalHoursService; +import com.ruoyi.system.mapper.UserMapper; +import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +@AllArgsConstructor +public class ReportServiceImpl implements ReportService { + + @Autowired + private InsOrderMapper insOrderMapper; + + @Autowired + private InsSampleMapper insSampleMapper; + + @Autowired + private UserMapper userMapper; + + @Autowired + private InsSampleUserMapper insSampleUserMapper; + + @Autowired + private AuxiliaryOriginalHoursService auxiliaryOriginalHoursService; + + //棣栭〉-->鏃ュ巻浠诲姟鍥� + @Override + public Map<String, Object> calendarWorkByWeek() { + Integer userId = SecurityUtils.getUserId().intValue(); + // + List<SysRole> roleList = SecurityUtils.getLoginUser().getUser().getRoles(); + +// String name = roleMapper.selectById(userMapper.selectById(userId).getRoleId()).getName(); + String name = roleList.stream().map(SysRole::getRoleName).collect(Collectors.joining(",")); + Map<String, Object> map = new HashMap<>(); + List<Integer> insState = new ArrayList<>(); + insState.add(0); + insState.add(1); + /*鑾峰彇鍚庝竴鍛ㄦ棩鏈�*/ + LocalDate currentDate = LocalDate.now(); + List<LocalDate> weekDays = new ArrayList<>(); + for (int i = 6, j = 0; i >= 0; i--, j++) { + weekDays.add(currentDate.minusDays(i)); + //鏌ヨ褰撳ぉ闇�瑕佹娴嬬殑濮旀墭璁㈠崟 + List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery() + .eq(InsOrder::getState, 1) + .in(InsOrder::getInsState, insState) + .apply("DATE(create_time) = CURDATE() - INTERVAL " + j + " DAY")); + //濡傛灉褰撳墠鐧诲綍浜烘槸娴嬭瘯宸ョ▼甯堟垨鑰呮槸妫�娴嬬粍闀�,闇�瑕佽繃婊ゅ嚭妫�楠屼汉鏄粬浠殑璁㈠崟鎴栬�呮槸杩樻病妫�楠岀殑璁㈠崟 + if (name.contains("娴嬭瘯宸ョ▼甯�") || name.contains("妫�娴嬬粍闀�")) { + insOrders = insOrders.stream().filter(insOrder -> { + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insOrder.getId())); + List<Integer> sampleId = insSamples.stream().map(InsSample::getId).collect(Collectors.toList()); + List<InsSampleUser> insSampleUsers = insSampleUserMapper.selectList(Wrappers.<InsSampleUser>lambdaQuery() + .in(InsSampleUser::getInsSampleId, sampleId) + .eq(InsSampleUser::getState, 0) //妫�楠屼汉 + ); + return insSampleUsers.size() == 0 || insSampleUsers.stream().map(InsSampleUser::getUserId).collect(Collectors.toList()).contains(userId); + }).collect(Collectors.toList()); + } + //濡傛灉褰撳墠鐧诲綍浜烘槸閫佹牱鍛�,闇�杩囨护鍑哄崟瀛愮殑閫佹牱鍛樻槸褰撳墠浜虹殑璁㈠崟 + else if (name.contains("閫佹牱鍛�")) { + insOrders = insOrders.stream().filter(insOrder -> + ObjectUtils.isNotEmpty(insOrder.getIssueUser()) && insOrder.getIssueUser().equals(userId) + ).collect(Collectors.toList()); + } + List<Map<String, Object>> works = insOrders.stream().map(insOrder -> { + List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insOrder.getId())); + HashMap<String, Object> hashMap = new HashMap<>(); + hashMap.put("text", insOrder.getEntrustCode()); + hashMap.put("sample", insSamples.stream().map(InsSample::getSample).collect(Collectors.joining(","))); + hashMap.put("type", insOrder.getType()); + hashMap.put("state", insOrder.getState()); + User user = userMapper.selectById(insOrder.getCreateUser()); + hashMap.put("name", user.getName()); + return hashMap; + }).collect(Collectors.toList()); + map.put("work" + i, works); + } + map.put("weekDays", weekDays); + return map; + } + + @Override + public AuxiliaryAllDto currentUserWorkHourCount(AuxiliaryOriginalHoursLookDto dto) { + List<AuxiliaryAllDto> auxiliaryAllDtos = auxiliaryOriginalHoursService.selectAuxiliaryAllByMonth(dto); + int userId = SecurityUtils.getUserId().intValue(); + // 杩囨护鎺夐潪褰撳墠鐢ㄦ埛鏁版嵁 + AuxiliaryAllDto auxiliaryAllDto = null; + for (AuxiliaryAllDto allDto : auxiliaryAllDtos) { + if(userId == allDto.getUserId()){ + auxiliaryAllDto = allDto; + break; + } + } + if(ObjectUtils.isEmpty(auxiliaryAllDto)){ + auxiliaryAllDto = new AuxiliaryAllDto( + new BigDecimal(0), + new BigDecimal(0), + new BigDecimal(0), + userId,SecurityUtils.getUsername(), + dto.getMonth() + ); + } + return auxiliaryAllDto; + } +} diff --git a/performance-server/src/main/java/com/ruoyi/performance/dto/AuxiliaryAllDto.java b/performance-server/src/main/java/com/ruoyi/performance/dto/AuxiliaryAllDto.java index 8b3afb1..88fadc0 100644 --- a/performance-server/src/main/java/com/ruoyi/performance/dto/AuxiliaryAllDto.java +++ b/performance-server/src/main/java/com/ruoyi/performance/dto/AuxiliaryAllDto.java @@ -1,7 +1,9 @@ package com.ruoyi.performance.dto; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import java.math.BigDecimal; @@ -12,6 +14,8 @@ * @Date 2024/10/25 */ @Data +@AllArgsConstructor +@NoArgsConstructor public class AuxiliaryAllDto { @ApiModelProperty("浜ч噺宸ユ椂") diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/InformationNotificationMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/InformationNotificationMapper.java index 6eec64c..06a3ea9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/InformationNotificationMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/InformationNotificationMapper.java @@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.entity.InformationNotification; import com.ruoyi.common.core.domain.entity.InformationNotificationDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * <p> @@ -17,4 +20,12 @@ public interface InformationNotificationMapper extends BaseMapper<InformationNotification> { IPage<InformationNotificationDto> getPage(Page page, String messageType, Integer userId); + + /** + * 娑堟伅閫氱煡-婊氬姩鏌ヨ + * + * @param userId + * @return + */ + IPage<InformationNotificationDto> msgRoll(Page page,@Param("userId") Integer userId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/InformationNotificationService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/InformationNotificationService.java index 3842f7d..5bd76f2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/InformationNotificationService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/InformationNotificationService.java @@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.entity.InformationNotification; import com.ruoyi.common.core.domain.entity.InformationNotificationDto; +import java.util.List; import java.util.Map; /** @@ -30,5 +31,10 @@ Map<String, Object> getNumberFourTypesMessagesHomePage(); - + /** + * 娑堟伅閫氱煡-婊氬姩鏌ヨ + * + * @return + */ + IPage<InformationNotificationDto> msgRoll(Page page); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InformationNotificationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InformationNotificationServiceImpl.java index 31af676..229e192 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InformationNotificationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InformationNotificationServiceImpl.java @@ -13,6 +13,7 @@ import javax.annotation.Resource; import java.time.LocalDate; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -95,4 +96,14 @@ map.put("totalNumberOfMessagesInThePastSevenDays", totalNumberOfMessagesInThePastSevenDays); return map; } + + /** + * 娑堟伅閫氱煡-婊氬姩鏌ヨ + * + * @return + */ + @Override + public IPage<InformationNotificationDto> msgRoll(Page page) { + return baseMapper.msgRoll(page,SecurityUtils.getUserId().intValue()); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/InformationNotificationMapper.xml b/ruoyi-system/src/main/resources/mapper/system/InformationNotificationMapper.xml index 3936965..68a9b49 100644 --- a/ruoyi-system/src/main/resources/mapper/system/InformationNotificationMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/InformationNotificationMapper.xml @@ -13,4 +13,14 @@ </if> order by i.create_time desc </select> + + <select id="msgRoll" resultType="com.ruoyi.common.core.domain.entity.InformationNotificationDto"> + select i.*, u.name senderUser, u2.name consigneeUser + from information_notification i + left join user u on i.sender_id = u.id + left join user u2 on u2.id = i.consignee_id + where i.consignee_id = #{userId} + order by i.create_time desc + </select> + </mapper> -- Gitblit v1.9.3