|
@@ -17,6 +17,7 @@ import org.springblade.control.dto.*;
|
|
|
import org.springblade.control.entity.*;
|
|
|
import org.springblade.control.mapper.TaskProcessMapper;
|
|
|
import org.springblade.control.service.TaskProcessService;
|
|
|
+import org.springblade.control.utils.ByteArrayToMultipartFileConverter;
|
|
|
import org.springblade.control.utils.PDFConverter;
|
|
|
import org.springblade.control.vo.*;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -31,7 +32,6 @@ import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.resource.feign.IOSSClient;
|
|
|
-import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
@@ -41,6 +41,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
@@ -64,7 +65,7 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
private final ProjectCostBudgetServiceImpl projectCostBudgetService;
|
|
|
private final ProjectInfoServiceImpl projectInfoServiceImpl;
|
|
|
private final ProjectCostBudgetStatsServiceImpl projectCostBudgetStatsService;
|
|
|
- private final NewIOSSClient newIOSSClient;
|
|
|
+ private final IOSSClient iossClient;
|
|
|
|
|
|
@Override
|
|
|
public IPage<TaskProcessInfoVO> taskPage(IPage<TaskProcessInfo> page, TaskProcessInfoDTO dto) {
|
|
@@ -200,29 +201,37 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
data = jdbcTemplate.query("select * from c_expense_financial_reimbursement_info where id = " + record.getExpenseInfoId(), new BeanPropertyRowMapper<>(EMFinancialReimbursementInfo.class)).stream().findAny().orElse(null);
|
|
|
EMFinancialReimbursementInfoVO voCW = BeanUtil.copyProperties(data, EMFinancialReimbursementInfoVO.class);
|
|
|
if (voCW != null) {
|
|
|
- //pdf转png
|
|
|
- /*if (ObjectUtil.isNotEmpty(voCW.getFrAttachmentUrl()) && ObjectUtil.isEmpty(voCW.getFrAttachmentUrlPng())) {
|
|
|
+ //pdf转jpg
|
|
|
+ if (ObjectUtil.isNotEmpty(voCW.getFrAttachmentUrl()) && ObjectUtil.isEmpty(voCW.getFrAttachmentUrlJpg())) {
|
|
|
InputStream ossInputStream = CommonUtil.getOSSInputStream(voCW.getFrAttachmentUrl());
|
|
|
- byte[] bytes = PDFConverter.convertToPNG(ossInputStream);
|
|
|
+ byte[] bytes = PDFConverter.convertToJPG(ossInputStream);
|
|
|
if (bytes != null) {
|
|
|
- BladeFile bladeFile = newIOSSClient.updateFile(bytes, SnowFlakeUtil.get() + ".png");
|
|
|
- if (ObjectUtil.isNotEmpty(bladeFile)) {
|
|
|
- jdbcTemplate.execute("update c_expense_financial_reimbursement_info set fr_electronic_invoice_url_png = '" + bladeFile.getLink() + "' where id = " + voCW.getId());
|
|
|
- voCW.setFrAttachmentUrl(bladeFile.getLink());
|
|
|
+ MultipartFile convert = ByteArrayToMultipartFileConverter.convert(bytes, SnowFlakeUtil.get() + ".jpg", "text/plain");
|
|
|
+ R<BladeFile> bladeFileR = iossClient.addFileInfo(convert);
|
|
|
+ if (ObjectUtil.isNotEmpty(bladeFileR) && ObjectUtil.isNotEmpty(bladeFileR.getData())) {
|
|
|
+ jdbcTemplate.execute("update c_expense_financial_reimbursement_info set fr_electronic_invoice_url_jpg = '" + bladeFileR.getData().getLink() + "' where id = " + voCW.getId());
|
|
|
+ voCW.setFrAttachmentUrl(bladeFileR.getData().getLink());
|
|
|
+ voCW.setFrAttachmentUrlJpg(bladeFileR.getData().getLink());
|
|
|
}
|
|
|
}
|
|
|
+ } else if (ObjectUtil.isNotEmpty(voCW.getFrAttachmentUrlJpg())) {
|
|
|
+ voCW.setFrAttachmentUrl(voCW.getFrAttachmentUrlJpg());
|
|
|
}
|
|
|
- if (ObjectUtil.isNotEmpty(voCW.getFrElectronicInvoiceUrl()) && ObjectUtil.isEmpty(voCW.getFrElectronicInvoiceUrlPng())) {
|
|
|
+ if (ObjectUtil.isNotEmpty(voCW.getFrElectronicInvoiceUrl()) && ObjectUtil.isEmpty(voCW.getFrElectronicInvoiceUrlJpg())) {
|
|
|
InputStream ossInputStream = CommonUtil.getOSSInputStream(voCW.getFrElectronicInvoiceUrl());
|
|
|
- byte[] bytes = PDFConverter.convertToPNG(ossInputStream);
|
|
|
+ byte[] bytes = PDFConverter.convertToJPG(ossInputStream);
|
|
|
if (bytes != null) {
|
|
|
- BladeFile bladeFile = newIOSSClient.updateFile(bytes, SnowFlakeUtil.get() + ".png");
|
|
|
- if (ObjectUtil.isNotEmpty(bladeFile)) {
|
|
|
- jdbcTemplate.execute("update c_expense_financial_reimbursement_info set fr_attachment_url_png = '" + bladeFile.getLink() + "' where id = " + voCW.getId());
|
|
|
- voCW.setFrElectronicInvoiceUrl(bladeFile.getLink());
|
|
|
+ MultipartFile convert = ByteArrayToMultipartFileConverter.convert(bytes, SnowFlakeUtil.get() + ".jpg", "text/plain");
|
|
|
+ R<BladeFile> bladeFileR = iossClient.addFileInfo(convert);
|
|
|
+ if (ObjectUtil.isNotEmpty(bladeFileR) && ObjectUtil.isNotEmpty(bladeFileR.getData())) {
|
|
|
+ jdbcTemplate.execute("update c_expense_financial_reimbursement_info set fr_attachment_url_jpg = '" + bladeFileR.getData().getLink() + "' where id = " + voCW.getId());
|
|
|
+ voCW.setFrElectronicInvoiceUrl(bladeFileR.getData().getLink());
|
|
|
+ voCW.setFrElectronicInvoiceUrlJpg(bladeFileR.getData().getLink());
|
|
|
}
|
|
|
}
|
|
|
- }*/
|
|
|
+ } else if (ObjectUtil.isNotEmpty(voCW.getFrElectronicInvoiceUrlJpg())) {
|
|
|
+ voCW.setFrElectronicInvoiceUrl(voCW.getFrElectronicInvoiceUrlJpg());
|
|
|
+ }
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(voCW.getProjectId()) && ObjectUtil.isNotEmpty(voCW.getBudgetPlanIds())) { //如果预算ids不为空,那么证明有关联计划任务(单关联)
|
|
|
TaskPlanInfoVO planTaskInfoList2 = this.getPlanTaskInfoList(voCW.getBudgetPlanIds(), controlProjectInfos);
|
|
@@ -1092,8 +1101,9 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
*
|
|
|
* @param type 任务类型
|
|
|
* @param taskProcessInfo 任务实体
|
|
|
+ * @param money 金额
|
|
|
*/
|
|
|
- public void buildTaskProcessInfoImpl(int type, TaskProcessInfo taskProcessInfo) {
|
|
|
+ public void buildTaskProcessInfoImpl(int type, TaskProcessInfo taskProcessInfo, BigDecimal money) {
|
|
|
taskProcessInfo.setId(SnowFlakeUtil.getId());
|
|
|
taskProcessInfo.setStatus(1); //待审批
|
|
|
taskProcessInfo.setReportDate(new Date());
|
|
@@ -1119,7 +1129,7 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
}
|
|
|
|
|
|
//获取审批人、抄送人信息
|
|
|
- Map<String, List<User>> approveUserMaps = this.getApproveUserMaps(type);
|
|
|
+ Map<String, List<User>> approveUserMaps = this.getApproveUserMaps(type, money);
|
|
|
|
|
|
//审批人
|
|
|
List<User> spUserList = approveUserMaps.getOrDefault("SP", null);
|
|
@@ -1191,7 +1201,7 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
*/
|
|
|
public User getDepartmentHead(Long deptId) {
|
|
|
if (ObjectUtil.isNotEmpty(deptId)) {
|
|
|
- List<User> leaderUser = jdbcTemplate.query("select * from blade_user where dept_id like '%" + deptId + "%' and is_leader like '%" + deptId + "%'", new BeanPropertyRowMapper<>(User.class));
|
|
|
+ List<User> leaderUser = jdbcTemplate.query("select * from blade_user where tenant_id = " + SecureUtil.getUser().getTenantId() + " and dept_id like '%" + deptId + "%' and is_leader like '%" + deptId + "%'", new BeanPropertyRowMapper<>(User.class));
|
|
|
if (leaderUser.size() == 1) {
|
|
|
return leaderUser.get(0);
|
|
|
}
|
|
@@ -1202,18 +1212,19 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
/**
|
|
|
* 根据审批类型获取审批人id信息(不包括部门负责人,单独处理)
|
|
|
*
|
|
|
- * @param type 数据类型
|
|
|
+ * @param type 数据类型
|
|
|
+ * @param money 报销金额
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, List<User>> getApproveUserMaps(int type) {
|
|
|
+ public Map<String, List<User>> getApproveUserMaps(int type, BigDecimal money) {
|
|
|
if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
|
}
|
|
|
//tenant_id = SecureUtil.getUser().getTenantId()(管控平台) dept_type = 3(最底层为岗位信息)
|
|
|
List<Dept> deptListControl = jdbcTemplate.query("select * from blade_dept where tenant_id = " + SecureUtil.getUser().getTenantId() + " and dept_type = 3", new BeanPropertyRowMapper<>(Dept.class));
|
|
|
Map<String, List<User>> resultMaps = new LinkedHashMap<>();
|
|
|
- List<String> spPostIds = new LinkedList<>();
|
|
|
- List<String> zcPostIds = new LinkedList<>();
|
|
|
+ Set<String> spPostIds = new LinkedHashSet<>();
|
|
|
+ Set<String> zcPostIds = new LinkedHashSet<>();
|
|
|
List<DictInfo> query = new ArrayList<>();
|
|
|
switch (type) {
|
|
|
case 2://财务报销
|
|
@@ -1252,10 +1263,23 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
List<TaskProcessRecordDictInfo> zcRoleInfos = dictInfoList.stream().filter(f -> f.getType().equals(2))
|
|
|
.sorted(Comparator.comparingInt(TaskProcessRecordDictInfo::getSort))
|
|
|
.collect(Collectors.toList());
|
|
|
+
|
|
|
+ String generalManagerUserId = ""; //总经理id
|
|
|
+
|
|
|
for (TaskProcessRecordDictInfo spRoleInfo : spRoleInfos) {
|
|
|
for (Dept dept : deptListControl) {
|
|
|
if (spRoleInfo.getRoleName().equals(dept.getDeptName())) {
|
|
|
spPostIds.add(dept.getId() + "");
|
|
|
+
|
|
|
+ if (dept.getDeptName().equals("总经理")) {
|
|
|
+ if (ObjectUtil.isEmpty(money)) {
|
|
|
+ money = new BigDecimal("0");
|
|
|
+ }
|
|
|
+ if (money.compareTo(new BigDecimal("1000")) < 0) {
|
|
|
+ //money小于1000,总经理不审批
|
|
|
+ generalManagerUserId = dept.getId() + "";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1266,13 +1290,25 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //money不超过1000移除总经理岗位
|
|
|
+ if (ObjectUtil.isNotEmpty(generalManagerUserId)) {
|
|
|
+ Iterator<String> iterator = spPostIds.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ String next = iterator.next();
|
|
|
+ if (next.equals(generalManagerUserId)) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (spPostIds.size() > 0) {
|
|
|
List<User> spUserListAll = new LinkedList<>();
|
|
|
for (String spPostId : spPostIds) {
|
|
|
- List<User> spUserList = jdbcTemplate.query("select * from blade_user where tenant_id = " + SecureUtil.getUser().getTenantId() + " and dept_id =" + spPostId, new BeanPropertyRowMapper<>(User.class));
|
|
|
+ List<User> spUserList = jdbcTemplate.query("select * from blade_user where tenant_id = " + SecureUtil.getUser().getTenantId() + " and role_id like '%" + spPostId + "%' and post_id like '%" + spPostId + "%'", new BeanPropertyRowMapper<>(User.class));
|
|
|
spUserListAll.addAll(spUserList);
|
|
|
}
|
|
|
if (spUserListAll.size() > 0) {
|
|
@@ -1280,9 +1316,13 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
}
|
|
|
}
|
|
|
if (zcPostIds.size() > 0) {
|
|
|
- List<User> zcUserList = jdbcTemplate.query("select * from blade_user where tenant_id = " + SecureUtil.getUser().getTenantId() + " and dept_id in(" + StringUtils.join(zcPostIds, ",") + ")", new BeanPropertyRowMapper<>(User.class));
|
|
|
- if (zcUserList.size() > 0) {
|
|
|
- resultMaps.put("ZC", zcUserList);
|
|
|
+ List<User> zcUserListAll = new LinkedList<>();
|
|
|
+ for (String zcPostId : zcPostIds) {
|
|
|
+ List<User> zcUserList = jdbcTemplate.query("select * from blade_user where tenant_id = " + SecureUtil.getUser().getTenantId() + " and role_id like '%" + zcPostId + "%' and post_id like '%" + zcPostId + "%'", new BeanPropertyRowMapper<>(User.class));
|
|
|
+ zcUserListAll.addAll(zcUserList);
|
|
|
+ }
|
|
|
+ if (zcUserListAll.size() > 0) {
|
|
|
+ resultMaps.put("ZC", zcUserListAll);
|
|
|
}
|
|
|
}
|
|
|
return resultMaps;
|