Bläddra i källkod

20220916
合同管理-合同登记

sunruiqi 2 år sedan
förälder
incheckning
d02550b2e6

+ 11 - 10
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/workContract/controller/WorkContractController.java

@@ -53,15 +53,8 @@ public class WorkContractController {
     @ApiOperation(value = "合同登记新增/修改")
     @PostMapping(value = "save")
     public ResponseEntity<String> save(@RequestBody WorkContractInfoDto workContractInfoDto) throws Exception{
-        if (StringUtils.isEmpty(workContractInfoDto.getId())) {
-            //新增
-            String id = workContractService.add(workContractInfoDto);
-            return ResponseUtil.newInstance ( ).add("businessTable", "work_contract_info").add("businessId", id).ok ("操作成功");
-        }else {
-            //修改
-            String id = workContractService.update(workContractInfoDto);
-            return ResponseUtil.newInstance ( ).add("businessTable", "work_contract_info").add("businessId", id).ok ("操作成功");
-        }
+        String id = workContractService.saveInfo(workContractInfoDto);
+        return ResponseUtil.newInstance().add("businessTable", "work_contract_info").add("businessId", id).ok ("操作成功");
     }
 
     /**
@@ -74,7 +67,7 @@ public class WorkContractController {
     }
 
     /**
-     * 客户信息查询
+     * 合同登记查询
      */
     @ApiOperation(value = "合同登记查询")
     @GetMapping(value = "findById")
@@ -82,4 +75,12 @@ public class WorkContractController {
         return workContractService.findById(id);
     }
 
+    /**
+     * 根据id修改状态status
+     */
+    @ApiOperation(value = "根据id修改状态status")
+    @PostMapping(value = "updateStatusById")
+    public void updateStatusById(@RequestBody WorkContractInfoDto workContractInfoDto) {
+        workContractService.updateStatusById(workContractInfoDto);
+    }
 }

+ 12 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/workContract/mapper/WorkContractInfoMapper.java

@@ -5,13 +5,24 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.jeeplus.test.workClientInfo.domain.WorkClientInfo;
+import com.jeeplus.test.oss.domain.WorkAttachment;
 import com.jeeplus.test.workContract.domain.WorkContractInfo;
+import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface WorkContractInfoMapper extends BaseMapper<WorkContractInfo> {
 
     IPage<WorkContractInfo> findPageList(Page<WorkContractInfo> page, @Param(Constants.WRAPPER)QueryWrapper queryWrapper);
 
     WorkContractInfo findById (@Param("id") String id);
+
+    Integer findIsExit(@Param("id") String id, @Param("name")String name);
+
+    List<WorkAttachment> findList(@Param("id") String id);
+
+    List<WorkAttachmentDto> findDtos(@Param("id") String id);
+
+    void updateStatusById(@Param("id") String id, @Param("status")String status);
 }

+ 34 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/workContract/mapper/xml/WorkContractInfoMapper.xml

@@ -14,7 +14,7 @@
 			a.client_name,
 			a.`no`,
 			a.`name`,
-			a.contract_date,
+			DATE_FORMAT(a.contract_date,'%Y-%m-%d') as contract_date,
 			a.effective_date,
 			a.closing_date,
 			a.contract_type,
@@ -78,4 +78,37 @@
 			id = #{id}
 			AND del_flag = 0
 	</select>
+
+	<select id="findIsExit" resultType="java.lang.Integer">
+		SELECT
+			COUNT( 0 )
+		FROM
+			work_attachment
+		WHERE
+			del_flag = 0
+			AND attachment_id = #{id}
+			AND attachment_name = #{name}
+	</select>
+
+	<select id="findList" resultType="com.jeeplus.test.oss.domain.WorkAttachment">
+		SELECT * FROM work_attachment WHERE del_flag = 0 AND attachment_id = #{id}
+	</select>
+
+	<select id="findDtos" resultType="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto">
+		SELECT
+			id,
+			url,
+			attachment_name AS `name`,
+			create_by AS `by`,
+			create_date
+		FROM
+			work_attachment
+		WHERE
+			del_flag = 0
+			AND attachment_id = #{id}
+	</select>
+
+	<update id="updateStatusById">
+		UPDATE work_contract_info SET `status` = #{status} WHERE del_flag = 0 AND id = #{id}
+	</update>
 </mapper>

