فهرست منبع

会计发票导入调整对账人和实际开票人校验

sangwenwei 3 ماه پیش
والد
کامیت
031ad9a836

+ 15 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/mapper/CwFinanceInvoiceMapper.java

@@ -11,6 +11,7 @@ import com.jeeplus.finance.invoice.domain.CwFinanceInvoiceBase;
 import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceBaseDTO;
 import com.jeeplus.finance.invoice.service.dto.CwFinanceInvoiceDTO;
 import com.jeeplus.sys.service.dto.AreaDTO;
+import com.jeeplus.sys.service.dto.UserDTO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -75,6 +76,20 @@ public interface CwFinanceInvoiceMapper extends BaseMapper<CwFinanceInvoice> {
     List<AreaDTO> getAllArea();
 
     void insertBatch(@Param("invoiceArrayList") List<CwFinanceInvoice> invoiceArrayList);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserDTO> findZhglgsUserList();
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserDTO> findZsUserList(@Param("zsOfficeName")String zsOfficeName);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserDTO> findCwglgsUserList();
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserDTO> finduserAllList();
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserDTO> findDtoList(@Param("tenantId") String tenantId);
 }
 
 

+ 71 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/mapper/xml/CwFinanceInvoiceMapper.xml

@@ -729,4 +729,75 @@
         </foreach>
     </insert>
 
+    <select id="findZhglgsUserList" resultType="com.jeeplus.sys.service.dto.UserDTO">
+        SELECT
+        a.id,
+        a.`name`,
+        a.office_id AS parent_id,
+        b.`name` AS office_name,
+        true AS is_user
+        FROM
+        sys_user a
+        LEFT JOIN sys_office b ON a.office_id = b.id
+        WHERE
+        a.del_flag = 0 and a.is_admin is null and a.tenant_id = '10002'
+    </select>
+
+    <select id="findZsUserList" resultType="com.jeeplus.sys.service.dto.UserDTO">
+        SELECT
+        a.id,
+        a.`name`,
+        a.office_id AS parent_id,
+        b.`name` AS office_name,
+        true AS is_user
+        FROM
+        sys_user a
+        LEFT JOIN sys_office b ON a.office_id = b.id
+        WHERE
+        a.del_flag = 0 and a.is_admin is null and a.tenant_id = '10004' and b.name = #{zsOfficeName}
+
+    </select>
+
+    <select id="findCwglgsUserList" resultType="com.jeeplus.sys.service.dto.UserDTO">
+        SELECT
+        a.id,
+        a.`name`,
+        a.office_id AS parent_id,
+        b.`name` AS office_name,
+        true AS is_user
+        FROM
+        sys_user a
+        LEFT JOIN sys_office b ON a.office_id = b.id
+        WHERE
+        a.del_flag = 0 and a.is_admin is null and a.tenant_id = '10003'
+    </select>
+
+    <select id="findDtoList" resultType="com.jeeplus.sys.service.dto.UserDTO">
+        SELECT
+        a.id,
+        a.`name`,
+        a.office_id AS parent_id,
+        b.`name` AS office_name,
+        true AS is_user
+        FROM
+        sys_user a
+        LEFT JOIN sys_office b ON a.office_id = b.id
+        WHERE
+        a.del_flag = 0 and a.is_admin is null and a.tenant_id = #{tenantId}
+    </select>
+
+    <select id="finduserAllList" resultType="com.jeeplus.sys.service.dto.UserDTO">
+        SELECT
+        a.id,
+        a.`name`,
+        a.office_id AS parent_id,
+        b.`name` AS office_name,
+        true AS is_user
+        FROM
+        sys_user a
+        LEFT JOIN sys_office b ON a.office_id = b.id
+        WHERE
+        a.del_flag = 0 and a.is_admin is null
+    </select>
+
 </mapper>

+ 111 - 45
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/invoice/service/CwFinanceInvoiceService.java

