瀏覽代碼

判断用户当年各货名累计量,,查客户待结算数量

zhangyuewww 3 年之前
父節點
當前提交
3b0d6d6c2a

+ 9 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/PaymentManagementController.java

@@ -72,6 +72,15 @@ public class PaymentManagementController {
     public Float cumulant(PaymentManagement paymentManagement) {
         return paymentManagementService.cumulant(paymentManagement);
     }
+    /**
+     * 结算开启审核流
+     * @param paymentManagement
+     * @return
+     */
+    @PostMapping("/api/openAuditFlow")
+    public  String openAuditFlow(@RequestBody PaymentManagement paymentManagement){
+        return paymentManagementService.openAuditFlow(paymentManagement);
+    }
 
 }
 

+ 7 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/QualityInspectionManagementController.java

@@ -86,6 +86,13 @@ public class QualityInspectionManagementController {
     public String addQualityInspectionOut(@RequestBody QualityInspectionManagement qualityInspectionManagement) {
         return qualityInspectionManagementService.addQualityInspectionOut(qualityInspectionManagement);
     }
+    /**
+     * 查客户待结算数量
+     */
+    @GetMapping("/api/settledCount")
+    public Integer settledCount(QualityInspectionManagement qualityInspectionManagement){
+        return qualityInspectionManagementService.settledCount(qualityInspectionManagement);
+    }
 
 }
 

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

@@ -236,6 +236,11 @@ public class PaymentManagement extends BaseModel<PaymentManagement> {
     private WeighingManagement weighingManagement;
     @TableField(exist = false)
     private List<PaymentManagement> paymentManagementList;
+    /**
+     * 公司名
+     */
+    @TableField(exist = false)
+    private String compName;
 
 
     @Override

+ 6 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IPaymentManagementService.java

@@ -47,4 +47,10 @@ public interface IPaymentManagementService extends IService<PaymentManagement> {
      * @return
      */
     Float cumulant(PaymentManagement paymentManagement);
+    /**
+     * 结算开启审核流
+     * @param paymentManagement
+     * @return
+     */
+    String openAuditFlow(PaymentManagement paymentManagement);
 }

+ 5 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IQualityInspectionManagementService.java

@@ -53,4 +53,9 @@ public interface IQualityInspectionManagementService extends IService<QualityIns
      * @param qualityInspectionManagement
      */
     String addQualityInspectionOut(QualityInspectionManagement qualityInspectionManagement);
+    /**
+     * 查客户待结算的数量
+     * @param qualityInspectionManagement
+     */
+    Integer settledCount(QualityInspectionManagement qualityInspectionManagement);
 }

+ 56 - 31
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/PaymentManagementServiceImpl.java

@@ -5,7 +5,9 @@ import com.alipay.sofa.runtime.api.annotation.SofaReference;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.google.common.collect.Lists;
+import com.winsea.svc.base.base.entity.CommonCompany;
 import com.winsea.svc.base.base.entity.CommonRoleResource;
+import com.winsea.svc.base.base.service.ICommonCompanyService;
 import com.winsea.svc.base.base.service.ICommonRoleResourceService;
 import com.winsea.svc.base.security.entity.User;
 import com.winsea.svc.base.security.util.AuthSecurityUtils;
@@ -23,12 +25,11 @@ import com.yh.saas.plugin.yiliangyiyun.service.IWeighingManagementService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -50,6 +51,8 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
     private IQualityInspectionManagementService qualityInspectionManagementService;
     @Autowired
     private IWeighingManagementService weighingManagementService;
