Jelajahi Sumber

权限控制

ljy121 1 tahun lalu
induk
melakukan
3f1fd73150

+ 23 - 0
zjugis-business/src/main/java/com/zjugis/business/bean/response/ButtonResp.java

@@ -0,0 +1,23 @@
+package com.zjugis.business.bean.response;
+
+import lombok.Data;
+
+import java.util.Map;
+
+/**
+ * @author ljy
+ * @version 1.0
+ * @date 2024/4/29 16:08
+ */
+@Data
+public class ButtonResp {
+
+    private boolean all;
+
+    private boolean xmLeader;
+
+    private boolean xsLeader;
+
+    private Map<String,Boolean> childButton;
+
+}

+ 5 - 0
zjugis-business/src/main/java/com/zjugis/business/controller/ProjectController.java

@@ -81,6 +81,11 @@ public class ProjectController{
         return CommonResult.success(this.projectService.addChild(project));
     }
 
+    @GetMapping("/project/info-button")
+    public CommonResult<ButtonResp> infoButton(@RequestParam String projectId) {
+        return CommonResult.success(this.projectService.infoButton(projectId));
+    }
+
     @GetMapping("/project/terminate")
     public CommonResult<String> terminate(@RequestParam("projectId") String projectId) {
         this.projectService.terminate(projectId);

+ 4 - 4
zjugis-business/src/main/java/com/zjugis/business/flow/contractinvoice/service/FlowContractInvoiceService.java

@@ -22,11 +22,9 @@ import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * @author ljy
@@ -94,6 +92,8 @@ public class FlowContractInvoiceService {
     private Map<String, Object>  createMap(ContractInvoice entity) {
         Map<String, Object> map = new HashMap<>();
         List<ContractReturnMoney> returnMoneyList = contractReturnMoneyService.selectByInoviceId(entity.getId());
+        BigDecimal totalReturn = returnMoneyList.stream().map(ContractReturnMoney::getReturnAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+        map.put("invoiceReceivable",entity.getInvoiceAmount().subtract(totalReturn));
         List<ContractInvoiceRelationDto> contractInvoiceRelations = contractInvoiceRelationService.selectByInvoiceId(entity.getId());
         map.put("returnMoneyListJson",JSON.toJSONString(returnMoneyList));
         map.put("contractListJson",JSON.toJSONString(contractInvoiceRelations));

+ 2 - 0
zjugis-business/src/main/java/com/zjugis/business/service/ProjectService.java

@@ -56,5 +56,7 @@ public interface ProjectService {
     ProjectTotalInfoResp totalInfo();
 
     List<String> selectAllIds();
+
+    ButtonResp infoButton(String projectId);
 }
 

+ 63 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/ProjectServiceImpl.java

@@ -20,10 +20,12 @@ import com.zjugis.business.service.ContractService;
 import com.zjugis.business.service.ProjectService;
 import com.zjugis.framework.common.exception.ServiceException;
 import com.zjugis.framework.common.pojo.CommonResult;
+import com.zjugis.framework.security.core.util.SecurityFrameworkUtils;
 import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
 import com.zjugis.module.system.api.dept.DeptApi;
 import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
 import com.zjugis.module.system.api.user.AdminUserApi;
+import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,11 +34,16 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import static com.zjugis.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static com.zjugis.module.system.enums.ErrorCodeConstants.AUTH_LOGIN_USER_UNLOGIN;
+
 /**
  * 项目表(Project)表服务实现类
  *
@@ -336,5 +343,61 @@ public class ProjectServiceImpl implements ProjectService {
     public List<String> selectAllIds() {
         return projectMapper.selectAllIds();
     }
+
+    /**
+     * @return
+     */
+    @Override
+    public ButtonResp infoButton(String projectId) {
+        String loginUserId = SecurityFrameworkUtils.getLoginUserId();
+        if(StringUtils.isBlank(loginUserId)){
+            throw exception(AUTH_LOGIN_USER_UNLOGIN);
+        }
+        ButtonResp buttonResp = new ButtonResp();
+        ProjectResponse project = selectWithChildren(projectId);
+        String deptId = project.getZrbmId();
+        boolean xsry = loginUserId.equals(project.getXsryId());
+        boolean xmLeader = loginUserId.equals(project.getXmjlId());
+        boolean deptLeader = false,leaderLeader = false,segLeader = false;
+        if (StringUtils.isNotBlank(deptId)) {
+            DeptRespDTO dept = deptApi.getDept(deptId).getCheckedData();
+            if (dept != null && StringUtils.isNotBlank(dept.getLeaderUserId())) {
+                deptLeader = loginUserId.equals(dept.getLeaderUserId());
+                CommonResult<AdminUserRespDTO> userLeader = adminUserApi.getUserLeader(dept.getLeaderUserId());
+                String leaderLeaderId = userLeader.getCheckedData().getId();
+                leaderLeader  = loginUserId.equals(leaderLeaderId);
+            }
+            DeptRespDTO secondDept = deptApi.getSecondDeptByDeptId(deptId).getCheckedData();
+            if (secondDept != null && StringUtils.isNotBlank(secondDept.getLeaderUserId())) {
+                segLeader  = loginUserId.equals(secondDept.getLeaderUserId());
+            }
+        }
+        if(leaderLeader || segLeader){
+            buttonResp.setAll(true);
+            return buttonResp;
+        }
+        if(xmLeader || deptLeader){
+            buttonResp.setXmLeader(true);
+        }
+        if(xsry || deptLeader){
+            buttonResp.setXsLeader(true);
+        }
+        List<ProjectResponse> children = project.getChildren();
+        Map<String,Boolean> childBtn = new HashMap<>();
+        for (ProjectResponse child : children) {
+            boolean show = false;
+            if(loginUserId.equals(child.getXmjlId())){
+                show = true;
+            } else if(StringUtils.isNotBlank(child.getZrbmId())){
+                DeptRespDTO dept = deptApi.getDept(child.getZrbmId()).getCheckedData();
+                if (dept != null && StringUtils.isNotBlank(dept.getLeaderUserId())) {
+                    show = loginUserId.equals(dept.getLeaderUserId());
+                }
+            }
+            childBtn.put(child.getId(),show);
+        }
+        buttonResp.setChildButton(childBtn);
+        return buttonResp;
+    }
 }
 

+ 10 - 2
zjugis-business/src/main/resources/mapper/oracle/ContractMilestoneMapper.xml

@@ -17,9 +17,17 @@
     </delete>
 
     <select id="list" resultType="com.zjugis.business.bean.entity.ContractMilestone">
-        select t.id,t.name,t.contract_id,t.sortnum,t1.return_amount,t.plan_return_time,t.actual_return_amount,t.description,t.is_remind_invoice,
+        select t.id,t.name,t.contract_id,t.sortnum,t.return_amount,t.plan_return_time,t1.returnAmount as actual_return_amount,t.description,t.is_remind_invoice,
                t.state from CONTRACT_MILESTONE t
-        LEFT JOIN (SELECT CONTRACT_MILESTONE_ID,COALESCE(sum(COALESCE(INVOICE_AMOUNT,0)),0) as return_amount FROM CONTRACT_INVOICE WHERE ISVALID = 1 AND FLOW_STATUS &gt;= 90 GROUP BY CONTRACT_MILESTONE_ID) t1 on t1.CONTRACT_MILESTONE_ID = t.ID
+        LEFT JOIN
+        (SELECT CI.CONTRACT_MILESTONE_ID,COALESCE(sum(R.returnAmount),0) as returnAmount
+         FROM CONTRACT_INVOICE CI
+            LEFT JOIN
+              (SELECT CONTRACT_INVOICE_ID, COALESCE(sum(COALESCE(RETURN_AMOUNT,0)),0) as returnAmount
+               FROM CONTRACT_RETURN_MONEY
+               WHERE ISVALID = 1 GROUP BY CONTRACT_INVOICE_ID) R on R.CONTRACT_INVOICE_ID = CI.ID
+         WHERE CI.ISVALID = 1 AND CI.FLOW_STATUS &gt;= 90 GROUP BY CI.CONTRACT_MILESTONE_ID) t1
+        on t1.CONTRACT_MILESTONE_ID = t.ID
         WHERE t.CONTRACT_ID = #{contractId,jdbcType=VARCHAR} AND t.ISVALID = 1
         ORDER BY t.SORTNUM,t.CREATE_TIME
     </select>

+ 8 - 0
zjugis-business/src/main/resources/templates/FlowContractInvoice/apply.ftl

@@ -743,6 +743,14 @@ styles=[ '/flow/css/formCommon.css', '/OwCommon/OwCommon.css' ]>
                       </div>
                   </div>
               </div>
+              <div name="returnStats" style="display: flex">
+                  <div style="width: 50%;" name="contractBalance">合同剩余回款金额:
+                      <span>${(amount.contractBalance)!}</span>
+                  </div>
+                  <div style="width: 50%;" name="invoiceReceivable">该开票剩余回款金额:
+                      <span>${invoiceReceivable!}</span>
+                  </div>
+              </div>
               <div class="qjsjxx-box" name="return-body">
                   <table class="form-table-info">
                       <thead>

+ 1 - 0
zjugis-module-system/zjugis-module-system-api/src/main/java/com/zjugis/module/system/enums/ErrorCodeConstants.java

@@ -16,6 +16,7 @@ public interface ErrorCodeConstants {
     ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1_002_000_005, "未绑定账号,需要进行绑定");
     ErrorCode AUTH_TOKEN_EXPIRED = new ErrorCode(1_002_000_006, "Token 已经过期");
     ErrorCode AUTH_MOBILE_NOT_EXISTS = new ErrorCode(1_002_000_007, "手机号不存在");
+    ErrorCode AUTH_LOGIN_USER_UNLOGIN = new ErrorCode(1_002_000_008, "用户未登录");
 
     // ========== 菜单模块 1-002-001-000 ==========
     ErrorCode MENU_NAME_DUPLICATE = new ErrorCode(1_002_001_000, "已经存在该名字的菜单");