huangjn 2 лет назад
Родитель
Сommit
bf7d9a9b71

+ 8 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/ContractLogClient.java

@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.util.List;
+
 @FeignClient(value =
         BusinessConstant.APPLICATION_WEATHER_NAME
 )
@@ -16,6 +18,12 @@ public interface ContractLogClient {
 
     String API_PREFIX = "/contractLog";
 
+    @PostMapping(API_PREFIX + "/removeContractLogWbsByTheLogId")
+    void removeContractLogWbsByTheLogId(@RequestParam String theLogId);
+
+    @PostMapping(API_PREFIX + "/queryContractLogWbsByTheLogId")
+    List<JSONObject> queryContractLogWbsByTheLogId(@RequestParam String theLogId);
+
     @PostMapping(API_PREFIX + "/updateTheLogPdfUrl")
     void updateTheLogPdfUrl(@RequestParam String theLogId, @RequestParam String pdfUrl);
 

+ 53 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/ContractLogController.java

@@ -1,5 +1,6 @@
 package org.springblade.business.controller;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -17,12 +18,18 @@ import org.springblade.business.feign.MessageWarningClient;
 import org.springblade.business.feign.OperationLogClient;
 import org.springblade.business.feign.TaskClient;
 import org.springblade.business.service.IContractLogWbsService;
+import org.springblade.business.utils.FileUtils;
 import org.springblade.business.vo.*;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.feign.WbsTreeContractClient;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springblade.system.cache.ParamCache;
 import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springblade.business.service.IContractLogService;
@@ -30,6 +37,7 @@ import org.springblade.core.boot.ctrl.BladeController;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -57,6 +65,49 @@ public class ContractLogController extends BladeController {
 
 	private final MessageWarningClient messageWarningClient;
 
+	private final NewIOSSClient newIOSSClient;
+
+
+
+	/**
+	 * 预览、打印
+	 */
+	@PostMapping("/theLogPreviewAndPrint")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "预览、打印")
+	@ApiImplicitParam(name = "json", value = "key为 ids数组,ids的数据为勾选的列表数据id集合")
+	public R<String> theLogPreviewAndPrint(@RequestBody JSONObject json){
+		//获取配置的路径
+		String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+
+		if(json.containsKey("ids")){
+			//id集合
+			List<String> ids = JSONArray.parseArray(JSONObject.toJSONString(json.getJSONArray("ids")), String.class);
+			//查询具体数据
+			List<ContractLog> logList = this.contractLogService.list(Wrappers.<ContractLog>lambdaQuery().in(ContractLog::getId, ids));
+			//获取pdf路径
+			List<String> pdfUrls = logList.stream().map(log -> StringUtils.isNotEmpty(log.getEVisaPdfUrl()) ? log.getEVisaPdfUrl() : log.getPdfUrl()).distinct().collect(Collectors.toList());
+
+			//删除空数据
+			pdfUrls.removeIf(StringUtils::isEmpty);
+
+			if(pdfUrls.size() > 0){
+				//合并的pdf路径
+				String fileName = SnowFlakeUtil.getId() + "-" + new Date().getTime() + ".pdf";
+				String mergePdfPath = file_path + "/pdf//" + fileName;
+				FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
+
+				//上传
+				BladeFile file = this.newIOSSClient.uploadFile(fileName, mergePdfPath);
+				if(file != null){
+					return R.data(file.getLink());
+				}
+			}
+
+		}
+		return R.fail("未找到数据");
+	}
+
 	/**
 	 * 获取当前日志资料关联的工序节点信息
 	 */
@@ -104,8 +155,8 @@ public class ContractLogController extends BladeController {
 	@PostMapping("/getSubmitLogDateList")
 	@ApiOperationSupport(order = 6)
 	@ApiOperation(value = "获取合同段当前日志节点下的填报日期记录")
-	public R<List<String>> getSubmitLogDateList(@RequestParam String contractId, @RequestParam String primaryKeyId){
-		return R.data(this.contractLogService.getSubmitLogDateList(contractId, primaryKeyId));
+	public R<List<String>> getSubmitLogDateList(@RequestParam String contractId, @RequestParam String primaryKeyId, @RequestParam String year){
+		return R.data(this.contractLogService.getSubmitLogDateList(contractId, primaryKeyId, year));
 	}
 
 	/**

+ 26 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/ContractLogClientImpl.java

@@ -29,6 +29,32 @@ public class ContractLogClientImpl implements ContractLogClient {
 
     private final IContractLogWbsService contractLogWbsService;
 
+    @Override
+    public void removeContractLogWbsByTheLogId(String theLogId) {
+        try{
+            this.contractLogWbsService.update(Wrappers.<ContractLogWbs>lambdaUpdate().set(ContractLogWbs::getIsDeleted, 1).eq(ContractLogWbs::getContractLogId, theLogId));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public List<JSONObject> queryContractLogWbsByTheLogId(String theLogId) {
+        List<JSONObject> wbsJsonList = new ArrayList<>();
+        List<ContractLogWbs> wbsList = this.contractLogWbsService.list(Wrappers.<ContractLogWbs>lambdaQuery().eq(ContractLogWbs::getContractLogId, theLogId));
+        if(wbsList != null && wbsList.size() > 0){
+            for(ContractLogWbs logWbs : wbsList){
+                JSONObject json = new JSONObject();
+                json.put("primaryKeyId", logWbs.getTreePrimaryKeyId());
+                json.put("path", logWbs.getTitle());
+
+                wbsJsonList.add(json);
+            }
+        }
+
+        return wbsJsonList;
+    }
+
     @Override
     public void updateTheLogPdfUrl(String theLogId, String pdfUrl) {
         this.contractLogService.update(Wrappers.<ContractLog>lambdaUpdate().set(ContractLog::getPdfUrl, pdfUrl).eq(ContractLog::getId, theLogId));

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ContractLogMapper.java

@@ -31,7 +31,7 @@ import java.util.List;
  */
 public interface ContractLogMapper extends BaseMapper<ContractLog> {
 
-	List<String> getSubmitLogDateList(@Param("contractId") String contractId, @Param("primaryKeyId") String primaryKeyId);
+	List<String> getSubmitLogDateList(@Param("contractId") String contractId, @Param("primaryKeyId") String primaryKeyId, @Param("year") String year);
 
 	List<ContractLog> queryFillUser(@Param("vo") ContractLogVO vo);
 

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ContractLogMapper.xml

@@ -28,7 +28,7 @@
     </resultMap>
 
     <select id="getSubmitLogDateList" resultType="java.lang.String">
-        select record_time from u_contract_log where is_deleted = 0 and wbs_node_id = #{primaryKeyId} and contract_id = #{contractId} group by record_time order by record_time DESC
+        select record_time from u_contract_log where is_deleted = 0 and wbs_node_id = #{primaryKeyId} and contract_id = #{contractId} and record_time like concat('%',#{year},'%') group by record_time order by record_time DESC
     </select>
 
     <select id="queryFillUser" resultMap="contractLogResultMap">

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/IContractLogService.java

@@ -34,7 +34,7 @@ public interface IContractLogService extends BaseService<ContractLog> {
 
 	List<FileUserVO> queryFillUser(ContractLogVO logVO);
 
-	List<String> getSubmitLogDateList(String contractId, String primaryKeyId);
+	List<String> getSubmitLogDateList(String contractId, String primaryKeyId, String year);
 
 	/**
 	 * 施工日志分页

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ContractLogServiceImpl.java

@@ -42,8 +42,8 @@ import java.util.List;
 public class ContractLogServiceImpl extends BaseServiceImpl<ContractLogMapper, ContractLog> implements IContractLogService {
 
 	@Override
-	public List<String> getSubmitLogDateList(String contractId, String primaryKeyId) {
-		return this.baseMapper.getSubmitLogDateList(contractId, primaryKeyId);
+	public List<String> getSubmitLogDateList(String contractId, String primaryKeyId, String year) {
+		return this.baseMapper.getSubmitLogDateList(contractId, primaryKeyId, year);
 	}
 
 	@Override

+ 107 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -28,6 +28,7 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springblade.business.feign.ContractLogClient;
+import org.springblade.business.vo.SaveContractLogVO;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.MathUtil;
@@ -1766,7 +1767,7 @@ public class ExcelTabController extends BladeController {
             }
 
             //获取数据
-            List<Map<String, Object>> businessDataMapList = (List<Map<String, Object>>)this.getTheLogBusinessData(theLogId, nodePrimaryKeyId, recordTime).getData();
+            List<Map<String, Object>> businessDataMapList = this.getTheLogBusinessData(theLogId, nodePrimaryKeyId, recordTime).getData();
             //PDF路径
             List<String> pdfUrls = new ArrayList<>();
 
@@ -1872,6 +1873,7 @@ public class ExcelTabController extends BladeController {
                                 int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
 
                                 final CellRange cellRange = sheet.getCellRange(y1, x1);
+
                                 cellRange.setText(e.getId() + "");
                                 cellRange.getCellStyle().getFont().setColor(Color.white);
 
@@ -1919,11 +1921,18 @@ public class ExcelTabController extends BladeController {
         return R.data(null);
     }
 
+    /**
+     * 获取当前用户当前日期的填报记录
+     */
     @GetMapping("/get-the-log-business-data")
     @ApiOperationSupport(order = 26)
     @ApiOperation(value = "获取当前用户当前日期的填报记录")
-    @ApiImplicitParam(name = "theLogId", value = "日志ID", required = true)
-    public R getTheLogBusinessData(String theLogId, String nodePrimaryKeyId, String recordTime) {
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "theLogId", value = "日志记录的id,可能为空"),
+            @ApiImplicitParam(name = "nodePrimaryKeyId", value = "当前操作的日志类型ID,即左侧列表的节点primaryKeyId"),
+            @ApiImplicitParam(name = "recordTime", value = "当前选择的填写日期,即右侧日期控件所选日期,格式为 yyyy-MM-dd")
+    })
+    public R<List<Map<String, Object>>> getTheLogBusinessData(String theLogId, String nodePrimaryKeyId, String recordTime) {
         List<Map<String, Object>> resultMapList = new ArrayList<>();
         //获取对应的记录
         JSONObject theLogJson;
@@ -2011,4 +2020,99 @@ public class ExcelTabController extends BladeController {
         return R.data(resultMapList);
     }
 
+    /**
+     * 复制指定日期的日志填报数据
+     */
+    @GetMapping("/copy-the-log-business-data")
+    @ApiOperationSupport(order = 27)
+    @ApiOperation(value = "复制指定日期的日志填报数据")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "nodePrimaryKeyId", value = "当前操作的日志类型ID,即左侧列表的节点primaryKeyId"),
+            @ApiImplicitParam(name = "currentTime", value = "当前选择的填写日期,即右侧日期控件所选日期,格式为 yyyy-MM-dd"),
+            @ApiImplicitParam(name = "targetTime", value = "需要复制的目标日期")
+    })
+    public R<List<Map<String, Object>>> copyTheLogBusinessData(@RequestParam String nodePrimaryKeyId, @RequestParam String currentTime, @RequestParam String targetTime){
+        if(StringUtils.isNotEmpty(nodePrimaryKeyId) && StringUtils.isNotEmpty(currentTime) && StringUtils.isNotEmpty(targetTime)){
+            //获取目标的数据
+            JSONObject targetJson = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTime(nodePrimaryKeyId, targetTime);
+            if(targetJson == null){
+                return R.fail("目标日期下未找到当前用户填报的数据,请重新选择");
+            }
+            //查询是否存在关联工序的数据
+            List<JSONObject> wbsJsonList = this.contractLogClient.queryContractLogWbsByTheLogId(targetJson.getString("id"));
+
+            //获取目标数据所在数据表
+            WbsTreePrivate table = this.wbsTreePrivateService.getById(targetJson.getString("tableId"));
+
+            //获取目标数据
+            String queryTargetDataSql = "SELECT * FROM " + table.getInitTableName() + " WHERE group_id = " + targetJson.getString("dataId");
+            List<Map<String, Object>> targetDatas = this.jdbcTemplate.queryForList(queryTargetDataSql);
+
+            //检查当前日期下是否存在数据
+            JSONObject currentJson = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTime(nodePrimaryKeyId, currentTime);
+            String businessId = SnowFlakeUtil.getId().toString();
+            boolean isNew = true;
+            if(currentJson != null){
+                //有记录,需要删除掉原本记录填写的数据
+                String removeOldSql = "DELETE FROM " + table.getInitTableName() + " WHERE group_id = " + currentJson.getString("dataId");
+                this.jdbcTemplate.execute(removeOldSql);
+
+                //删除掉原本关联的工序节点
+                this.contractLogClient.removeContractLogWbsByTheLogId(currentJson.getString("id"));
+
+                //使用原本的数据ID
+                businessId = currentJson.getString("dataId");
+                isNew = false;
+            }
+            //新增的SQL集合
+            List<String> insertSqlList = new ArrayList<>();
+
+            //只需要替换group_id和id即可
+            for(Map<String, Object> dataMap : targetDatas){
+                StringBuilder insertSql = new StringBuilder("INSERT INTO " + table.getInitTableName()), keySql = new StringBuilder(), valueSql = new StringBuilder();
+                for(Map.Entry<String, Object> mapEntry : dataMap.entrySet()){
+                    String key = mapEntry.getKey();
+                    Object value = mapEntry.getValue();
+
+                    if("id".equals(key)){
+                        value = SnowFlakeUtil.getId();
+                    } else if("group_id".equals(key)){
+                        value = businessId;
+                    }
+                    //设置参数
+                    keySql.append(",").append(key);
+                    valueSql.append(",").append("'").append(value).append("'");
+                }
+                //组装SQL
+                insertSql.append(" (").append(keySql.toString().substring(1)).append(") ");
+                insertSql.append(" VALUES(").append(valueSql.toString().substring(1)).append(")");
+
+                insertSqlList.add(insertSql.toString());
+            }
+
+            if(insertSqlList.size() > 0){
+                //新增数据
+                for(String insertSql : insertSqlList){
+                    this.jdbcTemplate.execute(insertSql);
+                }
+            }
+            //处理数据
+            this.contractLogClient.saveContractLog(new SaveContractLogVO(
+                    Long.parseLong(businessId),
+                    targetJson.getString("projectId"),
+                    targetJson.getString("contractId"),
+                    Long.parseLong(targetJson.getString("wbsNodeId")),
+                    Long.parseLong(targetJson.getString("tableId")),
+                    Integer.parseInt(targetJson.getString("wbsNodeType")),
+                    currentTime,
+                    wbsJsonList
+            ));
+
+            //返回当前的新数据
+            return this.getTheLogBusinessData(!isNew  ? currentJson.getString("id") : null, nodePrimaryKeyId, currentTime);
+        }
+
+        return null;
+    }
+
 }