@@ -1233,6 +1233,36 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
         ArrayList<String> clientList = new ArrayList<>();
         if (CollectionUtils.isNotEmpty(listA)){
             for (CwFinanceImportDTO cwFinanceImportDTO : listA) {
+                // 1. 报告号和项目编号校验
+                if (StringUtils.isBlank(cwFinanceImportDTO.getReportNo()) && StringUtils.isBlank(cwFinanceImportDTO.getProjectNo())) {
+                    return "报告号和项目编号不能同时为空";
+                }
+                // 4. 开票内容必填
+                if (StringUtils.isBlank(cwFinanceImportDTO.getBillingContent())) {
+                    return "开票内容不能为空";
+                }
+                // 5. 邮箱校验
+                if (StringUtils.isNotBlank(cwFinanceImportDTO.getActualDrawerEmailAddress()) &&
+                        !EMAIL_PATTERN.matcher(cwFinanceImportDTO.getActualDrawerEmailAddress()).matches()) {
+                    return "接收邮箱格式不正确";
+                }
+                // 6.单位名称校验
+                if (StringUtils.isBlank(cwFinanceImportDTO.getBillingWorkplaceReal())){
+                    return "单位名称不能为空";
+                }
+                //发票类型校验
+                if (StringUtils.isBlank(cwFinanceImportDTO.getType())){
+                    return "发票类型不能为空";
+                }
+                //开票类型校验
+                if (StringUtils.isBlank(cwFinanceImportDTO.getBillingType())){
+                    return "开票类型不能为空";
+                }
+                //银行名称校验
+                if ("专票".equals(cwFinanceImportDTO.getType()) && "企业开票".equals(cwFinanceImportDTO.getBillingType()) && StringUtils.isBlank(cwFinanceImportDTO.getOpenBank())){
+                    return "发票类型为专票且开票类型为企业开票下的开户银行名称不能为空";
+                }
+
                 if (StringUtils.isNotBlank(cwFinanceImportDTO.getProjectNo())){
                     projectNoList.add(cwFinanceImportDTO.getProjectNo());
                 }
@@ -1258,10 +1288,6 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
 
         if (CollectionUtils.isNotEmpty(listA)){
             for (CwFinanceImportDTO cwFinanceImportDTO : listA) {
-                // 1. 报告号和项目编号校验
-                if (StringUtils.isBlank(cwFinanceImportDTO.getReportNo()) && StringUtils.isBlank(cwFinanceImportDTO.getProjectNo())) {
-                    return "报告号和项目编号不能同时为空";
-                }
 
                 // 2. 项目开票金额校验
                 if (StringUtils.isNotBlank(cwFinanceImportDTO.getBaseAccount())){
@@ -1281,46 +1307,21 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                                     if (StringUtils.isNotBlank(cwFinanceInvoiceDTO.getAccount())){
                                         double parseDouble = Double.parseDouble(cwFinanceInvoiceDTO.getAccount());
                                         if (parseDouble < 0){
-                                            return "关联红字发票编号——"+cwFinanceImportDTO.getRedInvoiceRelevancyNumber()+"的开票金额为负,请重新填写关联红字发票编号";
+                                            return "关联红字发票编号"+cwFinanceImportDTO.getRedInvoiceRelevancyNumber()+" 的开票金额为负,请重新填写关联红字发票编号";
                                         }
                                     }else {
-                                        return "关联红字发票编号——"+cwFinanceImportDTO.getRedInvoiceRelevancyNumber()+"的开票金额为空,请重新填写关联红字发票编号";
+                                        return "关联红字发票编号"+cwFinanceImportDTO.getRedInvoiceRelevancyNumber()+" 的开票金额为空,请重新填写关联红字发票编号";
                                     }
                                 }
                             }
                         } else {
-                            return "关联红字发票编号——"+cwFinanceImportDTO.getRedInvoiceRelevancyNumber()+"不是当前登录人所创建,请重新填写";
+                            return "关联红字发票编号"+cwFinanceImportDTO.getRedInvoiceRelevancyNumber()+" 不是当前登录人所创建,请重新填写";
                         }
                     }
                 }else {
                     return "项目开票金额不能为空";
                 }
 
-                // 4. 开票内容必填
-                if (StringUtils.isBlank(cwFinanceImportDTO.getBillingContent())) {
-                    return "开票内容不能为空";
-                }
-                // 5. 邮箱校验
-                if (StringUtils.isNotBlank(cwFinanceImportDTO.getActualDrawerEmailAddress()) &&
-                        !EMAIL_PATTERN.matcher(cwFinanceImportDTO.getActualDrawerEmailAddress()).matches()) {
-                    return "接收邮箱格式不正确";
-                }
-                // 6.单位名称校验
-                if (StringUtils.isBlank(cwFinanceImportDTO.getBillingWorkplaceReal())){
-                    return "单位名称不能为空";
-                }
-                //发票类型校验
-                if (StringUtils.isBlank(cwFinanceImportDTO.getType())){
-                    return "发票类型不能为空";
-                }
-                //开票类型校验
-                if (StringUtils.isBlank(cwFinanceImportDTO.getBillingType())){
-                    return "开票类型不能为空";
-                }
-                //银行名称校验
-                if ("专票".equals(cwFinanceImportDTO.getType()) && "企业开票".equals(cwFinanceImportDTO.getBillingType()) && StringUtils.isBlank(cwFinanceImportDTO.getOpenBank())){
-                    return "发票类型为专票且开票类型为企业开票下的开户银行名称不能为空";
-                }
                 //发票类型校验
 //                if ("专票".equals(cwFinanceImportDTO.getType()) && "企业开票".equals(cwFinanceImportDTO.getBillingType()) && StringUtils.isNotBlank(cwFinanceImportDTO.getBillingWorkplaceReal())){
 //                    //根据单位查询客户信息
