|
@@ -0,0 +1,117 @@
|
|
|
+package com.fjhx.oa.service.personal.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
+import com.fjhx.common.utils.AuthorityUtils;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
+import com.fjhx.flow.entity.flow.po.FlowExample;
|
|
|
+import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
+import com.fjhx.flow.service.flow.FlowExampleService;
|
|
|
+import com.fjhx.oa.entity.personal.dto.PersonalInvoiceDto;
|
|
|
+import com.fjhx.oa.entity.personal.dto.PersonalInvoiceSelectDto;
|
|
|
+import com.fjhx.oa.entity.personal.po.PersonalInvoice;
|
|
|
+import com.fjhx.oa.entity.personal.vo.PersonalInvoiceVo;
|
|
|
+import com.fjhx.oa.mapper.personal.PersonalInvoiceMapper;
|
|
|
+import com.fjhx.oa.service.personal.PersonalInvoiceService;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+import com.ruoyi.system.utils.UserUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 个人电子发票申请 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-04-11
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PersonalInvoiceServiceImpl extends ServiceImpl<PersonalInvoiceMapper, PersonalInvoice> implements PersonalInvoiceService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FlowExampleService flowExampleService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<PersonalInvoiceVo> getPage(PersonalInvoiceSelectDto dto) {
|
|
|
+ IWrapper<PersonalInvoice> wrapper = getWrapper();
|
|
|
+
|
|
|
+ //权限过滤
|
|
|
+ AuthorityUtils.cofAuthority("pi", PersonalInvoice::getCompanyId, wrapper);
|
|
|
+
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField("pi", PersonalInvoice::getCode),
|
|
|
+ new SqlField("pi", PersonalInvoice::getAmount),
|
|
|
+ new SqlField("pi", PersonalInvoice::getRemark)
|
|
|
+ );
|
|
|
+ wrapper.eq("su", PersonalInvoice::getStatus, dto.getStatus());
|
|
|
+
|
|
|
+ wrapper.orderByDesc("pi", PersonalInvoice::getId);
|
|
|
+ Page<PersonalInvoiceVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<PersonalInvoiceVo> records = page.getRecords();
|
|
|
+ setInfo(records);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PersonalInvoiceVo detail(Long id) {
|
|
|
+ PersonalInvoice personalInvoice = this.getById(id);
|
|
|
+ PersonalInvoiceVo result = BeanUtil.toBean(personalInvoice, PersonalInvoiceVo.class);
|
|
|
+ setInfo(Arrays.asList(result));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setInfo(List<PersonalInvoiceVo> records) {
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ UserUtil.assignmentNickName(records, PersonalInvoiceVo::getCreateUser, PersonalInvoiceVo::setCreateUserName);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void addOrEdit(PersonalInvoiceDto dto) {
|
|
|
+ dto.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
+ ObsFileUtil.saveFile(dto.getFileList(), dto.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cancellation(Long businessId) {
|
|
|
+ PersonalInvoice byId = getById(businessId);
|
|
|
+ this.update(q -> q
|
|
|
+ .eq(PersonalInvoice::getId, businessId)
|
|
|
+ .set(PersonalInvoice::getStatus, FlowStatusEnum1.CANCELLATION.getKey())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
+ //销毁审批中的流程
|
|
|
+ flowExampleService.update(q -> q
|
|
|
+ .eq(FlowExample::getId, byId.getFlowId())
|
|
|
+ .in(FlowExample::getStatus, FlowStatusEnum.READY_START.getKey(), FlowStatusEnum.IN_PROGRESS.getKey())
|
|
|
+ .set(FlowExample::getStatus, FlowStatusEnum.CANCELLATION.getKey())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+}
|