Commit 5bf6dabb66887590e12798a4b2a4fbf831f03da1
1 parent
022171e1
feature(*): 上传人员指标
上传人员指标
Showing
2 changed files
with
68 additions
and
0 deletions
fw-morax-server/src/main/java/cn/fw/morax/server/controller/erp/EvalIndicatorController.java
... | ... | @@ -127,6 +127,22 @@ public class EvalIndicatorController { |
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | + * 上传人员指标 | |
131 | + * | |
132 | + * @return | |
133 | + */ | |
134 | + @IgnoreAuth | |
135 | + @PostMapping("/analysis-staff-indicator") | |
136 | + @ControllerMethod("上传人员指标") | |
137 | + public Message<List<EvalIndicatorImportDetailVO>> analysisStaffExcel(@RequestParam("file") MultipartFile file, @CurrentUser LoginAuthBean user) { | |
138 | + if (file.isEmpty()) { | |
139 | + throw new BusinessException("请上传文件"); | |
140 | + } | |
141 | + evalIndicatorReportService.analysisStaffExcel(file, user); | |
142 | + return success(); | |
143 | + } | |
144 | + | |
145 | + /** | |
130 | 146 | * 上传门店指标 |
131 | 147 | * |
132 | 148 | * @return | ... | ... |
fw-morax-service/src/main/java/cn/fw/morax/service/biz/eval/EvalIndicatorReportService.java
... | ... | @@ -184,6 +184,51 @@ public class EvalIndicatorReportService { |
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | + public List<EvalIndicatorImportDetailVO> analysisStaffExcel(MultipartFile file, LoginAuthBean user) { | |
188 | + MultiKeyMap<String, EvalUserPool> staffPostMap = getShopUserPoolMap(user); | |
189 | + Map<String, EvalIndicator> evalIndicatorMap = getNameIndicatorMap(); | |
190 | + List<EvalIndicatorImportDetailVO> details = new ArrayList<>(); | |
191 | + List<StaffIndicatorValueVO> indicatorValues = this.analysisExcel(file, StaffIndicatorValueVO.class); | |
192 | + Integer errorNum = 0; | |
193 | + Set<String> uploadIndicatorCodes = new HashSet<>(); | |
194 | + | |
195 | + MultiKeyMap<String, String> repeatMap = new MultiKeyMap<>(); | |
196 | + for (StaffIndicatorValueVO staff : indicatorValues) { | |
197 | + Optional<StaffIndicatorValueVO> valueOptional = Optional.ofNullable(staff); | |
198 | + EvalIndicatorImportDetailVO importDetail = convertStaffVo(valueOptional); | |
199 | + details.add(importDetail); | |
200 | + if (repeatMap.containsKey(staff.getStaffName(), staff.getShopName(), staff.getIndicatorName())) { | |
201 | + importDetail.setErrorType(ImportErrorReasonEnum.NO_MATCH_STAFF); | |
202 | + errorNum += 1; | |
203 | + continue; | |
204 | + } | |
205 | + repeatMap.put(staff.getStaffName(), staff.getShopName(), staff.getIndicatorName(), ""); | |
206 | + | |
207 | + importDetail.setDataDate(transferDate(staff.getDataDate())); | |
208 | + if (! staffPostMap.containsKey(staff.getShopName(), staff.getStaffName())) { | |
209 | + importDetail.setErrorType(ImportErrorReasonEnum.NO_MATCH_STAFF); | |
210 | + errorNum += 1; | |
211 | + continue; | |
212 | + } | |
213 | + EvalUserPool userPool = staffPostMap.get(staff.getShopName(), staff.getStaffName()); | |
214 | + importDetail.setUserId(userPool.getUserId()); | |
215 | + importDetail.setShopId(userPool.getShopId()); | |
216 | + | |
217 | + if (! evalIndicatorMap.containsKey(staff.getIndicatorName())) { | |
218 | + importDetail.setErrorType(ImportErrorReasonEnum.NO_MATCH_INDICATOR); | |
219 | + errorNum += 1; | |
220 | + continue; | |
221 | + } | |
222 | + EvalIndicator evalIndicator = evalIndicatorMap.get(staff.getIndicatorName()); | |
223 | + uploadIndicatorCodes.add(evalIndicator.getCode()); | |
224 | + importDetail.setIndicatorCode(evalIndicator.getCode()); | |
225 | + importDetail.setIndicatorName(evalIndicator.getName()); | |
226 | + importDetail.setIndicatorValue(new BigDecimal(staff.getIndicatorValue())); | |
227 | + importDetail.setDataType(evalIndicator.getDataType()); | |
228 | + } | |
229 | + return details; | |
230 | + } | |
231 | + | |
187 | 232 | @Transactional(rollbackFor = Exception.class) |
188 | 233 | public void uploadShopIndicator(MultipartFile file, LoginAuthBean user) { |
189 | 234 | Map<String, EvalShopPool> shopPoolMap = this.getShopPoolMap(user); |
... | ... | @@ -243,6 +288,13 @@ public class EvalIndicatorReportService { |
243 | 288 | } |
244 | 289 | } |
245 | 290 | |
291 | + public EvalIndicatorImportDetailVO convertStaffVo(Optional<StaffIndicatorValueVO> valueOptional) { | |
292 | + EvalIndicatorImportDetailVO detail = new EvalIndicatorImportDetailVO(); | |
293 | + detail.setIndicatorName(valueOptional.map(StaffIndicatorValueVO::getIndicatorName).orElse("")); | |
294 | + detail.setUserName(valueOptional.map(StaffIndicatorValueVO::getStaffName).orElse("")); | |
295 | + detail.setShopName(valueOptional.map(StaffIndicatorValueVO::getShopName).orElse("")); | |
296 | + return detail; | |
297 | + } | |
246 | 298 | public EvalIndicatorImportDetail convertStaffPo(Optional<StaffIndicatorValueVO> valueOptional) { |
247 | 299 | EvalIndicatorImportDetail detail = new EvalIndicatorImportDetail(); |
248 | 300 | detail.setIndicatorName(valueOptional.map(StaffIndicatorValueVO::getIndicatorName).orElse("")); | ... | ... |