Quellcode durchsuchen

Merge branch 'master' of http://47.100.3.209:3000/gdc/yiliangyiyun

gongdecai vor 2 Jahren
Ursprung
Commit
83b93e6579

+ 2 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/TranProcessInfo.java

@@ -325,6 +325,8 @@ public class TranProcessInfo extends BaseModel<TranProcessInfo> {
      */
     @TableField(exist = false)
     private String relatedContract;
+    @TableField(exist = false)
+    private String taskId;
 
     @Override
     protected Serializable pkVal() {

+ 7 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/CostManagementInfoServiceImpl.java

@@ -64,6 +64,13 @@ public class CostManagementInfoServiceImpl extends ServiceImpl<CostManagementInf
 //        List<CostManagementInfo> costManagementInfoList = this.selectList(costManagementInfoWrapper);
         Map<String, Object> pageView = new HashMap<>();
         pageView.put("compId",compId);
+        if(AuthSecurityUtils.getCurrentUserInfo() != null && AuthSecurityUtils.getCurrentUserInfo().getUserId() != null){
+            String userId = AuthSecurityUtils.getCurrentUserInfo().getUserId();
+            //洮南瀚城合营人员查看
+            if("647b84ee01044e2a8d4fdc1943ce3d01,23eff8bab2ed4af38a1be1315ce7046d,d958ef5aa62849039802356a63f6e7ca".contains(userId)){
+                pageView.put("jointVentureParties","洮南市二龙乡瀚城农产品有限公司");
+            }
+        }
         List<CostManagementInfo> costManagementInfoList = baseMapper.getListByCondition(pageView);
         return costManagementInfoList;
     }

+ 11 - 6
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ExpenseInfoServiceImpl.java

@@ -465,17 +465,22 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
             //保证金也属于粮款
             if ("5".equals(expenseInfo1.getCostType())) {
                 contractExpensesInfo.setGrainType("1");
-                //累加合同收回保证金
-                contractManagementInfo.setWithdrawalOfMargin(contractManagementInfo.getWithdrawalOfMargin() + expenseInfo1.getAmountMoney());
+                if (contractManagementInfo!=null) {
+                    //累加合同收回保证金
+                    contractManagementInfo.setWithdrawalOfMargin(contractManagementInfo.getWithdrawalOfMargin() + expenseInfo1.getAmountMoney());
+                    contractManagementInfoService.updateById(contractManagementInfo);
+                }
             }
             //粮款
             else if ("1".equals(expenseInfo1.getCostType())) {
-                //累加合同收回预付款
-                contractManagementInfo.setAccumulatedRecovery(contractManagementInfo.getAccumulatedRecovery() + expenseInfo1.getAmountMoney());
-            } else {
+                if (contractManagementInfo!=null) {
+                    //累加合同收回预付款
+                    contractManagementInfo.setAccumulatedRecovery(contractManagementInfo.getAccumulatedRecovery() + expenseInfo1.getAmountMoney());
+                    contractManagementInfoService.updateById(contractManagementInfo);
+                }
+            }else {
                 contractExpensesInfo.setGrainType(expenseInfo1.getCostType());
             }
-            contractManagementInfoService.updateById(contractManagementInfo);
             //合同费用
             if ("1".equals(expenseInfo1.getExpensesPurpose())) {
                 contractExpensesInfo.setContractId(expenseInfo1.getContractId());

+ 48 - 72
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/TranProcessInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.plugins.Page;
@@ -162,6 +163,13 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
     public TranProcessInfo getTranProcess(String id) {
         //查看运输信息
         TranProcessInfo tranProcessInfo = this.selectById(id);
+        String taskId = "";
+        // 只有待审核状态才有taskId
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(tranProcessInfo.getWorkflowId())) {
+            JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(tranProcessInfo.getWorkflowId()), tranProcessInfo.getId());
+            taskId = jsonObject.getString("taskId");
+            tranProcessInfo.setTaskId(taskId);
+        }
         TranTaskInfo tranTaskInfo=tranTaskInfoService.selectById(tranProcessInfo.getInfoId());
         ContractManagementInfo contractManagementInfo=contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
                 .eq("contract_no",tranProcessInfo.getContractNo())
@@ -909,44 +917,28 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
         //物流部提交
         if ("1".equals(tranProcessInfo.getFlag())) {
             tranProcessInfo.setPriceStatus("审核中");
-            List<String> roleIdList = Lists.newArrayList();
-            if("1".equals(tranProcessInfo.getTranTypeKey())){
-                roleIdList = roleResourceService.getBindRoleIdsByResourceIds(AuthSecurityUtils.getCurrentUserInfo().getCompId(),
-                        Lists.newArrayList("transportationInfo-Exe"));
-                tesk(tranProcessInfo,roleIdList);
-            }
-            else if("2".equals(tranProcessInfo.getTranTypeKey())){
-                roleIdList = roleResourceService.getBindRoleIdsByResourceIds(AuthSecurityUtils.getCurrentUserInfo().getCompId(),
-                        Lists.newArrayList("transportationInfo-Trian"));
-                tesk(tranProcessInfo,roleIdList);
-            }
-            else{
-                roleIdList = roleResourceService.getBindRoleIdsByResourceIds(AuthSecurityUtils.getCurrentUserInfo().getCompId(),
-                        Lists.newArrayList("transportationInfo-Ship"));
-                tesk(tranProcessInfo,roleIdList);
-            }
+            tranProcessInfo.setPriceStatusCar("审核中");
+            tranProcessInfo.setTranPriceCar(0.0f);
+            TranProcessInfo tranProcessInfo1=this.selectById(tranProcessInfo.getId());
+            TranTaskInfo tranTaskInfo=tranTaskInfoService.selectById(tranProcessInfo1.getInfoId());
+            boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(tranProcessInfo1.getWorkflowId());
+            // 不是退回的单子
+            if (isStartWorkflow) {
+                Workflow workflow = workflowService
+                        .findLatestWorkflowByBusinessCodeByApp(tranTaskInfo.getCompId(), "YUNJIA-TRAN-APPROVE");
+                // 没配置审核流程,直接结束并处理信息
+                if (workflow == null) {
+                    throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+                }
+                // 开启审核流
+                else {
 
-        }
-        //决策人审核
-        else if ("2".equals(tranProcessInfo.getFlag())) {
-            tranProcessInfo.setTranPrice(tranProcessInfo.getTranPriceIng());
-            tranProcessInfo.setTranPriceIng(0.0f);
-            tranProcessInfo.setPriceStatus("已通过");
-            //汽运生成审核记录
-            if(tranProcessInfo.getTranTypeKey()!=null&&"1".equals(tranProcessInfo.getTranTypeKey())) {
-                //生成审核记录
-                TranPriceApprove tranPriceApprove = new TranPriceApprove();
-                tranPriceApprove.setProcessId(tranProcessInfo.getId());
-                tranPriceApprove.setId(IdGenerator.generateUUID());
-                tranPriceApprove.setReviewer(tranProcessInfo.getReviewer());
-                tranPriceApprove.setResult("通过");
-                tranPriceApprove.setRecordType("1");
-                tranPriceApprove.setTranPrice(tranProcessInfo.getTranPrice());
-                tranPriceApproveService.insert(tranPriceApprove);
+                    // 设置状态 已提交审核
+                    tranProcessInfo1.setWorkflowId(workflow.getId());
+                    this.updateById(tranProcessInfo1);
+                    workflowService.startInstance(workflow.getId(), tranProcessInfo1.getId());
+                }
             }
-            // 先删除任务
-            noticeService.removeNotice(BaseNotice.NoticeStatus.TASK, "TRAN-TASK-APPROVE",
-                    tranProcessInfo.getId(), null);
         }
         this.updateById(tranProcessInfo);
         return "ok";
@@ -957,44 +949,28 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
         //物流部提交
         if ("1".equals(tranProcessInfo.getFlag())) {
             tranProcessInfo.setPriceStatusCar("审核中");
-            List<String> roleIdList = Lists.newArrayList();
-            if("1".equals(tranProcessInfo.getTranTypeKey())){
-                roleIdList = roleResourceService.getBindRoleIdsByResourceIds(AuthSecurityUtils.getCurrentUserInfo().getCompId(),
-                        Lists.newArrayList("transportationInfo-Execar"));
-                teskCar(tranProcessInfo,roleIdList);
-            }
-            else if("2".equals(tranProcessInfo.getTranTypeKey())){
-                roleIdList = roleResourceService.getBindRoleIdsByResourceIds(AuthSecurityUtils.getCurrentUserInfo().getCompId(),
-                        Lists.newArrayList("transportationInfo-Triancar"));
-                teskCar(tranProcessInfo,roleIdList);
-            }
-            else{
-                roleIdList = roleResourceService.getBindRoleIdsByResourceIds(AuthSecurityUtils.getCurrentUserInfo().getCompId(),
-                        Lists.newArrayList("transportationInfo-Shipcar"));
-                teskCar(tranProcessInfo,roleIdList);
-            }
+            tranProcessInfo.setPriceStatus("审核中");
+            tranProcessInfo.setTranPrice(0.0f);
+            TranProcessInfo tranProcessInfo1=this.selectById(tranProcessInfo.getId());
+            TranTaskInfo tranTaskInfo=tranTaskInfoService.selectById(tranProcessInfo1.getInfoId());
+            boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(tranProcessInfo1.getWorkflowId());
+            // 不是退回的单子
+            if (isStartWorkflow) {
+                Workflow workflow = workflowService
+                        .findLatestWorkflowByBusinessCodeByApp(tranTaskInfo.getCompId(), "YUNJIA-TRAN-APPROVE");
+                // 没配置审核流程,直接结束并处理信息
+                if (workflow == null) {
+                    throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+                }
+                // 开启审核流
+                else {
 
-        }
-        //决策人审核
-        else if ("2".equals(tranProcessInfo.getFlag())) {
-            tranProcessInfo.setTranPriceCar(tranProcessInfo.getTranPriceIngCar());
-            tranProcessInfo.setTranPriceIngCar(0.0f);
-            tranProcessInfo.setPriceStatusCar("已通过");
-            //汽运生成审核记录
-            if(tranProcessInfo.getTranTypeKey()!=null&&"1".equals(tranProcessInfo.getTranTypeKey())) {
-                //生成审核记录
-                TranPriceApprove tranPriceApprove = new TranPriceApprove();
-                tranPriceApprove.setProcessId(tranProcessInfo.getId());
-                tranPriceApprove.setId(IdGenerator.generateUUID());
-                tranPriceApprove.setReviewer(tranProcessInfo.getReviewer());
-                tranPriceApprove.setResult("通过");
-                tranPriceApprove.setRecordType("1");
-                tranPriceApprove.setTranPrice(tranProcessInfo.getTranPriceCar());
-                tranPriceApproveService.insert(tranPriceApprove);
+                    // 设置状态 已提交审核
+                    tranProcessInfo1.setWorkflowId(workflow.getId());
+                    this.updateById(tranProcessInfo1);
+                    workflowService.startInstance(workflow.getId(), tranProcessInfo1.getId());
+                }
             }
-            // 先删除任务
-            noticeService.removeNotice(BaseNotice.NoticeStatus.TASK, "TRAN-TEAM-APPROVE",
-                    tranProcessInfo.getId(), null);
         }
         this.updateById(tranProcessInfo);
         return "ok";

+ 27 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/workflow/TranProessListener.java

@@ -1,10 +1,12 @@
 package com.yh.saas.plugin.yiliangyiyun.workflow;
 
+import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.common.support.workflow.AbstractWorkflowTaskListener;
 import com.yh.saas.common.support.workflow.annotation.WorkflowTaskListener;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
+import com.yh.saas.plugin.yiliangyiyun.entity.TranPriceApprove;
 import com.yh.saas.plugin.yiliangyiyun.entity.TranProcessInfo;
-import com.yh.saas.plugin.yiliangyiyun.service.ITradeWarehouseReceiptApplService;
+import com.yh.saas.plugin.yiliangyiyun.service.ITranPriceApproveService;
 import com.yh.saas.plugin.yiliangyiyun.service.ITranProcessInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -15,6 +17,8 @@ public class TranProessListener extends AbstractWorkflowTaskListener {
 
     @Autowired
     private ITranProcessInfoService tranProcessInfoService;
+    @Autowired
+    private ITranPriceApproveService tranPriceApproveService;
 
     @Override
     public void handleStatusChanged(String businessKey, String status, String statusEn, boolean processIsEnd) {
@@ -27,6 +31,28 @@ public class TranProessListener extends AbstractWorkflowTaskListener {
             tranProcessInfo.setPriceStatusCar(StatusEnum.GRAIN_ADOPT.getName());
             tranProcessInfo.setWorkflowId(null);
             tranProcessInfo.setApproveStatus(null);
+            if ("2".equals(tranProcessInfo.getBillingMethod())) {
+                tranProcessInfo.setTranPriceCar(tranProcessInfo.getTranPriceIngCar());
+                tranProcessInfo.setTranPriceIngCar(0.0f);
+                tranProcessInfo.setTranPrice(0.0f);
+            }
+            else {
+                tranProcessInfo.setTranPrice(tranProcessInfo.getTranPriceIng());
+                tranProcessInfo.setTranPriceIng(0.0f);
+                tranProcessInfo.setTranPriceCar(0.0f);
+            }
+            //汽运生成审核记录
+            if(tranProcessInfo.getTranTypeKey()!=null&&"1".equals(tranProcessInfo.getTranTypeKey())) {
+                //生成审核记录
+                TranPriceApprove tranPriceApprove = new TranPriceApprove();
+                tranPriceApprove.setProcessId(tranProcessInfo.getId());
+                tranPriceApprove.setId(IdGenerator.generateUUID());
+                tranPriceApprove.setReviewer(tranProcessInfo.getReviewer());
+                tranPriceApprove.setResult("通过");
+                tranPriceApprove.setRecordType("1");
+                tranPriceApprove.setTranPrice(tranProcessInfo.getTranPrice() != 0 ? tranProcessInfo.getTranPrice() : tranProcessInfo.getTranPriceCar());
+                tranPriceApproveService.insert(tranPriceApprove);
+            }
         } else {
             tranProcessInfo.setApproveStatus(status);
         }

+ 24 - 12
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/CostManagementInfoMapper.xml

@@ -4,18 +4,30 @@
 
     <select id="getListByCondition" resultType="com.yh.saas.plugin.yiliangyiyun.entity.CostManagementInfo">
         SELECT
-            wo.warehouse_name as warehouseName,
-            wo.goods_name as goodsName,
-            SUM(wo.surplus_weight) as storage,
-            ROUND(AVG(wo.avg_cost),3 )as cost
+            wbi.warehouse_name AS warehouseName,
+            wpsi.goods_name AS goodsName,
+            wpsi.`storage` AS STORAGE,
+            ROUND(AVG(wo.avg_cost), 3) AS cost
         FROM
-            warehousing_order wo
-        left join warehouse_base_info wbi on wbi.warehouse_name = wo.warehouse_name and wbi.warehouse_type = 1
-        WHERE
-            wo.delete_flag = 0
-        AND wo.surplus_weight > 0
-        and wbi.delete_flag = 0
-        and wo.comp_id = #{compId}
-        GROUP BY wo.goods_name,wo.warehouse_name
+            warehouse_base_info wbi
+        LEFT JOIN warehousing_order wo ON wbi.warehouse_name = wo.warehouse_name
+        AND wo.delete_flag = 0
+        AND wbi.comp_id = wo.comp_id
+        LEFT JOIN warehouse_position_info wpi ON wpi.base_id = wbi.id
+        AND wpi.delete_flag = 0
+        LEFT JOIN warehouse_position_storage_info wpsi ON wpsi.position_id = wpi.id
+        AND wpsi.delete_flag = 0
+        AND wpsi.goods_name = wo.goods_name
+        WHERE 1=1
+        and wpsi.`storage` > 0
+        AND wbi.warehouse_type = 1
+        AND wbi.delete_flag = 0
+        AND wbi.comp_id =#{compId}
+        <if test="jointVentureParties != null">
+            AND wbi.joint_venture_parties = #{jointVentureParties}
+        </if>
+        GROUP BY
+            wpsi.goods_name,
+            wbi.warehouse_name
     </select>
 </mapper>