Commit 5a94fa345e6e39510e9aabd8826f254b59a85a74

Authored by wangqian
1 parent 347bd6f2

人机材修改

urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/costfee/CostFeeServiceImpl.java
... ... @@ -272,18 +272,17 @@ public class CostFeeServiceImpl implements CostFeeService {
272 272 // 设置单位id
273 273 fee.setCompanyId(String.valueOf(nameToCompanyIdMap.get(fee.getCompanyName())));
274 274 //设置班组id
275   - //fee.setDeptId(getDeptList(teamIdMap, importObj.getTeamIds()));
  275 + fee.setDeptId(getDeptList(teamIdMap, importObj.getTeamIds()));
276 276 saveFeeList.add(fee);
277 277 }
278 278 }
279 279 // 4. 处理重复数据(删除+插入原子性)
280 280 if (!feeList.isEmpty()) {
281 281 // 4.1 查询并删除重复项
282   -
283   -// List<Long> duplicateIds = personalCostMapper.selectDuplicateIds(saveFeeList);
284   -// if (!duplicateIds.isEmpty()) {
285   -// personalCostMapper.deleteByIds(duplicateIds);
286   -// }
  282 + List<Long> duplicateIds = personalCostMapper.selectDuplicateIds(saveFeeList);
  283 + if (!duplicateIds.isEmpty()) {
  284 + personalCostMapper.deleteByIds(duplicateIds);
  285 + }
287 286  
288 287 // 4.2 批量插入主表
289 288 personalCostMapper.insertBatch(saveFeeList);
... ... @@ -339,10 +338,10 @@ public class CostFeeServiceImpl implements CostFeeService {
339 338 // 4. 批量插入主表(空集合直接跳过)
340 339 if (!feeList.isEmpty()) {
341 340 //查询重复项,进行删除
342   - List<Long> ids = mechanicalCostMapper.selectDuplicateIds(saveFeeList);
343   - if (!CollectionUtils.isEmpty(ids)) {
344   - mechanicalCostMapper.deleteByIds(ids);
345   - }
  341 + List<Long> ids = mechanicalCostMapper.selectDuplicateIds(saveFeeList);
  342 + if (!CollectionUtils.isEmpty(ids)) {
  343 + mechanicalCostMapper.deleteByIds(ids);
  344 + }
346 345 mechanicalCostMapper.insertBatch(saveFeeList);
347 346 }
348 347 log.info("成功插入 {} 自有机械费用数据", dataList.size());
... ... @@ -712,6 +711,27 @@ public class CostFeeServiceImpl implements CostFeeService {
712 711 rowNum, teamIds.length, weights.length
713 712 ));
714 713 }
  714 + //校验权重值合计不能大于100%
  715 + if (weights.length > 0) {
  716 + int totalWeight = 0;
  717 + for (int j = 0; j < weights.length; j++) {
  718 + String weightStr = weights[j].trim();
  719 + int weight = Integer.parseInt(weightStr);
  720 + totalWeight += weight;
  721 +
  722 + // 提前校验:避免超大数值溢出(可选,根据业务场景调整)
  723 + if (totalWeight > 100) {
  724 + break; // 已超100%,无需继续计算
  725 + }
  726 + }
  727 +
  728 + if (totalWeight > 100) {
  729 + throw exception0(BAD_REQUEST.getCode(), String.format(
  730 + "第%d条数据:权重值合计不能大于100%", rowNum, totalWeight
  731 + ));
  732 + }
  733 + }
  734 +
715 735 Long companyId = nameToCompanyIdMap.get(importBean.getCompanyName());
716 736 //单位校验
717 737 validatecompany(rowNum, importBean.getCompanyName(), companyId, belongCompanyId);
... ...
urbanops-module-garden/src/main/resources/mapper/personalcost/PersonalCostMapper.xml
... ... @@ -7,7 +7,7 @@
7 7 FROM garden_personal_cost
8 8 WHERE
9 9 <foreach collection="keyList" item="key" separator="OR">
10   - (salary_month = #{key.salaryMonth} AND name = #{key.name})
  10 + (salary_month = #{key.salaryMonth} AND name = #{key.name} and company_id = #{key.companyId})
11 11 </foreach>
12 12 </select>
13 13 </mapper>
... ...