Showing
6 changed files
with
27 additions
and
44 deletions
| ... | @@ -67,12 +67,12 @@ public class DinerController { | ... | @@ -67,12 +67,12 @@ public class DinerController { |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | @ApiOperation(value = "根据学校,班级和学号查询就餐人") | 69 | @ApiOperation(value = "根据学校,班级和学号查询就餐人") |
| 70 | - @PostMapping("/client/{clientId}/gradeclass/{gradeClassId}/diner") | 70 | + @PostMapping("/client/{clientId}/gradeclass/{gradeClassId}/diners") |
| 71 | @ResponseStatus(HttpStatus.OK) | 71 | @ResponseStatus(HttpStatus.OK) |
| 72 | - public DinerVO getClientClassDiner(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client, | 72 | + public List<DinerVO> getClientClassDiners(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client, |
| 73 | @RequestAttribute(INJECTED_GRADE_CLASS) final SingleGradeClassRpcResponse gradeClass, | 73 | @RequestAttribute(INJECTED_GRADE_CLASS) final SingleGradeClassRpcResponse gradeClass, |
| 74 | @RequestBody @Valid final DinerDTO.QueryUniqueDinerDTO queryUniqueDinerDTO) { | 74 | @RequestBody @Valid final DinerDTO.QueryUniqueDinerDTO queryUniqueDinerDTO) { |
| 75 | - return dinerService.getClientClassDiner(client, gradeClass, queryUniqueDinerDTO.getStudentNo()); | 75 | + return dinerService.getClientClassDiners(client, gradeClass, queryUniqueDinerDTO.getStudentNo()); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | @ApiOperation(value = "修改就餐人") | 78 | @ApiOperation(value = "修改就餐人") | ... | ... |
| ... | @@ -137,11 +137,11 @@ public class AutoCreateMealOrderTask { | ... | @@ -137,11 +137,11 @@ public class AutoCreateMealOrderTask { |
| 137 | final var client = clientMap.get(diner.getClientId()); | 137 | final var client = clientMap.get(diner.getClientId()); |
| 138 | final var gradeClass = classMap.get(diner.getClassId()); | 138 | final var gradeClass = classMap.get(diner.getClassId()); |
| 139 | final var mpAccountDinerRef = mpAccountDinerRefMap.get(diner.getId()); | 139 | final var mpAccountDinerRef = mpAccountDinerRefMap.get(diner.getId()); |
| 140 | - if (menu == null || client == null || gradeClass == null || mpAccountDinerRef == null) return null; | 140 | + if (menu == null || client == null || gradeClass == null) return null; |
| 141 | return MealOrderCreation.newBuilder() | 141 | return MealOrderCreation.newBuilder() |
| 142 | .setClientId(diner.getClientId()) | 142 | .setClientId(diner.getClientId()) |
| 143 | .setMenuId(menu.getId()) | 143 | .setMenuId(menu.getId()) |
| 144 | - .setAccountId(mpAccountDinerRef.getAccountId()) | 144 | + .setAccountId(mpAccountDinerRef == null ? 0 : mpAccountDinerRef.getAccountId()) |
| 145 | .setOrderMethod(MealOrderOrderMethodEnum.MEAL_ORDER_METHOD_SYSTEM) | 145 | .setOrderMethod(MealOrderOrderMethodEnum.MEAL_ORDER_METHOD_SYSTEM) |
| 146 | .setDinerId(diner.getId()) | 146 | .setDinerId(diner.getId()) |
| 147 | .setDinerName(diner.getName()) | 147 | .setDinerName(diner.getName()) |
| ... | @@ -161,10 +161,13 @@ public class AutoCreateMealOrderTask { | ... | @@ -161,10 +161,13 @@ public class AutoCreateMealOrderTask { |
| 161 | 161 | ||
| 162 | private List<MenuSchedule> buildNextWeekMeals(ZonedDateTime nextWeekStart) { | 162 | private List<MenuSchedule> buildNextWeekMeals(ZonedDateTime nextWeekStart) { |
| 163 | return IntStream.range(0, 5) | 163 | return IntStream.range(0, 5) |
| 164 | - .mapToObj(i -> MenuSchedule.newBuilder() | 164 | + .mapToObj(i -> { |
| 165 | - .setDate(nextWeekStart.plusDays(i).format(DateUtil.YYYY_MM_DD_LEFT_SYMBOL)) | 165 | + final var date = nextWeekStart.plusDays(i); |
| 166 | + return MenuSchedule.newBuilder() | ||
| 167 | + .setDate(date.format(DateUtil.YYYY_MM_DD_LEFT_SYMBOL)) | ||
| 166 | .setMenu("A") | 168 | .setMenu("A") |
| 167 | - .build()) | 169 | + .build(); |
| 170 | + }) | ||
| 168 | .toList(); | 171 | .toList(); |
| 169 | } | 172 | } |
| 170 | } | 173 | } | ... | ... |
| ... | @@ -17,7 +17,6 @@ public class DinerDTO { | ... | @@ -17,7 +17,6 @@ public class DinerDTO { |
| 17 | public static class QueryUniqueDinerDTO { | 17 | public static class QueryUniqueDinerDTO { |
| 18 | 18 | ||
| 19 | @ApiModelProperty(value = "学号") | 19 | @ApiModelProperty(value = "学号") |
| 20 | - @NotEmpty(message = "学号不能为空") | ||
| 21 | private String studentNo; | 20 | private String studentNo; |
| 22 | 21 | ||
| 23 | } | 22 | } | ... | ... |
| ... | @@ -22,5 +22,5 @@ public interface DinerService { | ... | @@ -22,5 +22,5 @@ public interface DinerService { |
| 22 | 22 | ||
| 23 | void deleteMpAccountDiner(SingleDinerRpcResponse diner); | 23 | void deleteMpAccountDiner(SingleDinerRpcResponse diner); |
| 24 | 24 | ||
| 25 | - DinerVO getClientClassDiner(SingleClientRpcResponse client, SingleGradeClassRpcResponse gradeClass, String studentNo); | 25 | + List<DinerVO> getClientClassDiners(SingleClientRpcResponse client, SingleGradeClassRpcResponse gradeClass, String studentNo); |
| 26 | } | 26 | } | ... | ... |
| ... | @@ -4,7 +4,6 @@ import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ... | @@ -4,7 +4,6 @@ import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; |
| 4 | import com.infoloop.tianting.context.LoginContextHolder; | 4 | import com.infoloop.tianting.context.LoginContextHolder; |
| 5 | import com.infoloop.tianting.exception.ClientEndExceptions; | 5 | import com.infoloop.tianting.exception.ClientEndExceptions; |
| 6 | import com.infoloop.tianting.exception.ErrorCodeEnum; | 6 | import com.infoloop.tianting.exception.ErrorCodeEnum; |
| 7 | -import com.infoloop.tianting.mealorderservice.DinerCreation; | ||
| 8 | import com.infoloop.tianting.mealorderservice.DinerModification; | 7 | import com.infoloop.tianting.mealorderservice.DinerModification; |
| 9 | import com.infoloop.tianting.mealorderservice.MpAccountDinerRefCreation; | 8 | import com.infoloop.tianting.mealorderservice.MpAccountDinerRefCreation; |
| 10 | import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | 9 | import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; |
| ... | @@ -75,7 +74,9 @@ public class DinerServiceImpl implements DinerService { | ... | @@ -75,7 +74,9 @@ public class DinerServiceImpl implements DinerService { |
| 75 | } | 74 | } |
| 76 | final var singleClientRpcResponse = clientsByCodes.get(0); | 75 | final var singleClientRpcResponse = clientsByCodes.get(0); |
| 77 | final var diners = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(singleClientRpcResponse.getId()), List.of(createDinerDTO.getClassId()), createDinerDTO.getStudentNo()); | 76 | final var diners = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(singleClientRpcResponse.getId()), List.of(createDinerDTO.getClassId()), createDinerDTO.getStudentNo()); |
| 78 | - if (!diners.isEmpty()) { | 77 | + if (diners.isEmpty()) { |
| 78 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_NOT_FOUND); | ||
| 79 | + } | ||
| 79 | if (diners.size() != 1) { | 80 | if (diners.size() != 1) { |
| 80 | throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_NOT_FOUND); | 81 | throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_NOT_FOUND); |
| 81 | } | 82 | } |
| ... | @@ -98,23 +99,6 @@ public class DinerServiceImpl implements DinerService { | ... | @@ -98,23 +99,6 @@ public class DinerServiceImpl implements DinerService { |
| 98 | return CreatedResult.<DinerVO>builder().id(dinerId).isCreated(mpAccountDinerRef.getIsCreated()).build(); | 99 | return CreatedResult.<DinerVO>builder().id(dinerId).isCreated(mpAccountDinerRef.getIsCreated()).build(); |
| 99 | } | 100 | } |
| 100 | } | 101 | } |
| 101 | - final var dinerCreation = DinerCreation.newBuilder() | ||
| 102 | - .setClientId(singleClientRpcResponse.getId()) | ||
| 103 | - .setClassId(createDinerDTO.getClassId()) | ||
| 104 | - .setStudentNo(createDinerDTO.getStudentNo()) | ||
| 105 | - .setName(createDinerDTO.getName()) | ||
| 106 | - .build(); | ||
| 107 | - final var dinerResponse = mealOrderServiceRpcClient.createDiner(loginInfo, dinerCreation); | ||
| 108 | - if (dinerResponse.getIsCreated()) { | ||
| 109 | - final var mpAccountDinerRefCreation = MpAccountDinerRefCreation.newBuilder() | ||
| 110 | - .setDinerId(dinerResponse.getId()) | ||
| 111 | - .setAccountId(loginInfo.getId()) | ||
| 112 | - .build(); | ||
| 113 | - final var mpAccountDinerRef = mealOrderServiceRpcClient.createMpAccountDinerRef(loginInfo, mpAccountDinerRefCreation); | ||
| 114 | - log.info("createMpAccountDiner dinerId:{} mpAccountDinerRefId:{}", dinerResponse.getId(), mpAccountDinerRef.getId()); | ||
| 115 | - } | ||
| 116 | - return CreatedResult.<DinerVO>builder().id(dinerResponse.getId()).isCreated(dinerResponse.getIsCreated()).build(); | ||
| 117 | - } | ||
| 118 | 102 | ||
| 119 | @Override | 103 | @Override |
| 120 | public List<GradeClassVO> getClientGradeClasses(SingleClientRpcResponse client) { | 104 | public List<GradeClassVO> getClientGradeClasses(SingleClientRpcResponse client) { |
| ... | @@ -164,23 +148,20 @@ public class DinerServiceImpl implements DinerService { | ... | @@ -164,23 +148,20 @@ public class DinerServiceImpl implements DinerService { |
| 164 | } | 148 | } |
| 165 | 149 | ||
| 166 | @Override | 150 | @Override |
| 167 | - public DinerVO getClientClassDiner(SingleClientRpcResponse client, SingleGradeClassRpcResponse gradeClass, String studentNo) { | 151 | + public List<DinerVO> getClientClassDiners(SingleClientRpcResponse client, SingleGradeClassRpcResponse gradeClass, String studentNo) { |
| 168 | final var loginInfo = LoginContextHolder.getLoginInfo(); | 152 | final var loginInfo = LoginContextHolder.getLoginInfo(); |
| 169 | - final var diner = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(client.getId()), List.of(gradeClass.getId()), studentNo); | 153 | + final var diners = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(client.getId()), List.of(gradeClass.getId()), studentNo); |
| 170 | - if (diner.size() != 1) { | 154 | + return diners.stream().map(diner -> DinerVO.builder() |
| 171 | - return null; | 155 | + .id(diner.getId()) |
| 172 | - } | 156 | + .enterpriseId(diner.getEnterpriseId()) |
| 173 | - return DinerVO.builder() | 157 | + .clientId(diner.getClientId()) |
| 174 | - .id(diner.get(0).getId()) | ||
| 175 | - .enterpriseId(diner.get(0).getEnterpriseId()) | ||
| 176 | - .clientId(diner.get(0).getClientId()) | ||
| 177 | .clientCode(client.getCode()) | 158 | .clientCode(client.getCode()) |
| 178 | .clientName(client.getName()) | 159 | .clientName(client.getName()) |
| 179 | - .classId(diner.get(0).getClassId()) | 160 | + .classId(diner.getClassId()) |
| 180 | .gradeName(gradeClass.getGradeName()) | 161 | .gradeName(gradeClass.getGradeName()) |
| 181 | .className(gradeClass.getClassName()) | 162 | .className(gradeClass.getClassName()) |
| 182 | - .studentNo(diner.get(0).getStudentNo()) | 163 | + .studentNo(diner.getStudentNo()) |
| 183 | - .name(diner.get(0).getName()) | 164 | + .name(diner.getName()) |
| 184 | - .build(); | 165 | + .build()).toList(); |
| 185 | } | 166 | } |
| 186 | } | 167 | } | ... | ... |
| ... | @@ -95,7 +95,7 @@ public class MealOrderServiceImpl implements MealOrderService { | ... | @@ -95,7 +95,7 @@ public class MealOrderServiceImpl implements MealOrderService { |
| 95 | } | 95 | } |
| 96 | final var latestMealMenuRecords = mealOrderServiceRpcClient.queryLatestMealMenuRecordsByClientIds(loginInfo.getEnterpriseId(), Collections.singletonList(dinerById.getClientId())); | 96 | final var latestMealMenuRecords = mealOrderServiceRpcClient.queryLatestMealMenuRecordsByClientIds(loginInfo.getEnterpriseId(), Collections.singletonList(dinerById.getClientId())); |
| 97 | if (latestMealMenuRecords.isEmpty()) { | 97 | if (latestMealMenuRecords.isEmpty()) { |
| 98 | - throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.MEAL_MENU_NOT_FOUND); | 98 | +// throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.MEAL_MENU_NOT_FOUND); |
| 99 | } | 99 | } |
| 100 | final var reserveDinerMealOrders = mealOrderServiceRpcClient.queryReserveMealOrdersByDinerIds(loginInfo.getEnterpriseId(), Collections.singletonList(createMealOrderDTO.getDinerId())); | 100 | final var reserveDinerMealOrders = mealOrderServiceRpcClient.queryReserveMealOrdersByDinerIds(loginInfo.getEnterpriseId(), Collections.singletonList(createMealOrderDTO.getDinerId())); |
| 101 | if (!reserveDinerMealOrders.isEmpty()) { | 101 | if (!reserveDinerMealOrders.isEmpty()) { |
| ... | @@ -103,7 +103,7 @@ public class MealOrderServiceImpl implements MealOrderService { | ... | @@ -103,7 +103,7 @@ public class MealOrderServiceImpl implements MealOrderService { |
| 103 | } | 103 | } |
| 104 | final var mealOrder = mealOrderServiceRpcClient.createMealOrder(loginInfo, MealOrderCreation.newBuilder() | 104 | final var mealOrder = mealOrderServiceRpcClient.createMealOrder(loginInfo, MealOrderCreation.newBuilder() |
| 105 | .setClientId(dinerById.getClientId()) | 105 | .setClientId(dinerById.getClientId()) |
| 106 | - .setMenuId(latestMealMenuRecords.get(0).getId()) | 106 | + .setMenuId(latestMealMenuRecords.isEmpty() ? 0 : latestMealMenuRecords.get(0).getId()) |
| 107 | .setAccountId(loginInfo.getId()) | 107 | .setAccountId(loginInfo.getId()) |
| 108 | .setOrderMethod(MealOrderOrderMethodEnum.MEAL_ORDER_METHOD_MICRO) | 108 | .setOrderMethod(MealOrderOrderMethodEnum.MEAL_ORDER_METHOD_MICRO) |
| 109 | .setDinerId(createMealOrderDTO.getDinerId()) | 109 | .setDinerId(createMealOrderDTO.getDinerId()) | ... | ... |
-
Please register or login to post a comment