|
|
|
@ -1,21 +1,26 @@
|
|
|
|
|
package cn.iocoder.yudao.module.bs.service.quotationsheet;
|
|
|
|
|
package cn.iocoder.yudao.module.bpm.service.quotationsheet;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationSheetCreateReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationSheetExportReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationSheetPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.quotationsheet.vo.QuotationSheetUpdateReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.materiel.MaterielDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetbidding.QuotationSheetBiddingDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheetdetail.QuotationSheetDetailDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.enums.QuotationSheetEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.materiel.MaterielService;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetbidding.QuotationSheetBiddingService;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailService;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.quotationsheetdetail.QuotationSheetDetailServiceImpl;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
|
|
|
|
|
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.tenant.TenantApi;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.tenant.dto.TenantDTO;
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
@ -24,10 +29,9 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
@ -36,12 +40,11 @@ import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.controller.admin.quotationsheet.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.bs.convert.quotationsheet.QuotationSheetConvert;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.mysql.quotationsheet.QuotationSheetMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.convert.quotationsheet.QuotationSheetConvert;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.dal.mysql.quotationsheet.QuotationSheetMapper;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
|
|
|
@ -93,6 +96,8 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
AdminUserRespDTO user = adminUserApi.getUser(loginUser.getId());
|
|
|
|
|
quotationSheet.setDeptId(user.getDeptId());
|
|
|
|
|
quotationSheet.setApplicant(loginUser.getId());
|
|
|
|
|
quotationSheet.setQuotationStatus(1);
|
|
|
|
|
quotationSheet.setStatus("0");
|
|
|
|
|
saveOrUpdate(quotationSheet);
|
|
|
|
|
if (createReqVO.getQuotationDetails().size() > 0){
|
|
|
|
|
//中间表插入数据
|
|
|
|
@ -100,7 +105,18 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
quotationSheetDetailDO.setCompanyId(quotationSheet.getId());
|
|
|
|
|
}
|
|
|
|
|
quotationSheetDetailService.saveBatch(createReqVO.getQuotationDetails());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (quotationSheet.getStatus().equals(QuotationSheetEnum.NOSUBMIT.getValue())) {
|
|
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
|
|
// variables.put("type", quotationSheet.getType());
|
|
|
|
|
variables.put("name", quotationSheet.getProductName());
|
|
|
|
|
// variables.put("number",quotationSheet.getNumber());
|
|
|
|
|
// variables.put("deptId", quotationSheet.getDeptId());
|
|
|
|
|
String processInstanceId = processInstanceApi.createProcessInstance(quotationSheet.getApplicant(),
|
|
|
|
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
|
|
|
|
.setVariables(variables).setBusinessKey(String.valueOf(quotationSheet.getId())));
|
|
|
|
|
updateById(new QuotationSheetDO().setId(quotationSheet.getId()).setProcessInstanceId(processInstanceId));
|
|
|
|
|
}
|
|
|
|
|
return quotationSheet.getId();
|
|
|
|
|
}
|
|
|
|
@ -432,6 +448,45 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
return sheetDOPageResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void processInstanceCallBack(long id, Integer result) {
|
|
|
|
|
QuotationSheetDO apply = getById(id);
|
|
|
|
|
if (BpmProcessInstanceResultEnum.APPROVE.getResult().equals(result)) {
|
|
|
|
|
//审核通过
|
|
|
|
|
apply.setQuotationStatus(3);
|
|
|
|
|
apply.setStatus(QuotationSheetEnum.APPROVE.getValue());
|
|
|
|
|
updateById(apply);
|
|
|
|
|
} else if (BpmProcessInstanceResultEnum.REJECT.getResult().equals(result)) {
|
|
|
|
|
//驳回
|
|
|
|
|
apply.setQuotationStatus(2);
|
|
|
|
|
apply.setStatus(QuotationSheetEnum.APPROVE.getValue());
|
|
|
|
|
updateById(apply);
|
|
|
|
|
}else if (BpmProcessInstanceResultEnum.CANCEL.getResult().equals(result)) {
|
|
|
|
|
//驳回
|
|
|
|
|
apply.setQuotationStatus(1);
|
|
|
|
|
apply.setStatus(QuotationSheetEnum.APPROVE.getValue());
|
|
|
|
|
updateById(apply);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setNickNameField(List<QuotationSheetDO> list) {
|
|
|
|
|
List<Long> userIds = list.stream().map(QuotationSheetDO::getApplicant).distinct().collect(Collectors.toList());
|
|
|
|
|
Map<Long, String> userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(AdminUserRespDTO::getId, user -> user.getNickname()));
|
|
|
|
|
for (QuotationSheetDO quotationSheetDO : list) {
|
|
|
|
|
quotationSheetDO.setNickname(userMap.get(quotationSheetDO.getApplicant()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setDeptNameField(List<QuotationSheetDO> toList) {
|
|
|
|
|
List<Long> deptIds = toList.stream().map(QuotationSheetDO::getDeptId).distinct().collect(Collectors.toList());
|
|
|
|
|
Map<Long, String> deptMap = deptApi.getDeptList(deptIds).stream().collect(Collectors.toMap(DeptRespDTO::getId, dept -> dept.getName()));
|
|
|
|
|
for (QuotationSheetDO quotationSheetDO : toList) {
|
|
|
|
|
quotationSheetDO.setDeptName(deptMap.get(quotationSheetDO.getDeptId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编号生成方法
|
|
|
|
|
* @return
|
|
|
|
@ -439,15 +494,15 @@ public class QuotationSheetServiceImpl extends MPJBaseServiceImpl<QuotationSheet
|
|
|
|
|
private String numberCreate(){
|
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
Date date = new Date(currentTime);
|
|
|
|
|
String companyNumber="bjd"+ DateUtils.dateToStr(DateUtils.FORMAT_HOUR_MINUT,date);
|
|
|
|
|
String companyNumber="BJD"+ DateUtils.dateToStr(DateUtils.FORMAT_HOUR_MINUT,date);
|
|
|
|
|
QuotationSheetDO supplierCompanyDO = quotationSheetMapper.selectOne(new QueryWrapper<QuotationSheetDO>().like("number", companyNumber).orderByDesc("create_time").last("limit 1"));
|
|
|
|
|
if (null!=supplierCompanyDO){
|
|
|
|
|
Long aLong = numKun(supplierCompanyDO.getNumber());
|
|
|
|
|
companyNumber ="bjd"+(aLong+1);
|
|
|
|
|
companyNumber ="BJD"+(aLong+1);
|
|
|
|
|
}else {
|
|
|
|
|
companyNumber=companyNumber+"0000";
|
|
|
|
|
long l = numKun(companyNumber) + 1;
|
|
|
|
|
companyNumber ="bjd"+(numKun(companyNumber) + 1);
|
|
|
|
|
companyNumber ="BJD"+(numKun(companyNumber) + 1);
|
|
|
|
|
}
|
|
|
|
|
return companyNumber;
|
|
|
|
|
}
|