zxz 2 年之前
父节点
当前提交
4b2d9597e0

+ 17 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/ExpenseInfoController.java

@@ -83,6 +83,13 @@ public class ExpenseInfoController {
     public String editInfo(@RequestBody ExpenseInfo expenseInfo) {
         return expenseInfoService.editInfo(expenseInfo);
     }
+    /**
+     * 财务点击修改任务状态
+     */
+    @PostMapping("/editCollectionStatus")
+    public String editCollectionStatus(@RequestBody ExpenseInfo expenseInfo) {
+        return expenseInfoService.editCollectionStatus(expenseInfo);
+    }
     /**
      * 上传附件
      */
@@ -183,7 +190,16 @@ public class ExpenseInfoController {
     public Page<ExpenseInfo> selectBondInfo(ExpenseInfo expenseInfo) {
         return expenseInfoService.selectBondInfo(expenseInfo);
     }
-
+    /**
+     * 备用金列表查询
+     *
+     * @param expenseInfo
+     * @return
+     */
+    @GetMapping("/selectPettyCashInfo")
+    public Page<ExpenseInfo> selectPettyCashInfo(ExpenseInfo expenseInfo) {
+        return expenseInfoService.selectPettyCashInfo(expenseInfo);
+    }
     /**
      * 燃料款列表请款记录列表
      *

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

@@ -1,10 +1,17 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.PettyCashInfo;
+import com.yh.saas.plugin.yiliangyiyun.service.IPettyCashInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * <p>
  * 记录备用金账户信息 前端控制器
@@ -16,6 +23,25 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/pettyCashInfo")
 public class PettyCashInfoController {
-
+    @Autowired private IPettyCashInfoService pettyCashInfoService;
+    /**
+     * 备用金账户列表查询
+     *
+     * @param pettyCashInfo
+     * @return
+     */
+    @GetMapping("/selectPettyAccountInfo")
+    public Page<PettyCashInfo> selectPettyAccountInfo(PettyCashInfo pettyCashInfo) {
+        return pettyCashInfoService.selectPettyAccountInfo(pettyCashInfo);
+    }
+    /**
+     * 备用金账户下拉列表
+     *
+     * @return
+     */
+    @GetMapping("/getPettyAccountList")
+    public List<PettyCashInfo> getPettyAccountList(String compId) {
+        return pettyCashInfoService.getPettyAccountList(compId);
+    }
 }
 

+ 15 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/ExpenseInfoMapper.java

@@ -53,7 +53,6 @@ public interface ExpenseInfoMapper extends BaseMapper<ExpenseInfo> {
      * @return
      */
     Integer getBondCountByCondition(Map<String, Object> pageView);
-
     /**
      * 根据条件查询保证金列表
      *
@@ -62,6 +61,21 @@ public interface ExpenseInfoMapper extends BaseMapper<ExpenseInfo> {
      */
     List<ExpenseInfo> getBondListByCondition(Map<String, Object> pageView);
 
+    /**
+     * 根据条件查询备用金列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<ExpenseInfo> getPettyCashListByCondition(Map<String, Object> pageView);
+    /**
+     * 根据条件查询备用金总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getPettyCashCountByCondition(Map<String, Object> pageView);
+
     /**
      * 根据条件查询请款记录总数
      *

+ 17 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/PettyCashInfoMapper.java

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.PettyCashInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录备用金账户信息 Mapper 接口
@@ -12,5 +15,18 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  * @since 2023-02-15
  */
 public interface PettyCashInfoMapper extends BaseMapper<PettyCashInfo> {
-
+    /**
+     * 根据条件查询备用金列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<PettyCashInfo> getPettyAccountListByCondition(Map<String, Object> pageView);
+    /**
+     * 根据条件查询备用金总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getPettyAccountCountByCondition(Map<String, Object> pageView);
 }

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

@@ -61,6 +61,12 @@ public interface IExpenseInfoService extends IService<ExpenseInfo> {
      * @param expenseInfo
      */
     String editInfo(ExpenseInfo expenseInfo);
+    /**
+     * 财务点击修改任务状态
+     *
+     * @param expenseInfo
+     */
+    String editCollectionStatus(ExpenseInfo expenseInfo);
     /**
      * 上传附件
      *
@@ -133,6 +139,13 @@ public interface IExpenseInfoService extends IService<ExpenseInfo> {
      * @return
      */
     Page<ExpenseInfo> selectBondInfo(ExpenseInfo expenseInfo);
+    /**
+     * 备用金列表列表查询
+     *
+     * @param expenseInfo
+     * @return
+     */
+    Page<ExpenseInfo> selectPettyCashInfo(ExpenseInfo expenseInfo);
 
     /**
      * 燃料款列表请款记录列表

+ 16 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IPettyCashInfoService.java

@@ -1,8 +1,11 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.PettyCashInfo;
 import com.baomidou.mybatisplus.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 记录备用金账户信息 服务类
@@ -12,5 +15,17 @@ import com.baomidou.mybatisplus.service.IService;
  * @since 2023-02-15
  */
 public interface IPettyCashInfoService extends IService<PettyCashInfo> {
-
+    /**
+     * 备用金账户列表查询
+     *
+     * @param pettyCashInfo
+     * @return
+     */
+    Page<PettyCashInfo> selectPettyAccountInfo(PettyCashInfo pettyCashInfo);
+    /**
+     * 备用金账户下拉列表
+     * @param compId
+     * @return
+     */
+    List<PettyCashInfo> getPettyAccountList(String compId);
 }

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

@@ -11,10 +11,12 @@ import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.google.common.collect.Lists;
 import com.winsea.svc.base.base.entity.CommonDepartment;
+import com.winsea.svc.base.base.entity.CommonRole;
 import com.winsea.svc.base.base.entity.CommonRoleResource;
 import com.winsea.svc.base.base.entity.CommonStaff;
 import com.winsea.svc.base.base.service.ICommonDepartmentService;
 import com.winsea.svc.base.base.service.ICommonRoleResourceService;
+import com.winsea.svc.base.base.service.ICommonRoleService;
 import com.winsea.svc.base.base.service.ICommonStaffService;
 import com.winsea.svc.base.base.util.DateUtils;
 import com.winsea.svc.base.security.entity.User;
@@ -110,6 +112,10 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
     private ICommonDepartmentService commonDepartmentService;
     @Autowired
     private ICommonUserService commonUserService;
+    @Autowired
+    private ICommonRoleService commonRoleService;
+    @Autowired
+    private IPettyCashInfoService pettyCashInfoService;
     @Value("${file-root-path}")
     private String localPath;
     @Autowired
@@ -137,7 +143,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
 //            return listRedis;
 //        }
         if (expenseInfo.getCompId() == null || expenseInfo.getCompId().isEmpty()) {
-            expenseInfo.setCompId(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId());
+                expenseInfo.setCompId(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId());
         }
         //查询所有费用集合
         List<ExpenseInfo> expenseInfoList = this.selectList(new EntityWrapper<ExpenseInfo>().eq("delete_flag", "0").eq("comp_id", expenseInfo.getCompId()).groupBy("agent"));
@@ -330,7 +336,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         //费用分配列表 查看不显示已驳回和分配已完成的数据
         List<ExpenseAllocationInfo> expenseAllocationInfos = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
                 .eq("info_id", id)
-                .ne("status", "已驳回")
+                .ne("status", "已驳回").or()
                 .ne("complete_flag","1"));
         if (!CollectionUtils.isEmpty(expenseAllocationInfos)) {
             expenseInfo.setExpenseAllocationInfoList(expenseAllocationInfos);
@@ -433,6 +439,22 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         if ("1".equals(expenseInfo.getExpensesType())) {
             expenseInfo.setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
             expenseInfo.setStatus(StatusEnum.TO_BE_CONFIRMED.getName());
+            //收款类型为备用金
+            if("7".equals(expenseInfo.getExpensesPurpose())){
+                //查询当前账户备用金余额
+                PettyCashInfo pettyCashInfo = pettyCashInfoService.selectOne(new EntityWrapper<PettyCashInfo>()
+                        .eq("common_id",AuthSecurityUtils.getCurrentUserId())
+                        .eq("delete_flag","0")
+                        .eq("comp_id",AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId())
+                        .eq("user_name",AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getStaffName()));
+                if(pettyCashInfo != null){
+                    //收款金额大于备用金账户余额
+                    if(expenseInfo.getAmountMoney().compareTo(pettyCashInfo.getAmountMoney()) > 0 ){
+                        //备用金账户余额不足
+                        throw new YException(YExceptionEnum.PETTY_ACCOUNT_ERROR);
+                    }
+                }
+            }
             this.insert(expenseInfo);
             String staffName = this.billOperateHisService.getStaffAndName();
             // 插入操作历史
@@ -441,10 +463,15 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         }
         //支出
         else {
-            expenseInfo.setStatusFlag(StatusEnum.COST_PAYMENT.getFlag());
-            expenseInfo.setStatus(StatusEnum.COST_PAYMENT.getName());
+            if("1".equals(expenseInfo.getNoPaymentFlag())){
+                expenseInfo.setStatusFlag(StatusEnum.NO_PAYMENT.getFlag());
+                expenseInfo.setStatus(StatusEnum.NO_PAYMENT.getName());
+            }else{
+                expenseInfo.setStatusFlag(StatusEnum.COST_PAYMENT.getFlag());
+                expenseInfo.setStatus(StatusEnum.COST_PAYMENT.getName());
+            }
             //合同非粮款和库点费用自动分配的情况,未分配金额默认等于费用金额
-            if (("3".equals(expenseInfo.getCostType()) && "1".equals(expenseInfo.getExpensesPurpose())) || ("3".equals(expenseInfo.getExpensesPurpose()) && !"1".equals(expenseInfo.getAutoAssign())) || "7".equals(expenseInfo.getExpensesPurpose())) {
+            if (("3".equals(expenseInfo.getCostType()) && "1".equals(expenseInfo.getExpensesPurpose())) || ("3".equals(expenseInfo.getExpensesPurpose()) && !"1".equals(expenseInfo.getAutoAssign())) || "7".equals(expenseInfo.getExpensesPurpose())|| ("7".equals(expenseInfo.getCostType()) && "1".equals(expenseInfo.getExpensesPurpose()))) {
                 expenseInfo.setUnallocatedAmount(expenseInfo.getAmountMoney());
             }
             //合同粮款校验
@@ -491,6 +518,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
                     expenseAllocationInfoList.get(i).setInfoId(expenseInfo.getId());
                     expenseAllocationInfoList.get(i).setStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
                     expenseAllocationInfoList.get(i).setStatus(StatusEnum.TO_BE_CONFIRMED.getName());
+                    expenseAllocationInfoList.get(i).setCompleteFlag("0");
                     Double distributionMoney = 0d;
                     List<ExpenseAllocationInfo> expenseAllocationInfoList1 = expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
                             .eq("order_id", expenseAllocationInfoList.get(i).getOrderId())
@@ -556,6 +584,28 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         return "ok";
     }
 
+    /**
+     * 财务点击修改任务状态
+     * @param expenseInfo
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public String editCollectionStatus(ExpenseInfo expenseInfo) {
+        List<NoticeTaskInfo> noticeTaskInfoList = noticeTaskService.selectList(new EntityWrapper<NoticeTaskInfo>()
+            .eq("business_id",expenseInfo.getId())
+            .eq("vessel_id","点击切换任务状态")
+            .eq("business_code","FEIYONGGUANLI-APPROVE"));
+        if(!CollectionUtils.isEmpty(noticeTaskInfoList)){
+            for(int i = 0;i<noticeTaskInfoList.size();i++){
+                noticeTaskInfoList.get(i).setDeleteFlag("1");
+            }
+        }
+        noticeTaskService.updateBatchById(noticeTaskInfoList);
+        expenseInfo.setNoticeTaskInfoList(noticeTaskInfoList);
+        return "OK";
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String editInfo(ExpenseInfo expenseInfo) {
@@ -607,26 +657,49 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
                 contractExpensesInfo.setWarehouseName(expenseInfo1.getWarehouseName());
                 contractExpensesInfo.setCostType("3");
             }
+            //备用金
+            else if("7".equals(expenseInfo1.getExpensesPurpose())){
+                //查询当前账户备用金余额
+                PettyCashInfo pettyCashInfo = pettyCashInfoService.selectOne(new EntityWrapper<PettyCashInfo>()
+                        .eq("common_id",expenseInfo1.getCreateUserId())
+                        .eq("delete_flag","0")
+                        .eq("comp_id",expenseInfo1.getCompId())
+                        .eq("user_name",expenseInfo1.getAgent()));
+                if(pettyCashInfo != null){
+                    pettyCashInfo.setAmountMoney(pettyCashInfo.getAmountMoney() - expenseInfo1.getAmountMoney());
+                    pettyCashInfoService.updateById(pettyCashInfo);
+                    expenseInfo1.setPettyRelationId(pettyCashInfo.getPettyRelationId());
+                    expenseInfo1.setPettyShowFlag("1");
+                    this.updateById(expenseInfo1);
+                }
+            }
             contractExpensesInfoService.insert(contractExpensesInfo);
             // 插入操作历史
             String staffName = this.billOperateHisService.getStaffAndName();
             // 插入操作历史
             this.billOperateHisService.saveBillOperateHis(expenseInfo.getId(), NumberConstant.EXPENSE_MANAGEMENT, staffName, null,
                     "确认", null, expenseInfo1.getRemark());
+
+
+            // 先删除任务
+            noticeService.removeNotice(BaseNotice.NoticeStatus.TASK, "FEIYONGGUANLI-APPROVE",
+                    expenseInfo1.getId(), null);
+            CommonStaff commitUserInfo = staffService.getInfo(AuthSecurityUtils.getCurrentUserId());
+            String taskContent = "";
+            if("1".equals(expenseInfo1.getIdentification())){
+                taskContent = expenseInfo1.getFieldName() + "收取" + expenseInfo1.getExpenseName() + expenseInfo1.getAmountMoney() + "元";
+            }else{
+                taskContent = expenseInfo1.getAgent() + "收取" + expenseInfo1.getExpenseName() + expenseInfo1.getAmountMoney() + "元";
+            }
+            NoticeTaskInfo taskInfo = new NoticeTaskInfo();
+            taskInfo.setCompId(commitUserInfo.getCompId());
+            taskInfo.setAcceptType(BaseNotice.AcceptStatus.STAFF);
+            taskInfo.setBusinessId(expenseInfo1.getId());
+            taskInfo.setBusinessType("WAREHOUSE");
+            taskInfo.setMessageContent(taskContent);
+            taskInfo.setBusinessCode("FEIYONGGUANLI-APPROVE");
             //外勤提交的请款出纳确认时需要给内勤发通知
             if ("1".equals(expenseInfo1.getIdentification())) {
-                // 先删除任务
-                noticeService.removeNotice(BaseNotice.NoticeStatus.TASK, "FEIYONGGUANLI-APPROVE",
-                        expenseInfo1.getId(), null);
-                CommonStaff commitUserInfo = staffService.getInfo(AuthSecurityUtils.getCurrentUserId());
-                String taskContent = expenseInfo1.getFieldName() + "收取" + expenseInfo1.getExpenseName() + expenseInfo1.getAmountMoney() + "元";
-                NoticeTaskInfo taskInfo = new NoticeTaskInfo();
-                taskInfo.setCompId(commitUserInfo.getCompId());
-                taskInfo.setAcceptType(BaseNotice.AcceptStatus.STAFF);
-                taskInfo.setBusinessId(expenseInfo1.getId());
-                taskInfo.setBusinessType("WAREHOUSE");
-                taskInfo.setMessageContent(taskContent);
-                taskInfo.setBusinessCode("FEIYONGGUANLI-APPROVE");
                 //查询内勤
                 List<CommonStaff> commonStaffList = staffService.selectList(new EntityWrapper<CommonStaff>()
                         .eq("dept_id", "7a0b63a0f07a4fc38136b10e8514d8de")
@@ -635,6 +708,19 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
                 noticeTaskService.createNoticeTask(staffIds,
                         null, taskInfo);
             }
+            //确认收款时给财务发通知
+            CommonRole commonRole = commonRoleService.selectOne(new EntityWrapper<CommonRole>()
+                    .eq("comp_id", commitUserInfo.getCompId())
+                    .eq("role_name", "财务")
+                    .eq("delete_flag", "0"));
+            if (commonRole != null) {
+                //查询财务
+                List<CommonStaff> commonStaffList = staffService.selectList(new EntityWrapper<CommonStaff>()
+                        .eq("dept_id", commonRole.getDeptId())
+                        .eq("delete_flag", "0"));
+                List<String> staffIds = commonStaffList.stream().map(CommonStaff::getStaffId).collect(Collectors.toList());
+                noticeTaskService.createNoticeTask(staffIds, "点击切换任务状态", taskInfo);
+            }
         }
         //完成收款
         else if ("1".equals(expenseInfo.getFlag())) {
@@ -1024,6 +1110,27 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         expenseInfo.setStatusFlag(StatusEnum.COST_PAID.getFlag());
         expenseInfo.setStatus(StatusEnum.COST_PAID.getName());
         expenseInfo.setPaymentDate(new Date());
+        //备用金支付标识为1
+        if ("1".equals(expenseInfo.getPaymentIdentifi())) {
+            CommonStaff commonStaff = staffService.selectOne(new EntityWrapper<CommonStaff>()
+                    .eq("staff_name", expenseInfo.getPettyName())
+                    .eq("comp_id", expenseInfo.getCompId()));
+            if (commonStaff != null) {
+                //查询所选账户备用金余额
+                PettyCashInfo pettyCashInfo = pettyCashInfoService.selectOne(new EntityWrapper<PettyCashInfo>()
+                        .eq("common_id", commonStaff.getStaffId())
+                        .eq("delete_flag", "0")
+                        .eq("comp_id", commonStaff.getCompId())
+                        .eq("user_name", expenseInfo.getPettyName()));
+                if (pettyCashInfo != null) {
+                    pettyCashInfo.setAmountMoney(pettyCashInfo.getAmountMoney() - expenseInfo.getAmountMoney());
+                    pettyCashInfoService.updateById(pettyCashInfo);
+                    expenseInfo.setPettyRelationId(pettyCashInfo.getPettyRelationId());
+                    expenseInfo.setPettyShowFlag("1");
+                    this.updateById(expenseInfo);
+                }
+            }
+        }
         this.updateById(expenseInfo);
         ExpenseInfo expenseInfo1 = this.selectById(expenseInfo.getId());
         //合同费用
@@ -1112,6 +1219,47 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
             expenseInfo1.setStatus(StatusEnum.COMPLETED.getName());
             this.updateById(expenseInfo1);
         }
+        //备用金
+        else if("7".equals(expenseInfo1.getExpensesPurpose())){
+            //查询该账户是否有备用金
+            PettyCashInfo pettyCashInfo = pettyCashInfoService.selectOne(new EntityWrapper<PettyCashInfo>()
+                    .eq("common_id",expenseInfo1.getCreateUserId())
+                    .eq("delete_flag","0"));
+            //为空新增
+            if (pettyCashInfo == null) {
+                PettyCashInfo pettyCashInfo1 = new PettyCashInfo();
+                pettyCashInfo1.setId(IdGenerator.generateUUID());
+                pettyCashInfo1.setCommonId(expenseInfo1.getCreateUserId());
+                pettyCashInfo1.setCompId(expenseInfo1.getCompId());
+                pettyCashInfo1.setPettyRelationId(IdGenerator.generateUUID());
+                expenseInfo1.setPettyRelationId(pettyCashInfo1.getPettyRelationId());
+                pettyCashInfo1.setAmountMoney(expenseInfo1.getAmountMoney());
+                //查询用户表
+                CommonStaff commonStaff = staffService.selectOne(new EntityWrapper<CommonStaff>()
+                        .eq("staff_id",expenseInfo1.getCreateUserId())
+                        .eq("delete_flag","0"));
+                if(commonStaff != null){
+                    pettyCashInfo1.setUserName(commonStaff.getStaffName());
+                    pettyCashInfo1.setDeptId(commonStaff.getDeptId());
+                }
+                //查询部门表
+                CommonDepartment commonDepartment = commonDepartmentService.selectOne(new EntityWrapper<CommonDepartment>()
+                        .eq("dept_id",commonStaff.getDeptId())
+                        .eq("delete_flag","0"));
+                if(commonDepartment != null){
+                    pettyCashInfo1.setDeptName(commonDepartment.getDeptName());
+                }
+                pettyCashInfoService.insert(pettyCashInfo1);
+            }
+            //不为空,编辑
+            else{
+                //更新备用金帐户余额
+                pettyCashInfo.setAmountMoney(pettyCashInfo.getAmountMoney() + expenseInfo1.getAmountMoney());
+                pettyCashInfoService.updateById(pettyCashInfo);
+                expenseInfo1.setPettyRelationId(pettyCashInfo.getPettyRelationId());
+            }
+            this.updateById(expenseInfo1);
+        }
         // 插入操作历史
         String staffName = this.billOperateHisService.getStaffAndName();
         // 插入操作历史
@@ -1599,31 +1747,51 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         return page;
     }
 
-//    /**
-//     * 备用金列表查询
-//     * @param expenseInfo
-//     * @return
-//     */
-//    @Override
-//    public Page<ExpenseInfo> selectPettyCashInfo(ExpenseInfo expenseInfo) {
-//        Map<String, Object> pageView = new HashMap<>();
-//        pageView.put("startRecord", (expenseInfo.getCurrentPage() - 1)
-//                * expenseInfo.getPageSize());
-//        pageView.put("searchKeyWord", expenseInfo.getSearchKeyWord());
-//        pageView.put("searchType", expenseInfo.getSearchType());
-//        pageView.put("pageSize", expenseInfo.getPageSize());
-//        pageView.put("currentPage", expenseInfo.getCurrentPage());
-//        pageView.put("contractNo", expenseInfo.getContractNo());
-//        // 查询总数
-//        Integer dataCount = baseMapper.getBondCountByCondition(pageView);
-//        List<ExpenseInfo> dataList = baseMapper.getBondListByCondition(pageView);
-//        Page<ExpenseInfo> page = new Page<>();
-//        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
-//        page.setTotal(dataCount == null ? 0 : dataCount);
-//        page.setCurrent(expenseInfo.getCurrentPage());
-//        page.setSize(expenseInfo.getPageSize());
-//        return page;
-//    }
+    /**
+     * 备用金列表查询
+     * @param expenseInfo
+     * @return
+     */
+    @Override
+    public Page<ExpenseInfo> selectPettyCashInfo(ExpenseInfo expenseInfo) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (expenseInfo.getCurrentPage() - 1)
+                * expenseInfo.getPageSize());
+        pageView.put("searchKeyWord", expenseInfo.getSearchKeyWord());
+        pageView.put("compId", expenseInfo.getCompId());
+        pageView.put("startDate", expenseInfo.getStartDate());
+        pageView.put("endDate", expenseInfo.getEndDate());
+        pageView.put("pageSize", expenseInfo.getPageSize());
+        pageView.put("currentPage", expenseInfo.getCurrentPage());
+        if (!StringUtils.isEmpty(expenseInfo.getAgent())) {
+            String str = expenseInfo.getAgent();
+            boolean str1 = str.contains(",");
+            if (str1) {
+                List<String> agentList = Arrays.asList(str.split(","));
+                pageView.put("agentList", agentList);
+            } else {
+                pageView.put("agent", expenseInfo.getAgent());
+            }
+        }
+        // 查询总数
+        Integer dataCount = baseMapper.getPettyCashCountByCondition(pageView);
+        List<ExpenseInfo> dataList = baseMapper.getPettyCashListByCondition(pageView);
+        if (!CollectionUtils.isEmpty(dataList)) {
+            dataList.forEach(expenseInfo1 -> {
+                if (expenseInfo1.getCreateUserId() != null) {
+                    CommonStaff commonStaff = staffService.getInfo(expenseInfo1.getCreateUserId());
+                    expenseInfo1.setCreater(commonStaff.getStaffName());
+                }
+            });
+
+        }
+        Page<ExpenseInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(expenseInfo.getCurrentPage());
+        page.setSize(expenseInfo.getPageSize());
+        return page;
+    }
     /**
      * 燃料款列表请款记录列表
      * @param expenseInfo

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

@@ -1,10 +1,26 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
+import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
+import com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.PettyCashInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.SearchRecordsInfo;
+import com.yh.saas.plugin.yiliangyiyun.exception.YException;
+import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
 import com.yh.saas.plugin.yiliangyiyun.mapper.PettyCashInfoMapper;
+import com.yh.saas.plugin.yiliangyiyun.service.IExpenseInfoService;
 import com.yh.saas.plugin.yiliangyiyun.service.IPettyCashInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -17,4 +33,66 @@ import org.springframework.stereotype.Service;
 @Service
 public class PettyCashInfoServiceImpl extends ServiceImpl<PettyCashInfoMapper, PettyCashInfo> implements IPettyCashInfoService {
 
+    @Autowired
+    private IExpenseInfoService expenseInfoService;
+
+    /**
+     * 备用金账户列表查询
+     *
+     * @param pettyCashInfo
+     * @return
+     */
+    @Override
+    public Page<PettyCashInfo> selectPettyAccountInfo(PettyCashInfo pettyCashInfo) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (pettyCashInfo.getCurrentPage() - 1)
+                * pettyCashInfo.getPageSize());
+        pageView.put("searchKeyWord", pettyCashInfo.getSearchKeyWord());
+        pageView.put("compId", pettyCashInfo.getCompId());
+        pageView.put("searchType", pettyCashInfo.getSearchType());
+        pageView.put("pageSize", pettyCashInfo.getPageSize());
+        pageView.put("currentPage", pettyCashInfo.getCurrentPage());
+        // 查询总数
+        Integer dataCount = baseMapper.getPettyAccountCountByCondition(pageView);
+        List<PettyCashInfo> dataList = baseMapper.getPettyAccountListByCondition(pageView);
+        if (!CollectionUtils.isEmpty(dataList)) {
+            dataList.forEach(pettyCashInfo1 -> {
+                //查询关联的费用列表
+                List<ExpenseInfo> expenseInfoList = expenseInfoService.selectList(new EntityWrapper<ExpenseInfo>()
+                        .eq("petty_relation_id", pettyCashInfo1.getPettyRelationId())
+                        .eq("delete_flag", "0")
+                        .eq("comp_id", pettyCashInfo1.getCompId()));
+                if (!CollectionUtils.isEmpty(expenseInfoList)) {
+                    pettyCashInfo1.setExpenseInfoList(expenseInfoList);
+                }
+            });
+        }
+        Page<PettyCashInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(pettyCashInfo.getCurrentPage());
+        page.setSize(pettyCashInfo.getPageSize());
+        return page;
+    }
+
+    /**
+     * 备用金账户下拉列表
+     *
+     * @param compId
+     * @return
+     */
+    @Override
+    public List<PettyCashInfo> getPettyAccountList(String compId) {
+        //查询备用金账户表
+        List<PettyCashInfo> pettyList = this.selectList(new EntityWrapper<PettyCashInfo>()
+                .eq("comp_id", compId)
+                .eq(SearchRecordsInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0)
+                .gt("amount_money", 0d));
+        if (!CollectionUtils.isEmpty(pettyList)) {
+            return pettyList;
+        }else {
+            //
+            throw new YException(YExceptionEnum.PETTY_ERROR);
+        }
+    }
 }

