Commit ccbb6df3 authored by zhangsen's avatar zhangsen

扣分问题处理

parent 4ee4e972
......@@ -27,6 +27,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
......@@ -284,8 +285,11 @@ public class PersonQrCodeController extends BaseController {
item.put("name", name);
item.put("faultInfo", "该存在缺陷或者告警");
item.put("faultLevel", "严重");
if (!Objects.isNull(score)) {
item.put("mark", new BigDecimal(100).subtract(score));
if (!Objects.isNull(score) && equipYardByPageCount != 0) {
BigDecimal divide = new BigDecimal(100).subtract(score).divide(BigDecimal.valueOf(equipYardByPageCount), 10, 2);
BigDecimal bigDecimal = divide.setScale(PersonBasicServiceImpl.getNonZeroDecimalPlaces(divide), RoundingMode.HALF_UP);
item.put("mark", bigDecimal);
}
});
resultList.setRecords(equipYardByPage);
......@@ -300,8 +304,11 @@ public class PersonQrCodeController extends BaseController {
item.put("name", name);
item.put("faultInfo", "该任务超时");
item.put("faultLevel", "严重");
if (!Objects.isNull(score)) {
item.put("mark", new BigDecimal(100).subtract(score));
if (!Objects.isNull(score) && jobYardByPageCount != 0) {
BigDecimal divide = new BigDecimal(100).subtract(score).divide(BigDecimal.valueOf(jobYardByPageCount), 10, 2);
BigDecimal bigDecimal = divide.setScale(PersonBasicServiceImpl.getNonZeroDecimalPlaces(divide), RoundingMode.HALF_UP);
item.put("mark", bigDecimal);
}
});
resultList.setRecords(jobYardByPage);
......
......@@ -23,6 +23,7 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -128,8 +129,10 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
item.put("name", name);
item.put("faultInfo", "证书不全或临期");
item.put("faultLevel", "严重");
if (!Objects.isNull(score)) {
item.put("mark", new BigDecimal(100).subtract(score));
if (!Objects.isNull(score) && count != 0) {
BigDecimal divide = new BigDecimal(100).subtract(score).divide(BigDecimal.valueOf(count), 10, 2);
BigDecimal bigDecimal = divide.setScale(getNonZeroDecimalPlaces(divide), RoundingMode.HALF_UP);
item.put("mark", bigDecimal);
}
});
Page<Map<String, Object>> mapPage = new Page<>();
......@@ -140,6 +143,20 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
return mapPage;
}
public static int getNonZeroDecimalPlaces(BigDecimal number) {
String str = number.stripTrailingZeros().toPlainString();
int index = str.indexOf(".");
if (index < 0) {
return 0;
}
for (int i = index + 1; i < str.length(); i++) {
if (str.charAt(i) != '0') {
return i - index;
}
}
return 0;
}
public Map<String, Object> getPersonDetailInfoByObjectId(String objectId) {
Map<String, Object> resultMap = personBasicMapper.getPersonDetailInfoByObjectId(objectId);
return resultMap;
......
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