Browse Source

8888888888

zhoulisky 5 months ago
parent
commit
8284dda774

+ 1 - 1
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/XmDTO.java

@@ -23,6 +23,6 @@ public class XmDTO extends XmEntity {
 	@Schema(description = "年月,如:202507")
 	@Schema(description = "年月,如:202507")
 	private String yearAndMonth;
 	private String yearAndMonth;
 
 
-	@Schema(description = "1:项目预算,0:其他")
+	@Schema(description = "0:项目预算,1:其他")
 	private Integer use=0;
 	private Integer use=0;
 }
 }

+ 8 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/ArchiveCenterController.java

@@ -78,6 +78,14 @@ public class ArchiveCenterController extends KdController {
 			if (dbTask == null) {
 			if (dbTask == null) {
 				return R.fail("下载任务不存在,请联系管理员");
 				return R.fail("下载任务不存在,请联系管理员");
 			}
 			}
+			if(dbTask.getStatus() == 1 && DateUtil.between(dbTask.getCreateTime(),DateUtil.now()).toSeconds() > 300){
+				task.setStatus(4);
+				downloadTaskMapper.updateById(task);
+				return R.fail("下载任务超时,3分钟未完成,请联系管理员");
+			}
+			if(dbTask.getStatus() == 4){
+				return R.fail("下载任务已超时,请联系管理员");
+			}
 			if (dbTask.getStatus() == 2 && dbTask.getExpireTime() != null && DateUtil.now().compareTo(dbTask.getExpireTime()) > 0) {
 			if (dbTask.getStatus() == 2 && dbTask.getExpireTime() != null && DateUtil.now().compareTo(dbTask.getExpireTime()) > 0) {
 				// 任务已过期
 				// 任务已过期
 				dbTask.setStatus(3);
 				dbTask.setStatus(3);

+ 3 - 3
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AssetMapper.xml

@@ -179,11 +179,11 @@
             (SELECT ROUND(IFNULL(sum(amount),0),2)
             (SELECT ROUND(IFNULL(sum(amount),0),2)
             from
             from
             (
             (
-                SELECT sum(amount) as amount,year_and_month  from kd_xm_goods where tenant_id =  #{tenantId}
+                SELECT xm_id,sum(unit_price*use_quantity) as amount,year_and_month from kd_xm_goods g where tenant_id =  #{tenantId} and year_and_month = #{yearAndMonth}
                 union
                 union
-                SELECT sum(amount) as amount,year_and_month from kd_xm_lease where tenant_id =  #{tenantId}
+                SELECT xm_id,sum(unit_price*quantity) as amount,year_and_month from kd_xm_lease l where tenant_id =  #{tenantId} and year_and_month = #{yearAndMonth}
                 union
                 union
-                select sum(amount) as amount,year_and_month from kd_xm_direct_cost where tenant_id =  #{tenantId}
+                select xm_id,sum(amount) as amount,year_and_month from kd_xm_direct_cost d where tenant_id =  #{tenantId} and year_and_month = #{yearAndMonth}
             )cost where cost.year_and_month = m.month) as zjtrfy,
             )cost where cost.year_and_month = m.month) as zjtrfy,
             (ROUND((SELECT IFNULL(sum(yanfa_tan_xiao),0) FROM yiqishebeiassetcostview WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(yanfa_fen_tan),0) FROM fangwujianzhuwuAssetCostView WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(ytxe*syzb),0) FROM kd_xm_cqdtfy WHERE  tenant_id = #{tenantId} and year_and_month = m.month),2)) as zjfyycqdtfy,
             (ROUND((SELECT IFNULL(sum(yanfa_tan_xiao),0) FROM yiqishebeiassetcostview WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(yanfa_fen_tan),0) FROM fangwujianzhuwuAssetCostView WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(ytxe*syzb),0) FROM kd_xm_cqdtfy WHERE  tenant_id = #{tenantId} and year_and_month = m.month),2)) as zjfyycqdtfy,
             (SELECT ROUND(IFNULL(sum(amount),0),2) FROM kd_xm_design_cost WHERE tenant_id = #{tenantId} and cost_type='设计费用' and year_and_month = m.month) as sjfy,
             (SELECT ROUND(IFNULL(sum(amount),0),2) FROM kd_xm_design_cost WHERE tenant_id = #{tenantId} and cost_type='设计费用' and year_and_month = m.month) as sjfy,

+ 2 - 16
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmMapper.xml

@@ -33,27 +33,13 @@
         <result column="is_deleted" property="isDeleted"/>
         <result column="is_deleted" property="isDeleted"/>
     </resultMap>
     </resultMap>
 
 
-    <resultMap id="ResultVoMap" type="org.sky.scientific.pojo.vo.XmVO" extends="ResultMap">
-<!--        <association property="technicianEntity" column="XMFZR" select="org.sky.scientific.mapper.TechnicianMapper.selectById"/>-->
-    </resultMap>
+    <resultMap id="ResultVoMap" type="org.sky.scientific.pojo.vo.XmVO" extends="ResultMap"/>
 
 
     <update id="updateXm" parameterType="org.sky.scientific.pojo.dto.XmUpdateDto">
     <update id="updateXm" parameterType="org.sky.scientific.pojo.dto.XmUpdateDto">
         update kd_xm set yjlx = #{yjlx},xmly = #{xmly},xmkzxs = #{xmkzxs},yqcgxs = #{yqcgxs},xmjsjjmb = #{xmjsjjmb},
         update kd_xm set yjlx = #{yjlx},xmly = #{xmly},xmkzxs = #{xmkzxs},yqcgxs = #{yqcgxs},xmjsjjmb = #{xmjsjjmb},
         lxpw = #{lxpw},lxbg = #{lxbg},qtzl = #{qtzl},remark = #{remark} where id = #{xmId}
         lxpw = #{lxpw},lxbg = #{lxbg},qtzl = #{qtzl},remark = #{remark} where id = #{xmId}
     </update>
     </update>
 
 
-    <!--        <trim prefix="set" suffixOverrides=",">-->
-    <!--            <if test="yjlx != null and yjlx!=''">yjlx = #{yjlx},</if>-->
-    <!--            <if test="xmly != null and xmly!=''">xmly = #{xmly},</if>-->
-    <!--            <if test="xmkzxs != null and xmkzxs!=''">xmkzxs = #{xmkzxs},</if>-->
-    <!--            <if test="yqcgxs != null and yqcgxs!=''">yqcgxs = #{yqcgxs},</if>-->
-    <!--            <if test="xmjsjjmb != null and xmjsjjmb!=''">xmjsjjmb = #{xmjsjjmb},</if>-->
-    <!--            <if test="lxpw != null and lxpw!=''">lxpw = #{lxpw},</if>-->
-    <!--            <if test="lxbg != null and lxbg!=''">lxbg = #{lxbg},</if>-->
-    <!--            <if test="qtzl != null and qtzl!=''">qtzl = #{qtzl},</if>-->
-    <!--            <if test="remark != null and remark!=''">remark = #{remark},</if>-->
-    <!--        </trim>-->
-
     <select id="selectXmPage" resultMap="ResultMap">
     <select id="selectXmPage" resultMap="ResultMap">
         SELECT
         SELECT
             xm.id,
             xm.id,
@@ -64,7 +50,7 @@
             COALESCE(get_xm_info(xm.id,'XMJSSJ', #{ew.yearAndMonth}),XMJSSJ) AS XMJSSJ
             COALESCE(get_xm_info(xm.id,'XMJSSJ', #{ew.yearAndMonth}),XMJSSJ) AS XMJSSJ
         FROM kd_xm xm
         FROM kd_xm xm
         WHERE xm.status != 0
         WHERE xm.status != 0
-          <if test = "ew.use==0">
+          <if test = "ew.use==1">
               and #{ew.yearAndMonth} between DATE_FORMAT(xm.XMKSSJ, '%Y%m') and date_format(COALESCE(get_xm_info(xm.id, 'XMJSSJ', #{ew.yearAndMonth}),xm.XMJSSJ), '%Y%m')
               and #{ew.yearAndMonth} between DATE_FORMAT(xm.XMKSSJ, '%Y%m') and date_format(COALESCE(get_xm_info(xm.id, 'XMJSSJ', #{ew.yearAndMonth}),xm.XMJSSJ), '%Y%m')
           </if>
           </if>
     </select>
     </select>

+ 123 - 75
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianMapper.xml

@@ -301,94 +301,141 @@
         order by m.xm_id, m.unicode
         order by m.xm_id, m.unicode
     </select>
     </select>
 
 
+<!--    <select id="meiyueyanfaxiangmurengongfenpeihuizongbiao" resultType="org.sky.scientific.pojo.vo.XmSalaryVO">-->
+<!--        SELECT-->
+<!--            t.xm_id,-->
+<!--            m.xmbh,-->
+<!--            m.xmmc,-->
+<!--            &#45;&#45; 工资薪金总和(每个人的工资×研发占比)-->
+<!--            ROUND(SUM(COALESCE(s.average_monthly_salary, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS averageMonthlySalary,-->
+<!--            &#45;&#45; 社保总和(每个人的社保×研发占比)-->
+<!--            ROUND(SUM((COALESCE(s.pension_insurance, 0) + COALESCE(s.medical_insurance, 0) + COALESCE(s.unemployment_insurance, 0) + COALESCE(s.injury_insurance, 0) + COALESCE(s.maternity_insurance, 0)) * COALESCE(rd_ratio.ratio, 0)), 2) AS totalInsurance,-->
+<!--            &#45;&#45; 公积金总和(每个人的公积金×研发占比)-->
+<!--            ROUND(SUM(COALESCE(s.provident_fund, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS providentFund,-->
+<!--            &#45;&#45; 奖金总和(每个人的公积金×研发占比)-->
+<!--            ROUND(SUM(COALESCE(s.bonus, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS bonus,-->
+<!--            &#45;&#45; 福利费总和(每个人的福利费×研发占比)-->
+<!--            ROUND(SUM(COALESCE(s.benefit, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS benefit,-->
+<!--            &#45;&#45; 补充养老保险总和(每个人的补充养老保险×研发占比)-->
+<!--            ROUND(SUM(COALESCE(s.pension_insurance_bc, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS pensionInsuranceBc,-->
+<!--            &#45;&#45; 补充医疗保险总和(每个人的补充医疗保险×研发占比)-->
+<!--            ROUND(SUM(COALESCE(s.medical_insurance_bc, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS medicalInsuranceBc-->
+<!--        FROM kd_xm_technician t-->
+<!--        &#45;&#45; 计算研发占比的子查询-->
+<!--        INNER JOIN (-->
+<!--            SELECT-->
+<!--                rd.tenant_id,rd.unicode,rd.work_year_month,rd.xm_id,-->
+<!--            &#45;&#45; 研发占比 = 研发工时 / 考勤工时-->
+<!--                CASE WHEN COALESCE(att.attendance_hours, 0) > 0 THEN LEAST(rd.rd_hours / att.attendance_hours, 1.0) ELSE 0 END AS ratio,-->
+<!--                rd.rd_hours,att.attendance_hours-->
+<!--            FROM (-->
+<!--                &#45;&#45; 计算每个人的研发工时-->
+<!--                SELECT-->
+<!--                    tenant_id,unicode,LEFT(work_date, 6) AS work_year_month, xm_id,SUM(work_hours) AS rd_hours-->
+<!--                FROM kd_xm_technician_hours-->
+<!--                GROUP BY tenant_id, unicode, LEFT(work_date, 6), xm_id-->
+<!--            ) rd-->
+<!--            LEFT JOIN (-->
+<!--                &#45;&#45; 计算每个人的考勤工时-->
+<!--                SELECT-->
+<!--                    tenant_id, unicode,LEFT(work_date, 6) AS work_year_month, SUM(work_hours) AS attendance_hours-->
+<!--                FROM kd_attendance_records-->
+<!--                GROUP BY tenant_id, unicode, LEFT(work_date, 6)-->
+<!--            ) att ON rd.tenant_id = att.tenant_id AND rd.unicode = att.unicode AND rd.work_year_month = att.work_year_month-->
+<!--        ) rd_ratio ON t.tenant_id = rd_ratio.tenant_id AND t.unicode = rd_ratio.unicode AND t.year_and_month = rd_ratio.work_year_month AND t.xm_id = rd_ratio.xm_id-->
+
+<!--        &#45;&#45; 关联工资数据-->
+<!--        LEFT JOIN kd_salary s ON t.tenant_id = s.tenant_id AND t.unicode = s.unicode AND t.year_and_month = s.year_and_month-->
+
+<!--        left join-->
+<!--        (-->
+<!--            select-->
+<!--                temp.id, XMBH ,-->
+<!--                COALESCE(get_xm_info(temp.id, 'XMMC', #{ew.yearAndMonth}), temp.XMMC) as XMMC from kd_xm temp-->
+<!--        ) m on m.id = t.xm_id-->
+<!--        WHERE t.tenant_id = #{ew.tenantId} and t.year_and_month = #{ew.yearAndMonth}-->
+<!--        <if test="ew.xmmc!=null and ew.xmmc!=''">and m.XMMC like concat('%',#{ew.xmmc},'%')</if>-->
+<!--        GROUP BY t.xm_id-->
+<!--    </select>-->
+
+
+
+<!--    <select id="meiyueyanfaxiangmurengongfenpeihuizongbiaoByYear" resultType="org.sky.scientific.pojo.vo.XmSalaryVO">-->
+<!--        SELECT-->
+<!--        xm.xm_id,m.XMBH,m.XMMC,-->
+<!--        xm.year_and_month,-->
+<!--        (SELECT IFNULL(SUM(work_hours),0) FROM kd_attendance_records r WHERE r.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and LEFT(tmp.year_and_month,4) = #{ew.yearAndMonth}) and LEFT(work_date,4)= #{ew.yearAndMonth}) AS attendanceHours,-->
+<!--        (SELECT IFNULL(SUM(work_hours),0) FROM kd_xm_technician_hours kxth WHERE kxth.xm_id = xm.xm_id AND LEFT(work_date,4)= #{ew.yearAndMonth})AS workHours,-->
+<!--        (SELECT IFNULL(sum(s.average_monthly_salary),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS average_monthly_salary,-->
+<!--        (SELECT IFNULL(sum(s.pension_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS pension_insurance,-->
+<!--        (SELECT IFNULL(sum(s.medical_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS medical_insurance,-->
+
+<!--        (SELECT IFNULL(sum(s.unemployment_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS unemployment_insurance,-->
+
+<!--        (SELECT IFNULL(sum(s.injury_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS injury_insurance,-->
+
+<!--        (SELECT IFNULL(sum(s.maternity_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left( s.year_and_month,4) = #{ew.yearAndMonth}) AS maternity_insurance,-->
+
+<!--        (SELECT IFNULL(sum(s.provident_fund),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS provident_fund,-->
+<!--        (SELECT IFNULL(sum(s.bonus),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS bonus,-->
+<!--        (SELECT IFNULL(sum(s.benefit),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS benefit,-->
+<!--        (SELECT IFNULL(sum(s.pension_insurance_bc),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS pension_insurance_bc,-->
+<!--        (SELECT IFNULL(sum(s.medical_insurance_bc),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS medical_insurance_bc-->
+<!--        FROM kd_xm_technician xm-->
+<!--        LEFT JOIN (-->
+<!--            SELECT-->
+<!--                temp.id, XMBH,-->
+<!--                COALESCE(get_xm_info(temp.id, 'XMMC', #{ew.yearAndMonth}), temp.XMMC ) AS XMMC-->
+<!--            FROM kd_xm as  temp-->
+<!--        ) m ON m.id = xm.xm_id-->
+<!--        WHERE xm.tenant_id = #{ew.tenantId} and LEFT(xm.year_and_month,4) = #{ew.yearAndMonth}-->
+<!--        <if test="ew.xmmc!=null and ew.xmmc!=''">and m.XMMC like concat('%',#{ew.xmmc},'%')</if>-->
+<!--        GROUP BY xm.xm_id-->
+<!--    </select>-->
+
     <select id="meiyueyanfaxiangmurengongfenpeihuizongbiao" resultType="org.sky.scientific.pojo.vo.XmSalaryVO">
     <select id="meiyueyanfaxiangmurengongfenpeihuizongbiao" resultType="org.sky.scientific.pojo.vo.XmSalaryVO">
         SELECT
         SELECT
-            t.xm_id,
-            m.xmbh,
-            m.xmmc,
-            -- 工资薪金总和(每个人的工资×研发占比)
-            ROUND(SUM(COALESCE(s.average_monthly_salary, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS averageMonthlySalary,
-            -- 社保总和(每个人的社保×研发占比)
-            ROUND(SUM((COALESCE(s.pension_insurance, 0) + COALESCE(s.medical_insurance, 0) + COALESCE(s.unemployment_insurance, 0) + COALESCE(s.injury_insurance, 0) + COALESCE(s.maternity_insurance, 0)) * COALESCE(rd_ratio.ratio, 0)), 2) AS totalInsurance,
-            -- 公积金总和(每个人的公积金×研发占比)
-            ROUND(SUM(COALESCE(s.provident_fund, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS providentFund,
-            -- 奖金总和(每个人的公积金×研发占比)
-            ROUND(SUM(COALESCE(s.bonus, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS bonus,
-            -- 福利费总和(每个人的福利费×研发占比)
-            ROUND(SUM(COALESCE(s.benefit, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS benefit,
-            -- 补充养老保险总和(每个人的补充养老保险×研发占比)
-            ROUND(SUM(COALESCE(s.pension_insurance_bc, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS pensionInsuranceBc,
-            -- 补充医疗保险总和(每个人的补充医疗保险×研发占比)
-            ROUND(SUM(COALESCE(s.medical_insurance_bc, 0) * COALESCE(rd_ratio.ratio, 0)), 2) AS medicalInsuranceBc
-        FROM kd_xm_technician t
-        -- 计算研发占比的子查询
-        INNER JOIN (
+            v.xm_id,m.XMBH,m.XMMC,v.year_and_month,
+            sum(averageMonthlySalary) as averageMonthlySalary,
+            sum(totalInsurance) as totalInsurance,
+            sum(providentFund) as providentFund,
+            sum(bonus) as bonus,
+            sum(benefit) as benefit,
+            sum(pensionInsuranceBc) as pensionInsuranceBc,
+            sum(medicalInsuranceBc) as medicalInsuranceBc
+        FROM ryrgfyhz_view v
+        LEFT JOIN (
             SELECT
             SELECT
-                rd.tenant_id,rd.unicode,rd.work_year_month,rd.xm_id,
-            -- 研发占比 = 研发工时 / 考勤工时
-                CASE WHEN COALESCE(att.attendance_hours, 0) > 0 THEN LEAST(rd.rd_hours / att.attendance_hours, 1.0) ELSE 0 END AS ratio,
-                rd.rd_hours,att.attendance_hours
-            FROM (
-                -- 计算每个人的研发工时
-                SELECT
-                    tenant_id,unicode,LEFT(work_date, 6) AS work_year_month, xm_id,SUM(work_hours) AS rd_hours
-                FROM kd_xm_technician_hours
-                GROUP BY tenant_id, unicode, LEFT(work_date, 6), xm_id
-            ) rd
-            LEFT JOIN (
-                -- 计算每个人的考勤工时
-                SELECT
-                    tenant_id, unicode,LEFT(work_date, 6) AS work_year_month, SUM(work_hours) AS attendance_hours
-                FROM kd_attendance_records
-                GROUP BY tenant_id, unicode, LEFT(work_date, 6)
-            ) att ON rd.tenant_id = att.tenant_id AND rd.unicode = att.unicode AND rd.work_year_month = att.work_year_month
-        ) rd_ratio ON t.tenant_id = rd_ratio.tenant_id AND t.unicode = rd_ratio.unicode AND t.year_and_month = rd_ratio.work_year_month AND t.xm_id = rd_ratio.xm_id
-
-        -- 关联工资数据
-        LEFT JOIN kd_salary s ON t.tenant_id = s.tenant_id AND t.unicode = s.unicode AND t.year_and_month = s.year_and_month
-
-        left join
-        (
-            select
-                temp.id, XMBH ,
-                COALESCE(get_xm_info(temp.id, 'XMMC', #{ew.yearAndMonth}), temp.XMMC) as XMMC from kd_xm temp
-        ) m on m.id = t.xm_id
-        WHERE t.tenant_id = #{ew.tenantId} and t.year_and_month = #{ew.yearAndMonth}
+            temp.id, XMBH,
+            COALESCE(get_xm_info(temp.id, 'XMMC', #{ew.yearAndMonth}), temp.XMMC ) AS XMMC
+            FROM kd_xm as  temp
+        ) m ON m.id = v.xm_id
+        WHERE v.tenant_id = #{ew.tenantId} and LEFT(v.year_and_month,6) = #{ew.yearAndMonth}
         <if test="ew.xmmc!=null and ew.xmmc!=''">and m.XMMC like concat('%',#{ew.xmmc},'%')</if>
         <if test="ew.xmmc!=null and ew.xmmc!=''">and m.XMMC like concat('%',#{ew.xmmc},'%')</if>
-        GROUP BY t.xm_id
+        GROUP BY v.xm_id
     </select>
     </select>
 
 
     <select id="meiyueyanfaxiangmurengongfenpeihuizongbiaoByYear" resultType="org.sky.scientific.pojo.vo.XmSalaryVO">
     <select id="meiyueyanfaxiangmurengongfenpeihuizongbiaoByYear" resultType="org.sky.scientific.pojo.vo.XmSalaryVO">
         SELECT
         SELECT
-        xm.xm_id,m.XMBH,m.XMMC,
-        xm.year_and_month,
-        (SELECT IFNULL(SUM(work_hours),0) FROM kd_attendance_records r WHERE r.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and LEFT(tmp.year_and_month,4) = #{ew.yearAndMonth}) and LEFT(work_date,4)= #{ew.yearAndMonth}) AS attendanceHours,
-        (SELECT IFNULL(SUM(work_hours),0) FROM kd_xm_technician_hours kxth WHERE kxth.xm_id = xm.xm_id AND LEFT(work_date,4)= #{ew.yearAndMonth})AS workHours,
-        (SELECT IFNULL(sum(s.average_monthly_salary),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS average_monthly_salary,
-        (SELECT IFNULL(sum(s.pension_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS pension_insurance,
-        (SELECT IFNULL(sum(s.medical_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS medical_insurance,
-
-        (SELECT IFNULL(sum(s.unemployment_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS unemployment_insurance,
-
-        (SELECT IFNULL(sum(s.injury_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS injury_insurance,
-
-        (SELECT IFNULL(sum(s.maternity_insurance),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left( s.year_and_month,4) = #{ew.yearAndMonth}) AS maternity_insurance,
-
-        (SELECT IFNULL(sum(s.provident_fund),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS provident_fund,
-        (SELECT IFNULL(sum(s.bonus),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS bonus,
-        (SELECT IFNULL(sum(s.benefit),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS benefit,
-        (SELECT IFNULL(sum(s.pension_insurance_bc),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS pension_insurance_bc,
-        (SELECT IFNULL(sum(s.medical_insurance_bc),0) FROM kd_salary s WHERE s.unicode in (select distinct (tmp.unicode) from kd_xm_technician tmp WHERE tmp.xm_id = xm.xm_id and left(tmp.year_and_month,4) = #{ew.yearAndMonth}) AND left(s.year_and_month,4) = #{ew.yearAndMonth}) AS medical_insurance_bc
-        FROM kd_xm_technician xm
+            v.xm_id,m.XMBH,m.XMMC,v.year_and_month,
+            sum(averageMonthlySalary) as averageMonthlySalary,
+            sum(totalInsurance) as totalInsurance,
+            sum(providentFund) as providentFund,
+            sum(bonus) as bonus,
+            sum(benefit) as benefit,
+            sum(pensionInsuranceBc) as pensionInsuranceBc,
+            sum(medicalInsuranceBc) as medicalInsuranceBc
+        FROM ryrgfyhz_view v
         LEFT JOIN (
         LEFT JOIN (
             SELECT
             SELECT
                 temp.id, XMBH,
                 temp.id, XMBH,
                 COALESCE(get_xm_info(temp.id, 'XMMC', #{ew.yearAndMonth}), temp.XMMC ) AS XMMC
                 COALESCE(get_xm_info(temp.id, 'XMMC', #{ew.yearAndMonth}), temp.XMMC ) AS XMMC
             FROM kd_xm as  temp
             FROM kd_xm as  temp
-        ) m ON m.id = xm.xm_id
-        WHERE xm.tenant_id = #{ew.tenantId} and LEFT(xm.year_and_month,4) = #{ew.yearAndMonth}
+        ) m ON m.id = v.xm_id
+        WHERE v.tenant_id = #{ew.tenantId} and LEFT(v.year_and_month,4) = #{ew.yearAndMonth}
         <if test="ew.xmmc!=null and ew.xmmc!=''">and m.XMMC like concat('%',#{ew.xmmc},'%')</if>
         <if test="ew.xmmc!=null and ew.xmmc!=''">and m.XMMC like concat('%',#{ew.xmmc},'%')</if>
-        GROUP BY xm.xm_id
+        GROUP BY v.xm_id
+        order by v.xm_id asc
     </select>
     </select>
 
 
     <select id="statisticsWorkHoursByXmAndUnicodeAndMonth" resultType="com.alibaba.fastjson.JSONObject">
     <select id="statisticsWorkHoursByXmAndUnicodeAndMonth" resultType="com.alibaba.fastjson.JSONObject">
@@ -402,6 +449,7 @@
             kd_xm_technician m
             kd_xm_technician m
         WHERE
         WHERE
             m.tenant_id = #{tenantId} and LEFT(m.year_and_month,4)= #{year}
             m.tenant_id = #{tenantId} and LEFT(m.year_and_month,4)= #{year}
-        GROUP BY m.xm_id, m.unicode,m.year_and_month
+        GROUP BY v.xm_id, m.unicode,m.year_and_month
+        order by v.xm_id asc
     </select>
     </select>
 </mapper>
 </mapper>

+ 2 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/ArchiveServiceImpl.java

@@ -350,7 +350,7 @@ public class ArchiveServiceImpl implements IArchiveService {
 			Path path7 = FileUtil.mkdir(Paths.get(basePath.toString(), "7.高新研发项目全套技术资料"));
 			Path path7 = FileUtil.mkdir(Paths.get(basePath.toString(), "7.高新研发项目全套技术资料"));
 			XmFinanceEntity dto = new XmFinanceEntity();
 			XmFinanceEntity dto = new XmFinanceEntity();
 			dto.setYearAndMonth(year);
 			dto.setYearAndMonth(year);
-			dto.setType(2);
+			dto.setType(3);
 			List<XmFinanceEntity> list = xmFinanceService.selectXmFinanceList(dto);
 			List<XmFinanceEntity> list = xmFinanceService.selectXmFinanceList(dto);
 			AtomicInteger iii = new AtomicInteger(1);
 			AtomicInteger iii = new AtomicInteger(1);
 			for (XmFinanceEntity xm : list) {
 			for (XmFinanceEntity xm : list) {
@@ -364,7 +364,7 @@ public class ArchiveServiceImpl implements IArchiveService {
 			Path path8 = FileUtil.mkdir(Paths.get(basePath.toString(), "8.加计扣除研发项目全套技术资料"));
 			Path path8 = FileUtil.mkdir(Paths.get(basePath.toString(), "8.加计扣除研发项目全套技术资料"));
 			XmFinanceEntity dto = new XmFinanceEntity();
 			XmFinanceEntity dto = new XmFinanceEntity();
 			dto.setYearAndMonth(year);
 			dto.setYearAndMonth(year);
-			dto.setType(3);
+			dto.setType(2);
 			List<XmFinanceEntity> list = xmFinanceService.selectXmFinanceList(dto);
 			List<XmFinanceEntity> list = xmFinanceService.selectXmFinanceList(dto);
 			AtomicInteger jjj = new AtomicInteger(1);
 			AtomicInteger jjj = new AtomicInteger(1);
 			for (XmFinanceEntity xm : list) {
 			for (XmFinanceEntity xm : list) {

+ 20 - 12
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmFixedAssetServiceImpl.java

@@ -108,7 +108,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 					jtXmIdList.add(dbAsset.getXmId());
 					jtXmIdList.add(dbAsset.getXmId());
 					continue;
 					continue;
 				}
 				}
-				if (dbAsset.getAsset()!=null && !Func.equals(dbAsset.getAsset().getStatus(), AssetStatusEnum.正常.getCode())) {
+				if (dbAsset.getAsset() != null && !Func.equals(dbAsset.getAsset().getStatus(), AssetStatusEnum.正常.getCode())) {
 					continue;
 					continue;
 				}
 				}
 				XmFixedAsset asset = new XmFixedAsset();
 				XmFixedAsset asset = new XmFixedAsset();
@@ -122,7 +122,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 			//若无,则获取预算表中的资产,研发项目周期(含变更)包含本月的
 			//若无,则获取预算表中的资产,研发项目周期(含变更)包含本月的
 			List<YsZjfyycqdtfyEntity> ysList = ysZjfyycqdtfyMapper.selectByYearAndMonth(yearAndMonth, type.getCode());
 			List<YsZjfyycqdtfyEntity> ysList = ysZjfyycqdtfyMapper.selectByYearAndMonth(yearAndMonth, type.getCode());
 			if (CollectionUtil.isEmpty(ysList)) {
 			if (CollectionUtil.isEmpty(ysList)) {
- 				throw new ServiceException("项目预算表中无数据");
+				throw new ServiceException("项目预算表中无数据");
 			}
 			}
 			for (YsZjfyycqdtfyEntity ys : ysList) {
 			for (YsZjfyycqdtfyEntity ys : ysList) {
 				if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(ys.getZcbm())) {
 				if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(ys.getZcbm())) {
@@ -246,7 +246,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 		}
 		}
 		AssetEntity dbAsset = assetMapper.selectByYearAndMonthAndBmOrMc(xmAsset.getYearAndMonth(), xmAsset.getZcbm(), null);
 		AssetEntity dbAsset = assetMapper.selectByYearAndMonthAndBmOrMc(xmAsset.getYearAndMonth(), xmAsset.getZcbm(), null);
 		if (Func.notNull(dbAsset) && !Func.equals(dbAsset.getStatus(), AssetStatusEnum.正常.getCode())) {
 		if (Func.notNull(dbAsset) && !Func.equals(dbAsset.getStatus(), AssetStatusEnum.正常.getCode())) {
- 			throw new ServiceException("资产状态非正常");
+			throw new ServiceException("资产状态非正常");
 		}
 		}
 		return this.save(xmAsset);
 		return this.save(xmAsset);
 	}
 	}
@@ -326,20 +326,28 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
 			data.put("yearAndMonth", yearAndMonth);
 			data.put("yearAndMonth", yearAndMonth);
 			data.put("xmbh", temp.getXmbh());
 			data.put("xmbh", temp.getXmbh());
 			data.put("xmmc", temp.getXmmc());
 			data.put("xmmc", temp.getXmmc());
-			data.put("zcbm", temp.getAsset().getZcbm());
-			data.put("zcmc", temp.getAsset().getZcmc());
-			data.put("zclb", temp.getAsset().getZclb());
-			data.put("yt", temp.getAsset().getYt());
-			data.put("zcyz", temp.getAsset().getZcyz());
-			data.put("jcz", temp.getAsset().getJcz());
-			data.put("yzje", temp.getAsset().getYzje());
-			data.put("zgs", temp.getAsset().getZgs());
+			AssetEntity asset = temp.getAsset();
+			if (Func.isNull(asset)) {
+				asset = new AssetEntity();
+				asset.setZcyz(BigDecimal.ZERO);
+				asset.setYzje(BigDecimal.ZERO);
+				asset.setZgs(0.0);
+			}
+			data.put("zcbm", asset.getZcbm());
+			data.put("zcmc", asset.getZcmc());
+			data.put("zclb", asset.getZclb());
+			data.put("yt", asset.getYt());
+			data.put("zcyz", asset.getZcyz());
+			data.put("jcz", asset.getJcz());
+			data.put("yzje", asset.getYzje());
+			data.put("zgs", asset.getZgs());
+
 			data.put("workHours", temp.getWorkHours());
 			data.put("workHours", temp.getWorkHours());
 			data.put("yanfaFenTanLv", temp.getYanfaFenTanLv());
 			data.put("yanfaFenTanLv", temp.getYanfaFenTanLv());
 			if (Func.isNull(temp.getYanfaFenTanLv())) {
 			if (Func.isNull(temp.getYanfaFenTanLv())) {
 				temp.setYanfaFenTanLv(0.00);
 				temp.setYanfaFenTanLv(0.00);
 			}
 			}
-			data.put("yanfazhejiu", BigDecimal.valueOf(temp.getYanfaFenTanLv()).multiply(temp.getAsset().getYzje()));
+			data.put("yanfazhejiu", BigDecimal.valueOf(temp.getYanfaFenTanLv()).multiply(asset.getYzje()));
 			data.put("fenTanLvQueDingYiJu", temp.getFenTanLvQueDingYiJu());
 			data.put("fenTanLvQueDingYiJu", temp.getFenTanLvQueDingYiJu());
 			results.add(data);
 			results.add(data);
 
 

+ 4 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmServiceImpl.java

@@ -154,9 +154,13 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
 		xm.setStatus(baseMapper.getXmStatusByXmId(xmId).getInteger("status"));
 		xm.setStatus(baseMapper.getXmStatusByXmId(xmId).getInteger("status"));
 		if (xm.getXmfzr() != null) {
 		if (xm.getXmfzr() != null) {
 			xm.setXmfzrxm(Func.toStr(technicianMapper.getNameById(xm.getXmfzr()), ""));
 			xm.setXmfzrxm(Func.toStr(technicianMapper.getNameById(xm.getXmfzr()), ""));
+		}else{
+			xm.setXmfzrxm("");
 		}
 		}
 		if (xm.getXmsqdwid() != null) {
 		if (xm.getXmsqdwid() != null) {
 			xm.setXmsqdw(Func.toStr(departmentMapper.getFullNameById(xm.getXmsqdwid()), ""));
 			xm.setXmsqdw(Func.toStr(departmentMapper.getFullNameById(xm.getXmsqdwid()), ""));
+		}else {
+			xm.setXmsqdw("");
 		}
 		}
   		return cn.hutool.core.bean.BeanUtil.copyProperties(xm, XmVO.class);
   		return cn.hutool.core.bean.BeanUtil.copyProperties(xm, XmVO.class);
 	}
 	}

+ 1 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmTechnicianHoursServiceImpl.java

@@ -173,7 +173,7 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
 				}
 				}
 
 
 				String attendanceByDay = unicode + ":" + dailyAttendance.getWorkDate();
 				String attendanceByDay = unicode + ":" + dailyAttendance.getWorkDate();
-				Map<String, Double> allHoursMap = Stream.concat(insertList.stream(), updateList.stream())
+				Map<String, Double> allHoursMap = Stream.concat(insertList.stream(), dbList.stream())
 					.collect(Collectors.groupingBy(item -> item.getUnicode() + ":" + item.getWorkDate(), Collectors.summingDouble(XmTechnicianHours::getWorkHours)));
 					.collect(Collectors.groupingBy(item -> item.getUnicode() + ":" + item.getWorkDate(), Collectors.summingDouble(XmTechnicianHours::getWorkHours)));
 				Double attendanceHours = attHoursByEveryDay.getOrDefault(attendanceByDay, 0.0);
 				Double attendanceHours = attHoursByEveryDay.getOrDefault(attendanceByDay, 0.0);
 				Double hoursFilled = allHoursMap.getOrDefault(unicode + ":" + dailyAttendance.getWorkDate(), 0.0);
 				Double hoursFilled = allHoursMap.getOrDefault(unicode + ":" + dailyAttendance.getWorkDate(), 0.0);