Commit eba5d3bc by lijingjing

对进场物资逻辑调整;

parent 51f15bbb
......@@ -1454,8 +1454,8 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
handleSampleBrand(ids, finalSampleBrandMap, true);
// 针对铝成品和原铝进行发送ERP数据处理
// logger.error("{}开始执行发送ERP请求:---->ERP---", DateUtils.toYearMonthDayTime(new Date()));
// sendTestDataToErp(Arrays.asList(ids), finalSampleBrandMap);
logger.error("{}开始执行发送ERP请求:---->ERP---", DateUtils.toYearMonthDayTime(new Date()));
sendTestDataToErp(Arrays.asList(ids), finalSampleBrandMap);
});
logger.error("======================质量判定结束========================");
......
......@@ -255,7 +255,7 @@
<if test="null != vo.timeS and null != vo.timeE">
AND EXISTS (
select 1 from entrust_sample_item si where si.deleted = 0 and si.entrust_sample_id = s.id
and to_char(si.test_time, 'YYYY-MM-dd HH24:MI:SS') BETWEEN #{vo.timeS} AND #{vo.timeE}
and si.test_time BETWEEN #{vo.timeS} AND #{vo.timeE}
)
</if>
GROUP BY e.model, e.plant
......@@ -386,9 +386,9 @@
WHERE i.deleted = 0
AND s.name like '%磷生铁%'
AND i.period is not null
AND ii.test_value is not null and is_numeric(ii.test_value)
AND ii.test_value is not null
<if test="null != vo.timeS and null != vo.timeE">
and date(i.test_time) &gt;= date(#{vo.timeS}) AND date(i.test_time) &lt;= date(#{vo.timeE})
and i.test_time &gt;= #{vo.timeS} AND i.test_time &lt;= #{vo.timeE}
</if>
GROUP BY i.company_id,i.period,i.entrust_sample_id
) PI
......
......@@ -647,21 +647,20 @@
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id and e.deleted = 0
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time"
FROM
entrust_sample_item i
WHERE
i.deleted = 0
GROUP BY
i.entrust_sample_id
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time"
FROM
entrust_sample_item i
WHERE
i.deleted = 0 and to_char(i.test_time, 'yyyy-mm') = #{vo.yearMonth}
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include refid="ledger_where"/>
ORDER BY
s.slot_no, i.test_time
......@@ -669,75 +668,51 @@
<!-- 原铝品味台账统计 -->
<select id="selectAlGradeLedgerStats" resultType="com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO">
SELECT
s.sample_grading "label",
i.test_time "day",
count(1) "value"
s.sample_grading "label",
i.test_time "day",
count(1) "value"
FROM
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time"
FROM
entrust_sample_item i
WHERE
i.deleted = 0
GROUP BY
i.entrust_sample_id
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time"
FROM
entrust_sample_item i
WHERE
i.deleted = 0 AND to_char(i.test_time,'yyyy-mm') = #{vo.yearMonth}
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0 and e.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include refid="ledger_where"/>
GROUP BY s.sample_grading,i.test_time
ORDER BY
s.sample_grading desc, i.test_time
ORDER BY s.sample_grading desc, i.test_time
</select>
<!-- 原铝杂质含量台账 -->
<select id="selectAlImpurityLedger" resultType="com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO">
SELECT
s.slot_no "label",
i.test_time "day",
i.value
FROM
entrust_sample s
JOIN electrolyzer e on e.id = s.electrolyzer_id
JOIN (
SELECT
i.entrust_sample_id,
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "test_time",
sum(ii.zz_value) "value"
s.slot_no "label",
to_char( MAX ( i.test_time ), 'yyyy-mm-dd' ) "day",
SUM ( ii.test_value::NUMERIC ) "value"
FROM
entrust_sample_item i
join (
select
ii.entrust_sample_item_id,
sum(cast(ii.test_value as numeric)) "zz_value"
from entrust_sample_item_index ii
where ii.deleted = 0 and is_numeric(ii.test_value)
<if test="null != vo.impurity">
and ii.name like concat('%',#{vo.impurity},'%')
</if>
group by ii.entrust_sample_item_id
) ii on ii.entrust_sample_item_id = i.id
entrust_sample s
JOIN entrust_sample_item i on i.entrust_sample_id = s.id and i.deleted = 0
JOIN entrust_sample_item_index ii on ii.entrust_sample_item_id = i.id and ii.deleted = 0
JOIN electrolyzer e ON e.ID = s.electrolyzer_id and e.deleted = 0
WHERE
i.deleted = 0
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
WHERE
s.deleted = 0 and e.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include refid="ledger_where"/>
ORDER BY
s.slot_no, i.test_time
s.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND to_char(i.test_time,'yyyy-mm') = #{vo.yearMonth}
AND TRIM(ii.test_value) ~ '^([-]?[0-9]+[.]?[0-9]*|[.][0-9]+)$'
<include refid="ledger_where"/>
GROUP BY s.id
ORDER BY s.slot_no, "day"
</select>
<!--原铝含铁量台账统计 -->
<select id="selectAlFeLedgerStats" resultType="com.patzn.cloud.service.hmhj.vo.DailyStatsLedgerVO">
......@@ -783,9 +758,8 @@
WHERE
i.deleted = 0
AND i.NAME IN ( '原铝Fe', '原铝Ni')
AND to_char(i.test_time,'yyyy-mm-dd') LIKE '${vo.yearMonth}%'
AND ii.test_value is not null
AND is_numeric ( ii.test_value )
AND to_char(i.test_time,'yyyy-mm') = #{vo.yearMonth}
AND (TRIM(ii.test_value) ~ '^([-]?[0-9]+[.]?[0-9]*|[.][0-9]+)$')
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
......@@ -793,7 +767,6 @@
s.deleted = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND i.test_time LIKE '${vo.yearMonth}%'
<include refid="ledger_where"/>
GROUP BY
I.test_time
......@@ -811,39 +784,27 @@
FROM
(
SELECT
i."name",
to_char( i.test_time, 'yyyy-mm-dd' ) "test_time",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) "max_val",
MIN ( CAST ( ii.test_value AS NUMERIC ) ) "min_val",
round( AVG ( CAST ( ii.test_value AS NUMERIC ) ), 5 ) "avg_val",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) - MIN ( CAST ( ii.test_value AS NUMERIC ) ) "dif_val"
i."name",
to_char( i.test_time, 'yyyy-mm-dd' ) "test_time",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) "max_val",
MIN ( CAST ( ii.test_value AS NUMERIC ) ) "min_val",
ROUND( AVG ( CAST ( ii.test_value AS NUMERIC ) ), 5 ) "avg_val",
MAX ( CAST ( ii.test_value AS NUMERIC ) ) - MIN ( CAST ( ii.test_value AS NUMERIC ) ) "dif_val"
FROM
entrust_sample_item i
JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.ID
AND ii.NAME = i.NAME
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.ID AND ii.NAME = i.NAME AND ii.deleted = 0
JOIN electrolyzer e ON e.ID = s.electrolyzer_id and e.deleted = 0
WHERE
i.deleted = 0
AND ii.deleted = 0
AND i.NAME = ii.NAME
AND I.NAME LIKE'%原铝%'
AND to_char( i.test_time, 'yyyy-mm-dd' ) like '${vo.yearMonth}%'
AND is_numeric ( ii.test_value )
<if test="null != vo.branch or null != vo.partition or null != vo.plant">
AND EXISTS (
SELECT
1
FROM entrust_sample s
join electrolyzer e ON e.ID = s.electrolyzer_id
WHERE s.deleted = 0 and e.deleted = 0 and s.id = i.entrust_sample_id
<include refid="ledger_where"/>
)
</if>
AND s.NAME in ('原铝','原铝散样','原铝重取')
AND to_char( i.test_time, 'yyyy-mm') = #{vo.yearMonth}
AND (TRIM(ii.test_value) ~ '^([-]?[0-9]+[.]?[0-9]+)$')
<include refid="ledger_where"/>
GROUP BY
i.NAME,
to_char( i.test_time, 'yyyy-mm-dd' )
i.NAME, "test_time"
ORDER BY
i.NAME,
to_char( i.test_time, 'yyyy-mm-dd' )
i.NAME,"test_time"
) T order by t.name, sn, label, day
</select>
<!--获取检测项目委托量统计数据: 获取LIMS平台某段时间的检测项目委托总数量-->
......
ALTER TABLE "public"."material"
ALTER TABLE "public"."material"
ADD COLUMN "type" int2 default 0;
COMMENT ON COLUMN "public"."material"."type" IS '物资类型(0:自产,1:进场)';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment