|
|
@@ -0,0 +1,159 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package org.springblade.business.service.impl;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.business.entity.TaskProgress;
|
|
|
+import org.springblade.business.vo.TaskProgressVO;
|
|
|
+import org.springblade.business.mapper.TaskProgressMapper;
|
|
|
+import org.springblade.business.service.ITaskProgressService;
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.business.vo.TaskProgressVO1;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 任务进度表 服务实现类
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2025-10-15
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class TaskProgressServiceImpl extends BaseServiceImpl<TaskProgressMapper, TaskProgress> implements ITaskProgressService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<TaskProgressVO> selectTaskProgressPage(IPage<TaskProgressVO> page, TaskProgressVO taskProgress) {
|
|
|
+ return page.setRecords(baseMapper.selectTaskProgressPage(page, taskProgress));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, TaskProgressVO1> selectNewTaskProgress(Long projectId, Long contractId) {
|
|
|
+ Map<String, TaskProgressVO1> map = new HashMap<>();
|
|
|
+ TaskProgressVO vo1 = baseMapper.selectNewTaskProgress1(projectId, contractId,1);
|
|
|
+ if(vo1!=null){
|
|
|
+ BigDecimal result = (vo1.getTaskTotal() != null && vo1.getTaskTotal() > 0 && vo1.getFinishTatol() != null) ?
|
|
|
+ new BigDecimal(vo1.getFinishTatol())
|
|
|
+ .divide(new BigDecimal(vo1.getTaskTotal()), 2, RoundingMode.HALF_UP)
|
|
|
+ .multiply(new BigDecimal(100)) :
|
|
|
+ BigDecimal.ZERO;
|
|
|
+ map.put("save-again", new TaskProgressVO1(vo1.getFinishTatol(),vo1.getTaskTotal(),result));
|
|
|
+ }
|
|
|
+ TaskProgressVO vo2 = baseMapper.selectNewTaskProgress1(projectId, contractId,2);
|
|
|
+ if(vo2!=null){
|
|
|
+ Integer size=0;
|
|
|
+ if(StringUtils.isNotEmpty(vo2.getDataId())){
|
|
|
+ size=baseMapper.selectTaskBatchSize(Func.toLongList(vo2.getDataId()));
|
|
|
+ }
|
|
|
+ Integer finishTatol=vo2.getTaskTotal()-size;
|
|
|
+ // 使用 BigDecimal 进行精确计算并保留两位小数
|
|
|
+ BigDecimal result = vo2.getTaskTotal() > 0 ?
|
|
|
+ new BigDecimal(finishTatol).divide(new BigDecimal(vo2.getTaskTotal()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)) :
|
|
|
+ BigDecimal.ZERO;
|
|
|
+ result = result.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ map.put("re-sign", new TaskProgressVO1(finishTatol,vo2.getTaskTotal(),result));
|
|
|
+ if(size==0){
|
|
|
+ vo2.setIsDeleted(0);
|
|
|
+ baseMapper.updateById(vo2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TaskProgressVO vo3 = baseMapper.selectNewTaskProgress1(projectId, contractId,4);
|
|
|
+ if(vo3!=null){
|
|
|
+ Integer size=0;
|
|
|
+ if(StringUtils.isNotEmpty(vo3.getDataId())){
|
|
|
+ size=baseMapper.selectTaskBatchSize(Func.toLongList(vo3.getDataId()));
|
|
|
+ }
|
|
|
+ Integer finishTatol=vo3.getTaskTotal()-size;
|
|
|
+ // 使用 BigDecimal 进行精确计算并保留两位小数
|
|
|
+ BigDecimal result = vo3.getTaskTotal() > 0 ?
|
|
|
+ new BigDecimal(finishTatol).divide(new BigDecimal(vo3.getTaskTotal()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)) :
|
|
|
+ BigDecimal.ZERO;
|
|
|
+ result = result.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ map.put("electronic-sign", new TaskProgressVO1(finishTatol,vo3.getTaskTotal(),result));
|
|
|
+ if(size==0){
|
|
|
+ vo3.setIsDeleted(0);
|
|
|
+ baseMapper.updateById(vo3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 完成任务后更新进度
|
|
|
+ * @param projectId
|
|
|
+ * @param contractId
|
|
|
+ * @param type 1.sava_again 2.re_sign 3.电签检测 4.一键电签
|
|
|
+ * @param finishTotal
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean updateTaskProgress(Long projectId,Long contractId,Integer type,Integer finishTotal,String dataId) {
|
|
|
+ TaskProgressVO vo = baseMapper.selectNewTaskProgress(projectId, contractId,type);
|
|
|
+ if (vo==null) {
|
|
|
+ return false;
|
|
|
+ } else if (StringUtils.isNotEmpty(dataId)&&StringUtils.isNotEmpty(vo.getDataId())) {
|
|
|
+ if(!vo.getDataId().contains(dataId)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(vo.getIsFinish()!=1){
|
|
|
+ baseMapper.addFinishTotalById(vo.getId(),finishTotal);
|
|
|
+ baseMapper.checkAndUpdateIsFinish(vo.getId());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加任务进度
|
|
|
+ * @param projectId
|
|
|
+ * @param contractId
|
|
|
+ * @param type
|
|
|
+ * @param taskTotal
|
|
|
+ * @param dataIds
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean addTaskProgress(Long projectId,Long contractId,Integer type,Integer taskTotal,String dataIds) {
|
|
|
+ TaskProgressVO vo = baseMapper.selectNewTaskProgress(projectId, contractId,type);
|
|
|
+ if(vo==null){
|
|
|
+ TaskProgress progress = new TaskProgress();
|
|
|
+ progress.setId(SnowFlakeUtil.getId());
|
|
|
+ progress.setProjectId(projectId);
|
|
|
+ progress.setContractId(contractId);
|
|
|
+ progress.setType(type);
|
|
|
+ progress.setTaskTotal(taskTotal);
|
|
|
+ progress.setFinishTatol(0);
|
|
|
+ progress.setIsFinish(0);
|
|
|
+ if(StringUtils.isNotEmpty(dataIds)){
|
|
|
+ progress.setDataId(dataIds);
|
|
|
+ }
|
|
|
+ baseMapper.insert(progress);
|
|
|
+ }else {
|
|
|
+ vo.setTaskTotal(vo.getTaskTotal()+taskTotal);
|
|
|
+ if(StringUtils.isNotEmpty(dataIds)){
|
|
|
+ vo.setDataId(vo.getDataId()+","+dataIds);
|
|
|
+ }
|
|
|
+ baseMapper.updateById(vo);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|