Commit 81133afa by lijingjing

相关大屏统计查询;

parent 7ab18466
......@@ -53,27 +53,27 @@ public class NoticeAnnouncementController extends ServiceController {
@ApiImplicitParam(name = "id", value = "主键", required = true, paramType = "path", dataTypeClass = Long.class),
})
@PutMapping("/{id}")
public RestResult<Boolean> edit(@PathVariable("id") Long id, NoticeAnnouncement noticeAnnouncement) {
public RestResult<Boolean> edit(@PathVariable("id") Long id, NoticeAnnouncement noticeAnnouncement) {
noticeAnnouncement.setId(id);
noticeAnnouncement.setUpdater(getAccount().getUserName());
return success(noticeAnnouncementService.updateAndRecord(noticeAnnouncement));
}
}
@ApiOperation("添加")
@PostMapping("/")
public RestResult<Boolean> add(NoticeAnnouncement noticeAnnouncement) {
noticeAnnouncement.setCreator(getAccount().getUserName());
return success(noticeAnnouncementService.save(noticeAnnouncement));
}
}
@ApiOperation("根据 ids 删除")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "主键列表", required = true, paramType = "query", allowMultiple = true, dataTypeClass = Long.class),
})
@DeleteMapping("/")
public RestResult<Boolean> delete(@RequestParam("ids") List<Long> ids) {
@DeleteMapping("/")
public RestResult<Boolean> delete(@RequestParam("ids") List<Long> ids) {
return success(noticeAnnouncementService.removeByIds(ids));
}
}
@ApiOperation("显示最近修改的通知")
@ApiImplicitParams({
......@@ -81,9 +81,15 @@ public class NoticeAnnouncementController extends ServiceController {
})
@PostMapping("/recent/")
public RestResult<List<NoticeAnnouncement>> recent(
@RequestParam(value = "count",required = false) Integer count) {
@RequestParam(value = "count", required = false) Integer count) {
if (count == null)
count = 3;
return success(noticeAnnouncementService.recent(count));
}
@ApiOperation("显示最新 N 条通知公告")
@PostMapping("/latest")
public RestResult<List<NoticeAnnouncement>> latestNotices(Integer limit) {
return success(noticeAnnouncementService.latestNotices(limit));
}
}
package com.patzn.cloud.service.lims.hmhj.controller;
import com.baomidou.kisso.annotation.Action;
import com.baomidou.kisso.annotation.Login;
import com.patzn.cloud.commons.api.RestResult;
import com.patzn.cloud.commons.controller.ServiceController;
import com.patzn.cloud.commons.toolkit.DateUtils;
import com.patzn.cloud.service.hmhj.dto.LedgerQueryDTO;
import com.patzn.cloud.service.hmhj.dto.QueryDTO;
import com.patzn.cloud.service.hmhj.dto.RangeStatsQueryDTO;
......@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -32,17 +36,40 @@ public class StatisticsController extends ServiceController {
}
@ApiOperation("阳极检查量统计")
@Login(action = Action.Skip)
@PostMapping("/anode_inspection_quantity")
public RestResult<List<Statistics>> getAnodeInspectionQuantity(QueryDTO queryDTO) {
public RestResult<Integer> getAnodeInspectionQuantity(QueryDTO queryDTO) {
return success(statsService.getAnodeInspectionQuantity(queryDTO));
}
@ApiOperation("获取阳极检查量合格率")
@Login(action = Action.Skip)
@PostMapping("/anode_inspection_done_quantity")
public RestResult<Statistics> getAnodeInspectionDoneQuantity(QueryDTO queryDTO) {
return success(statsService.getAnodeInspectionDoneQuantity(queryDTO));
}
@ApiOperation("报告发放量统计")
@PostMapping("/report_send_quantity")
@Login(action = Action.Skip)
public RestResult<Map<String, Object>> getReportSendQuantity(RangeStatsQueryDTO queryDTO) {
return success(statsService.getReportSendQuantity(queryDTO));
}
@ApiOperation("获取报告发放量数据统计")
@Login(action = Action.Skip)
@PostMapping("/month_report_send_quantity")
public RestResult<Map<String, Object>> getMonthReportSendQuantity(RangeStatsQueryDTO queryDTO) {
return success(statsService.getMonthReportSendQuantity(queryDTO));
}
@ApiOperation("获取报告发放量同比环比数据")
@Login(action = Action.Skip)
@PostMapping("/sames_chain_report_send_quantity")
public RestResult<Statistics> getSamesChainReportSendQuantity(RangeStatsQueryDTO queryDTO) {
return success(statsService.getSamesChainReportSendQuantity(queryDTO));
}
@ApiOperation("检测项目数量统计")
@PostMapping("/item_quantity")
......@@ -52,11 +79,47 @@ public class StatisticsController extends ServiceController {
@ApiOperation("取样量统计")
@PostMapping("/sampling_quantity")
@Login(action = Action.Skip)
public RestResult<List<Statistics>> getSamplingQuantity(RangeStatsQueryDTO queryDTO) {
return success(statsService.getSamplingQuantity(queryDTO));
}
@ApiOperation("外检完成量统计")
@ApiOperation("获取取样量统计数据")
@PostMapping("/total_sampling_quantity")
@Login(action = Action.Skip)
public RestResult<Integer> getTotalSamplingQuantity(QueryDTO queryDTO) {
return success(statsService.getTotalSamplingQuantity(queryDTO));
}
@ApiOperation("获取铝成品检查数量")
@PostMapping("/al_pro_inspection_quantity")
@Login(action = Action.Skip)
public RestResult<Integer> getAlProductInspectionQuantity(QueryDTO queryDTO) {
return success(statsService.getAlProductInspectionQuantity(queryDTO));
}
@ApiOperation("获取铝成品检查量合格率数据")
@PostMapping("/al_pro_inspection_quantity_rate")
@Login(action = Action.Skip)
public RestResult<Statistics> getAlProductInspectionQuantityRate(QueryDTO queryDTO) {
return success(statsService.getAlProductInspectionQuantityRate(queryDTO));
}
@ApiOperation("获取验收工作量同比环比数据")
@Login(action = Action.Skip)
@PostMapping("/accept_sames_chain_quantity")
public RestResult<Statistics> getAcceptSamesChainQuantity(RangeStatsQueryDTO queryDTO) {
return success(statsService.getAcceptSamesChainQuantity(queryDTO));
}
@ApiOperation("获取项目委托量同比环比数据")
@Login(action = Action.Skip)
@PostMapping("/item_sames_chain_quantity")
public RestResult<Statistics> getItemSamesChainQuantity(RangeStatsQueryDTO queryDTO) {
return success(statsService.getItemSamesChainQuantity(queryDTO));
}
@ApiOperation("获取外检完成量数据")
@PostMapping("/out_test_finish_quantity")
public RestResult<Statistics> getOutTestFinishQuantity(QueryDTO queryDTO) {
return success(statsService.getOutTestFinishQuantity(queryDTO));
......@@ -80,6 +143,20 @@ public class StatisticsController extends ServiceController {
return success(statsService.getCurWeekAcceptanceQualified(queryDTO));
}
@ApiOperation("上周验收合格情况")
@Login(action = Action.Skip)
@PostMapping("/prev_week_acceptance_qualified")
public RestResult<List<Statistics>> getPrevWeekAcceptanceQualified(QueryDTO queryDTO) {
return success(statsService.getPrevWeekAcceptanceQualified(queryDTO));
}
@ApiOperation("获取某个时间段验收合格情况")
@Login(action = Action.Skip)
@PostMapping("/frame_acceptance_qualified")
public RestResult<Statistics> getFrameAcceptanceQualified(QueryDTO queryDTO) {
return success(statsService.getAcceptanceQualifiedByTimeFrame(queryDTO));
}
@ApiOperation("本周自产炭块质量统计")
@PostMapping("/cur_week_carbon_blocks")
public RestResult<List<Statistics>> getCurWeekCarbonBlocks(QueryDTO queryDTO) {
......@@ -92,6 +169,14 @@ public class StatisticsController extends ServiceController {
return success(statsService.getAlBrandsRate(queryDTO));
}
@ApiOperation("昨日原铝质量统计")
@Login(action = Action.Skip)
@PostMapping("/prev_al_brands_rate")
public RestResult<List<Statistics>> getPrevAlBrandsRate(QueryDTO queryDTO) {
queryDTO.setQueryDate(DateUtils.dateAddDays(new Date(), -1));
return success(statsService.getPrevAlBrandsRate(queryDTO));
}
@ApiOperation("原铝品味台账")
@PostMapping("/al_grade_ledger")
public RestResult<List<Map>> getAlGradeLedger(LedgerQueryDTO ledgerQueryDTO) {
......@@ -129,4 +214,10 @@ public class StatisticsController extends ServiceController {
return success(statsService.getSummaryLedgerStats(ledgerQueryDTO));
}
@ApiOperation("获取检测项目委托量统计数据")
@Login(action = Action.Skip)
@PostMapping("/test_item_quantity_stats")
public RestResult<Statistics> getTestItemQuantityStats(QueryDTO queryDTO) {
return success(statsService.getTestItemQuantityStats(queryDTO));
}
}
......@@ -16,6 +16,19 @@ import java.util.List;
*/
public interface NoticeAnnouncementMapper extends BatchMapper<NoticeAnnouncement> {
/* 最近的count条数据 */
/**
* 最近的count条数据 .
*
* @param count the count
* @return the list
*/
List<NoticeAnnouncement> recent(@Param("count") Integer count);
/**
* Select last notices list.
*
* @param limit the limit
* @return the list
*/
List<NoticeAnnouncement> selectLatestNotices(@Param("limit") Integer limit);
}
......@@ -13,26 +13,52 @@ import java.util.List;
public interface StatisticsMapper extends BatchMapper<Statistics> {
@SqlParser(filter = true)
List<Statistics> selectAlBrandsRateStats(@Param("vo") QueryDTO dto);
@SqlParser(filter = true)
Integer selectAlBrandLowFeStats(@Param("vo") QueryDTO dto);
@SqlParser(filter = true)
Statistics selectOutTestFinishQuantity(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
List<Statistics> selectCurWeekCarbonBlocks(@Param("vo") QueryDTO queryDTO);
List<Statistics> selectCurWeekAcceptanceQualified(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
List<Statistics> selectAcceptanceQualifiedByDate (@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
Statistics selectAcceptanceQualifiedByTimeFrame(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
Statistics selectWorkloadQuantity(@Param("vo") RangeStatsQueryDTO workloadStatsQueryDTO);
@SqlParser(filter = true)
List<Statistics> selectOutTestItemQuantity(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
List<Statistics> selectSamplingQuantity(@Param("vo") RangeStatsQueryDTO queryDTO);
@SqlParser(filter = true)
Integer selectTotalSamplingQuantity(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
Integer selectAlProductInspectionQuantity(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
List<Statistics> selectItemQuantity(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
List<Statistics> selectReportSendQuantityMonth(@Param("vo") RangeStatsQueryDTO queryDTO);
Statistics selectReportSendQuantity(@Param("vo") RangeStatsQueryDTO queryDTO);
@SqlParser(filter = true)
Statistics selectReportSendQuantitySamesChain(@Param("vo") RangeStatsQueryDTO queryDTO);
@SqlParser(filter = true)
Integer selectReportSendQuantityTotal(@Param("vo") RangeStatsQueryDTO queryDTO);
@SqlParser(filter = true)
List<Statistics> selectEntrustedQuantity(QueryDTO queryDTO);
@SqlParser(filter = true)
......@@ -50,4 +76,21 @@ public interface StatisticsMapper extends BatchMapper<Statistics> {
@SqlParser(filter = true)
List<DailyStatsLedgerVO> selectAlImpurityLedgerStats(@Param("vo") LedgerQueryDTO ledgerQueryDTO);
@SqlParser(filter = true)
Statistics selectTestItemQuantityStats(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
Statistics selectAcceptSamesChainQuantity(@Param("vo") RangeStatsQueryDTO queryDTO);
@SqlParser(filter = true)
Statistics selectItemSamesChainQuantity(@Param("vo") RangeStatsQueryDTO queryDTO);
@SqlParser(filter = true)
Integer selectAnodeInspectionQuantity(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
Statistics selectAnodeInspectionDoneQuantity(@Param("vo") QueryDTO queryDTO);
@SqlParser(filter = true)
Statistics selectAlProductInspectionQuantityRate(@Param("vo") QueryDTO queryDTO);
}
......@@ -21,4 +21,6 @@ public interface INoticeAnnouncementService extends IBaseService<NoticeAnnouncem
boolean updateAndRecord(NoticeAnnouncement noticeAnnouncement);
List<NoticeAnnouncement> recent(Integer count);
List<NoticeAnnouncement> latestNotices(Integer limit);
}
......@@ -15,16 +15,26 @@ public interface IStatisticsService extends IBaseService<Statistics> {
*/
List<Statistics> getAlBrandsRate(QueryDTO queryDTO);
List<Statistics> getPrevAlBrandsRate(QueryDTO queryDTO);
List<Statistics> getEntrustedQuantity(QueryDTO queryDTO);
List<Statistics> getAnodeInspectionQuantity(QueryDTO queryDTO);
Integer getAnodeInspectionQuantity(QueryDTO queryDTO);
Statistics getAnodeInspectionDoneQuantity(QueryDTO queryDTO);
Map<String, Object> getReportSendQuantity(RangeStatsQueryDTO queryDTO);
Map<String, Object> getMonthReportSendQuantity(RangeStatsQueryDTO queryDTO);
Statistics getSamesChainReportSendQuantity(RangeStatsQueryDTO queryDTO);
List<Statistics> getItemQuantity(QueryDTO queryDTO);
List<Statistics> getSamplingQuantity(RangeStatsQueryDTO queryDTO);
Statistics getItemSamesChainQuantity(RangeStatsQueryDTO queryDTO);
Statistics getOutTestFinishQuantity(QueryDTO queryDTO);
List<Statistics> getOutTestItemQuantity(QueryDTO queryDTO);
......@@ -33,6 +43,10 @@ public interface IStatisticsService extends IBaseService<Statistics> {
List<Statistics> getCurWeekAcceptanceQualified(QueryDTO queryDTO);
List<Statistics> getPrevWeekAcceptanceQualified(QueryDTO queryDTO);
Statistics getAcceptanceQualifiedByTimeFrame(QueryDTO queryDTO);
List<Statistics> getCurWeekCarbonBlocks(QueryDTO queryDTO);
List<Map> getAlGradeLedger(LedgerQueryDTO ledgerQueryDTO);
......@@ -47,4 +61,13 @@ public interface IStatisticsService extends IBaseService<Statistics> {
List<Map> getSummaryLedgerStats(LedgerQueryDTO ledgerQueryDTO);
Statistics getTestItemQuantityStats(QueryDTO queryDTO);
Statistics getAcceptSamesChainQuantity(RangeStatsQueryDTO queryDTO);
Integer getTotalSamplingQuantity(QueryDTO queryDTO);
Integer getAlProductInspectionQuantity(QueryDTO queryDTO);
Statistics getAlProductInspectionQuantityRate(QueryDTO queryDTO);
}
......@@ -60,7 +60,6 @@ public class NoticeAnnouncementServiceImpl extends BaseServiceImpl<NoticeAnnounc
}
/**
*
* @param count 查询最近修改的几条数据
* @return
*/
......@@ -68,4 +67,10 @@ public class NoticeAnnouncementServiceImpl extends BaseServiceImpl<NoticeAnnounc
public List<NoticeAnnouncement> recent(Integer count) {
return baseMapper.recent(count);
}
@Override
public List<NoticeAnnouncement> latestNotices(Integer limit) {
limit = null == limit ? 2 : limit;
return baseMapper.selectLatestNotices(limit);
}
}
......@@ -3,6 +3,7 @@ package com.patzn.cloud.service.lims.hmhj.service.impl;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.patzn.cloud.commons.api.RestAssert;
import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
import com.patzn.cloud.commons.toolkit.BigDecimalUtils;
import com.patzn.cloud.service.hmhj.dto.LedgerQueryDTO;
import com.patzn.cloud.service.hmhj.dto.QueryDTO;
import com.patzn.cloud.service.hmhj.dto.RangeStatsQueryDTO;
......@@ -15,6 +16,7 @@ import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
......@@ -46,11 +48,7 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
private void handleQueryTimeRange(RangeStatsQueryDTO queryDTO) {
handleQueryTime(queryDTO);
queryDTO.setLastYearTimeS(DateUtils.addYears(queryDTO.getTimeS(), -1));
queryDTO.setLastYearTimeE(DateUtils.addYears(queryDTO.getTimeE(), -1));
Integer days = DateKit.monthsBetweenTwoDates(queryDTO.getTimeS(), queryDTO.getTimeE());
queryDTO.setPrevTimeS(DateUtils.addDays(queryDTO.getTimeS(), -days));
queryDTO.setPrevTimeE(queryDTO.getTimeS());
handleTimeRange(queryDTO);
}
private List<Statistics> handleMonthData(QueryDTO queryDTO, List<Statistics> statistics) {
......@@ -82,10 +80,37 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
@Override
public List<Statistics> getAlBrandsRate(QueryDTO queryDTO) {
if (null == queryDTO.getQueryDate()) {
queryDTO.setQueryDate(new Date());
}
return baseMapper.selectAlBrandsRateStats(queryDTO);
}
@Override
public List<Statistics> getPrevAlBrandsRate(QueryDTO queryDTO) {
List<Statistics> statistics = getAlBrandsRate(queryDTO);
if (CollectionUtils.isEmpty(statistics)) {
return statistics;
}
queryDTO.setType("Al99.70");
Integer total = statistics.get(0).getTotal();
Integer num = baseMapper.selectAlBrandLowFeStats(queryDTO);
num = null == num ? 0 : num;
Statistics lowFe = new Statistics();
lowFe.setBrand(queryDTO.getType() + "低铁");
lowFe.setTotal(total);
lowFe.setBrandNum(num);
if (null == total || 0 == total) {
lowFe.setRatio(0.0000);
} else {
double def = 1.0000;
lowFe.setRatio(BigDecimalUtils.div(new BigDecimal(def * num), new BigDecimal(def * total), 4).doubleValue());
}
statistics.add(lowFe);
return statistics;
}
@Override
public List<Statistics> getEntrustedQuantity(QueryDTO queryDTO) {
handleQueryTime(queryDTO);
List<String> sampleNameList = Arrays.asList("电解质", "硅铁", "磷铁", "锰铁", "水", "纯铝", "铝合金", "石灰石");
......@@ -113,8 +138,13 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
}
@Override
public List<Statistics> getAnodeInspectionQuantity(QueryDTO queryDTO) {
return null;
public Integer getAnodeInspectionQuantity(QueryDTO queryDTO) {
return baseMapper.selectAnodeInspectionQuantity(queryDTO);
}
@Override
public Statistics getAnodeInspectionDoneQuantity(QueryDTO queryDTO){
return baseMapper.selectAnodeInspectionDoneQuantity(queryDTO);
}
@Override
......@@ -124,12 +154,29 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
List<Statistics> monthList = baseMapper.selectReportSendQuantityMonth(queryDTO);
monthList = handleMonthData(queryDTO, monthList);
result.put("monthList", monthList);
Statistics statistics = baseMapper.selectReportSendQuantity(queryDTO);
Statistics statistics = baseMapper.selectReportSendQuantitySamesChain(queryDTO);
result.put("statsData", statistics);
return result;
}
@Override
public Map<String, Object> getMonthReportSendQuantity(RangeStatsQueryDTO queryDTO) {
handleQueryTimeRange(queryDTO);
Map<String, Object> result = new HashMap<>();
List<Statistics> monthList = baseMapper.selectReportSendQuantityMonth(queryDTO);
monthList = handleMonthData(queryDTO, monthList);
result.put("total", baseMapper.selectReportSendQuantityTotal(queryDTO));
result.put("monthList", monthList);
return result;
}
@Override
public Statistics getSamesChainReportSendQuantity(RangeStatsQueryDTO queryDTO) {
handleSamesChainTimeRange(queryDTO);
return baseMapper.selectReportSendQuantitySamesChain(queryDTO);
}
@Override
public List<Statistics> getItemQuantity(QueryDTO queryDTO) {
handleQueryTime(queryDTO);
return baseMapper.selectItemQuantity(queryDTO);
......@@ -142,6 +189,54 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
}
@Override
public Statistics getAcceptSamesChainQuantity(RangeStatsQueryDTO queryDTO) {
handleSamesChainTimeRange(queryDTO);
return baseMapper.selectAcceptSamesChainQuantity(queryDTO);
}
@Override
public Integer getTotalSamplingQuantity(QueryDTO queryDTO) {
return baseMapper.selectTotalSamplingQuantity(queryDTO);
}
@Override
public Integer getAlProductInspectionQuantity(QueryDTO queryDTO) {
return baseMapper.selectAlProductInspectionQuantity(queryDTO);
}
@Override
public Statistics getAlProductInspectionQuantityRate(QueryDTO queryDTO) {
return baseMapper.selectAlProductInspectionQuantityRate(queryDTO);
}
@Override
public Statistics getItemSamesChainQuantity(RangeStatsQueryDTO queryDTO) {
handleSamesChainTimeRange(queryDTO);
return baseMapper.selectItemSamesChainQuantity(queryDTO);
}
private void handleSamesChainTimeRange(RangeStatsQueryDTO queryDTO) {
RestAssert.fail(Objects.isNull(queryDTO.getQueryDate()), "查询日期不能为空!");
String queryDateStr = com.patzn.cloud.commons.toolkit.DateUtils.toYearMonthDay(queryDTO.getQueryDate());
queryDTO.setTimeS(com.patzn.cloud.commons.toolkit.DateUtils.getYearMonthStart(queryDateStr));
queryDTO.setTimeE(com.patzn.cloud.commons.toolkit.DateUtils.getYearMonthEnd(queryDateStr));
handleTimeRange(queryDTO);
}
/**
* 根据当前时间区域,处理其他时间区域
*
* @param queryDTO
*/
private void handleTimeRange(RangeStatsQueryDTO queryDTO) {
queryDTO.setLastYearTimeS(DateUtils.addYears(queryDTO.getTimeS(), -1));
queryDTO.setLastYearTimeE(DateUtils.addYears(queryDTO.getTimeE(), -1));
Integer days = DateKit.monthsBetweenTwoDates(queryDTO.getTimeS(), queryDTO.getTimeE());
queryDTO.setPrevTimeS(DateUtils.addDays(queryDTO.getTimeS(), -days));
queryDTO.setPrevTimeE(queryDTO.getTimeS());
}
@Override
public Statistics getOutTestFinishQuantity(QueryDTO queryDTO) {
handleQueryTime(queryDTO);
return baseMapper.selectOutTestFinishQuantity(queryDTO);
......@@ -163,7 +258,23 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
@Override
public List<Statistics> getCurWeekAcceptanceQualified(QueryDTO queryDTO) {
return baseMapper.selectCurWeekAcceptanceQualified(queryDTO);
// 由于map.xml文件中是取上一周的数据
// 默认查询的话,查询本周的数据,需要天数+7
if (null == queryDTO.getQueryDate()) {
queryDTO.setQueryDate(DateUtils.addDays(new Date(), 7));
}
return baseMapper.selectAcceptanceQualifiedByDate(queryDTO);
}
@Override
public List<Statistics> getPrevWeekAcceptanceQualified(QueryDTO queryDTO) {
queryDTO.setQueryDate(new Date());
return baseMapper.selectAcceptanceQualifiedByDate(queryDTO);
}
@Override
public Statistics getAcceptanceQualifiedByTimeFrame(QueryDTO queryDTO) {
return baseMapper.selectAcceptanceQualifiedByTimeFrame(queryDTO);
}
@Override
......@@ -269,6 +380,11 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
return null;
}
@Override
public Statistics getTestItemQuantityStats(QueryDTO queryDTO) {
return baseMapper.selectTestItemQuantityStats(queryDTO);
}
private String getDataLabel(String label, List<String> names) {
if (StringUtils.isBlank(label) || CollectionUtils.isEmpty(names) || null == names.get(0)) {
return label;
......
......@@ -8,4 +8,16 @@
ORDER BY ltime DESC
LIMIT #{count}
</select>
<!--查询最新发布的 N 条数据-->
<select id="selectLatestNotices" resultType="com.patzn.cloud.service.hmhj.entity.NoticeAnnouncement">
SELECT
na."content",
na.creator,
na.ctime
FROM
notice_announcement na
ORDER BY
na.ctime DESC
LIMIT #{limit}
</select>
</mapper>
......@@ -3,39 +3,121 @@
<mapper namespace="com.patzn.cloud.service.lims.hmhj.mapper.StatisticsMapper">
<!--当日原铝质量统计-->
<select id="selectAlBrandsRateStats" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT s.sample_grading "brand",
A.total,
count(1) "brand_num",
round(count(1)::numeric / a.total_num, 2) "ratio"
FROM entrust_sample s,
(
SELECT COUNT(1) "total"
FROM entrust_sample s
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(now(), 'yyyy-MM-dd')
) A
WHERE s.deleted = 0
AND s.type = 0
with total as (
SELECT
COUNT(1) "total"
FROM
entrust_sample s
JOIN entrust e ON s.entrust_id = e.ID AND e.deleted = 0
WHERE
s.deleted = 0
AND s.TYPE = 0
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(#{vo.queryDate}::TIMESTAMP, 'yyyy-MM-dd')
)
SELECT
s.sample_grading "brand",
total,
count(1) "brand_num",
round(count(1)::numeric / total, 4) "ratio"
FROM
entrust_sample s,total, entrust e
WHERE
s.entrust_id = e.id and s.deleted = 0 and e.deleted = 0
AND s.TYPE = 0 and s.name = '原铝'
AND s.sample_grading IS NOT NULL
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(now(), 'yyyy-MM-dd')
GROUP BY A.total,
s.sample_grading
ORDER BY s.sample_grading DESC
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(#{vo.queryDate}::TIMESTAMP, 'yyyy-MM-dd')
GROUP BY s.sample_grading, total
order by s.sample_grading DESC
</select>
<!--查询原铝某一牌号低铁-->
<select id="selectAlBrandLowFeStats" resultType="java.lang.Integer">
SELECT
count(distinct(case when to_number(ii.test_value, '99.9999') &lt;= 0.1 then s.id else null end)) "num"
FROM
entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
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
WHERE
s.deleted = 0 and s.name = '原铝' and s.type = 0 and s.sample_grading = #{vo.type} and ii.NAME = '原铝Fe'
AND to_char(s.judge_time, 'yyyy-MM-dd') = to_char(#{vo.queryDate}, 'yyyy-MM-dd')
</select>
<!--外委完成量统计-->
<!--外委完成量统计(获取外检完成量数据): 获取LIMS平台某段时间的外检数据总数量和已检测数量-->
<select id="selectOutTestFinishQuantity" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT count(distinct c.id) "total",
sum(case when s.status = 70 and s.judge_status = 2 then 1 else 0 end) "done_num"
FROM contract_sample c,
entrust_sample s
WHERE c.deleted = 0
and s.deleted = 0
and c.id = s.contract_sample_id
and c.type = 1
FROM contract_sample c
JOIN entrust_sample s on c.id = s.contract_sample_id
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE c.deleted = 0 and c.type = 1 AND s.type = 0
<if test="null != vo.timeS">
AND e.entrust_time >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND e.entrust_time &lt;= #{vo.timeE}
</if>
</select>
<!--获取阳极检查量: 获取LIMS平台某段时间的阳极检查总数量-->
<select id="selectAnodeInspectionQuantity" resultType="java.lang.Integer">
select
count(1) "total"
from
entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
where
s.deleted = 0
and s.name = '自产阳极炭块'
<if test="null != vo.timeS">
AND e.entrust_time >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND e.entrust_time &lt;= #{vo.timeE}
</if>
</select>
<!--获取阳极检查量合格率:获取LIMS平台某段时间的阳极检查合格数量以及不合格数量数据-->
<select id="selectAnodeInspectionDoneQuantity" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT
sum(case when s.ok_judge = '合格' then 1 else 0 end) "done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
<if test="null != vo.timeS">
AND e.entrust_time >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND e.entrust_time &lt;= #{vo.timeE}
</if>
</select>
<!--获取铝成品检查量合格率数据: 获取LIMS平台某段时间内的铝成品检查合格数量及不合格数量-->
<select id="selectAlProductInspectionQuantityRate" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT
sum(case when s.ok_judge = '合格' then 1 else 0 end) "done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0 and s.name = '铝成品'
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
<if test="null != vo.timeS">
AND e.entrust_time >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND e.entrust_time &lt;= #{vo.timeE}
</if>
</select>
<!--本周自产炭块质量统计-->
......@@ -49,6 +131,7 @@
(
SELECT COUNT(1) "total"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
......@@ -67,23 +150,44 @@
ORDER BY s.sample_grading DESC
</select>
<!--周验收合格情况-->
<select id="selectCurWeekAcceptanceQualified" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
<!--周验收合格情况-->
<select id="selectAcceptanceQualifiedByDate" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT to_char(s.judge_time, 'yyyy-MM-dd') "occur_date",
sum(case when s.ok_judge = '合格' then 1 else 0 end) "done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
AND EXTRACT(YEAR FROM s.judge_time) = EXTRACT(YEAR FROM NOW())
AND EXTRACT(WEEK FROM s.judge_time) = EXTRACT(WEEK FROM NOW())
AND s.judge_time >= DATE_TRUNC('week', #{vo.queryDate}::TIMESTAMP) - interval '7 day'
AND s.judge_time &lt; DATE_TRUNC('week', #{vo.queryDate}::TIMESTAMP)
GROUP BY to_char(s.judge_time, 'yyyy-MM-dd')
ORDER BY to_char(s.judge_time, 'yyyy-MM-dd') ASC
</select>
<!--获取验收合格率数据: 获取LIMS平台某段时间的验收合格数量和验收不合格数量-->
<select id="selectAcceptanceQualifiedByTimeFrame" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT
sum(case when s.ok_judge = '合格' then 1 else 0 end) "done_num",
sum(case when s.ok_judge = '不合格' then 1 else 0 end) "fail_num"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0
AND s.type = 0
AND s.sample_grading IS NOT NULL
AND s.status = 70
AND s.judge_status = 2
<if test="null != vo.timeS">
AND s.judge_time >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND s.judge_time &lt;= #{vo.timeE}
</if>
</select>
<!--工作量统计-->
<select id="selectWorkloadQuantity" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT a.*,
......@@ -98,11 +202,9 @@
round((count(1) - sum(case when s.ok_judge = '合格' then 1 else 0 end)):: NUMERIC / count(1),
2) "fail_ratio"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id
join entrust_report r on r.entrust_id = e.id
join entrust e on e.id = s.entrust_id and e.deleted = 0
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE s.deleted = 0
and e.deleted = 0
and r.deleted = 0
AND s.status = 70
AND s.judge_status = 2
AND s.type = 0
......@@ -110,11 +212,9 @@
) a,
(SELECT count(r.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id
join entrust_report r on r.entrust_id = e.id
join entrust e on e.id = s.entrust_id and e.deleted = 0
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE s.deleted = 0
and e.deleted = 0
and r.deleted = 0
AND s.status = 70
AND s.judge_status = 2
AND s.type = 0
......@@ -122,11 +222,9 @@
) b,
(SELECT count(r.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id
join entrust_report r on r.entrust_id = e.id
join entrust e on e.id = s.entrust_id and e.deleted = 0
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE s.deleted = 0
and e.deleted = 0
and r.deleted = 0
AND s.status = 70
AND s.judge_status = 2
AND s.type = 0
......@@ -167,27 +265,112 @@
(case when 0 = c.total then 1 else c.total end), 2) "sames_ratio"
from (SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id
WHERE s.deleted = 0
and e.deleted = 0
AND s.type = 0
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id
WHERE s.deleted = 0
and e.deleted = 0
AND s.type = 0
AND s.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id
WHERE s.deleted = 0
and e.deleted = 0
AND s.type = 0
AND s.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
<!--获取取样量统计数据: 获取LIMS平台某段时间的质检取样量总数量-->
<select id="selectTotalSamplingQuantity" resultType="java.lang.Integer">
SELECT
count(s.id) "total"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
<if test="null != vo.timeS">
AND e.entrust_time >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND e.entrust_time &lt;= #{vo.timeE}
</if>
</select>
<!--获取铝成品检查数量: 获取LIMS平台某段时间的铝成品检查数量-->
<select id="selectAlProductInspectionQuantity" resultType="java.lang.Integer">
SELECT
count(s.id) "total"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0 and s.name = '铝成品'
<if test="null != vo.timeS">
AND e.entrust_time >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND e.entrust_time &lt;= #{vo.timeE}
</if>
</select>
<!--获取验收工作量同比环比数据:获取工作量的同比环比数据-->
<select id="selectAcceptSamesChainQuantity" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT a.*,
b.total "sames_num",
c.total "chain_num",
round((case when 0 = b.total then 0 else a.total - b.total end)::numeric /
(case when 0 = b.total then 1 else b.total end), 2) "chain_ratio",
round((case when 0 = c.total then 0 else a.total - c.total end)::numeric /
(case when 0 = c.total then 1 else c.total end), 2) "sames_ratio"
from (SELECT count(s.id) "total"
FROM entrust_sample s
JOIN entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(s.id) "total"
FROM entrust_sample s
join entrust e on e.id = s.entrust_id and e.deleted = 0
WHERE s.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
<!--获取项目委托量同比环比数据:获取项目委托量的同比环比数量-->
<select id="selectItemSamesChainQuantity" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT a.*,
b.total "sames_num",
c.total "chain_num",
round((case when 0 = b.total then 0 else a.total - b.total end)::numeric /
(case when 0 = b.total then 1 else b.total end), 2) "chain_ratio",
round((case when 0 = c.total then 0 else a.total - c.total end)::numeric /
(case when 0 = c.total then 1 else c.total end), 2) "sames_ratio"
from (SELECT count(i.id) "total"
FROM entrust_sample_item i
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(i.id) "total"
FROM entrust_sample_item i
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(i.id) "total"
FROM entrust_sample_item i
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
JOIN entrust e on e.id = i.entrust_id and e.deleted = 0
WHERE i.deleted = 0 AND s.type = 0
AND e.entrust_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
......@@ -212,24 +395,28 @@
<!--报告发放量统计A-->
<select id="selectReportSendQuantityMonth" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT
to_char(r.report_check_time,'yyyy-MM') "occur_date",
count(r.id) "done_num"
FROM
entrust e
join entrust_report r on r.entrust_id = e.id
WHERE
e.deleted = 0 and r.deleted = 0 AND s.type = 0 and r.status = 50
<if test="null != vo.timeS and null != vo.timeE">
AND r.report_check_time between #{vo.timeS} and #{vo.timeE}
</if>
GROUP BY
to_char(r.report_check_time,'yyyy-MM')
ORDER BY
to_char(r.report_check_time,'yyyy-MM') ASC
select
t.occur_date,
count(t.id) "done_num"
from
(select
to_char(r.report_check_time, 'yyyy-MM') "occur_date",
r.id
from
entrust e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
where e.deleted = 0 and r.status = 50
<if test="null != vo.timeS and null != vo.timeE">
AND (r.report_check_time between #{vo.timeS} and #{vo.timeE})
</if>
) t
group by
t.occur_date
order by
t.occur_date asc
</select>
<!--报告发放量统计B-->
<select id="selectReportSendQuantity" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
<select id="selectReportSendQuantitySamesChain" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
SELECT a.*,
b.total "sames_num",
c.total "chain_num",
......@@ -239,26 +426,35 @@
(case when 0 = c.total then 1 else c.total end), 2) "sames_ratio"
from (SELECT count(r.id) "total"
FROM entrust e
join entrust_report r on r.entrust_id = e.id
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE e.deleted = 0
and r.deleted = 0
AND r.report_check_time between #{vo.timeS} and #{vo.timeE}
) a,
(SELECT count(r.id) "total"
FROM entrust e
join entrust_report r on r.entrust_id = e.id
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE e.deleted = 0
and r.deleted = 0
AND r.report_check_time between #{vo.lastYearTimeS} and #{vo.lastYearTimeE}
) b,
(SELECT count(r.id) "total"
FROM entrust e
join entrust_report r on r.entrust_id = e.id
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
WHERE e.deleted = 0
and r.deleted = 0
AND r.report_check_time between #{vo.prevTimeS} and #{vo.prevTimeE}
AND r.report_check_time between #{vo.prevTimeS} and #{vo.prevTimeE}
) c
</select>
<!--报告发放量统计C-->
<select id="selectReportSendQuantityTotal" resultType="java.lang.Integer">
select
count(r.id) "total"
from
entrust e
join entrust_report r on r.entrust_id = e.id and r.deleted = 0
where e.deleted = 0 and r.status = 50
<if test="null != vo.timeS and null != vo.timeE">
AND (r.report_check_time between #{vo.timeS} and #{vo.timeE})
</if>
</select>
<!--化验委托量统计-->
<select id="selectEntrustedQuantity" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
......@@ -506,5 +702,26 @@
to_char( i.test_time, 'yyyy-mm-dd' )
) T order by t.name, sn, label, day
</select>
<!--获取检测项目委托量统计数据: 获取LIMS平台某段时间的检测项目委托总数量-->
<select id="selectTestItemQuantityStats" resultType="com.patzn.cloud.service.hmhj.entity.Statistics">
select
COUNT(i.ID) "total"
from
entrust_sample_item i
join entrust_sample s on
s.id = i.entrust_sample_id
and s.deleted = 0
join entrust e on
e.ID = i.entrust_id
and e.deleted = 0
where
i.deleted = 0 and s.type = 0
<if test="null != vo.timeS">
AND e.ctime >= #{vo.timeS}
</if>
<if test="null != vo.timeE">
AND e.ctime &lt;= #{vo.timeE}
</if>
</select>
</mapper>
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