|
@@ -39,6 +39,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -131,6 +133,10 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
|
|
|
private ApsProductionTechnicalRequirementService apsProductionTechnicalRequirementService;
|
|
|
@Autowired
|
|
|
private ApsWorkInProgressInventoryService apsWorkInProgressInventoryService;
|
|
|
+ @Autowired
|
|
|
+ private ApsReportYearAndMonthService apsReportYearAndMonthService;
|
|
|
+ @Resource
|
|
|
+ private ApsReportYearAndMonthDao apsReportYearAndMonthDao;
|
|
|
|
|
|
|
|
|
public static final String ERROR_MSG = "%s上诉订单的排程交货期大于承诺交货期";
|
|
@@ -1046,10 +1052,25 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
|
|
|
public void dataEyeReport() {
|
|
|
|
|
|
|
|
|
+ //生成大屏中间部分数据
|
|
|
+ try {
|
|
|
+ log.info("开始生成大屏中间的数据");
|
|
|
+ setMiddleData();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("生成大屏中间数据失败");
|
|
|
+ }
|
|
|
+ //
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成大屏中间部分数据
|
|
|
+ private void setMiddleData() {
|
|
|
//存储最终数据
|
|
|
List<ApsReportYearAndMonth> resInsertList = new LinkedList<>();
|
|
|
//初始化数据
|
|
|
- SaveConstans.COMPANY_MAP.forEach((key,value) -> {
|
|
|
+ SaveConstans.COMPANY_MAP.forEach((key, value) -> {
|
|
|
ApsReportYearAndMonth apsReportYearAndMonth = new ApsReportYearAndMonth();
|
|
|
apsReportYearAndMonth.setId(SecurityUtil.getUUID());
|
|
|
apsReportYearAndMonth.setTenantid(key);
|
|
@@ -1060,7 +1081,149 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
|
|
|
|
|
|
//===================今年计划接单量==================
|
|
|
List<ApsReportYearAndMonth> apsReportYearAndMonthList = this.baseMapper.selectNowYearPlanGetOrderNum();
|
|
|
-
|
|
|
+ for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList) {
|
|
|
+ if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
|
|
|
+ resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
|
|
|
+ item.setPlanordernumyear(apsReportYearAndMonth.getPlanordernumyear());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //==================今年实际已接单===================
|
|
|
+ List<ApsReportYearAndMonth> apsReportYearAndMonthList1 = this.baseMapper.selectNowYearActualGetOrderNum();
|
|
|
+ for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList1) {
|
|
|
+ if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
|
|
|
+ resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
|
|
|
+ item.setActualordernumyear(apsReportYearAndMonth.getActualordernumyear());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //==================今年实际已完成===================
|
|
|
+ List<ApsReportYearAndMonth> apsReportYearAndMonthList2 = this.baseMapper.selectNowYearActualProduceNum();
|
|
|
+ for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList2) {
|
|
|
+ if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
|
|
|
+ resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
|
|
|
+ item.setActualfinishnumyear(apsReportYearAndMonth.getActualfinishnumyear());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //==================今年接单量完成比例 = 今年实际已接单/今年计划接单量===================
|
|
|
+ resInsertList.forEach(item -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getPlanordernumyear())
|
|
|
+ && ObjectUtil.isNotEmpty(item.getActualordernumyear())
|
|
|
+ && new BigDecimal(item.getPlanordernumyear()).compareTo(BigDecimal.ZERO) != 0
|
|
|
+ && new BigDecimal(item.getActualordernumyear()).compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ //计算比例,保留4位小数,以便百分比保留两位小数
|
|
|
+ item.setPlanordernumyearpercent(
|
|
|
+ new BigDecimal(item.getActualordernumyear()).divide(new BigDecimal(item.getPlanordernumyear()), 4, RoundingMode.HALF_UP).toString());
|
|
|
+ } else {
|
|
|
+ item.setPlanordernumyearpercent("0");
|
|
|
+ }
|
|
|
+ //拼接展示字段
|
|
|
+ String pre = new BigDecimal(item.getPlanordernumyearpercent()).multiply(BigDecimal.valueOf(100)).toString();
|
|
|
+ item.setActualordernumyearshow(
|
|
|
+ item.getActualordernumyear() + "(" + pre + "%)");
|
|
|
+ });
|
|
|
+ //==================今年完成比例=今年实际已完成/今年实际已接单===================
|
|
|
+ resInsertList.forEach(item -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getActualordernumyear())
|
|
|
+ && ObjectUtil.isNotEmpty(item.getActualfinishnumyear())
|
|
|
+ && new BigDecimal(item.getActualordernumyear()).compareTo(BigDecimal.ZERO) != 0
|
|
|
+ && new BigDecimal(item.getActualfinishnumyear()).compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ //计算比例,保留4位小数,以便百分比保留两位小数
|
|
|
+ item.setActualfinishnumyearpercent(
|
|
|
+ new BigDecimal(item.getActualfinishnumyear()).divide(new BigDecimal(item.getActualordernumyear()), 4, RoundingMode.HALF_UP).toString());
|
|
|
+ } else {
|
|
|
+ item.setActualfinishnumyearpercent("0");
|
|
|
+ }
|
|
|
+ //拼接展示字段
|
|
|
+ String pre = new BigDecimal(item.getActualfinishnumyearpercent()).multiply(BigDecimal.valueOf(100)).toString();
|
|
|
+ item.setActualfinishnumyearshow(
|
|
|
+ item.getActualfinishnumyear() + "(" + pre + "%)");
|
|
|
+ });
|
|
|
+ //==================本月计划接单量==================
|
|
|
+ List<ApsReportYearAndMonth> apsReportYearAndMonthList3 = this.baseMapper.selectNowMonthPlanGetOrderNum();
|
|
|
+ for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList3) {
|
|
|
+ if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
|
|
|
+ resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
|
|
|
+ item.setPlanordernummonth(apsReportYearAndMonth.getPlanordernummonth());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //==================本月实际已接单===================
|
|
|
+ List<ApsReportYearAndMonth> apsReportYearAndMonthList4 = this.baseMapper.selectNowMonthActualGetOrderNum();
|
|
|
+ for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList4) {
|
|
|
+ if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
|
|
|
+ resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
|
|
|
+ item.setActualordernummonth(apsReportYearAndMonth.getActualordernummonth());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //==================本月实际已完成===================
|
|
|
+ List<ApsReportYearAndMonth> apsReportYearAndMonthList5 = this.baseMapper.selectNowMonthActualProduceNum();
|
|
|
+ for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList5) {
|
|
|
+ if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
|
|
|
+ resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
|
|
|
+ item.setActualfinishnummonth(apsReportYearAndMonth.getActualfinishnummonth());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //==================本月接单量完成比例 = 本月实际已接单/本月计划接单量===================
|
|
|
+ resInsertList.forEach(item -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getPlanordernummonth())
|
|
|
+ && ObjectUtil.isNotEmpty(item.getActualordernummonth())
|
|
|
+ && new BigDecimal(item.getPlanordernummonth()).compareTo(BigDecimal.ZERO) != 0
|
|
|
+ && new BigDecimal(item.getActualordernummonth()).compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ //计算比例,保留4位小数,以便百分比保留两位小数
|
|
|
+ item.setPlanordernummonthpercent(
|
|
|
+ new BigDecimal(item.getActualordernummonth()).divide(new BigDecimal(item.getPlanordernummonth()), 4, RoundingMode.HALF_UP).toString());
|
|
|
+ } else {
|
|
|
+ item.setPlanordernummonthpercent("0");
|
|
|
+ }
|
|
|
+ //拼接展示字段
|
|
|
+ String pre = new BigDecimal(item.getPlanordernummonthpercent()).multiply(BigDecimal.valueOf(100)).toString();
|
|
|
+ item.setActualordernummonthshow(
|
|
|
+ item.getActualordernummonth() + "(" + pre + "%)");
|
|
|
+ });
|
|
|
+ //==================本月完成比例=本月实际已完成/本月实际已接单===================
|
|
|
+ resInsertList.forEach(item -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getActualordernummonth())
|
|
|
+ && ObjectUtil.isNotEmpty(item.getActualfinishnummonth())
|
|
|
+ && new BigDecimal(item.getActualordernummonth()).compareTo(BigDecimal.ZERO) != 0
|
|
|
+ && new BigDecimal(item.getActualfinishnummonth()).compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ //计算比例,保留4位小数,以便百分比保留两位小数
|
|
|
+ item.setActualfinishnummonthpercent(
|
|
|
+ new BigDecimal(item.getActualfinishnummonth()).divide(new BigDecimal(item.getActualordernummonth()), 4, RoundingMode.HALF_UP).toString());
|
|
|
+ } else {
|
|
|
+ item.setActualfinishnummonthpercent("0");
|
|
|
+ }
|
|
|
+ //拼接展示字段
|
|
|
+ String pre = new BigDecimal(item.getActualfinishnummonthpercent()).multiply(BigDecimal.valueOf(100)).toString();
|
|
|
+ item.setActualfinishnummonthshow(
|
|
|
+ item.getActualfinishnummonth() + "(" + pre + "%)");
|
|
|
+ });
|
|
|
+ //================更新数据==================
|
|
|
+ //删除所有之前的数据
|
|
|
+ apsReportYearAndMonthService.remove(new QueryWrapper<ApsReportYearAndMonth>().lambda().eq(ApsReportYearAndMonth::getDeleted, "0"));
|
|
|
+ //插入新的数据
|
|
|
+ apsReportYearAndMonthService.saveBatch(resInsertList);
|
|
|
}
|
|
|
|
|
|
}
|