ly 1 rok pred
rodič
commit
d287e36701

+ 27 - 6
src/main/java/cn/ezhizao/project/business/salary/controller/BizFinancialSalaryController.java

@@ -11,6 +11,7 @@ import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import javax.servlet.ServletOutputStream;
@@ -42,8 +43,10 @@ import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
 import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
 import cn.ezhizao.project.system.domain.SysUser;
 import cn.ezhizao.project.system.mapper.SysUserMapper;
+import cn.ezhizao.project.system.service.ISysUserService;
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.poi.excel.ExcelWriter;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.itextpdf.kernel.geom.PageSize;
 import freemarker.cache.FileTemplateLoader;
@@ -116,6 +119,8 @@ public class BizFinancialSalaryController extends BaseController {
     @Resource
     private IBizFinancialKeepAccountDetailService financialKeepAccountDetailService;
 
+
+
     /**
      * 查询工资列表
      */
@@ -161,7 +166,16 @@ public class BizFinancialSalaryController extends BaseController {
         //非零申报
         bizFinancialSalary.setIsZero(0);
         //查询数据
-        List<BizFinancialSalary> list = bizFinancialSalaryService.getList(bizFinancialSalary);
+//        List<BizFinancialSalary> list = bizFinancialSalaryService.getList(bizFinancialSalary);
+        List<BizFinancialSalary> list = bizFinancialSalaryService.getList2(bizFinancialSalary);
+        //优化
+        Map<String, BizFinancialSalaryDetail> detailMap = bizFinancialSalaryDetailService
+                .list(new LambdaQueryWrapper<BizFinancialSalaryDetail>().eq(BizFinancialSalaryDetail::getDeleted,0))
+                .stream().collect(Collectors.toMap(d -> d.getFinancialSalaryId() + d.getYear() + d.getMonth(),
+                Function.identity(), (d1, d2) -> d1));
+        List<SysUser> sysUsers = sysUserMapper.selectUserList(new SysUser());
+        Map<Long, SysUser> userMap = sysUsers.stream().collect(Collectors.toMap(user -> user.getUserId(), Function.identity()));
+
         //设置状态和当前期间
         for (BizFinancialSalary salary : list) {
             //设置当前期间
@@ -170,14 +184,21 @@ public class BizFinancialSalaryController extends BaseController {
             salaryDetail.setFinancialSalaryId(salary.getId());
             salaryDetail.setYear(bizFinancialSalary.getYear());
             salaryDetail.setMonth(bizFinancialSalary.getMonth());
-            //查询当前期间明细
-            List<BizFinancialSalaryDetail> bizFinancialSalaryDetails = bizFinancialSalaryDetailService.getList(salaryDetail);
-            if (bizFinancialSalaryDetails.size() == 0) {
+//            //查询当前期间明细
+//            List<BizFinancialSalaryDetail> bizFinancialSalaryDetails = bizFinancialSalaryDetailService.getList(salaryDetail);
+            String query = salary.getId() + bizFinancialSalary.getYear() + bizFinancialSalary.getMonth();
+
+//            if (bizFinancialSalaryDetails.size() == 0 ) {
+//                salaryDetail.setStatus(0);
+//                salary.setServiceName("");
+            if (detailMap.get(query) == null ) {
                 salaryDetail.setStatus(0);
                 salary.setServiceName("");
             } else {
-                salaryDetail = bizFinancialSalaryDetails.get(0);
-                SysUser sysUser = sysUserMapper.selectUserById(salaryDetail.getVerifierId());
+//                salaryDetail = bizFinancialSalaryDetails.get(0);
+                salaryDetail = detailMap.get(query);
+//                SysUser sysUser = sysUserMapper.selectUserById(salaryDetail.getVerifierId());
+                SysUser sysUser = userMap.getOrDefault(salaryDetail.getVerifierId(), null);
                 salary.setServiceName(sysUser == null ? "" : sysUser.getNickName());
             }
             //设置状态

+ 2 - 0
src/main/java/cn/ezhizao/project/business/salary/mapper/BizFinancialSalaryMapper.java

@@ -28,4 +28,6 @@ public interface BizFinancialSalaryMapper extends BaseMapper<BizFinancialSalary>
     public int physicalDelete(BizFinancialSalary bizFinancialSalary);
 
     int physicalDeleteIds(List<Long> ids);
+
+    List<BizFinancialSalary> getList2(BizFinancialSalary bizFinancialSalary);
 }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/salary/service/IBizFinancialSalaryService.java

@@ -32,4 +32,6 @@ public interface IBizFinancialSalaryService extends IService<BizFinancialSalary>
     String importSalary(List<BizFinancialSalaryDetailEmployee> detailList, String year, String month, Long tenantId,Integer isZero);
 
     int physicalDeleteIds(List<Long> ids);
+
+    List<BizFinancialSalary> getList2(BizFinancialSalary bizFinancialSalary);
 }

+ 5 - 0
src/main/java/cn/ezhizao/project/business/salary/service/impl/BizFinancialSalaryServiceImpl.java

@@ -163,4 +163,9 @@ public class BizFinancialSalaryServiceImpl extends ServiceImpl<BizFinancialSalar
     public int physicalDeleteIds(List<Long> ids) {
         return bizFinancialSalaryMapper.physicalDeleteIds(ids);
     }
+
+    @Override
+    public List<BizFinancialSalary> getList2(BizFinancialSalary bizFinancialSalary) {
+        return bizFinancialSalaryMapper.getList2(bizFinancialSalary);
+    }
 }

+ 0 - 6
src/main/java/cn/ezhizao/project/business/workOrder/controller/OnceWorkOrderProductionController.java

@@ -8,15 +8,10 @@ import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
 import cn.ezhizao.framework.web.controller.BaseController;
 import cn.ezhizao.framework.web.domain.AjaxResult;
 import cn.ezhizao.framework.web.page.TableDataInfo;
-import cn.ezhizao.project.business.deduction.domain.BizDeduction;
 import cn.ezhizao.project.business.entrust.domain.BizEntrust;
 import cn.ezhizao.project.business.entrust.service.IBizEntrustService;
-import cn.ezhizao.project.business.keepAccounts.domain.BizFinancialKeepAccountDetail;
-import cn.ezhizao.project.business.reportTaxIsZero.domain.BizFinancialReportTaxDetail;
-import cn.ezhizao.project.business.urgent.domain.BizFinancialUrgent;
 import cn.ezhizao.project.business.workOrder.domain.BizWorkOrder;
 import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
-import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderDetailService;
 import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
 import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderService;
 import cn.ezhizao.project.system.domain.SysDictData;
@@ -31,7 +26,6 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
-import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 

+ 79 - 1
src/main/resources/mybatis/business/BizFinancialSalaryMapper.xml

@@ -11,7 +11,11 @@
         <association property="socialCreditCode" select="getSocialCreditCode" column="company_id"></association>
     </resultMap>
 
-
+    <resultMap type="cn.ezhizao.project.business.salary.domain.BizFinancialSalary" id="BizFinancialSalaryResult2">
+        <id column="id" property="id"/>
+        <result column="company_id" jdbcType="BIGINT" property="companyId"/>
+<!--        <association property="socialCreditCode" select="getSocialCreditCode" column="company_id"></association>-->
+    </resultMap>
     <select id="getList" parameterType="BizFinancialSalary" resultMap="BizFinancialSalaryResult">
         SELECT t1.*, t2.name as company_name,t2.tax_type, t3.account_name as from_company_name,
         t2.customer_label_id, t4.lable as customerLabelName,
@@ -98,6 +102,80 @@
         FROM biz_company c
         WHERE c.id = #{company_id}
     </select>
+    <select id="getList2" parameterType="BizFinancialSalary" resultMap="BizFinancialSalaryResult2">
+        SELECT t1.*, t2.name as company_name,t2.tax_type,t2.social_credit_code ,t3.account_name as from_company_name,
+        t2.customer_label_id, t4.lable as customerLabelName,
+        (select concat(bwor.year, '年', bwor.month, '月') from biz_work_order_record bwor where bwor.work_order_id =
+        t1.work_order_id order by year desc, month desc limit 1) currentDate,
+        t5.verifier_id,
+        t6.nick_name as verifierName,
+        t5.verifier_time
+        FROM biz_financial_salary t1
+        left join biz_company t2 on t2.id = t1.company_id
+        left join biz_tenant t3 on t3.id = t1.tenant_id
+        left join biz_lable t4 on t4.id = t2.customer_label_id
+        left join biz_financial_salary_detail t5 on t5.financial_salary_id = t1.id
+        and t5.deleted = 0 and t5.month = #{month} and t5.year = #{year} and t5.financial_salary_id = t1.id
+        left join sys_user t6 on t6.user_id = t5.verifier_id
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            t1.deleted = 0
+
+            <if test="isStop != null ">AND is_stop = #{isStop}</if>
+            <if test="companyName != null ">AND t2.name like concat('%', #{companyName}, '%')</if>
+            <if test="taxType != null and taxType != ''">
+                AND t2.tax_type = #{taxType}
+            </if>
+            <if test="verifierName != null">
+                AND t6.nick_name like concat('%', #{verifierName}, '%')
+            </if>
+            <if test="dateFilter != null and dateFilter.size()>0 ">
+                AND (
+                DATE_FORMAT(t5.update_time,'%Y-%m-%d') &gt;= #{dateFilter[0]}
+                AND
+                DATE_FORMAT(t5.update_time,'%Y-%m-%d') &lt;= #{dateFilter[1]}
+                )
+            </if>
+            <if test="customerLabelId != null">
+                AND t2.customer_label_id = #{customerLabelId}
+            </if>
+            <if test="isZero != null">
+                AND t2.is_zero = #{isZero}
+            </if>
+            <if test="fromCompanyName != null and fromCompanyName != ''">
+                AND (t3.account_name like concat('%', #{fromCompanyName}, '%'))
+            </if>
+            <if test="principal != null and principal != ''">
+                AND (t2.leader_id=#{principal} OR t2.adviser_id=#{principal})
+            </if>
+
+            <if test="month != null and year != null">
+                <if test="tenantId != null">
+                    AND exists (select 1 from biz_entrust eb
+                    where eb.deleted = 0
+                    and (eb.to_tenant_id = #{tenantId} or eb.from_tenant_id = #{tenantId})
+                    and date_format(eb.current_month, '%Y%m') = concat(#{year}, #{month})
+                    and eb.work_order_id = t1.work_order_id
+                    )
+                </if>
+                <if test="status != null and status != 0">
+                    AND exists (select 1 from biz_financial_salary_detail fsd where fsd.deleted = 0 and
+                    fsd.financial_salary_id = t1.id and
+                    fsd.month = #{month} and fsd.year = #{year} and fsd.status = #{status})
+                </if>
+                <if test="status != null and status == 0">
+                    AND not exists (select 1 from biz_financial_salary_detail fsd where fsd.financial_salary_id = t1.id and
+                    fsd.month = #{month} and fsd.year = #{year})
+                </if>
+                <if test="hasIndividualIncomeTax != null">
+                    AND exists (select 1 from biz_financial_salary_detail fsd where fsd.deleted = 0 and
+                    fsd.financial_salary_id = t1.id and
+                    has_individual_income_tax=#{hasIndividualIncomeTax} and fsd.month = #{month} and fsd.year = #{year})
+                </if>
+            </if>
+
+
+        </trim>
+    </select>
 
     <delete id="physicalDelete">
         DELETE FROM biz_financial_salary