+    @Autowired
+    private ICommonCompanyService commonCompanyService;
 
     /**
      * 付款管理列表
@@ -117,6 +120,12 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
         //检斤信息
         WeighingManagement weighingManagement = weighingManagementService.selectOne(new EntityWrapper<WeighingManagement>()
                 .eq("relation_id", paymentManagement.getRelationId()));
+        CommonCompany commonCompany=commonCompanyService.selectOne(new EntityWrapper<CommonCompany>()
+                .eq("comp_id",qualityInspectionManagement.getCompId()));
+        //公司名
+        if (commonCompany!=null){
+            paymentManagement.setCompName(commonCompany.getCompName());
+        }
         paymentManagement.setQualityInspectionManagement(qualityInspectionManagement);
         paymentManagement.setWeighingManagement(weighingManagement);
         return paymentManagement;
@@ -128,32 +137,11 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
      * @return
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String editInfo(PaymentManagement paymentManagement) {
         PaymentManagement paymentManagement1=this.selectById(paymentManagement.getId());
+        this.openAuditFlow(paymentManagement1);
         this.updateById(paymentManagement);
-        boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(paymentManagement.getWorkflowId());
-        // 不是退回的单子
-        if (isStartWorkflow) {
-            Workflow workflow = workflowService
-                    .findLatestWorkflowByBusinessCodeByApp(paymentManagement1.getCompId(), "PAYMENT-MANAGEMENT-APPROVE");
-            // 没配置审核流程,直接结束并处理信息
-            if (workflow == null) {
-                throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
-            }
-            // 开启审核流
-            else {
-
-                // 设置状态 已提交审核
-                paymentManagement1.setWorkflowId(workflow.getId());
-                this.updateById(paymentManagement1);
-                workflowService.startInstance(workflow.getId(), paymentManagement1.getId());
-            }
-        }
-        // 退回的单子 再启用
-        else {
-            this.updateById(paymentManagement1);
-            workflowService.activateInstance(paymentManagement1.getWorkflowId(), paymentManagement1.getId());
-        }
         return "OK";
     }
 
@@ -224,20 +212,28 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
     @Override
     public Float cumulant(PaymentManagement paymentManagement) {
         Float cumulant=0.0f;
+        //本年第一天零点
+        SimpleDateFormat now = new SimpleDateFormat("yyyy-01-01 00:00:00");
+        Calendar c = Calendar.getInstance();
+        c.setTime(new Date());
+        c.add(Calendar.YEAR, 0);
+        Date y = c.getTime();
+        String year = now.format(y);
         List<PaymentManagement> paymentManagementList = this.selectList(new EntityWrapper<PaymentManagement>()
         .eq("goods_name",paymentManagement.getGoodsName())
         .eq("customer_name",paymentManagement.getCustomerName())
-        .eq("comp_id",paymentManagement.getCompId()));
+        .eq("comp_id",paymentManagement.getCompId())
+        .ge("create_date",year));
         if (!CollectionUtils.isEmpty(paymentManagementList)){
             Float netWeight = 0f;
             for (PaymentManagement paymentManagement1:paymentManagementList){
                 //干粮净重
                 if ("干粮".equals(paymentManagement1.getType())){
-                    netWeight=paymentManagement1.getNetWeight();
+                    netWeight=netWeight+(paymentManagement1.getNetWeight()!=null?paymentManagement1.getNetWeight():0f);
                 }
                 //潮粮纯重
-                else {
-                    netWeight=paymentManagement1.getPureWeight();
+                else if("潮粮".equals(paymentManagement1.getType())){
+                    netWeight=netWeight+(paymentManagement1.getPureWeight()!=null?paymentManagement1.getPureWeight():0f);
                 }
             }
             cumulant=cumulant+netWeight;
@@ -245,6 +241,35 @@ public class PaymentManagementServiceImpl extends ServiceImpl<PaymentManagementM
         return cumulant;
     }
 
+    @Override
+    public String openAuditFlow(PaymentManagement paymentManagement1) {
+        PaymentManagement paymentManagement = this.selectById(paymentManagement1.getId());
+        boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(paymentManagement.getWorkflowId());
+        // 不是退回的单子
+        if (isStartWorkflow) {
+            Workflow workflow = workflowService
+                    .findLatestWorkflowByBusinessCodeByApp(paymentManagement.getCompId(), "PAYMENT-MANAGEMENT-APPROVE");
+            // 没配置审核流程,直接结束并处理信息
+            if (workflow == null) {
+                throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+            }
+            // 开启审核流
+            else {
+
+                // 设置状态 已提交审核
+                paymentManagement.setWorkflowId(workflow.getId());
+                this.updateById(paymentManagement);
+                workflowService.startInstance(workflow.getId(), paymentManagement.getId());
+            }
+        }
+        // 退回的单子 再启用
+        else {
+            this.updateById(paymentManagement);
+            workflowService.activateInstance(paymentManagement.getWorkflowId(), paymentManagement.getId());
+        }
+        return "OK";
+    }
+
 
     private List<String> getResourceIdList() {
         User currentUser = AuthSecurityUtils.getCurrentUserInfo();

+ 18 - 8
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/QualityInspectionManagementServiceImpl.java

@@ -7,16 +7,10 @@ import com.winsea.svc.base.base.entity.CommonCompany;
 import com.winsea.svc.base.base.service.ICommonCompanyService;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
-import com.yh.saas.plugin.yiliangyiyun.entity.PurchasePrice;
-import com.yh.saas.plugin.yiliangyiyun.entity.QualityInspectionManagement;
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseBaseInfo;
-import com.yh.saas.plugin.yiliangyiyun.entity.WeighingManagement;
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
 import com.yh.saas.plugin.yiliangyiyun.mapper.QualityInspectionManagementMapper;
-import com.yh.saas.plugin.yiliangyiyun.service.IPurchasePriceService;
-import com.yh.saas.plugin.yiliangyiyun.service.IQualityInspectionManagementService;
+import com.yh.saas.plugin.yiliangyiyun.service.*;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
-import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseBaseInfoService;
-import com.yh.saas.plugin.yiliangyiyun.service.IWeighingManagementService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -42,6 +36,8 @@ public class QualityInspectionManagementServiceImpl extends ServiceImpl<QualityI
     private ICommonCompanyService commonCompanyService;
     @Autowired
     private IWarehouseBaseInfoService warehouseBaseInfoService;
+    @Autowired
+    private IPaymentManagementService paymentManagementService;
     /**
      * 质检管理列表
      * @param qualityInspectionManagement
@@ -196,4 +192,18 @@ public class QualityInspectionManagementServiceImpl extends ServiceImpl<QualityI
             return "NG";
         }
     }
+
+    /**
+     * 查客户待结算的数量
+     * @param qualityInspectionManagement
+     * @return
+     */
+    @Override
+    public Integer settledCount(QualityInspectionManagement qualityInspectionManagement) {
+        Integer count=paymentManagementService.selectCount(new EntityWrapper<PaymentManagement>()
+        .eq("comp_id",qualityInspectionManagement.getCompId())
+        .eq("customer_name",qualityInspectionManagement.getCustomerName())
+        .eq("status_flag","1"));
+        return count;
+    }
 }