+ 117 - 26
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/workContract/service/WorkContractService.java

@@ -9,6 +9,7 @@ import com.jeeplus.test.workClientInfo.domain.WorkClientInfo;
 import com.jeeplus.test.workClientInfo.domain.dto.WorkClientInfosDto;
 import com.jeeplus.test.workClientInfo.mapper.WorkClientInfoMapper;
 import com.jeeplus.test.workClientInfo.service.WorkClientService;
+import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
 import net.sf.json.JSONObject;
 import org.flowable.editor.language.json.converter.util.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -26,9 +27,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 
 @Service
 public class WorkContractService {
@@ -40,13 +39,20 @@ public class WorkContractService {
     private OssServiceMapper ossServiceMapper;
 
     @Resource
-    private OssService ossService;
-
-    @Resource
     private SerialnumTplService serialnumTplService;
 
     private final String BIZ_CODE = "htdj";
 
+    public String saveInfo(WorkContractInfoDto workContractInfoDto) throws Exception {
+        if (StringUtils.isNotEmpty(workContractInfoDto.getId())) {
+            WorkContractInfo info = workContractInfoMapper.selectById(workContractInfoDto.getId());
+            if (info != null) {
+                return update(workContractInfoDto);
+            }
+        }
+        return add(workContractInfoDto);
+    }
+
     /**
      * 客户信息列表
      * @param
@@ -91,20 +97,9 @@ public class WorkContractService {
         info.setUpdateBy(userDTO.getId());
         info.setUpdateDate(new Date());
         workContractInfoMapper.insert(info);
-        List<WorkAttachment> list = workContractInfoDto.getWorkAttachmentList();
+        List<WorkAttachmentDto> list = workContractInfoDto.getWorkAttachmentList();
         if (CollectionUtils.isNotEmpty(list)) {
-            int j = 1;
-            for (WorkAttachment i : list) {
-                i.setId(UUID.randomUUID().toString().replace("-", ""));
-                i.setCreateBy(userDTO.getId());
-                i.setCreateDate(new Date());
-                i.setUpdateBy(userDTO.getId());
-                i.setUpdateDate(new Date());
-                i.setAttachmentId(id);
-                i.setSort(j);
-                ossServiceMapper.insert(i);
-                j++;
-            }
+            saveFiles(list, userDTO, id);
         }
         return id;
     }
@@ -124,10 +119,9 @@ public class WorkContractService {
         info.setUpdateBy(userDTO.getId());
         info.setUpdateDate(new Date());
         workContractInfoMapper.updateById(info);
-        List<WorkAttachment> list = workContractInfoDto.getWorkAttachmentList();
+        List<WorkAttachmentDto> list = workContractInfoDto.getWorkAttachmentList();
         if (CollectionUtils.isNotEmpty(list)) {
-            list.stream().forEach(i -> i.setAttachmentId(info.getId()));
-            ossService.saveMsg(list);
+            updateFiles(list, userDTO, workContractInfoDto.getId());
         }
         return workContractInfoDto.getId();
     }
@@ -152,10 +146,107 @@ public class WorkContractService {
         WorkContractInfo info = workContractInfoMapper.findById(id);
         BeanUtils.copyProperties(info, dto);
         // 查询附件信息
-        LambdaQueryWrapper<WorkAttachment> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(WorkAttachment::getAttachmentId, id);
-        wrapper.orderByAsc(WorkAttachment::getSort);
-        dto.setWorkAttachmentList(ossServiceMapper.selectList(wrapper));
+        List<WorkAttachmentDto> dtos = workContractInfoMapper.findDtos(id);
+        if (CollectionUtils.isNotEmpty(dtos)) {
+            for (WorkAttachmentDto i : dtos) {
+                i.setCreateBy(UserUtils.get(i.getBy()));
+            }
+        }
+        dto.setWorkAttachmentList(dtos);
         return dto;
     }
+
+    /**
+     * 根据id修改status
+     */
+    public void updateStatusById(WorkContractInfoDto workContractInfoDto) {
+        workContractInfoMapper.updateStatusById(workContractInfoDto.getId(), workContractInfoDto.getStatus());
+    }
+
+    /**
+     * 保存附件信息
+     * @param list 待保存的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void saveFiles(List<WorkAttachmentDto> list, UserDTO userDTO, String id) {
+        int j = 1;
+        for (WorkAttachmentDto dto : list) {
+            WorkAttachment i = new WorkAttachment();
+            //包含了url、size、name
+            i.setId(UUID.randomUUID().toString().replace("-", ""));
+            i.setCreateBy(userDTO.getId());
+            i.setCreateDate(new Date());
+            i.setUpdateBy(userDTO.getId());
+            i.setUpdateDate(new Date());
+            i.setDelFlag(0);
+            i.setUrl(dto.getUrl());
+            //文件类型处理
+            List<String> strings = Arrays.asList(dto.getName().split("\\."));
+            if (CollectionUtils.isNotEmpty(strings)) {
+                i.setType(strings.get(1));
+            }
+            i.setAttachmentId(id);
+            i.setAttachmentName(dto.getName());
+            i.setAttachmentFlag("workcontract");
+            i.setFileSize(dto.getSize());
+            i.setSort(j);
+            ossServiceMapper.insert(i);
+            j++;
+        }
+    }
+
+    /**
+     * 修改附件信息
+     * @param list 待修改的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateFiles(List<WorkAttachmentDto> list, UserDTO userDTO, String id) {
+        int j = 1;
+        String names = new String();
+        //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
+        for (WorkAttachmentDto dto : list) {
+            names = names + "," +dto.getUrl();
+        }
+        //查询保存的附件信息
+        List<WorkAttachment> infoList = workContractInfoMapper.findList(id);
+        if (CollectionUtils.isNotEmpty(infoList)) {
+            for (WorkAttachment i : infoList) {
+                if (!names.contains(i.getUrl())) {
+                    ossServiceMapper.deleteById(i.getId());
+                }
+            }
+        }
+        //保存信息
+        for (WorkAttachmentDto dto : list) {
+            //判断是否存在
+            Integer isExit = workContractInfoMapper.findIsExit(id, dto.getName());
+            if (isExit == 0) {
+                WorkAttachment i = new WorkAttachment();
+                //包含了url、size、name
+                i.setId(UUID.randomUUID().toString().replace("-", ""));
+                i.setCreateBy(userDTO.getId());
+                i.setCreateDate(new Date());
+                i.setUpdateBy(userDTO.getId());
+                i.setUpdateDate(new Date());
+                i.setDelFlag(0);
+                i.setUrl(dto.getUrl());
+                //文件类型处理
+                List<String> strings = Arrays.asList(dto.getName().split("\\."));
+                if (CollectionUtils.isNotEmpty(strings)) {
+                    i.setType(strings.get(1));
+                }
+                i.setAttachmentId(id);
+                i.setAttachmentName(dto.getName());
+                i.setAttachmentFlag("workcontract");
+                i.setFileSize(dto.getSize());
+                i.setSort(j);
+                ossServiceMapper.insert(i);
+                j++;
+            }
+        }
+    }
 }

+ 20 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/workContract/service/dto/WorkAttachmentDto.java

@@ -0,0 +1,20 @@
+package com.jeeplus.test.workContract.service.dto;
+
+import com.jeeplus.core.service.dto.BaseDTO;
+import com.jeeplus.sys.service.dto.UserDTO;
+import lombok.Data;
+
+@Data
+public class WorkAttachmentDto extends BaseDTO {
+
+    private String name;
+
+    private String size;
+
+    private String url;
+
+    private UserDTO createBy;
+
+    private String by;
+
+}

+ 6 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/workContract/service/dto/WorkContractInfoDto.java

@@ -85,8 +85,13 @@ public class WorkContractInfoDto extends BaseDTO {
     private String remarks;
 
     /**
+     * 状态
+     */
+    private String status;
+
+    /**
      * 附件信息
      */
-    private List<WorkAttachment> workAttachmentList;
+    private List<WorkAttachmentDto> workAttachmentList;
 
 }

+ 22 - 19
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/FlowTaskService.java

@@ -686,27 +686,30 @@ public class FlowTaskService {
      */
     public List<Flow> getBackNodes(String taskId) {
         Task taskEntity = taskService.createTaskQuery ().taskId (taskId).singleResult ();
-        String processInstanceId = taskEntity.getProcessInstanceId ();
-        String currActId = taskEntity.getTaskDefinitionKey ();
-        String processDefinitionId = taskEntity.getProcessDefinitionId ();
-        Process process = repositoryService.getBpmnModel (processDefinitionId).getMainProcess ();
-        FlowNode currentFlowElement = (FlowNode) process.getFlowElement (currActId, true);
-        List<ActivityInstance> activitys =
-                runtimeService.createActivityInstanceQuery ().processInstanceId (processInstanceId).finished ().orderByActivityInstanceStartTime ().asc ().list ();
-        List<String> activityIds =
-                activitys.stream ().filter (activity -> activity.getActivityType ().equals (BpmnXMLConstants.ELEMENT_TASK_USER) || activity.getActivityType ().equals (BpmnXMLConstants.ELEMENT_EVENT_START)).filter (activity -> !activity.getActivityId ().equals (currActId)).map (ActivityInstance::getActivityId).distinct ().collect (Collectors.toList ());
-        List<Flow> result = new ArrayList<> ();
-        for (String activityId : activityIds) {
-            FlowNode toBackFlowElement = (FlowNode) process.getFlowElement (activityId, true);
-            if (FlowableUtils.isReachable (process, toBackFlowElement, currentFlowElement)) {
-                Flow vo = new Flow ();
-                vo.setTaskDefKey (activityId);
-                vo.setTaskName (toBackFlowElement.getName ());
-                vo.setTaskId (activityId);
-                result.add (vo);
+        if (taskEntity != null) {
+            String processInstanceId = taskEntity.getProcessInstanceId();
+            String currActId = taskEntity.getTaskDefinitionKey();
+            String processDefinitionId = taskEntity.getProcessDefinitionId();
+            Process process = repositoryService.getBpmnModel(processDefinitionId).getMainProcess();
+            FlowNode currentFlowElement = (FlowNode) process.getFlowElement(currActId, true);
+            List<ActivityInstance> activitys =
+                    runtimeService.createActivityInstanceQuery().processInstanceId(processInstanceId).finished().orderByActivityInstanceStartTime().asc().list();
+            List<String> activityIds =
+                    activitys.stream().filter(activity -> activity.getActivityType().equals(BpmnXMLConstants.ELEMENT_TASK_USER) || activity.getActivityType().equals(BpmnXMLConstants.ELEMENT_EVENT_START)).filter(activity -> !activity.getActivityId().equals(currActId)).map(ActivityInstance::getActivityId).distinct().collect(Collectors.toList());
+            List<Flow> result = new ArrayList<>();
+            for (String activityId : activityIds) {
+                FlowNode toBackFlowElement = (FlowNode) process.getFlowElement(activityId, true);
+                if (FlowableUtils.isReachable(process, toBackFlowElement, currentFlowElement)) {
+                    Flow vo = new Flow();
+                    vo.setTaskDefKey(activityId);
+                    vo.setTaskName(toBackFlowElement.getName());
+                    vo.setTaskId(activityId);
+                    result.add(vo);
+                }
             }
+            return result;
         }
-        return result;
+        return null;
     }
 
     public void addSignTask(String taskId, List<String> userIds, String comment, Boolean flag) throws Exception {