|
@@ -2,6 +2,7 @@ package com.fjhx.service.quality.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -28,6 +29,7 @@ import com.fjhx.service.water.WaterBatchService;
|
|
|
import com.fjhx.service.water.WaterTagService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.BigDecimalUtil;
|
|
|
+import com.fjhx.utils.UserClientUtil;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.utils.ThreadUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -278,12 +280,13 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
}
|
|
|
|
|
|
qualityTesting.setCompleteStatus(StatusConstant.YES);
|
|
|
+ qualityTesting.setCheckUserId(AuthUtil.getUserId());
|
|
|
qualityTesting.setCheckTime(date);
|
|
|
qualityTesting.setCheckQuantity(checkQuantity);
|
|
|
qualityTesting.setCheckArea(checkQuantity.multiply(width).divide(new BigDecimal(100), RoundingMode.HALF_UP));
|
|
|
qualityTesting.setCheckJudgment(checkJudgment);
|
|
|
qualityTesting.setAdjustRate(lakeNumSum.divide(checkQuantity, RoundingMode.HALF_UP));
|
|
|
- qualityTesting.setCheckInvalidRatio(getCheckInvalidRatio(qualityTesting.getCreateTime()));
|
|
|
+ qualityTesting.setCheckInvalidRatio(getCheckInvalidRatio(date, qualityTesting.getCreateTime()));
|
|
|
updateById(qualityTesting);
|
|
|
|
|
|
// 同批次其他标签改为无需质检
|
|
@@ -303,6 +306,51 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> recordStatistics(Condition condition) {
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query();
|
|
|
+ creationTimeCondition(wrapper, condition);
|
|
|
+ wrapper.eq("qt.complete_status", StatusConstant.YES)
|
|
|
+ .eq("qt.del_flag", StatusConstant.NOT_DELETED);
|
|
|
+
|
|
|
+ return baseMapper.recordStatistics(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> recordPage(Condition condition) {
|
|
|
+ Integer completeStatus = condition.getInt("completeStatus");
|
|
|
+ Long checkUserId = condition.getLong("checkUserId");
|
|
|
+ String keyword = condition.getKeyword();
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query();
|
|
|
+
|
|
|
+ creationTimeCondition(wrapper, condition);
|
|
|
+
|
|
|
+ wrapper.eq("qt.del_flag", StatusConstant.NOT_DELETED)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(completeStatus), "qt.complete_status", completeStatus)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(checkUserId), "qt.check_user_id", checkUserId)
|
|
|
+ .and(ObjectUtil.isNotEmpty(keyword), q -> q
|
|
|
+ .like("wb.contract_code", keyword).or()
|
|
|
+ .like("m.code", keyword).or()
|
|
|
+ .like("m.name", keyword));
|
|
|
+
|
|
|
+ Page<Map<String, Object>> page = baseMapper.recordPage(condition.getPage(), wrapper);
|
|
|
+ List<Map<String, Object>> records = page.getRecords();
|
|
|
+ if (records.size() == 0) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, String> userMap = UserClientUtil.getUserNameMapFunctionLong(records,
|
|
|
+ item -> Convert.toLong(item.get("checkUserId")));
|
|
|
+
|
|
|
+
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ record.put("checkUserName", userMap.get(Convert.toLong(record.get("checkUserId"))));
|
|
|
+ }
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
private static String getCode() {
|
|
|
ThreadUtil.sleep(1);
|
|
|
return "TP-" + DateUtil.format(new Date(), "yyMMdd-HHmmss-SSS");
|
|
@@ -311,8 +359,8 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
/**
|
|
|
* 计算质检及时率
|
|
|
*/
|
|
|
- private Integer getCheckInvalidRatio(Date createTime) {
|
|
|
- long day = DateUtil.betweenDay(createTime, new Date(), false);
|
|
|
+ private Integer getCheckInvalidRatio(Date date, Date createTime) {
|
|
|
+ long day = DateUtil.betweenDay(createTime, date, false);
|
|
|
|
|
|
if (day <= 3) {
|
|
|
return 100;
|
|
@@ -321,4 +369,14 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
return Math.max(Convert.toInt(100 - (day - 3) * 5), 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建时间条件
|
|
|
+ */
|
|
|
+ private void creationTimeCondition(QueryWrapper<Object> wrapper, Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+
|
|
|
+ wrapper.between(ObjectUtil.isAllNotEmpty(beginTime, endTime), "qt.create_time", beginTime, endTime);
|
|
|
+ }
|
|
|
+
|
|
|
}
|