+ 2 - 2
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WeighingManagementServiceImpl.java

@@ -158,12 +158,12 @@ public class WeighingManagementServiceImpl extends ServiceImpl<WeighingManagemen
                 PurchasePrice purchasePrice=purchasePriceService.selectOne(new EntityWrapper<PurchasePrice>()
                         .eq("warehouse_id",weighingManagement.getWarehouseId())
                 .eq("goods_name",weighingManagement.getGoodsName()));
-                Float pureWeight=weighingManagement1.getNetWeight()* (100-(Float.valueOf(qualityInspectionManagement1.getWaterContent())-purchasePrice.getWaterMin())*purchasePrice.getDeductWeight())/100;
+                Float pureWeight=weighingManagement.getNetWeight()* (100-(Float.valueOf(qualityInspectionManagement1.getWaterContent())-purchasePrice.getWaterMin())*purchasePrice.getDeductWeight())/100;
                 paymentManagement1.setPureWeight(pureWeight);
             }
             paymentManagement1.setStatus(StatusEnum.TO_BE_SETTLED.getName());
             paymentManagement1.setStatusFlag(StatusEnum.TO_BE_SETTLED.getFlag());
-            paymentManagement1.setNetWeight(weighingManagement1.getNetWeight());
+            paymentManagement1.setNetWeight(weighingManagement.getNetWeight());
             paymentManagement1.setWarehouseName(weighingManagement1.getWarehouseName());
             //质检信息
             QualityInspectionManagement qualityInspectionManagement = qualityInspectionManagementService.selectOne(new EntityWrapper<QualityInspectionManagement>()

+ 7 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/IdentityAuthenticationInfoMapper.xml

@@ -36,6 +36,8 @@
         <if test="authenticationStatusKey != null and authenticationStatusKey != ''">
             a.authentication_status_key=#{authenticationStatusKey}
         </if>
+        group by
+        a.id
         ORDER BY a.update_date DESC
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}
@@ -43,6 +45,9 @@
     </select>
     <!-- 获得客户总数 -->
     <select id="getIdentityCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        select
+        count(1)
+        from(
         SELECT
         COUNT(a.id)
         FROM identity_authentication_info a
@@ -62,5 +67,7 @@
         <if test="authenticationStatusKey != null and authenticationStatusKey != ''">
             a.authentication_status_key=#{authenticationStatusKey}
         </if>
+        group by
+        a.id) t
     </select>
 </mapper>

+ 1 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/WeighingManagementMapper.xml

@@ -34,6 +34,7 @@
         bin_number as binNumber,
         storage_number as storageNumber,
         secretary_weigher as secretaryWeigher,
+        skin_inspector as skinInspector,
         gross_date as grossDate,
         tare_date as tareDate,
         status,