diff --git a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWriteoffApplyController.java b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWriteoffApplyController.java index b4b316212..4c8d0a0dd 100644 --- a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWriteoffApplyController.java +++ b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisWriteoffApplyController.java @@ -43,7 +43,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 查询销账申请列表 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:list')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:list')") @GetMapping("/list") public TableDataInfo list(EmisWriteoffApply emisWriteoffApply) { // 处理params参数,支持运单号、账单号多选查询 @@ -108,7 +108,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 获取销账申请详细信息 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:query')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(emisWriteoffApplyService.selectEmisWriteoffApplyById(id)); @@ -117,7 +117,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 新增销账申请 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:add')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:add')") @Log(title = "销账申请", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody EmisWriteoffApply emisWriteoffApply) { @@ -132,7 +132,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 修改销账申请 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:edit')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:edit')") @Log(title = "销账申请", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody EmisWriteoffApply emisWriteoffApply) throws EmisBizError { @@ -143,7 +143,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { * 删除销账申请 * 仅支持删除已撤销的数据,审核中以及审核完成的数据不支持删除 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:remove')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:remove')") @Log(title = "销账申请", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { @@ -158,7 +158,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 财务中心审核通过 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:centerPass')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:centerPass')") @Log(title = "财务中心审核通过", businessType = BusinessType.UPDATE) @PostMapping("/auditCenterPass/{ids}") public AjaxResult auditCenterPass(@PathVariable Long[] ids) { @@ -188,7 +188,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 财务中心审核驳回 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:centerReject')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:centerReject')") @Log(title = "财务中心审核驳回", businessType = BusinessType.UPDATE) @PostMapping("/auditCenterReject/{ids}") public AjaxResult auditCenterReject(@PathVariable Long[] ids, @RequestBody EmisWriteoffApply emisWriteoffApply) { @@ -219,7 +219,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 总部确认 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:headquartersConfirm')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:headquartersConfirm')") @Log(title = "总部确认", businessType = BusinessType.UPDATE) @PostMapping("/auditHeadquartersConfirm/{ids}") public AjaxResult auditHeadquartersConfirm(@PathVariable Long[] ids) { @@ -249,7 +249,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 总部驳回 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:headquartersReject')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:headquartersReject')") @Log(title = "总部驳回", businessType = BusinessType.UPDATE) @PostMapping("/auditHeadquartersReject/{ids}") public AjaxResult auditHeadquartersReject(@PathVariable Long[] ids, @@ -281,7 +281,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 撤销申请 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:revoke')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:revoke')") @Log(title = "撤销申请", businessType = BusinessType.UPDATE) @PostMapping("/revoke/{ids}") public AjaxResult revoke(@PathVariable Long[] ids) { @@ -311,7 +311,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 再次申请 */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:reapply')") +// @PreAuthorize("@ss.hasPermi('emis:writeoffApply:reapply')") @Log(title = "再次申请", businessType = BusinessType.UPDATE) @PostMapping("/reapply") public AjaxResult reapply(@RequestBody EmisWriteoffApply emisWriteoffApply) { @@ -326,7 +326,7 @@ public class EmisWriteoffApplyController extends EmisBaseController { /** * 根据运单号查询运单、结算账单、结算子账单信息(返回EmisWriteoffApplyDetail列表) */ - // @PreAuthorize("@ss.hasPermi('emis:writeoffApply:queryByBillCodes')") + @PreAuthorize("@ss.hasPermi('emis:writeoffApply:queryByBillCodes')") @GetMapping("/queryByBillCodes") public AjaxResult queryByBillCodes(EmisWriteoffApply emisWriteoffApply) { try { diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java index e9165894c..c022fdf36 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWriteoffApplyServiceImpl.java @@ -14,6 +14,8 @@ import java.math.BigDecimal; import java.util.*; import java.util.HashSet; import java.util.Set; +import java.util.Map; +import java.util.Objects; import com.xdadan.erp.common.core.domain.entity.SysUser; import com.xdadan.erp.common.utils.SecurityUtils; @@ -28,6 +30,7 @@ import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; /** * 销账申请Service业务层处理 @@ -37,7 +40,7 @@ import org.springframework.transaction.annotation.Transactional; */ @Service @Slf4j -public class EmisWriteoffApplyServiceImpl implements IEmisWriteoffApplyService { +public class EmisWriteoffApplyServiceImpl extends EmisBaseService implements IEmisWriteoffApplyService { @Autowired private EmisWriteoffApplyMapper emisWriteoffApplyMapper; @@ -354,6 +357,9 @@ public class EmisWriteoffApplyServiceImpl implements IEmisWriteoffApplyService { // 重算并更新月结客户额度和现金客户额度 updateCreditLimits(existingApply, detailList); + // 发送通知给申请人 + sendWriteoffApplyNotification(existingApply, "centerPass", null); + return result; } catch (Exception e) { log.error("财务中心审核通过失败", e); @@ -391,6 +397,9 @@ public class EmisWriteoffApplyServiceImpl implements IEmisWriteoffApplyService { // 更新申请状态 int result = emisWriteoffApplyMapper.auditCenterReject(emisWriteoffApply); + // 发送通知给申请人 + sendWriteoffApplyNotification(existingApply, "centerReject", emisWriteoffApply.getCenterRejectReason()); + return result; } catch (Exception e) { log.error("财务中心审核驳回失败", e); @@ -487,6 +496,9 @@ public class EmisWriteoffApplyServiceImpl implements IEmisWriteoffApplyService { // 重算并更新月结客户额度和现金客户额度 updateCreditLimits(existingApply, detailList); + // 发送通知给申请人和财务中心审批人员 + sendWriteoffApplyNotification(existingApply, "headquartersReject", emisWriteoffApply.getHeadquartersRejectReason()); + return result; } catch (Exception e) { log.error("总部驳回失败", e); @@ -1107,4 +1119,75 @@ public class EmisWriteoffApplyServiceImpl implements IEmisWriteoffApplyService { throw e; } } + + /** + * 发送销账申请通知 + * + * @param apply 销账申请 + * @param actionType 操作类型:centerPass-财务中心通过,centerReject-财务中心驳回,headquartersReject-总部驳回 + * @param rejectReason 驳回原因(驳回时使用) + */ + private void sendWriteoffApplyNotification(EmisWriteoffApply apply, String actionType, String rejectReason) { + try { + if (apply == null || StringUtils.isEmpty(apply.getApplyManCode())) { + log.warn("销账申请或申请人代码为空,无法发送通知"); + return; + } + + String title = ""; + String message = ""; + String clickPath = "/d24/financialManagement/WriteoffApplyList"; + + // 获取申请人姓名 + String applyManName = StringUtils.hasText(apply.getApplyManName()) ? + apply.getApplyManName() : apply.getApplyManCode(); + + // 获取操作人姓名 + String operatorName = ""; + if ("centerPass".equals(actionType) || "centerReject".equals(actionType)) { + operatorName = StringUtils.hasText(apply.getCenterConfirmManName()) ? + apply.getCenterConfirmManName() : apply.getCenterConfirmManCode(); + } else if ("headquartersReject".equals(actionType)) { + operatorName = StringUtils.hasText(apply.getHeadquartersConfirmManName()) ? + apply.getHeadquartersConfirmManName() : apply.getHeadquartersConfirmManCode(); + } + + // 构建通知内容 + switch (actionType) { + case "centerPass": + title = "销账申请已通过,申请编号【" + apply.getApplyNo() + "】"; + message = operatorName + "已通过您的销账申请,申请编号:" + apply.getApplyNo() + + ",销账金额:" + apply.getWriteoffAmount(); + break; + case "centerReject": + title = "销账申请被驳回,申请编号【" + apply.getApplyNo() + "】"; + message = operatorName + "驳回了您的销账申请,申请编号:" + apply.getApplyNo() + + ",驳回原因:" + (StringUtils.hasText(rejectReason) ? rejectReason : "无"); + break; + case "headquartersReject": + title = "销账申请被总部驳回,申请编号【" + apply.getApplyNo() + "】"; + message = operatorName + "驳回了您的销账申请,申请编号:" + apply.getApplyNo() + + ",驳回原因:" + (StringUtils.hasText(rejectReason) ? rejectReason : "无"); + break; + default: + log.warn("未知的操作类型:{}", actionType); + return; + } + + // 发送通知给申请人 + sendNoticeToEmpUser(apply.getApplyManCode(), title, message, clickPath); + + // 如果是总部驳回,还需要通知财务中心审批人员 + if ("headquartersReject".equals(actionType) && StringUtils.hasText(apply.getCenterConfirmManCode())) { + String centerTitle = "您审核的销账申请被总部驳回,申请编号【" + apply.getApplyNo() + "】"; + String centerMessage = "您审核通过的销账申请被" + operatorName + "驳回,申请编号:" + apply.getApplyNo() + + ",驳回原因:" + (StringUtils.hasText(rejectReason) ? rejectReason : "无"); + sendNoticeToEmpUser(apply.getCenterConfirmManCode(), centerTitle, centerMessage, clickPath); + } + + log.info("销账申请通知发送成功,申请编号:{},操作类型:{}", apply.getApplyNo(), actionType); + } catch (Exception e) { + log.error("发送销账申请通知失败,申请编号:{},操作类型:{}", apply.getApplyNo(), actionType, e); + } + } }