@@ -1382,8 +1383,8 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
         String invoiceBillingContentDatas = SpringUtil.getBean ( IDictApi.class ).getDictValueListMapByDict ("invoice_billing_content");
         Map<String,Object> invoiceBillingContentValueDTOs = JSON.parseObject(invoiceBillingContentDatas, new TypeReference<Map<String,Object>>() {});
 
-        //获取所有人信息
-        List<UserDTO> allUserInfo = SpringUtil.getBean(IUserApi.class).getAllUserInfo();
+        //根据当前登录人所属部门查询不同的人员信息
+        List<UserDTO> allUserInfo = findUserByTenantId(userDTO);
         //区域
         List<AreaDTO> areaDTOList = cwFinanceInvoiceMapper.getAllArea();
         List<AreaDTO> buildTree = buildTree(areaDTOList);
@@ -1415,7 +1416,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                             }
                         }
                     }else {
-                        return "项目编号——"+cwFinanceImportDTO.getProjectNo()+"不是当前登录人所创建或该项目下存在报告,请重新填写";
+                        return "项目编号:"+cwFinanceImportDTO.getProjectNo()+" 不是当前登录人所创建或该项目下存在报告,请重新填写";
                     }
                 }
                 if ((StringUtils.isNotBlank(cwFinanceImportDTO.getReportNo()) && StringUtils.isBlank(cwFinanceImportDTO.getProjectNo())) ||(StringUtils.isNotBlank(cwFinanceImportDTO.getReportNo()) && StringUtils.isNotBlank(cwFinanceImportDTO.getProjectNo()))){
@@ -1432,7 +1433,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                             }
                         }
                     }else {
-                        return "报告号——"+cwFinanceImportDTO.getReportNo()+"不是当前登录人所创建,请重新填写";
+                        return "报告号:"+cwFinanceImportDTO.getReportNo()+" 不是当前登录人所创建,请重新填写";
                     }
                 }
                 //开票金额
@@ -1561,7 +1562,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                                 .findFirst();
                         cwFinanceInvoice.setBillingPeopleReal(matchedUser.get());
                     }else {
-                        return "实际开票人——"+cwFinanceImportDTO.getBillingPeopleRealName()+"不存在,请重新填写";
+                        return "实际开票人:"+cwFinanceImportDTO.getBillingPeopleRealName()+" 不存在或不在可选择的人员列表中,请重新填写";
                     }
                 }else {
                     cwFinanceInvoice.setBillingPeopleReal(userDTO.getId());
@@ -1576,7 +1577,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                                 .findFirst();
                         cwFinanceInvoice.setReconciliationPeople(matchedUser.get());
                     }else {
-                        return "对账人——"+cwFinanceImportDTO.getReconciliationPeopleName()+"不存在,请重新填写";
+                        return "对账人"+cwFinanceImportDTO.getReconciliationPeopleName()+" 不存在或不在可选择的人员列表中,请重新填写";
                     }
                 }else {
                     cwFinanceInvoice.setReconciliationPeople(userDTO.getId());
@@ -1587,7 +1588,7 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
                     if (StringUtils.isNotBlank(lastLevelCode)){
                         cwFinanceInvoice.setReconciliationArea(lastLevelCode);
                     }else {
-                        return "对账地区——"+cwFinanceImportDTO.getReconciliationArea()+"不正确,请重新填写";
+                        return "对账地区:"+cwFinanceImportDTO.getReconciliationArea()+" 不正确,请重新填写";
                     }
 
                 }
@@ -1649,15 +1650,9 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
 
         }
 
-
-
-
-
-
     return "";
     }
 
-
     public String findLastLevelCode(List<AreaDTO> areaDTOList, String reconciliationArea) {
         // 按 "-" 拆分层级
         String[] split = reconciliationArea.split("-");
@@ -1705,4 +1700,75 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
         }
         return rootList;
     }
