MateDeliveryDayReportMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.wx.blink.backend.repository.MateDeliveryDayReportRepository">
  4. <select id="queryDayReportSubmitCountByParam"
  5. resultType="com.wx.blink.backend.domain.dataobject.MateDeliveryDayReportDO">
  6. select *
  7. from mate_delivery_day_report
  8. where deleted_flag = 0
  9. and position_staff = #{positionStaff}
  10. and submit_date = #{currentDay}
  11. </select>
  12. <select id="createDayReportNormal" resultType="boolean">
  13. INSERT INTO mate_delivery_day_report_normal(report_id, project_id, task_position_id, task_progress,
  14. accumulate_days, submit_days, submit_describe, create_user_id, create_time) VALUES
  15. <foreach collection="list" separator="," item="item">
  16. ( #{item.reportId} , #{item.projectId}, #{item.taskPositionId},#{item.taskProgress}
  17. ,#{item.accumulateDays},#{item.submitDays},#{item.submitDescribe},#{item.createUserId},#{item.createTime})
  18. </foreach>
  19. </select>
  20. <insert id="createDayReportAbnormal">
  21. INSERT INTO mate_delivery_day_report_abnormal(report_id, submit_days, submit_describe,
  22. delivery_id,delivery_name,create_user_id,
  23. create_time) VALUES
  24. <foreach collection="list" separator="," item="item">
  25. ( #{item.reportId} , #{item.submitDays},
  26. #{item.submitDescribe},#{item.deliveryId},#{item.deliveryName},#{item.createUserId},#{item.createTime})
  27. </foreach>
  28. </insert>
  29. <select id="supportsDeliveryDayReportQueryPage"
  30. resultType="com.wx.blink.backend.domain.dto.MateDeliveryDayReportDTO">
  31. SELECT o1.*
  32. FROM mate_delivery_day_report o1
  33. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  34. FROM mate_delivery_day_report
  35. GROUP BY position_staff, submit_date) o2
  36. ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
  37. <where>
  38. <if test="query.submitDate != null and query.submitDate != ''">
  39. and o1.submit_date like concat('%', #{query.submitDate}, '%')
  40. </if>
  41. </where>
  42. order by create_time desc
  43. </select>
  44. <select id="getDayReportNormalListByReportId"
  45. resultType="com.wx.blink.backend.domain.dto.MateDeliveryDayReportNormalDTO">
  46. select t1.id,
  47. t1.id taskPositionId,
  48. t1.delivery_id projectId,
  49. t2.delivery_name,
  50. t1.task_id,
  51. t3.task_name,
  52. t1.position_id,
  53. t1.position_staff,
  54. t1.task_grade,
  55. t1.task_status,
  56. t1.task_progress,
  57. t1.plan_days,
  58. t1.actual_days accumulateDays,
  59. t1.plan_start_date,
  60. t1.plan_end_date,
  61. t1.actual_start_date,
  62. t1.actual_end_date,
  63. t4.submit_days,
  64. t4.submit_describe
  65. from mate_delivery_task_positions t1
  66. left join mate_delivery t2 on t1.delivery_id = t2.id
  67. left join mate_delivery_task t3 on t1.task_id = t3.id
  68. left join mate_delivery_day_report_normal t4
  69. on t4.project_id = t1.delivery_id and task_position_id = t1.id
  70. where t1.deleted_flag = 0
  71. and t2.deleted_flag = 0
  72. and t3.deleted_flag = 0
  73. and t4.report_id = #{id}
  74. </select>
  75. <select id="getDayReportAbnormalListByReportId"
  76. resultType="com.wx.blink.backend.domain.dto.MateDeliveryDayReportAbnormalDTO">
  77. select *
  78. from mate_delivery_day_report_abnormal
  79. where report_id = #{id}
  80. </select>
  81. <select id="getDayReportListByPositionStaff" resultType="com.wx.blink.backend.domain.dto.MateDeliveryDayReportDTO">
  82. SELECT *
  83. FROM mate_delivery_day_report
  84. where position_staff = #{positionStaff}
  85. and deleted_flag = 0
  86. order by create_time
  87. desc
  88. </select>
  89. <select id="supportsDeliveryDayReportTask"
  90. resultType="com.wx.blink.backend.domain.dto.MateDeliveryDayReportNormalDTO">
  91. select t1.id,
  92. t1.id taskPositionId,
  93. t1.delivery_id projectId,
  94. t2.delivery_name,
  95. t1.task_id,
  96. t3.task_name,
  97. t1.position_id,
  98. t1.position_staff,
  99. t1.task_grade,
  100. t1.task_status,
  101. t1.task_progress,
  102. t1.plan_days,
  103. t1.actual_days accumulateDays,
  104. t1.plan_start_date,
  105. t1.plan_end_date,
  106. t1.actual_start_date,
  107. t1.actual_end_date
  108. from mate_delivery_task_positions t1
  109. left join mate_delivery t2 on t1.delivery_id = t2.id
  110. left join mate_delivery_task t3 on t1.task_id = t3.id
  111. where t1.deleted_flag = 0
  112. and t2.deleted_flag = 0
  113. and t3.deleted_flag = 0
  114. and t1.position_staff = #{query.createUserId}
  115. <if test="query.deliveryName != null and query.deliveryName != ''">
  116. and t2.delivery_name like concat('%', #{query.deliveryName}, '%')
  117. </if>
  118. <if test="query.taskName != null and query.taskName != ''">
  119. and t3.task_name like concat('%', #{query.taskName}, '%')
  120. </if>
  121. </select>
  122. <select id="getTaskListByReportIdWithDayReport"
  123. resultType="com.wx.blink.backend.domain.dto.MateDeliveryDayReportNormalDTO">
  124. select t1.id,
  125. t1.id taskPositionId,
  126. t1.delivery_id projectId,
  127. t2.delivery_name,
  128. t1.task_id,
  129. t3.task_name,
  130. t1.position_id,
  131. t1.position_staff,
  132. t1.task_grade,
  133. t1.task_status,
  134. t1.task_progress,
  135. t1.plan_days,
  136. t1.actual_days accumulateDays,
  137. t1.plan_start_date,
  138. t1.plan_end_date,
  139. t1.actual_start_date,
  140. t1.actual_end_date,
  141. t4.submit_days,
  142. t4.submit_describe
  143. from mate_delivery_task_positions t1
  144. left join mate_delivery t2 on t1.delivery_id = t2.id
  145. left join mate_delivery_task t3 on t1.task_id = t3.id
  146. left join mate_delivery_day_report_normal t4
  147. on t4.project_id = t1.delivery_id and task_position_id = t1.id
  148. where t1.deleted_flag = 0
  149. and t2.deleted_flag = 0
  150. and t3.deleted_flag = 0
  151. and t1.position_staff = #{positionStaff}
  152. and t4.report_id = #{id}
  153. </select>
  154. <select id="getDayReportNormal" resultType="com.wx.blink.backend.domain.dto.MateDeliveryDayReportNormalDTO">
  155. select *
  156. from mate_delivery_day_report_normal
  157. where report_id = #{id}
  158. and task_position_id = #{taskPositionId}
  159. and deleted_flag = 0
  160. </select>
  161. <select id="supportsDeliveryDayReportValid"
  162. resultType="com.wx.blink.backend.domain.vo.MateDeliveryDayReportSummary">
  163. SELECT o1.submit_date submitDate,count(1) submitCount,sum(site_state) siteCount,
  164. COALESCE (GROUP_CONCAT(CASE WHEN o1.site_state = 1 THEN CONCAT( t1.actual_name, ':', o1.customer_name ) END
  165. ORDER BY t1.actual_name SEPARATOR '|' ), '' ) AS residentSituation
  166. FROM mate_delivery_day_report o1
  167. left join mate_employee t1 on t1.login_name = o1.position_staff
  168. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  169. FROM mate_delivery_day_report
  170. GROUP BY position_staff, submit_date) o2
  171. ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
  172. <where>
  173. <if test="query.firstDayThisMonth != null and query.firstDayThisMonth != ''">
  174. and o1.submit_date >= #{query.firstDayThisMonth}
  175. </if>
  176. <if test="query.firstDayNextMonth != null and query.firstDayNextMonth != ''">
  177. and o1.submit_date <![CDATA[<]]> #{query.firstDayNextMonth}
  178. </if>
  179. </where>
  180. GROUP BY o1.submit_date
  181. order by o1.submit_date desc
  182. </select>
  183. <select id="supportsDeliveryDayReportValidForNormal"
  184. resultType="com.wx.blink.backend.domain.vo.MateDeliveryDayReportSummary">
  185. select submit_date submitDate, FORMAT(sum(submit_days), 1) normalSubmitDays
  186. from mate_delivery_day_report t1
  187. left join
  188. mate_delivery_day_report_normal t2 on t1.id = t2.report_id
  189. where t1.deleted_flag = 0
  190. and t2.deleted_flag = 0
  191. and report_id in (SELECT o1.id
  192. FROM mate_delivery_day_report o1
  193. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  194. FROM mate_delivery_day_report
  195. GROUP BY position_staff, submit_date) o2
  196. ON o1.position_staff = o2.position_staff AND
  197. o1.create_time = o2.latest_date
  198. where deleted_flag = 0
  199. order by o1.submit_date desc)
  200. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  201. and t1.submit_date >= #{firstDayThisMonth}
  202. </if>
  203. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  204. and t1.submit_date <![CDATA[<]]> #{firstDayNextMonth}
  205. </if>
  206. GROUP BY submit_date
  207. </select>
  208. <select id="supportsDeliveryDayReportValidForAbnormal"
  209. resultType="com.wx.blink.backend.domain.vo.MateDeliveryDayReportSummary">
  210. select submit_date submitDate, FORMAT(sum(submit_days), 1) abnormalSubmitDays
  211. from mate_delivery_day_report t1
  212. left join
  213. mate_delivery_day_report_abnormal t2 on t1.id = t2.report_id
  214. where t1.deleted_flag = 0
  215. and t2.deleted_flag = 0
  216. and report_id in (SELECT o1.id
  217. FROM mate_delivery_day_report o1
  218. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  219. FROM mate_delivery_day_report
  220. GROUP BY position_staff, submit_date) o2
  221. ON o1.position_staff = o2.position_staff AND
  222. o1.create_time = o2.latest_date
  223. where deleted_flag = 0
  224. order by o1.submit_date desc)
  225. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  226. and t1.submit_date >= #{firstDayThisMonth}
  227. </if>
  228. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  229. and t1.submit_date <![CDATA[<]]> #{firstDayNextMonth}
  230. </if>
  231. GROUP BY submit_date
  232. </select>
  233. <select id="supportsDeliveryDayReportValidForRequireSubmit"
  234. resultType="com.wx.blink.backend.domain.vo.MateDeliveryDayReportSummary">
  235. select submit_day submitDate, count(1) requireSubmitCount,
  236. sum(case when work_state = '0' then 1 else 0 end ) dutyCount
  237. from mate_delivery_day_report_require
  238. where require_state = '0'
  239. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  240. and submit_day >= #{firstDayThisMonth}
  241. </if>
  242. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  243. and submit_day <![CDATA[<]]> #{firstDayNextMonth}
  244. </if>
  245. GROUP BY submit_day
  246. </select>
  247. <select id="supportsDeliveryDayReportUnSubmitList"
  248. resultType="com.wx.blink.backend.domain.vo.MateDeliveryDayReportUnSubmitVO">
  249. SELECT r.submit_day submitDate,
  250. GROUP_CONCAT(t.actual_name ORDER BY t.actual_name) AS unSubmitStaff
  251. FROM mate_delivery_day_report_require AS r
  252. left join mate_employee t on t.login_name = r.position_staff
  253. WHERE r.require_state = '0'
  254. AND r.work_state = '0'
  255. AND NOT EXISTS (SELECT 1
  256. FROM (SELECT position_staff, submit_date, MAX(create_time) AS latest_time
  257. FROM mate_delivery_day_report
  258. GROUP BY position_staff, submit_date) AS latest
  259. WHERE latest.position_staff = r.position_staff
  260. AND latest.submit_date = r.submit_day)
  261. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  262. and r.submit_day >= #{firstDayThisMonth}
  263. </if>
  264. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  265. and r.submit_day <![CDATA[<]]> #{firstDayNextMonth}
  266. </if>
  267. GROUP BY r.submit_day
  268. ORDER BY r.submit_day
  269. </select>
  270. <select id="supportsDeliveryDayReportLeaveSituation"
  271. resultType="com.wx.blink.backend.domain.vo.MateDeliveryDayReportSummary">
  272. SELECT
  273. t1.submit_day submitDate,
  274. GROUP_CONCAT(CONCAT(t2.actual_name, ':', CAST(t1.leave_hour AS UNSIGNED))
  275. ORDER BY t2.actual_name
  276. SEPARATOR '|') AS leaveSituation
  277. FROM mate_delivery_day_report_require t1
  278. LEFT JOIN mate_employee t2 ON t1.position_staff = t2.login_name
  279. WHERE t1.require_state = '0'
  280. AND t1.leave_hour > 0
  281. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  282. and t1.submit_day >= #{firstDayThisMonth}
  283. </if>
  284. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  285. and t1.submit_day <![CDATA[<]]> #{firstDayNextMonth}
  286. </if>
  287. GROUP BY t1.submit_day
  288. ORDER BY t1.submit_day
  289. </select>
  290. <select id="queryEmployeeDaySalaryList" resultType="com.wx.blink.backend.domain.vo.MateEmployeeDaySalaryVO">
  291. select t1.position_staff, grant_month, work_hour, salary + insurance + accumulation_fund salary
  292. from mate_delivery_day_report_require t1
  293. left join mate_employee_salary t2
  294. on t1.position_staff = t2.position_staff and grant_month = #{yearMonth}
  295. where require_state = 0
  296. and work_state = 0
  297. and t1.submit_day = #{date}
  298. </select>
  299. <select id="queryExpenseAmountByDate" resultType="java.math.BigDecimal">
  300. select sum(expense_amount) expenseAmount
  301. from l_expense_statement t1
  302. left join st_instance t2 on t1.flow_id = t2.biz_objectid
  303. where state = 4
  304. and DATE_FORMAT(finish_time, '%Y-%m-%d') = #{date}
  305. </select>
  306. <select id="queryResidentFixedSubsidyByDate" resultType="java.math.BigDecimal">
  307. select sum(subsidy_amount) subsidyAmount
  308. from mate_delivery_day_report t1
  309. left join mate_delivery t2 on t2.id = t1.delivery_id
  310. where site_state = 1
  311. and t1.submit_date = #{date}
  312. and t1.deleted_flag = '0'
  313. and t2.deleted_flag = '0'
  314. </select>
  315. <select id="queryCategorySubmitDaysList"
  316. resultType="com.wx.blink.backend.domain.vo.MateDeliveryCategorySubmitDaysVO">
  317. SELECT t2.delivery_category deliveryCategory, sum(t1.submit_days) submitDays
  318. FROM mate_delivery_day_report o1
  319. left join mate_delivery_day_report_normal t1 on o1.id = t1.report_id
  320. left join mate_delivery t2 on t1.project_id = t2.id
  321. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  322. FROM mate_delivery_day_report
  323. GROUP BY position_staff, submit_date) o2
  324. ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
  325. where o1.submit_date = #{date}
  326. and t1.id is not null
  327. group by t2.delivery_category
  328. </select>
  329. <select id="queryEmployeeSalaryListByMonth" resultType="com.wx.blink.backend.domain.vo.MateEmployeeDaySalaryVO">
  330. select grant_month, work_hour, salary + insurance + accumulation_fund salary
  331. from mate_delivery_day_report_require t1
  332. left join mate_employee_salary t2
  333. on t1.position_staff = t2.position_staff and grant_month = #{paramMonth}
  334. where require_state = 0
  335. and work_state = 0
  336. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  337. and t1.submit_day >= #{firstDayThisMonth}
  338. </if>
  339. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  340. and t1.submit_day <![CDATA[<=]]> #{firstDayNextMonth}
  341. </if>
  342. </select>
  343. <select id="queryResidentFixedSubsidyByDateRange" resultType="java.math.BigDecimal">
  344. select sum(subsidy_amount) subsidyAmount
  345. from mate_delivery_day_report t1
  346. left join mate_delivery t2 on t2.id = t1.delivery_id
  347. where site_state = 1
  348. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  349. and t1.submit_date >= #{firstDayThisMonth}
  350. </if>
  351. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  352. and t1.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
  353. </if>
  354. and t1.deleted_flag = '0'
  355. and t2.deleted_flag = '0'
  356. </select>
  357. <select id="queryExpenseAmountByDateRange" resultType="java.math.BigDecimal">
  358. select sum(expense_amount) expenseAmount
  359. from l_expense_statement t1
  360. left join st_instance t2 on t1.flow_id = t2.biz_objectid
  361. where state = 4
  362. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  363. and DATE_FORMAT(finish_time, '%Y-%m-%d') >= #{firstDayThisMonth}
  364. </if>
  365. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  366. and DATE_FORMAT(finish_time, '%Y-%m-%d') <![CDATA[<=]]> #{firstDayNextMonth}
  367. </if>
  368. </select>
  369. <select id="queryCategorySubmitDaysListByDateRange"
  370. resultType="com.wx.blink.backend.domain.vo.MateDeliveryCategorySubmitDaysVO">
  371. SELECT t2.delivery_category deliveryCategory,sum(t1.submit_days) submitDays
  372. FROM mate_delivery_day_report o1
  373. left join mate_delivery_day_report_normal t1 on o1.id = t1.report_id
  374. left join mate_delivery t2 on t1.project_id = t2.id
  375. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  376. FROM mate_delivery_day_report
  377. GROUP BY position_staff, submit_date) o2
  378. ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
  379. where
  380. t1.id is not null
  381. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  382. and o1.submit_date >= #{firstDayThisMonth}
  383. </if>
  384. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  385. and o1.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
  386. </if>
  387. group by t2.delivery_category
  388. </select>
  389. <select id="queryEmployeeDutyDays" resultType="com.wx.blink.backend.domain.vo.MateEmployeeRankVO">
  390. select submit_day, position_staff, actual_name employeeName, work_hour dutyDays
  391. from mate_delivery_day_report_require t1
  392. left join mate_employee t2 on t1.position_staff = t2.login_name
  393. where require_state = 0
  394. and work_state = 0
  395. and submit_day = #{date}
  396. </select>
  397. <select id="queryEmployeeSubmitDays" resultType="com.wx.blink.backend.domain.vo.MateEmployeeRankVO">
  398. SELECT o1.position_staff,
  399. SUM(IFNULL(t1.submit_days, 0)) AS normalSubmitDays,
  400. COALESCE(
  401. (SELECT SUM(ab.submit_days)
  402. FROM mate_delivery_day_report_abnormal ab
  403. JOIN mate_delivery_day_report r ON r.id = ab.report_id
  404. WHERE r.position_staff = o1.position_staff
  405. AND r.submit_date = #{date}), 0) AS unNormalSubmitDays,
  406. COALESCE(
  407. (SELECT GROUP_CONCAT(
  408. CONCAT(ab.submit_days, ':', ab.submit_describe) ORDER BY ab.id
  409. SEPARATOR '|')
  410. FROM mate_delivery_day_report_abnormal ab
  411. JOIN mate_delivery_day_report r ON r.id = ab.report_id
  412. WHERE r.position_staff = o1.position_staff
  413. AND r.submit_date = #{date}), '') AS unNormalSubmitDaysDescribe,
  414. CASE
  415. WHEN ANY_VALUE(o1.site_state) = 1
  416. THEN ANY_VALUE(t2.subsidy_amount)
  417. ELSE 0 END AS residentFixedSubsidy
  418. FROM mate_delivery_day_report o1
  419. LEFT JOIN mate_delivery_day_report_normal t1 ON t1.report_id = o1.id
  420. LEFT JOIN mate_delivery t2 ON t2.id = o1.delivery_id
  421. JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  422. FROM mate_delivery_day_report
  423. GROUP BY position_staff, submit_date) o2
  424. ON o1.position_staff = o2.position_staff
  425. AND o1.create_time = o2.latest_date
  426. WHERE o1.submit_date = #{date}
  427. GROUP BY o1.position_staff
  428. </select>
  429. <select id="queryCategoryEmployeeSubmitDaysList"
  430. resultType="com.wx.blink.backend.domain.vo.MateDeliveryCategoryEmployeeSubmitDaysVO">
  431. SELECT o1.position_staff, t2.delivery_category deliveryCategory, sum(t1.submit_days) submitDays
  432. FROM mate_delivery_day_report o1
  433. left join mate_delivery_day_report_normal t1 on o1.id = t1.report_id
  434. left join mate_delivery t2 on t1.project_id = t2.id
  435. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  436. FROM mate_delivery_day_report
  437. GROUP BY position_staff, submit_date) o2
  438. ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
  439. where o1.submit_date = #{date}
  440. and t1.id is not null
  441. group by t2.delivery_category, o1.position_staff
  442. </select>
  443. <select id="queryEmployeeMonthDutyDays" resultType="com.wx.blink.backend.domain.vo.MateEmployeeRankVO">
  444. select position_staff, actual_name employeeName, sum(work_hour) dutyDays
  445. from mate_delivery_day_report_require t1
  446. left join mate_employee t2 on t1.position_staff = t2.login_name
  447. where require_state = 0
  448. and work_state = 0
  449. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  450. and submit_day >= #{firstDayThisMonth}
  451. </if>
  452. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  453. and submit_day <![CDATA[<=]]> #{firstDayNextMonth}
  454. </if>
  455. group by position_staff,actual_name
  456. </select>
  457. <select id="queryEmployeeMonthSubmitDays" resultType="com.wx.blink.backend.domain.vo.MateEmployeeRankVO">
  458. SELECT o1.position_staff,
  459. SUM(IFNULL(t1.submit_days,0)) AS normalSubmitDays,
  460. COALESCE(
  461. ( SELECT SUM(ab.submit_days)
  462. FROM mate_delivery_day_report_abnormal ab
  463. JOIN mate_delivery_day_report r ON r.id = ab.report_id
  464. WHERE r.position_staff = o1.position_staff
  465. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  466. and r.submit_date >= #{firstDayThisMonth}
  467. </if>
  468. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  469. and r.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
  470. </if>
  471. ),0) AS unNormalSubmitDays,
  472. COALESCE(
  473. ( SELECT GROUP_CONCAT(
  474. CONCAT(r.submit_date,",",ab.submit_days,':',ab.submit_describe)
  475. ORDER BY ab.id
  476. SEPARATOR '|')
  477. FROM mate_delivery_day_report_abnormal ab
  478. JOIN mate_delivery_day_report r ON r.id = ab.report_id
  479. WHERE r.position_staff = o1.position_staff
  480. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  481. and r.submit_date >= #{firstDayThisMonth}
  482. </if>
  483. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  484. and r.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
  485. </if>
  486. ),'') AS unNormalSubmitDaysDescribe,
  487. sum(CASE WHEN ANY_VALUE(o1.site_state) = 1
  488. THEN ANY_VALUE(t2.subsidy_amount)
  489. ELSE 0 END) AS residentFixedSubsidy
  490. FROM mate_delivery_day_report o1
  491. LEFT JOIN mate_delivery_day_report_normal t1 ON t1.report_id = o1.id
  492. LEFT JOIN mate_delivery t2 ON t2.id = o1.delivery_id
  493. JOIN (
  494. SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  495. FROM mate_delivery_day_report
  496. GROUP BY position_staff, submit_date
  497. ) o2
  498. ON o1.position_staff = o2.position_staff
  499. AND o1.create_time = o2.latest_date
  500. <where>
  501. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  502. and o1.submit_date >= #{firstDayThisMonth}
  503. </if>
  504. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  505. and o1.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
  506. </if>
  507. </where>
  508. GROUP BY o1.position_staff
  509. </select>
  510. <select id="queryEmployeeMonthSalaryList" resultType="com.wx.blink.backend.domain.vo.MateEmployeeDaySalaryVO">
  511. select t1.position_staff, grant_month, work_hour, salary + insurance + accumulation_fund salary
  512. from mate_delivery_day_report_require t1
  513. left join mate_employee_salary t2
  514. on t1.position_staff = t2.position_staff and grant_month = #{yearMonth}
  515. where require_state = 0
  516. and work_state = 0
  517. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  518. and t1.submit_day >= #{firstDayThisMonth}
  519. </if>
  520. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  521. and t1.submit_day <![CDATA[<=]]> #{firstDayNextMonth}
  522. </if>
  523. </select>
  524. <select id="queryCategoryEmployeeMonthSubmitDaysList"
  525. resultType="com.wx.blink.backend.domain.vo.MateDeliveryCategoryEmployeeSubmitDaysVO">
  526. SELECT o1.position_staff, t2.delivery_category deliveryCategory, sum(t1.submit_days) submitDays
  527. FROM mate_delivery_day_report o1
  528. left join mate_delivery_day_report_normal t1 on o1.id = t1.report_id
  529. left join mate_delivery t2 on t1.project_id = t2.id
  530. INNER JOIN (SELECT position_staff, submit_date, MAX(create_time) AS latest_date
  531. FROM mate_delivery_day_report
  532. GROUP BY position_staff, submit_date) o2
  533. ON o1.position_staff = o2.position_staff AND o1.create_time = o2.latest_date
  534. <where>
  535. <if test="firstDayThisMonth != null and firstDayThisMonth != ''">
  536. and o1.submit_date >= #{firstDayThisMonth}
  537. </if>
  538. <if test="firstDayNextMonth != null and firstDayNextMonth != ''">
  539. and o1.submit_date <![CDATA[<=]]> #{firstDayNextMonth}
  540. </if>
  541. </where>
  542. and t1.id is not null
  543. group by t2.delivery_category, o1.position_staff
  544. </select>
  545. </mapper>