+ 66 - 56
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ExpenseInfoMapper.xml

@@ -8,6 +8,7 @@
         FROM expense_info
         WHERE
         delete_flag = '0'
+        and petty_show_flag != '1'
         and comp_id = #{compId}
         <if test="searchType != null and searchType != ''">
             <if test="searchType == 1">
@@ -161,6 +162,7 @@
         cost_no as costNo,
         expenses_type as expensesType,
         purpose,
+        petty_show_flag as pettyShowFlag,
         expense_name as expenseName,
         cost_type as costType,
         contract_no as contractNo,
@@ -189,6 +191,7 @@
         FROM expense_info
         WHERE
         delete_flag = '0'
+        and petty_show_flag != '1'
         and comp_id = #{compId}
         <if test="searchType != null and searchType != ''">
             <if test="searchType == 1">
@@ -515,62 +518,69 @@
             LIMIT ${startRecord}, ${pageSize}
         </if>
     </select>
-<!--    &lt;!&ndash;查询备用金列表总数&ndash;&gt;-->
-<!--    <select id="getPettyCashCountByCondition" parameterType="Map" resultType="java.lang.Integer">-->
-<!--        SELECT-->
-<!--        COUNT(ei.id)-->
-<!--        FROM expense_info ei-->
-<!--        cmi.delete_flag='0'-->
-<!--        WHERE-->
-<!--        ei.delete_flag = '0'-->
-<!--        and ei.expenses_purpose='7'-->
-<!--        <if test="searchType != null and searchType != ''">-->
-<!--            <if test="searchType == 1">-->
-<!--                AND ei.expenses_type = '1'-->
-<!--            </if>-->
-<!--            <if test="searchType == 2">-->
-<!--                AND ei.expenses_type = '2'-->
-<!--            </if>-->
-<!--        </if>-->
-<!--        <if test="searchKeyWord != null and searchKeyWord != ''">-->
-<!--            AND (lower(cmi.seller) like lower(CONCAT('%',#{searchKeyWord},'%'))-->
-<!--            OR lower(cmi.seller) like lower(CONCAT('%',#{searchKeyWord},'%')))-->
-<!--        </if>-->
-<!--    </select>-->
-<!--    &lt;!&ndash;查询备用金列表&ndash;&gt;-->
-<!--    <select id="getPettyCashListByCondition" parameterType="Map"-->
-<!--            resultType="com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo">-->
-<!--        SELECT-->
-<!--        ei.id,-->
-<!--        ei.expenses_type as expensesType,-->
-<!--        ei.contract_no as contractNo,-->
-<!--        ei.amount_money as amountMoney,-->
-<!--        ei.expense_name as expenseName,-->
-<!--        ei.create_user_id as createUserId,-->
-<!--        ei.address_url as addressUrl,-->
-<!--        ei.create_date as createDate-->
-<!--        FROM expense_info ei-->
-<!--        WHERE-->
-<!--        ei.delete_flag = '0'-->
-<!--        and ei.expenses_purpose='7'-->
-<!--        and ei.status!='待确认'-->
-<!--        <if test="searchType != null and searchType != ''">-->
-<!--            <if test="searchType == 1">-->
-<!--                AND ei.expenses_type = '1'-->
-<!--            </if>-->
-<!--            <if test="searchType == 2">-->
-<!--                AND ei.expenses_type = '2'-->
-<!--            </if>-->
-<!--        </if>-->
-<!--        <if test="searchKeyWord != null and searchKeyWord != ''">-->
-<!--            AND (lower(cmi.seller) like lower(CONCAT('%',#{searchKeyWord},'%'))-->
-<!--            OR lower(cmi.seller) like lower(CONCAT('%',#{searchKeyWord},'%')))-->
-<!--        </if>-->
-<!--        ORDER BY ei.update_date DESC-->
-<!--        <if test="currentPage != null and currentPage != ''">-->
-<!--            LIMIT ${startRecord}, ${pageSize}-->
-<!--        </if>-->
-<!--    </select>-->
+    <!--查询备用金列表总数-->
+    <select id="getPettyCashCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(ei.id)
+        FROM expense_info ei
+        WHERE
+        ei.delete_flag = '0'
+        and ei.expenses_purpose='7'
+        and ei.comp_id = #{compId}
+        <if test="startDate != null">
+            AND (DATE_FORMAT(ei.create_date ,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(ei.create_date ,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+        <if test="agent != null and agent != ''">
+            AND (lower(agent) like lower(CONCAT('%',#{agent},'%')))
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(ei.cost_no) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+    </select>
+    <!--查询备用金列表-->
+    <select id="getPettyCashListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.ExpenseInfo">
+        SELECT
+        ei.id,
+        ei.expenses_type as expensesType,
+        ei.cost_no as costNo,
+        ei.amount_money as amountMoney,
+        ei.expense_name as expenseName,
+        ei.expenses_purpose as expensesPurpose,
+        ei.create_user_id as createUserId,
+        ei.address_url as addressUrl,
+        ei.create_date as createDate,
+        ei.approve_status as approveStatus,
+        ei.status,
+        ei.status_flag as statusFlag
+        FROM expense_info ei
+        WHERE ei.delete_flag = '0'
+        and ei.expenses_purpose='7'
+        and ei.comp_id = #{compId}
+        <if test="startDate != null">
+            AND (DATE_FORMAT(ei.create_date ,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(ei.create_date ,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+        <if test="agent != null and agent != ''">
+            AND (lower(agent) like lower(CONCAT('%',#{agent},'%')))
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(ei.cost_no) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        ORDER BY ei.create_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 
     <select id="getRequestRecordCountByCondition" parameterType="Map" resultType="java.lang.Integer">
         SELECT

+ 49 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/PettyCashInfoMapper.xml

@@ -1,5 +1,53 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yh.saas.plugin.yiliangyiyun.mapper.PettyCashInfoMapper">
-
+    <!--查询备用金账户列表总数-->
+    <select id="getPettyAccountCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM petty_cash_info
+        WHERE
+        delete_flag = '0'
+        and comp_id = #{compId}
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(user_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND amount_money > 0.0
+            </if>
+            <if test="searchType == 3">
+                AND amount_money &lt; 0.0 OR amount_money = 0.0
+            </if>
+        </if>
+    </select>
+    <!--查询备用金账户列表-->
+    <select id="getPettyAccountListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.PettyCashInfo">
+        SELECT
+        id,
+        user_name as userName,
+        dept_name as deptName,
+        amount_money as amountMoney,
+        comp_id as compId,
+        petty_relation_id as pettyRelationId
+        FROM petty_cash_info
+        WHERE delete_flag = '0'
+        and comp_id = #{compId}
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(user_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND amount_money > 0.0
+            </if>
+            <if test="searchType == 3">
+                AND amount_money &lt; 0.0 OR amount_money = 0.0
+            </if>
+        </if>
+        ORDER BY update_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>