|
@@ -0,0 +1,156 @@
|
|
|
+package com.rongwei.bscommon.sys.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.rongwei.bscommon.sys.service.ZhcxReprotSameDayRealTimeInspectionStatisticsLocationService;
|
|
|
+import com.rongwei.bsentity.domain.ZhcxReprotSameDayRealTimeInspectionStatisticsDo;
|
|
|
+import com.rongwei.bscommon.sys.dao.ZhcxReprotSameDayRealTimeInspectionStatisticsDao;
|
|
|
+import com.rongwei.bscommon.sys.service.ZhcxReprotSameDayRealTimeInspectionStatisticsService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.rongwei.bsentity.domain.ZhcxReprotSameDayRealTimeInspectionStatisticsLocationDo;
|
|
|
+import com.rongwei.bsentity.vo.report.SameDayRealTimeInspectionVo;
|
|
|
+import com.rongwei.commonservice.service.dao.CommonSqlDao;
|
|
|
+import com.rongwei.rwadmincommon.system.dao.CommonDao;
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 报表管理-当日全项目实时报验统计 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author wm
|
|
|
+ * @since 2024-01-29
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ZhcxReprotSameDayRealTimeInspectionStatisticsServiceImpl extends ServiceImpl<ZhcxReprotSameDayRealTimeInspectionStatisticsDao, ZhcxReprotSameDayRealTimeInspectionStatisticsDo> implements ZhcxReprotSameDayRealTimeInspectionStatisticsService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxReprotSameDayRealTimeInspectionStatisticsDao dao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxReprotSameDayRealTimeInspectionStatisticsLocationService locationService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成统计
|
|
|
+ * 查询前一小时数据,并做数据统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void genStatistics() {
|
|
|
+
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ //前一小时开始时间
|
|
|
+ calendar.add(Calendar.HOUR_OF_DAY, -1);;
|
|
|
+ calendar.set(Calendar.MINUTE, 0);
|
|
|
+ calendar.set(Calendar.SECOND, 0);
|
|
|
+ calendar.set(Calendar.MILLISECOND, 0);
|
|
|
+ String startTime = dateFormat.format(calendar.getTime());
|
|
|
+
|
|
|
+ //统计时间
|
|
|
+ Date statisticsTime = calendar.getTime();
|
|
|
+
|
|
|
+ //前一小时结束时间
|
|
|
+ calendar.add(Calendar.HOUR_OF_DAY, 1);
|
|
|
+ calendar.add(Calendar.MILLISECOND, -1);
|
|
|
+ String endTime = dateFormat.format(calendar.getTime());
|
|
|
+
|
|
|
+ //前一小时报验单
|
|
|
+ List<SameDayRealTimeInspectionVo> inspetionList = dao.getInspetion(startTime, endTime);
|
|
|
+
|
|
|
+ //数据处理
|
|
|
+ analysisDataData(inspetionList, statisticsTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据处理
|
|
|
+ *
|
|
|
+ * @param inspetionList
|
|
|
+ * @param statisticsTime
|
|
|
+ */
|
|
|
+ private void analysisDataData(List<SameDayRealTimeInspectionVo> inspetionList, Date statisticsTime) {
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(inspetionList)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ ZhcxReprotSameDayRealTimeInspectionStatisticsDo mainEntity = ZhcxReprotSameDayRealTimeInspectionStatisticsDo.builder()
|
|
|
+ .statistictime(statisticsTime)
|
|
|
+ .statisticday(DateUtil.format(statisticsTime, "yyyy-MM-dd"))
|
|
|
+ .appliedqty(0)
|
|
|
+ .executedqty(0)
|
|
|
+ .tobeexecutedqty(0)
|
|
|
+ .receivedqty(0)
|
|
|
+ .conditionreceivedqty(0)
|
|
|
+ .rejectionqty(0)
|
|
|
+ .cancelqty(0)
|
|
|
+ .build();
|
|
|
+ mainEntity.setId(SecurityUtil.getUUID());
|
|
|
+
|
|
|
+ Map<String, ZhcxReprotSameDayRealTimeInspectionStatisticsLocationDo> map = new HashMap<>();
|
|
|
+
|
|
|
+ for(SameDayRealTimeInspectionVo row : inspetionList) {
|
|
|
+
|
|
|
+ ZhcxReprotSameDayRealTimeInspectionStatisticsLocationDo locationDo = map.get(row.getInspectioncontent());
|
|
|
+
|
|
|
+ if(ObjectUtil.isNull(locationDo)) {
|
|
|
+ locationDo = ZhcxReprotSameDayRealTimeInspectionStatisticsLocationDo.builder()
|
|
|
+ .statistictime(statisticsTime)
|
|
|
+ .statisticday(DateUtil.format(statisticsTime, "yyyy-MM-dd"))
|
|
|
+ .appliedqty(0)
|
|
|
+ .executedqty(0)
|
|
|
+ .id(SecurityUtil.getUUID())
|
|
|
+ .tobeexecutedqty(0)
|
|
|
+ .receivedqty(0)
|
|
|
+ .conditionreceivedqty(0)
|
|
|
+ .rejectionqty(0)
|
|
|
+ .cancelqty(0)
|
|
|
+ .statisticsid(mainEntity.getId())
|
|
|
+ .inspectioncontent(row.getInspectioncontent())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ //报验完成
|
|
|
+ if("30".equals(row.getInspectionstatus())) {
|
|
|
+ //接收
|
|
|
+ if("10".equals(row.getInspectionconclusion())) {
|
|
|
+ mainEntity.setReceivedqty(mainEntity.getReceivedqty() + 1);
|
|
|
+ locationDo.setReceivedqty(locationDo.getReceivedqty() + 1);
|
|
|
+ }
|
|
|
+ //拒收
|
|
|
+ else if("20".equals(row.getInspectionconclusion())) {
|
|
|
+ mainEntity.setRejectionqty(mainEntity.getRejectionqty() + 1);
|
|
|
+ locationDo.setRejectionqty(locationDo.getRejectionqty() + 1);
|
|
|
+ }
|
|
|
+ //有条件接收
|
|
|
+ else if("30".equals(row.getInspectionconclusion())) {
|
|
|
+ mainEntity.setConditionreceivedqty(mainEntity.getConditionreceivedqty() + 1);
|
|
|
+ locationDo.setConditionreceivedqty(locationDo.getConditionreceivedqty() + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //待报验
|
|
|
+ else if("20".equals(row.getInspectionstatus())) {
|
|
|
+ mainEntity.setTobeexecutedqty(mainEntity.getTobeexecutedqty() + 1);
|
|
|
+ locationDo.setTobeexecutedqty(locationDo.getTobeexecutedqty() + 1);
|
|
|
+ }
|
|
|
+ //取消
|
|
|
+ else if("40".equals(row.getInspectionstatus())) {
|
|
|
+ mainEntity.setCancelqty(mainEntity.getCancelqty() + 1);
|
|
|
+ locationDo.setCancelqty(locationDo.getCancelqty() + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put(row.getInspectioncontent(), locationDo);
|
|
|
+ }
|
|
|
+
|
|
|
+ save(mainEntity);
|
|
|
+ locationService.saveBatch(map.values());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|