+
+    /**
+     * 根据当前登录人的公司查询对应的人员信息
+     * @param userDTO
+     * @return
+     */
+    private List<UserDTO> findUserByTenantId(UserDTO userDTO) {
+
+        //查询综合管理公司用户信息
+        List<UserDTO> userList1=cwFinanceInvoiceMapper.findZhglgsUserList();
+        //获取当前登录人所属公司的人员
+        List<UserDTO> dtoList=cwFinanceInvoiceMapper.findDtoList(userDTO.getTenantDTO().getId());
+
+        ArrayList<UserDTO> treeUserDtos = new ArrayList<>();
+        treeUserDtos.addAll(userList1);
+        treeUserDtos.addAll(dtoList);
+
+        String zsOfficeName = "";
+        if (userDTO != null && userDTO.getOfficeDTO() != null && StringUtils.isNotBlank(userDTO.getOfficeDTO().getName())){
+            if (userDTO.getOfficeDTO().getName().contains("审计一部")){
+                //获取中审公司的张宁部门
+                zsOfficeName = "张宁部门";
+            }else if (userDTO.getOfficeDTO().getName().contains("审计二部") ){
+                //获取中审公司的孙文宝部门
+                zsOfficeName = "孙文宝部门";
+            }
+        }
+
+        //查询中审公司用户信息
+        if (null != userDTO && null != userDTO.getOfficeDTO() && StringUtils.isNotBlank(userDTO.getOfficeDTO().getName()) && (userDTO.getOfficeDTO().getName().contains("审计一部") || userDTO.getOfficeDTO().getName().contains("审计二部"))){
+            List<UserDTO> zsUserList=cwFinanceInvoiceMapper.findZsUserList(zsOfficeName);
+            treeUserDtos.addAll(zsUserList);
+        }
+
+        if(null != userDTO && null != userDTO.getOfficeDTO() && StringUtils.isNotBlank(userDTO.getOfficeDTO().getId()) && ("1826176524081065985".equals(userDTO.getOfficeDTO().getId()) || "1826176609011527681".equals(userDTO.getOfficeDTO().getId()))) {
+            //查询会计公司用户信息
+            List<UserDTO> userList2 = cwFinanceInvoiceMapper.findCwglgsUserList();
+            treeUserDtos.addAll(userList2);
+        }
+
+        ArrayList<UserDTO> treeUsers = new ArrayList<>();
+        //如果当前登录人角色是多公司报销则查询全部公司
+        if (CollectionUtil.isNotEmpty(userDTO.getRoleDTOList())){
+            for (RoleDTO roleDTO : userDTO.getRoleDTOList()) {
+                RoleDTO roleDTOById = SpringUtil.getBean(IRoleApi.class).getRoleDTOById(roleDTO.getId());
+                if (null != roleDTOById && (roleDTOById.getEnName().equals("dgsbx")|| roleDTOById.getEnName().equals("zjbry"))){
+                    List<UserDTO> users=cwFinanceInvoiceMapper.finduserAllList();
+                    treeUsers.addAll(users);
+                }
+            }
+        }
+        //管理员则查询全部人员
+        if (userDTO.isAdmin()){
+            List<UserDTO> users=cwFinanceInvoiceMapper.finduserAllList();
+            treeUsers.addAll(users);
+        }
+
+        treeUserDtos.addAll(treeUsers);
+
+
+
+        //去重
+        List<UserDTO> newList = treeUserDtos.stream().filter(new HashSet<>()::add)
+                .collect(Collectors.toList());
+
+        return newList;
+
+
+    }
+
+
 }

+ 1 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectRecords/mapper/xml/CwProjectRecordsMapper.xml

@@ -746,7 +746,7 @@
         where a.del_flag = '0' and a.create_by_id = #{userId}
         and ((a.create_time >=(SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time')
         and a.is_have_report = '0') or a.create_time &lt; (SELECT dv.label FROM sys_dict_type dt LEFT JOIN sys_dict_value dv on dt.id = dv.dict_type_id where dt.type='new_project_time'))
-        <if test="projectNoList != null">
+        <if test="projectNoList != null and projectNoList.size > 0">
             and a.project_number in
             <foreach collection="projectNoList" item="item" separator="," open="(" close=")" index="index">
                 #{item}

+ 1 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/CwProjectReportMapper.xml

@@ -1428,7 +1428,7 @@
         left join cw_work_contract_info cw_wci on cw_wci.id = cw_pro.contract_id and cw_wci.del_flag = '0'
         where
             a.del_flag = '0' and cw_prnl.del_flag = '0' and a.status = '5' and a.create_by_id = #{userId}
-            <if test="reportNoList != null">
+            <if test="reportNoList != null and reportNoList.size > 0">
                 and cw_prnl.report_no in
                 <foreach collection="reportNoList" item="item" separator="," open="(" close=")" index="index">
                     #{item}

+ 1 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/workClientInfo/mapper/xml/CwWorkClientBaseMapper.xml

@@ -412,7 +412,7 @@
         <include refid="Base_Column_List"></include>
         from cw_work_client_base cw_wcb
         where cw_wcb.del_flag = '0'
-        <if test="clientList != null">
+        <if test="clientList != null and clientList.size > 0">
             and cw_wcb.name in
             <foreach collection="clientList" item="item" separator="," open="(" close=")" index="index">
                 #{item}