|
@@ -0,0 +1,107 @@
|
|
|
+package com.fjhx.oa.service.epiboly.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.CodingRuleEnum;
|
|
|
+import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
+import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
+import com.fjhx.common.service.contractor.ContractorService;
|
|
|
+import com.fjhx.common.utils.AuthorityUtils;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
+import com.fjhx.oa.entity.epiboly.dto.EpibolyBillDto;
|
|
|
+import com.fjhx.oa.entity.epiboly.dto.EpibolyBillSelectDto;
|
|
|
+import com.fjhx.oa.entity.epiboly.po.EpibolyBill;
|
|
|
+import com.fjhx.oa.entity.epiboly.vo.EpibolyBillVo;
|
|
|
+import com.fjhx.oa.mapper.epiboly.EpibolyBillMapper;
|
|
|
+import com.fjhx.oa.service.epiboly.EpibolyBillService;
|
|
|
+import com.fjhx.tenant.utils.DeptUstil;
|
|
|
+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.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 外包加工账单 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-04-15
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class EpibolyBillServiceImpl extends ServiceImpl<EpibolyBillMapper, EpibolyBill> implements EpibolyBillService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractorService contractorService;
|
|
|
+ @Autowired
|
|
|
+ private CodingRuleService codingRuleService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<EpibolyBillVo> getPage(EpibolyBillSelectDto dto) {
|
|
|
+ IWrapper<EpibolyBill> wrapper = getWrapper();
|
|
|
+
|
|
|
+ //权限过滤
|
|
|
+ AuthorityUtils.cofAuthority("eb", EpibolyBill::getCompanyId, wrapper);
|
|
|
+
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField("eb", EpibolyBill::getCode),
|
|
|
+ new SqlField("eb", EpibolyBill::getFinalAmount)
|
|
|
+ );
|
|
|
+
|
|
|
+ wrapper.eq("eb", EpibolyBill::getContractorId, dto.getContractorId());
|
|
|
+
|
|
|
+ wrapper.orderByDesc("eb", EpibolyBill::getId);
|
|
|
+ Page<EpibolyBillVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ setInfo(page.getRecords());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public EpibolyBillVo detail(Long id) {
|
|
|
+ EpibolyBill EpibolyBill = this.getById(id);
|
|
|
+ EpibolyBillVo result = BeanUtil.toBean(EpibolyBill, EpibolyBillVo.class);
|
|
|
+ Arrays.asList(result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ void setInfo(List<EpibolyBillVo> records) {
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ UserUtil.assignmentNickName(records, EpibolyBill::getCreateUser, EpibolyBillVo::setCreateUserName);
|
|
|
+ DeptUstil.assignmentNickName(records, EpibolyBill::getDeptId, EpibolyBillVo::setDeptName);
|
|
|
+ DeptUstil.assignmentNickName(records, EpibolyBill::getCompanyId, EpibolyBillVo::setCompanyName);
|
|
|
+ //赋值承包商
|
|
|
+ contractorService.attributeAssign(records, EpibolyBillVo::getContractorId, (item, contractor) -> {
|
|
|
+ item.setContractorName(contractor.getName());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void add(EpibolyBillDto dto) {
|
|
|
+ dto.setStatus(FlowStatusEnum1.PASS.getKey());
|
|
|
+ dto.setCode(codingRuleService.createCode(CodingRuleEnum.EPIBOLY_BILL.getKey(), null));
|
|
|
+ this.save(dto);
|
|
|
+ ObsFileUtil.saveFile(dto.getFileList(), dto.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(EpibolyBillDto epibolyBillDto) {
|
|
|
+ this.updateById(epibolyBillDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|