Compare commits
7 Commits
e31365ad90
...
6cf49d88b1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6cf49d88b1 | ||
![]() |
ca80611f91 | ||
![]() |
32cc7a4f65 | ||
![]() |
3aef43868f | ||
![]() |
52fc51c738 | ||
![]() |
d4bda37927 | ||
![]() |
b6fb1c99ad |
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOARei
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAReimbursementService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.ProjectApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.dto.ProjectDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -37,6 +38,9 @@ public class BpmOAReimbursementController {
|
||||
@Resource
|
||||
private ProjectApi projectApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
// @PreAuthorize("@ss.hasPermission('bpm:oa-reimbursement:create')")
|
||||
@Operation(summary = "创建请求申请")
|
||||
@ -52,10 +56,16 @@ public class BpmOAReimbursementController {
|
||||
|
||||
BpmOAReimbursementDO reimbursement = service.getReimbursement(id);
|
||||
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
||||
if (respVO != null && StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
if (respVO != null) {
|
||||
if (StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
}
|
||||
if (respVO.getPaymentCompany() != null) {
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(deptApi.getDept(respVO.getPaymentCompany()).getCheckedData().getName());
|
||||
}
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
@ -82,10 +92,16 @@ public class BpmOAReimbursementController {
|
||||
|
||||
BpmOAReimbursementDO reimbursement = service.getByProcessInstanceId(processInstanceId);
|
||||
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
||||
if (respVO != null && StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
if (respVO != null) {
|
||||
if (StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
}
|
||||
if (respVO.getPaymentCompany() != null) {
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(deptApi.getDept(respVO.getPaymentCompany()).getCheckedData().getName());
|
||||
}
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
|
@ -26,4 +26,7 @@ public class BpmOAPaymentPageReqVO extends PageParam {
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private String[] createTime;
|
||||
|
||||
@Schema(description = "申请人用户编号")
|
||||
private Long userId;
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ public class BpmOAReimbursementCreateReqVO {
|
||||
@Schema(description = "开户行信息")
|
||||
private String bankName;
|
||||
|
||||
@Schema(description = "付款公司")
|
||||
private Long paymentCompany;
|
||||
|
||||
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "报销项目不能为空")
|
||||
private List<Reimbursement> reimbursements;
|
||||
|
@ -27,6 +27,12 @@ public class BpmOAReimbursementRespVO extends BpmOABaseRespVO {
|
||||
@Schema(description = "收款人卡号")
|
||||
private String bankNo;
|
||||
|
||||
@Schema(description = "付款公司")
|
||||
private Long paymentCompany;
|
||||
|
||||
@Schema(description = "付款公司名称")
|
||||
private String paymentCompanyName;
|
||||
|
||||
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "报销项目不能为空")
|
||||
private List<ReimbursementDTO> reimbursements;
|
||||
|
@ -1,8 +1,7 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.Reimbursement;
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -64,6 +63,11 @@ public class BpmOAReimbursementDO extends BaseDO {
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
/**
|
||||
* 付款公司编号
|
||||
*/
|
||||
private Long paymentCompany;
|
||||
|
||||
// /**
|
||||
// * 报销明细数据JSON
|
||||
// */
|
||||
|
@ -26,6 +26,7 @@ public interface BpmOAPaymentMapper extends BaseMapperX<BpmOAPaymentDO> {
|
||||
.eq(BpmOAPaymentDO::getIsTickets, 1)
|
||||
.eqIfPresent(BpmOAPaymentDO::getStatus, pageReqVO.getStatus())
|
||||
.betweenIfPresent(BpmOAPaymentDO::getCreateTime, pageReqVO.getCreateTime())
|
||||
.eqIfPresent(BpmOAPaymentDO::getUserId, pageReqVO.getUserId())
|
||||
.eq(pageReqVO.getIsMy(), BpmOAPaymentDO::getUserId, userId)
|
||||
.orderByAsc(BpmOAPaymentDO::getStatus)
|
||||
.orderByDesc(BpmOAPaymentDO::getId));
|
||||
|
@ -20,6 +20,8 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.FactoryInfoApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.dto.FactoryInfoDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||
import cn.iocoder.yudao.module.system.api.bank.BankApi;
|
||||
@ -77,6 +79,9 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
@Resource
|
||||
private FactoryInfoApi factoryInfoApi;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -97,8 +102,18 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
loanMapper.insert(loan);
|
||||
|
||||
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
// 提交是费用借支时
|
||||
if (vo.getLoanType() == 2) {
|
||||
|
||||
// 获取借支人所属厂区信息
|
||||
FactoryInfoDTO factoryInfoDTO = factoryInfoApi.getFactoryInfo(loan.getFactoryId()).getCheckedData();
|
||||
processInstanceVariables.put("factoryType", factoryInfoDTO.getType());
|
||||
}
|
||||
|
||||
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(loan.getId())));
|
||||
|
File diff suppressed because one or more lines are too long
@ -70,12 +70,10 @@
|
||||
SUM(a.total_money) - SUM(a.amount_paid) AS remainingPayable
|
||||
FROM
|
||||
bpm_oa_expenses a
|
||||
LEFT JOIN bpm_oa_expenses_item b ON b.expenses_id = a.id
|
||||
LEFT JOIN bpm_process_instance_ext c ON c.process_instance_id = a.process_instance_id
|
||||
LEFT JOIN system_bank ub ON ub.id = a.bank_id
|
||||
WHERE
|
||||
a.deleted = 0
|
||||
AND b.deleted = 0
|
||||
AND a.result = 2
|
||||
<if test="pageReqVO.userId != null">
|
||||
AND a.user_id = #{pageReqVO.userId}
|
||||
|
@ -19,6 +19,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode STAFF_NOT_EXISTS = new ErrorCode(1_000_000_005, "员工不存在");
|
||||
ErrorCode ACCESSORIES_COLLAR_NOT_EXISTS = new ErrorCode(1_000_000_006, "配件费用不存在");
|
||||
ErrorCode IMPORT_LIST_IS_EMPTY = new ErrorCode(1_000_000_007, "导入数据不存在");
|
||||
|
||||
//打包线模块
|
||||
ErrorCode PACKAGE_NOT_EXISTS = new ErrorCode(1_000_001_001, "打包线信息不存在");
|
||||
@ -38,6 +39,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode STAFF_SALARY_EXISTS = new ErrorCode(1_000_004_003, "工资记录已存在");
|
||||
// ========== 搬运模块 1_000_005_000 ==========
|
||||
ErrorCode CANNOT_FIND_THE_CORRESPONDING_FACTORY_HANDLING_SPECIFICATION = new ErrorCode(1_000_005_001, "找不到对应的工厂搬运规格");
|
||||
|
||||
ErrorCode FACTORY_HANDLING_SPECIFICATION_EXISTS = new ErrorCode(1_000_005_002, "工厂搬运规格已存在");
|
||||
ErrorCode SPECIFICATION_USER_AMOUNT_NOT_EXISTS = new ErrorCode(1_000_005_003, "工厂当前月份存在未分配人员数据!");
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,8 @@ import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamount
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountItemVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsService;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount.HandlingGroupUserAmountService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -47,9 +45,6 @@ public class HandlingGroupAmountSpecificationsController {
|
||||
@Resource
|
||||
private HandlingGroupUserAmountService handlingGroupUserAmountService;
|
||||
|
||||
@Resource
|
||||
private FactoryInfoService factoryInfoService;
|
||||
|
||||
@PostMapping("/batchCreate")
|
||||
@Operation(summary = "批量创建搬运组工资规格关联")
|
||||
public CommonResult<Boolean> batchCreate(@Valid @RequestBody HandlingGroupAmountSpecificationsBatchCreateVO vo) {
|
||||
@ -119,7 +114,7 @@ public class HandlingGroupAmountSpecificationsController {
|
||||
List<HandlingGroupUserAmountDO> items = handlingGroupUserAmountMap.get(handlingGroupAmountSpecificationsDO.getHandlingGroupId());
|
||||
if (CollUtil.isNotEmpty(items)) {
|
||||
List<HandlingGroupUserAmountItemVO> handlingGroupUserAmountItemVOS = BeanUtils.toBean(items, HandlingGroupUserAmountItemVO.class);
|
||||
handlingGroupAmountSpecificationsDO.setHandlingGroupUserAmountItemVOS(handlingGroupUserAmountItemVOS);
|
||||
handlingGroupAmountSpecificationsDO.setHandlingGroupUserAmountItemVOS(handlingGroupUserAmountItemVOS);
|
||||
}
|
||||
}
|
||||
return success(result);
|
||||
|
@ -99,6 +99,15 @@ public class HandlingGroupUserAmountController {
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/confirm")
|
||||
@Operation(summary = "确认搬运组薪资")
|
||||
public CommonResult<Boolean> confirmHandlingGroupUserAmount(@RequestParam("factoryId") Long factoryId,
|
||||
@RequestParam("month") String month) {
|
||||
|
||||
handlingGroupUserAmountService.confirmHandlingGroupUserAmount(factoryId, month);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出搬运组每日个人工资记录 Excel")
|
||||
@OperateLog(type = EXPORT)
|
||||
|
@ -6,7 +6,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@ -22,4 +21,7 @@ public class HandlingGroupUserAmountItemVO {
|
||||
@Schema(description = "搬运组每日个人工资")
|
||||
@ExcelProperty("搬运组每日个人工资")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "状态 0未确认 1已确认")
|
||||
private Integer status;
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 搬运组每日个人工资记录 Response VO")
|
||||
@Data
|
||||
@ -38,6 +37,9 @@ public class HandlingGroupUserAmountRespVO {
|
||||
@ExcelProperty("搬运组每日个人工资")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "状态 0.未确认 1.已确认")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
@ -1,33 +1,37 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.*;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlingspecifications.HandlingSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlingspecifications.HandlingSpecificationsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 工厂搬运规格")
|
||||
@RestController
|
||||
@ -38,6 +42,9 @@ public class HandlingSpecificationsController {
|
||||
@Resource
|
||||
private HandlingSpecificationsService handlingSpecificationsService;
|
||||
|
||||
@Resource
|
||||
private FactoryInfoService factoryInfoService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建工厂搬运规格")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-specifications:create')")
|
||||
@ -99,4 +106,38 @@ public class HandlingSpecificationsController {
|
||||
BeanUtils.toBean(list, HandlingSpecificationsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入用户模板")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
|
||||
//获取部门名称
|
||||
List<FactoryInfoDO> factoryInfoDOS = factoryInfoService.getFactoryListByType();
|
||||
List<String> factoryName = factoryInfoDOS.stream()
|
||||
.map(item -> item.getId() + ":" + item.getShortName())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 类型选择
|
||||
List<String> type = Arrays.asList("0:数量", "1:重量");
|
||||
|
||||
Map<Integer, List<String>> mapDropDown = new HashMap<>();
|
||||
mapDropDown.put(0, factoryName);
|
||||
mapDropDown.put(2, type);
|
||||
|
||||
// 输出
|
||||
ExcelUtils.write(response, "搬运规格列表模板.xlsx", "搬运规格列表",
|
||||
HandlingSpecificationsImportVO.class, null,
|
||||
mapDropDown);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入搬运规格列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
||||
})
|
||||
public CommonResult<HandlingSpecificationsImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<HandlingSpecificationsImportVO> list = ExcelUtils.read(file, HandlingSpecificationsImportVO.class);
|
||||
return success(handlingSpecificationsService.importList(list, updateSupport));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 用户导入 Response VO")
|
||||
@Data
|
||||
@Builder
|
||||
public class HandlingSpecificationsImportRespVO {
|
||||
|
||||
@Schema(description = "创建成功的用户名数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<String> createUsernames;
|
||||
|
||||
@Schema(description = "更新成功的用户名数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<String> updateUsernames;
|
||||
|
||||
@Schema(description = "导入失败的用户集合,key 为用户名,value 为失败原因", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Map<String, String> failureUsernames;
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 工厂搬运规格导入 Request VO")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
|
||||
public class HandlingSpecificationsImportVO {
|
||||
|
||||
@ExcelProperty("厂区名称")
|
||||
@NotNull(message = "厂区名称不能为空")
|
||||
private String factoryName;
|
||||
|
||||
@ExcelProperty("规格名称")
|
||||
@NotNull(message = "规格名称不能为空")
|
||||
private String specificationsName;
|
||||
|
||||
@ExcelProperty("类型")
|
||||
@NotNull(message = "类型不能为空")
|
||||
private String type;
|
||||
|
||||
@ExcelProperty("重量 /(公斤 kg)")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ExcelProperty("单价/(吨/1000 or 件)")
|
||||
@NotNull(message = "单价不能为空")
|
||||
private BigDecimal unitPrice;
|
||||
}
|
@ -153,7 +153,7 @@ public class StaffController {
|
||||
//获取部门名称
|
||||
List<FactoryInfoDO> factoryInfoDOS = factoryInfoService.getFactoryListByType();
|
||||
List<String> factoryName = factoryInfoDOS.stream()
|
||||
.map(item -> item.getId() + ":" + item.getName())
|
||||
.map(item -> item.getId() + ":" + item.getShortName())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//获取工种名称
|
||||
|
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -64,4 +63,8 @@ public class HandlingGroupUserAmountDO extends BaseDO {
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 状态 1未确认 2已确认
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 搬运组每日个人工资记录 Mapper
|
||||
@ -74,4 +73,8 @@ public interface HandlingGroupUserAmountMapper extends BaseMapperX<HandlingGroup
|
||||
List<HandlingGroupUserAmountDO> getByHandlingGroupAmountSpecificationsId(@Param("handlingGroupAmountSpecificationsIds") List<Long> handlingGroupAmountSpecificationsIds);
|
||||
|
||||
List<HandlingGroupUserAmountDO> getByHandlingGroupIds(@Param("handlingGroupIds") List<Long> handlingGroupIds);
|
||||
|
||||
List<HandlingGroupUserAmountDO> selectAmountSum(@Param("factoryId") Long factoryId, @Param("month") String month);
|
||||
|
||||
Long selectIsExists(@Param("factoryId") Long factoryId, @Param("month") String month);
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.smartfactory.service.handlingspecifications.Handl
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -69,8 +68,9 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
|
||||
public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
|
||||
// 判断当前登录人是否属于工厂主管
|
||||
List<DeptRespDTO> deptRespDTOS = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
|
||||
if (CollUtil.isNotEmpty(deptRespDTOS)) {
|
||||
pageReqVO.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
|
||||
List<DeptRespDTO> factoryDeptVOs = deptRespDTOS.stream().filter(item -> item.getFactoryId() != null).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(factoryDeptVOs)) {
|
||||
pageReqVO.setFactoryIds(factoryDeptVOs.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
IPage<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO);
|
||||
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
||||
@ -170,8 +170,9 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
|
||||
public HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(HandlingGroupAmountSpecificationsTotalNumDTO dto) {
|
||||
// 判断当前登录人是否属于工厂主管
|
||||
List<DeptRespDTO> deptRespDTOS = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
|
||||
if (CollUtil.isNotEmpty(deptRespDTOS)) {
|
||||
dto.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
|
||||
List<DeptRespDTO> factoryDeptVOs = deptRespDTOS.stream().filter(item -> item.getFactoryId() != null).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(factoryDeptVOs)) {
|
||||
dto.setFactoryIds(factoryDeptVOs.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
return handlingGroupAmountSpecificationsMapper.getTotalNum(dto);
|
||||
}
|
||||
|
@ -96,5 +96,12 @@ public interface HandlingGroupUserAmountService extends IService<HandlingGroupUs
|
||||
*/
|
||||
List<HandlingGroupUserAmountDO> getByHandlingGroupAmountSpecificationsId(List<Long> handlingGroupAmountSpecificationsIds);
|
||||
|
||||
/**
|
||||
* 确认搬运工组薪资,确认后添加至员工薪资表
|
||||
* @param factoryId
|
||||
* @param month
|
||||
*/
|
||||
void confirmHandlingGroupUserAmount(Long factoryId, String month);
|
||||
|
||||
List<HandlingGroupUserAmountDO> getByHandlingGroupIds(List<Long> handlingGroupIds);
|
||||
}
|
||||
|
@ -1,16 +1,27 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOALoanApi;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.vo.loan.BpmOALoanSumDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.dto.StaffWagesPageDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.*;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.DeductionItemsVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalarySubjectItemsVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staffsalary.StaffSalaryDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupuseramount.HandlingGroupUserAmountMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.staffsalary.StaffSalaryMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
|
||||
import cn.iocoder.yudao.module.system.api.loan.LoanApi;
|
||||
import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -18,8 +29,15 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.SPECIFICATION_USER_AMOUNT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 搬运组每日个人工资记录 Service 实现类
|
||||
@ -34,6 +52,19 @@ public class HandlingGroupUserAmountServiceImpl extends ServiceImpl<HandlingGrou
|
||||
private HandlingGroupUserAmountMapper handlingGroupUserAmountMapper;
|
||||
@Resource
|
||||
private HandlingGroupAmountSpecificationsMapper handlingGroupAmountSpecificationsMapper;
|
||||
|
||||
@Resource
|
||||
private BpmOALoanApi bpmOALoanApi;
|
||||
|
||||
@Resource
|
||||
private LoanApi loanApi;
|
||||
|
||||
@Resource
|
||||
private StaffService staffService;
|
||||
|
||||
@Resource
|
||||
private StaffSalaryMapper staffSalaryMapper;
|
||||
|
||||
private static final String NAME = "姓名";
|
||||
private static final String TOTAL_AMOUNT = "总金额";
|
||||
// 提取常量
|
||||
@ -81,7 +112,6 @@ public class HandlingGroupUserAmountServiceImpl extends ServiceImpl<HandlingGrou
|
||||
// 插入
|
||||
createReqVO.setFactoryId(handlingGroupAmountSpecificationsDO.getFactoryId());
|
||||
HandlingGroupUserAmountDO handlingGroupUserAmount = BeanUtils.toBean(createReqVO, HandlingGroupUserAmountDO.class);
|
||||
handlingGroupUserAmount.setHandlingGroupId(handlingGroupAmountSpecificationsDO.getHandlingGroupId());
|
||||
handlingGroupUserAmountMapper.insertOrUpdate(handlingGroupUserAmount);
|
||||
}
|
||||
|
||||
@ -146,10 +176,82 @@ public class HandlingGroupUserAmountServiceImpl extends ServiceImpl<HandlingGrou
|
||||
return handlingGroupUserAmountMapper.getByHandlingGroupAmountSpecificationsId(handlingGroupAmountSpecificationsIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmHandlingGroupUserAmount(Long factoryId, String month) {
|
||||
|
||||
// 查询搬运工 月工资总额
|
||||
List<HandlingGroupUserAmountDO> userAmountSums = handlingGroupUserAmountMapper.selectAmountSum(factoryId, month);
|
||||
if (CollUtil.isEmpty(userAmountSums)) {
|
||||
throw exception(SPECIFICATION_USER_AMOUNT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 校验 工厂当前月份是否存在未分配搬运工数据
|
||||
Long count = handlingGroupUserAmountMapper.selectIsExists(factoryId, month);
|
||||
if (count > 0L) {
|
||||
throw exception(SPECIFICATION_USER_AMOUNT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 更新搬运组薪资 状态
|
||||
handlingGroupUserAmountMapper.update(null, new LambdaUpdateWrapper<HandlingGroupUserAmountDO>()
|
||||
.set(HandlingGroupUserAmountDO::getStatus, 1)
|
||||
.eq(HandlingGroupUserAmountDO::getFactoryId, factoryId)
|
||||
.like(HandlingGroupUserAmountDO::getDateStr, month));
|
||||
|
||||
// 获取厂区得员工信息
|
||||
Set<Long> staffIds = convertSet(userAmountSums, HandlingGroupUserAmountDO::getUserId);
|
||||
List<StaffDO> staffDOS = staffService.getList(staffIds);
|
||||
Map<Long, StaffDO> staffMap = convertMap(staffDOS, StaffDO::getId);
|
||||
|
||||
// 获取员工借支记录
|
||||
List<BpmOALoanSumDTO> loanDOS = bpmOALoanApi.getListByStaffId(staffIds, month).getCheckedData();
|
||||
Map<Long, BigDecimal> loanMap = loanDOS.stream()
|
||||
.collect(Collectors.toMap(
|
||||
BpmOALoanSumDTO::getSfUserId,
|
||||
BpmOALoanSumDTO::getTotalAmount,
|
||||
BigDecimal::add
|
||||
));
|
||||
|
||||
// 获取员工剩余的 工资借支金额
|
||||
List<LoanDTO> sysLoanDOS = loanApi.getListByMonth(staffIds, month).getCheckedData();
|
||||
Map<Long, BigDecimal> sysLoanMap = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(sysLoanDOS)) {
|
||||
sysLoanMap = sysLoanDOS.stream()
|
||||
.collect(Collectors.toMap(LoanDTO::getUserId, LoanDTO::getRemainingAmount));
|
||||
}
|
||||
|
||||
Map<Long, BigDecimal> finalSysLoanMap = sysLoanMap;
|
||||
List<StaffSalaryDO> salaryDOS = userAmountSums.stream().map(item -> {
|
||||
StaffSalaryDO salaryDO = new StaffSalaryDO()
|
||||
.setStaffId(item.getUserId())
|
||||
.setFactoryId(item.getFactoryId())
|
||||
.setMonth(month)
|
||||
.setPayableAmount(item.getAmount())
|
||||
.setReturnAmount(loanMap.getOrDefault(item.getUserId(), BigDecimal.ZERO)
|
||||
.add(finalSysLoanMap.getOrDefault(item.getUserId(), BigDecimal.ZERO)))
|
||||
.setDeductionItems(Collections.singletonList(
|
||||
new DeductionItemsVO()
|
||||
.setKey("insurance")
|
||||
.setValue("50")));
|
||||
// 设置实发工资
|
||||
salaryDO.setRealAmount(salaryDO.getPayableAmount().subtract(salaryDO.getReturnAmount()));
|
||||
// 设置薪资主体数据
|
||||
if (staffMap.get(item.getUserId()).getSalarySubject() != null) {
|
||||
salaryDO.setSalarySubjectItems(Collections.singletonList(
|
||||
new SalarySubjectItemsVO()
|
||||
.setSalarySubjectId(staffMap.get(item.getUserId()).getSalarySubject())
|
||||
.setAmount(salaryDO.getPayableAmount())
|
||||
));
|
||||
}
|
||||
return salaryDO;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 插入工资记录
|
||||
staffSalaryMapper.insertBatch(salaryDOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HandlingGroupUserAmountDO> getByHandlingGroupIds(List<Long> handlingGroupIds) {
|
||||
return handlingGroupUserAmountMapper.getByHandlingGroupIds(handlingGroupIds);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.handlingspecifications;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsImportRespVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsImportVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlingspecifications.HandlingSpecificationsDO;
|
||||
@ -61,4 +63,12 @@ public interface HandlingSpecificationsService extends IService<HandlingSpecific
|
||||
* @return
|
||||
*/
|
||||
List<HandlingSpecificationsDO> getHandlingSpecificationsList(@Valid HandlingSpecificationsPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导入列表
|
||||
* @param list
|
||||
* @param updateSupport
|
||||
* @return
|
||||
*/
|
||||
HandlingSpecificationsImportRespVO importList(List<HandlingSpecificationsImportVO> list, Boolean updateSupport);
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.handlingspecifications;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsImportRespVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsImportVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlingspecifications.vo.HandlingSpecificationsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlingspecifications.HandlingSpecificationsDO;
|
||||
@ -10,12 +16,18 @@ import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlingspecifications.Han
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACTORY_HANDLING_SPECIFICATION_EXISTS;
|
||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.IMPORT_LIST_IS_EMPTY;
|
||||
|
||||
/**
|
||||
* 工厂搬运规格 Service 实现类
|
||||
*
|
||||
@ -66,4 +78,87 @@ public class HandlingSpecificationsServiceImpl extends ServiceImpl<HandlingSpeci
|
||||
return handlingSpecificationsMapper.getHandlingSpecificationsList(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
||||
public HandlingSpecificationsImportRespVO importList(List<HandlingSpecificationsImportVO> list, Boolean updateSupport) {
|
||||
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception(IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
HandlingSpecificationsImportRespVO respVO = HandlingSpecificationsImportRespVO.builder()
|
||||
.createUsernames(new ArrayList<>())
|
||||
.updateUsernames(new ArrayList<>())
|
||||
.failureUsernames(new HashMap<>()).build();
|
||||
|
||||
list.forEach(importUser -> {
|
||||
if (importUser.getFactoryName() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 解析工厂名称数据 格式为 id:name
|
||||
Long factoryId = Long.valueOf(importUser.getFactoryName().split(":")[0]);
|
||||
String factoryName = importUser.getFactoryName().split(":")[1];
|
||||
|
||||
//校验,判断是否有不符合的原因
|
||||
try {
|
||||
if (!updateSupport) {
|
||||
validateForCreate(factoryId, importUser.getSpecificationsName());
|
||||
}
|
||||
} catch (ServiceException ex) {
|
||||
respVO.getFailureUsernames().put(factoryName, ex.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
HandlingSpecificationsDO updateDo = new HandlingSpecificationsDO();
|
||||
// 设置工厂编号
|
||||
updateDo.setFactoryId(factoryId);
|
||||
// 设置规格名称
|
||||
updateDo.setSpecificationsName(importUser.getSpecificationsName());
|
||||
// 设置重量
|
||||
updateDo.setWeight(importUser.getWeight());
|
||||
// 设置单价
|
||||
updateDo.setUnitPrice(importUser.getUnitPrice());
|
||||
|
||||
Integer type = null;
|
||||
if (importUser.getType() != null) {
|
||||
// 解析类型数据
|
||||
type = Integer.valueOf(importUser.getType().split(":")[0]);
|
||||
updateDo.setType(type);
|
||||
}
|
||||
|
||||
// 判断如果不存在,在进行插入
|
||||
if (updateSupport) {
|
||||
HandlingSpecificationsDO handlingSpecificationsDO = handlingSpecificationsMapper.selectOne(new LambdaQueryWrapperX<HandlingSpecificationsDO>()
|
||||
.eqIfPresent(HandlingSpecificationsDO::getFactoryId, factoryId)
|
||||
.eqIfPresent(HandlingSpecificationsDO::getSpecificationsName, importUser.getSpecificationsName()));
|
||||
|
||||
updateDo.setId(handlingSpecificationsDO.getId());
|
||||
handlingSpecificationsMapper.updateById(updateDo);
|
||||
respVO.getUpdateUsernames().add(factoryName);
|
||||
return;
|
||||
}
|
||||
|
||||
// 插入用户
|
||||
handlingSpecificationsMapper.insert(updateDo);
|
||||
respVO.getCreateUsernames().add(factoryName);
|
||||
});
|
||||
|
||||
return respVO;
|
||||
}
|
||||
|
||||
private void validateForCreate(Long factoryId, String specificationsName) {
|
||||
|
||||
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
||||
DataPermissionUtils.executeIgnore(() -> {
|
||||
|
||||
// 校验用户名、身份证号是否已经存在
|
||||
Long cunt = handlingSpecificationsMapper.selectCount(new LambdaQueryWrapperX<HandlingSpecificationsDO>()
|
||||
.eqIfPresent(HandlingSpecificationsDO::getFactoryId, factoryId)
|
||||
.eqIfPresent(HandlingSpecificationsDO::getSpecificationsName, specificationsName));
|
||||
if (cunt > 0) {
|
||||
throw exception(FACTORY_HANDLING_SPECIFICATION_EXISTS);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -149,6 +149,38 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAmountSum" resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO">
|
||||
SELECT
|
||||
user_id AS userId,
|
||||
SUM(amount) AS amount
|
||||
FROM
|
||||
sf_handling_group_user_amount
|
||||
WHERE
|
||||
deleted = 0
|
||||
AND status = 0
|
||||
AND factory_id = #{factoryId}
|
||||
AND date_str LIKE CONCAT('%', #{month}, '%')
|
||||
GROUP BY
|
||||
user_id
|
||||
</select>
|
||||
|
||||
<select id="selectIsExists" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
sf_handling_group_amount_specifications a
|
||||
WHERE
|
||||
NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sf_handling_group_user_amount b
|
||||
WHERE a.factory_id = b.factory_id AND a.date_str = b.date_str
|
||||
)
|
||||
AND a.factory_id = #{factoryId}
|
||||
AND a.date_str LIKE CONCAT('%', #{month}, '%')
|
||||
AND a.deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getByHandlingGroupIds"
|
||||
resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO">
|
||||
select a.*,
|
||||
|
Loading…
Reference in New Issue
Block a user