|
@@ -15,9 +15,12 @@ import com.fjhx.entity.quality.QualityTestingDetails;
|
|
|
import com.fjhx.entity.water.WaterBatch;
|
|
|
import com.fjhx.entity.water.WaterTag;
|
|
|
import com.fjhx.enums.CheckJudgmentEnum;
|
|
|
+import com.fjhx.enums.CheckStatusEnum;
|
|
|
import com.fjhx.enums.PurchaseProgressEnum;
|
|
|
import com.fjhx.mapper.quality.QualityTestingMapper;
|
|
|
+import com.fjhx.service.contract.ContractService;
|
|
|
import com.fjhx.service.flow.CheckQuantityCorrectFlowService;
|
|
|
+import com.fjhx.service.flow.InspectionExemptionFlowService;
|
|
|
import com.fjhx.service.material.MaterialService;
|
|
|
import com.fjhx.service.quality.QualityTestingDetailsService;
|
|
|
import com.fjhx.service.quality.QualityTestingService;
|
|
@@ -25,6 +28,8 @@ import com.fjhx.service.water.WaterBatchService;
|
|
|
import com.fjhx.service.water.WaterTagService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.BigDecimalUtil;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.utils.ThreadUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -59,6 +64,12 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
@Autowired
|
|
|
private CheckQuantityCorrectFlowService checkQuantityCorrectFlowService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ContractService contractService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InspectionExemptionFlowService inspectionExemptionFlowService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<Map<String, Object>> getPage(Condition condition) {
|
|
|
|
|
@@ -127,6 +138,7 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
qualityTesting.setCheckRate(checkRate);
|
|
|
qualityTesting.setCheckQuantity(BigDecimal.ZERO);
|
|
|
qualityTesting.setCheckArea(BigDecimal.ZERO);
|
|
|
+ qualityTesting.setAdjustRate(BigDecimal.ZERO);
|
|
|
|
|
|
qualityTestingList.add(qualityTesting);
|
|
|
});
|
|
@@ -202,8 +214,13 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
@Override
|
|
|
public void submit(Condition condition) {
|
|
|
Long qualityTestingId = condition.getLong("qualityTestingId", "质检id不能为空");
|
|
|
+ Integer isInspectionExemption = condition.getInt("isInspectionExemption", "是否免检不能为空");
|
|
|
+ if (StatusConstant.YES.equals(isInspectionExemption)) {
|
|
|
+ inspectionExemptionFlowService.create(qualityTestingId);
|
|
|
+ }
|
|
|
|
|
|
Date date = new Date();
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
|
|
|
|
|
|
QualityTesting qualityTesting = getById(qualityTestingId);
|
|
@@ -218,44 +235,75 @@ public class QualityTestingServiceImpl extends ServiceImpl<QualityTestingMapper,
|
|
|
BigDecimal checkQuantity = BigDecimal.ZERO;
|
|
|
|
|
|
Integer checkJudgment = CheckJudgmentEnum.QUALIFIED.getType();
|
|
|
-
|
|
|
+
|
|
|
BigDecimal lakeNumSum = BigDecimal.ZERO;
|
|
|
-
|
|
|
- for (QualityTestingDetails qualityTestingDetails : qualityTestingDetailsList) {
|
|
|
-
|
|
|
- checkQuantity = checkQuantity.add(qualityTestingDetails.getQuantity());
|
|
|
-
|
|
|
- lakeNumSum = lakeNumSum.add(qualityTestingDetails.getLakeNum());
|
|
|
-
|
|
|
- if (CheckJudgmentEnum.UNQUALIFIED.equals(CheckJudgmentEnum.get(qualityTestingDetails.getCheckJudgment()))) {
|
|
|
- checkJudgment = CheckJudgmentEnum.UNQUALIFIED.getType();
|
|
|
+
|
|
|
+ List<Long> tagIdList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (qualityTestingDetailsList.size() > 0) {
|
|
|
+
|
|
|
+ for (QualityTestingDetails qualityTestingDetails : qualityTestingDetailsList) {
|
|
|
+
|
|
|
+ checkQuantity = checkQuantity.add(qualityTestingDetails.getQuantity());
|
|
|
+
|
|
|
+ lakeNumSum = lakeNumSum.add(qualityTestingDetails.getLakeNum());
|
|
|
+
|
|
|
+ if (CheckJudgmentEnum.UNQUALIFIED.equals(CheckJudgmentEnum.get(qualityTestingDetails.getCheckJudgment()))) {
|
|
|
+ checkJudgment = CheckJudgmentEnum.UNQUALIFIED.getType();
|
|
|
+ }
|
|
|
+ tagIdList.add(qualityTestingDetails.getWaterTagId());
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
+ waterTagService.update(Wrappers.<WaterTag>lambdaUpdate()
|
|
|
+ .in(StorageBaseEntity::getId, tagIdList)
|
|
|
+ .set(WaterTag::getCheckStatus, CheckStatusEnum.INSPECTED.getType())
|
|
|
+ .set(StorageBaseEntity::getUpdateTime, date)
|
|
|
+ .set(StorageBaseEntity::getUpdateUser, userId));
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
qualityTesting.setCompleteStatus(StatusConstant.YES);
|
|
|
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()));
|
|
|
+ updateById(qualityTesting);
|
|
|
+
|
|
|
+
|
|
|
+ waterTagService.update(Wrappers.<WaterTag>lambdaUpdate()
|
|
|
+ .eq(WaterTag::getWaterBatchId, qualityTesting.getWaterBatchId())
|
|
|
+ .notIn(tagIdList.size() > 0, StorageBaseEntity::getId, tagIdList)
|
|
|
+ .set(WaterTag::getCheckStatus, CheckStatusEnum.NO_QUALITY_INSPECTION_REQUIRED.getType())
|
|
|
+ .set(StorageBaseEntity::getUpdateTime, date)
|
|
|
+ .set(StorageBaseEntity::getUpdateUser, userId));
|
|
|
|
|
|
|
|
|
if (lakeNumSum.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
checkQuantityCorrectFlowService.create(qualityTestingId);
|
|
|
+ } else {
|
|
|
+ contractService.updateAdjustByQualityTestingId(qualityTestingId);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private static String getCode() {
|
|
|
- try {
|
|
|
- Thread.sleep(1);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ ThreadUtil.sleep(1);
|
|
|
return "TP-" + DateUtil.format(new Date(), "yyMMdd-HHmmss-SSS");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 计算质检及时率
|
|
|
+ */
|
|
|
+ private Integer getCheckInvalidRatio(Date createTime) {
|
|
|
+ long day = DateUtil.betweenDay(createTime, new Date(), false);
|
|
|
+
|
|
|
+ if (day <= 3) {
|
|
|
+ return 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Math.max(Convert.toInt(100 - (day - 3) * 5), 0);
|
|
|
+ }
|
|
|
+
|
|
|
}
|