This commit is contained in:
cwchen 2023-12-16 13:01:37 +08:00
parent b57fd54e9e
commit 9edf649b72
15 changed files with 1240 additions and 9 deletions

View File

@ -581,13 +581,11 @@ public class DateTimeHelper {
Calendar thisMonthFirstDateCal = Calendar.getInstance();
thisMonthFirstDateCal.set(Calendar.DAY_OF_MONTH, 1);
String thisMonthFirstTime = format.format(thisMonthFirstDateCal.getTime());
System.out.println("本月起始:" + thisMonthFirstTime);
// 本月末尾
Calendar thisMonthEndDateCal = Calendar.getInstance();
thisMonthEndDateCal.set(Calendar.DAY_OF_MONTH, thisMonthEndDateCal.getActualMaximum(Calendar.DAY_OF_MONTH));
String thisMonthEndTime = format.format(thisMonthEndDateCal.getTime());
System.out.println("本月末尾:" + thisMonthEndTime);
map.put("beginDate", thisMonthFirstTime);
map.put("endDate", thisMonthEndTime);
@ -742,6 +740,11 @@ public class DateTimeHelper {
return lastDayOfMonth;
}
public static void main(String[] args) {
System.err.println(getFisrtDayOfMonth(2023,11));
System.err.println(getLastDayOfMonth(2023,11));
}
/**
* @return int
* @description 获取当前月的天数
@ -854,5 +857,17 @@ public class DateTimeHelper {
}
}
public static List<String> getYearMonth() {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
List<String> list = new ArrayList<>();
for (int i = 1; i < 13; i++) {
String month = i + "";
if (i < 10) {
month = "0" + i;
}
list.add(year + "-" + month);
}
return list;
}
}

View File

@ -4,6 +4,7 @@ import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.largeScreen.domain.ParamsDto;
import com.bonus.sgzb.largeScreen.service.ILargeScreenService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -27,4 +28,59 @@ public class LargeScreenController extends BaseController {
public AjaxResult getMaterialReqData() {
return service.getMaterialReqData();
}
@Log(title = "退料数据", businessType = BusinessType.QUERY)
@PostMapping("getMaterialReturnData")
public AjaxResult getMaterialReturnData() {
return service.getMaterialReturnData();
}
@Log(title = "设备分布图",businessType = BusinessType.QUERY)
@PostMapping("getEquipmentDisByMap")
public AjaxResult getEquipmentDisByMap(ParamsDto dto) {
return service.getEquipmentDisByMap(dto);
}
@Log(title = "施工机具/安全工器具总保有量",businessType = BusinessType.QUERY)
@PostMapping("getTotalOwnership")
public AjaxResult getTotalOwnership() {
return service.getTotalOwnership();
}
@Log(title = "当月报废分析", businessType = BusinessType.QUERY)
@PostMapping("getScrapAnalysisByMonth")
public AjaxResult getScrapAnalysisByMonth(ParamsDto dto) {
return service.getScrapAnalysisByMonth(dto);
}
@Log(title = "新购验收入库分析",businessType = BusinessType.QUERY)
@PostMapping("getAcceptanceStorage")
public AjaxResult getAcceptanceStorage(ParamsDto dto) {
return service.getAcceptanceStorage(dto);
}
@Log(title = "当月领料分析", businessType = BusinessType.QUERY)
@PostMapping("getPickingAnalysisByMonth")
public AjaxResult getPickingAnalysisByMonth(ParamsDto dto) {
return service.getPickingAnalysisByMonth(dto);
}
@Log(title = "当月退料分析", businessType = BusinessType.QUERY)
@PostMapping("getMaterialReturnByMonth")
public AjaxResult getMaterialReturnByMonth(ParamsDto dto) {
return service.getMaterialReturnByMonth(dto);
}
@Log(title = "当月维修分析", businessType = BusinessType.QUERY)
@PostMapping("getMaintenanceByMonth")
public AjaxResult getMaintenanceByMonth(ParamsDto dto) {
return service.getMaintenanceByMonth(dto);
}
@Log(title = "当月车辆使用", businessType = BusinessType.QUERY)
@PostMapping("getCarUseByMonth")
public AjaxResult getCarUseByMonth() {
return service.getCarUseByMonth();
}
}

View File

@ -0,0 +1,20 @@
package com.bonus.sgzb.largeScreen.domain;
import lombok.Data;
/**
* @author 10488
* 车辆使用-VO
*/
@Data
public class CarUseVo {
/** 车牌号*/
private String carNo;
/** 使用频次油耗*/
private int useNum;
/** 油耗*/
private double squander;
}

View File

@ -0,0 +1,20 @@
package com.bonus.sgzb.largeScreen.domain;
/**
* @author 10488
* 常量信息
*/
public class CommonConstants {
/** 施工机具*/
public static final String SGJJ = "施工机具";
/** 安全工器具*/
public static final String AQGQJ = "安全工器具";
/** 机具分公司*/
public static final String JJ = "机具分公司";
/** 调试分公司*/
public static final String TS = "调试分公司";
}

View File

@ -0,0 +1,23 @@
package com.bonus.sgzb.largeScreen.domain;
import lombok.Data;
/**
* @author 10488
* 设备分布-VO
*/
@Data
public class EquipmentDisVo {
/** 经度*/
private String lon;
/** 维度*/
private String lat;
/** 工程名称*/
private String lotName;
/** 机具类型名称*/
private String typeName;
}

View File

@ -0,0 +1,26 @@
package com.bonus.sgzb.largeScreen.domain;
import lombok.Data;
/**
* @author 10488
* 机具类型-DO
*/
@Data
public class MaTypeDo {
/** 机具类型名称*/
private String typeName;
/** 数量*/
private double num;
/** 管理方式(0编号 1计数)*/
private String manageType;
/** 机具分公司id*/
private String companyId;
/** 机具分公司名称*/
private String companyName;
}

View File

@ -0,0 +1,17 @@
package com.bonus.sgzb.largeScreen.domain;
import lombok.Data;
/**
* @author 10488
* 报废
*/
@Data
public class MaterialDataVo {
/** 往来单位名称*/
private String unitName;
/** 数量*/
private double num;
}

View File

@ -0,0 +1,24 @@
package com.bonus.sgzb.largeScreen.domain;
import lombok.Data;
/**
* @author 10488
* 接受前端-参数
*/
@Data
public class ParamsDto {
/** 1.施工机具 2.安全工器具*/
private String maType;
private String maTypeName;
/** 开始日期*/
private String startDate;
/** 结束日期*/
private String endDate;
/** 类型*/
private String type;
}

View File

@ -0,0 +1,34 @@
package com.bonus.sgzb.largeScreen.domain;
import lombok.Data;
/**
* @author 10488
* 当月退料分析-VO
*/
@Data
public class ScrapAnalysisVo {
/** 计划退料数量*/
private double planNum;
/** 实际退料数量*/
private double realityNum;
/** 维修总量*/
private double repairNum;
/** 维修合格*/
private double repairedNum;
/** 维修报废数量*/
private double scrapNum;
/** 数量*/
private double num;
/** 数量2*/
private double num2;
/** 机具类型名称*/
private String typeName;
}

View File

@ -0,0 +1,30 @@
package com.bonus.sgzb.largeScreen.domain;
import lombok.Data;
/**
* @author 10488
* 总保有量-VO
*/
@Data
public class TotalOwnershipVo {
/** 总保有量*/
private int totalOwnershipNum;
/** 在库机具/工器具*/
private int stockNum;
/** 待入库机具/工器具*/
private int storedNum;
/** 在用机具/工器具*/
private int useNum;
/** 在修机具/工器具*/
private int repairNum;
/** 报废机具/工器具*/
private int scrapNum;
}

View File

@ -1,11 +1,95 @@
package com.bonus.sgzb.largeScreen.mapper;
import com.bonus.sgzb.largeScreen.domain.*;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @author 10488
* 大屏
*/
@Repository("LargeScreenMapper")
public interface LargeScreenMapper {
/**
* @param nowDate
* @return List<MaTypeDo>
* @description 领料数据
* @author cwchen
* @date 2023/12/13 10:56
*/
List<MaTypeDo> getMaterialReqData(String nowDate);
/**
* @param nowDate
* @return List<MaTypeDo>
* @description 退料数据
* @author cwchen
* @date 2023/12/13 14:24
*/
List<MaTypeDo> getMaterialReturnData(String nowDate);
/**
* @param dto
* @return List<MaTypeDo>
* @description 当月领料分析
* @author cwchen
* @date 2023/12/15 15:57
*/
List<MaTypeDo> getPickingAnalysisByMonth(ParamsDto dto);
/**
* @param dto
* @return List<EquipmentDisVo>
* @description 设备分布
* @author cwchen
* @date 2023/12/13 15:04
*/
List<EquipmentDisVo> getEquipmentDisByMap(ParamsDto dto);
/**
* @param dto
* @return List<String>
* @description 新购验收入库分析
* @author cwchen
* @date 2023/12/14 16:06
*/
List<Map<String, String>> getAcceptanceStorage(ParamsDto dto);
/**
* @param dto
* @return List<MaterialDataVo>
* @description 当月报废分析
* @author cwchen
* @date 2023/12/15 9:46
*/
List<MaterialDataVo> getScrapAnalysisByMonth(ParamsDto dto);
/**
* @param dto
* @return List<ScrapAnalysisVo>
* @description 当月退料分析
* @author cwchen
* @date 2023/12/15 14:31
*/
List<ScrapAnalysisVo> getMaterialReturnByMonth(ParamsDto dto);
/**
* @param dto
* @return List<ScrapAnalysisVo>
* @description 当月维修分析
* @author cwchen
* @date 2023/12/15 15:12
*/
List<ScrapAnalysisVo> getMaintenanceByMonth(ParamsDto dto);
/**
* @param dto
* @description 施工机具/工器具总保有量
* @author cwchen
* @date 2023/12/15 18:57
*/
List<ScrapAnalysisVo> getTotalOwnership(ParamsDto dto);
}

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.largeScreen.service;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.largeScreen.domain.ParamsDto;
/**
* @author 10488
@ -15,4 +16,76 @@ public interface ILargeScreenService {
* @date 2023/12/11 15:34
*/
AjaxResult getMaterialReqData();
/**
* @return AjaxResult
* @description 退料数据
* @author cwchen
* @date 2023/12/11 17:00
*/
AjaxResult getMaterialReturnData();
/**
* @return AjaxResult
* @description 当月报废分析
* @author cwchen
* @date 2023/12/12 9:28
*/
AjaxResult getScrapAnalysisByMonth(ParamsDto dto);
/**
* @return AjaxResult
* @description 设备分布图
* @author cwchen
* @date 2023/12/13 14:56
*/
AjaxResult getEquipmentDisByMap(ParamsDto dto);
/**
* @return AjaxResult
* @description 新购验收入库分析
* @author cwchen
* @date 2023/12/12 9:34
*/
AjaxResult getAcceptanceStorage(ParamsDto dto);
/**
* @return AjaxResult
* @description 当月领料分析
* @author cwchen
* @date 2023/12/12 9:36
*/
AjaxResult getPickingAnalysisByMonth(ParamsDto dto);
/**
* @return AjaxResult
* @description 当月退料分析
* @author cwchen
* @date 2023/12/12 9:40
*/
AjaxResult getMaterialReturnByMonth(ParamsDto dto);
/**
* @return AjaxResult
* @description 当月维修分析
* @author cwchen
* @date 2023/12/12 9:42
*/
AjaxResult getMaintenanceByMonth(ParamsDto dto);
/**
* @return AjaxResult
* @description 施工机具/安全工器具总保有量
* @author cwchen
* @date 2023/12/13 15:26
*/
AjaxResult getTotalOwnership();
/**
* @return AjaxResult
* @description 当月车辆使用分析
* @author cwchen
* @date 2023/12/13 15:40
*/
AjaxResult getCarUseByMonth();
}

View File

@ -1,31 +1,318 @@
package com.bonus.sgzb.largeScreen.service.impl;
import com.bonus.sgzb.common.core.utils.DateTimeHelper;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.largeScreen.domain.*;
import com.bonus.sgzb.largeScreen.mapper.LargeScreenMapper;
import com.bonus.sgzb.largeScreen.service.ILargeScreenService;
import com.bonus.sgzb.largeScreen.util.CommonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.*;
/**
* @author 10488
* 大屏
*/
@Service("ILargeScreenService")
@Slf4j
public class LargeScreenServiceImpl implements ILargeScreenService {
@Resource(name = "LargeScreenMapper")
private LargeScreenMapper mapper;
@Autowired
private CommonUtil commonUtil;
@Override
public AjaxResult getMaterialReqData() {
HashMap<Object, Object> map = new HashMap<>(2);
int a = 1/0;
// 施工工具今日出库
map.put("num", 330);
// 工器具今日出库
map.put("num2", 201);
// 施工工具安全工器具数量
int num = 0, num2 = 0;
try {
List<MaTypeDo> list = mapper.getMaterialReqData(DateTimeHelper.getNowDate());
List<Integer> valueList = commonUtil.totalValue3(list);
num = valueList.get(0);
num2 = valueList.get(1);
} catch (Exception e) {
log.error("领料数据", e);
}
map.put("num", num);
map.put("num2", num2);
return AjaxResult.success(map);
}
@Override
public AjaxResult getMaterialReturnData() {
HashMap<Object, Object> map = new HashMap<>(2);
// 施工工具安全工器具数量
int num = 0, num2 = 0;
try {
List<MaTypeDo> list = mapper.getMaterialReturnData(DateTimeHelper.getNowDate());
List<Integer> valueList = commonUtil.totalValue3(list);
num = valueList.get(0);
num2 = valueList.get(1);
} catch (Exception e) {
log.error("退料数据", e);
}
map.put("num", num);
map.put("num2", num2);
return AjaxResult.success(map);
}
@Override
public AjaxResult getEquipmentDisByMap(ParamsDto dto) {
List<EquipmentDisVo> list = new ArrayList<>();
try {
} catch (Exception e) {
log.error("设备分布", e);
}
return AjaxResult.success(list);
}
@Override
public AjaxResult getTotalOwnership() {
List<TotalOwnershipVo> list = new ArrayList<>();
ParamsDto dto = new ParamsDto();
try {
// 施工机具
// 施工机具-在库
dto.setMaTypeName(CommonConstants.SGJJ);
dto.setType("1");
List<ScrapAnalysisVo> zkValueList = mapper.getTotalOwnership(dto);
// 安全工器具
TotalOwnershipVo vo2 = new TotalOwnershipVo();
// 工器具-在库
dto.setMaTypeName(CommonConstants.AQGQJ);
dto.setType("1");
List<ScrapAnalysisVo> zkValueList2 = mapper.getTotalOwnership(dto);
vo2.setTotalOwnershipNum(2000);
vo2.setStockNum(220);
vo2.setStoredNum(280);
vo2.setUseNum(600);
vo2.setRepairNum(450);
vo2.setScrapNum(450);
list.add(vo2);
} catch (Exception e) {
list.removeAll(list);
TotalOwnershipVo vo = new TotalOwnershipVo();
TotalOwnershipVo vo2 = new TotalOwnershipVo();
list.add(vo);
list.add(vo2);
log.error("施工机具总保有量/安全工器具总保有量", e);
}
return AjaxResult.success(list);
}
/**
* @param maTypeName
* @return TotalOwnershipVo
* @description 保有量统计
* @author cwchen
* @date 2023/12/15 19:33
*/
public TotalOwnershipVo countNum(String maType,String maTypeName) {
TotalOwnershipVo vo = new TotalOwnershipVo();
ParamsDto dto = new ParamsDto();
dto.setMaType(maType);
dto.setMaTypeName(maTypeName);
// 在库数量
dto.setType("1");
List<ScrapAnalysisVo> zkValueList = mapper.getTotalOwnership(dto);
Integer zkValue = commonUtil.setZKData(zkValueList);
vo.setStockNum(zkValue);
// 待入库数量
dto.setType("2");
List<ScrapAnalysisVo> drkValueList = mapper.getTotalOwnership(dto);
return vo;
}
@Override
public AjaxResult getScrapAnalysisByMonth(ParamsDto dto) {
List<String> nameList = new ArrayList<>();
List<Integer> valueList = new ArrayList<>();
List<Integer> valueList2 = new ArrayList<>();
HashMap<Object, Object> map = new HashMap<>(3);
try {
dto.setType("1");
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null);
List<MaterialDataVo> lyList = mapper.getScrapAnalysisByMonth(dto);
dto.setType("2");
List<MaterialDataVo> bfList = mapper.getScrapAnalysisByMonth(dto);
List<Object> objectList = commonUtil.setScrapAnalysisData(lyList, bfList);
nameList = (List<String>) objectList.get(0);
valueList = (List<Integer>) objectList.get(1);
valueList2 = (List<Integer>) objectList.get(2);
} catch (Exception e) {
log.error("当月报废分析", e);
}
map.put("nameList", nameList);
map.put("valueList", valueList);
map.put("valueList2", valueList2);
return AjaxResult.success(map);
}
@Override
public AjaxResult getAcceptanceStorage(ParamsDto dto) {
HashMap<Object, Object> map = new HashMap<>(3);
List<String> yearMonthList = DateTimeHelper.getYearMonth();
List<Integer> valueList = new ArrayList<>();
List<Integer> valueList2 = new ArrayList<>();
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null);
try {
for (String date : yearMonthList) {
String year = date.substring(0, 4);
String month = date.substring(5, 7);
// 验收数量
dto.setType("1");
dto.setStartDate(DateTimeHelper.getFisrtDayOfMonth(Integer.parseInt(year), Integer.parseInt(month)));
dto.setEndDate(DateTimeHelper.getLastDayOfMonth(Integer.parseInt(year), Integer.parseInt(month)));
List<Map<String, String>> checkList = mapper.getAcceptanceStorage(dto);
valueList.add(commonUtil.totalValue(checkList, dto.getMaType()));
// 入库数量
dto.setType("2");
List<Map<String, String>> warehousingList = mapper.getAcceptanceStorage(dto);
valueList2.add(commonUtil.totalValue(warehousingList, dto.getMaType()));
}
} catch (Exception e) {
log.error("新购验收入库分析", e);
valueList.removeAll(valueList);
valueList2.removeAll(valueList2);
yearMonthList.forEach(item -> {
valueList.add(0);
valueList2.add(0);
});
}
map.put("nameList", yearMonthList);
map.put("valueList", valueList);
map.put("valueList2", valueList2);
return AjaxResult.success(map);
}
@Override
public AjaxResult getPickingAnalysisByMonth(ParamsDto dto) {
HashMap<Object, Object> map = new HashMap<>(4);
Map<String, String> monthDayMap = DateTimeHelper.getNowOneMonthDay();
// 数量领料编码领料
int num = 0, num2 = 0;
String rate = "0%", rate2 = "0%";
try {
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null);
dto.setStartDate(monthDayMap.get("beginDate"));
dto.setEndDate(monthDayMap.get("endDate"));
List<MaTypeDo> list = mapper.getPickingAnalysisByMonth(dto);
List<Integer> valueList = commonUtil.totalValue2(list, dto.getMaType());
num = valueList.get(0);
num2 = valueList.get(1);
rate = commonUtil.getRate(valueList.get(0), valueList.get(0) + valueList.get(1));
rate2 = commonUtil.getRate(valueList.get(1), valueList.get(0) + valueList.get(1));
} catch (Exception e) {
log.error("当月领料分析", e);
}
map.put("num", num);
map.put("num2", num2);
map.put("rate", rate);
map.put("rate2", rate2);
return AjaxResult.success(map);
}
@Override
public AjaxResult getMaterialReturnByMonth(ParamsDto dto) {
HashMap<Object, Object> map = new HashMap<>(4);
int num = 0, num2 = 0;
String rate = "0%";
Map<String, String> monthDayMap = DateTimeHelper.getNowOneMonthDay();
dto.setStartDate(monthDayMap.get("beginDate"));
dto.setEndDate(monthDayMap.get("endDate"));
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null);
try {
List<ScrapAnalysisVo> list = mapper.getMaterialReturnByMonth(dto);
List<Integer> valueList = commonUtil.setMaterialReturnData(list);
num = valueList.get(0);
num2 = valueList.get(1);
rate = commonUtil.getRate(num, num + num2);
} catch (Exception e) {
log.error("当月退料分析", e);
}
map.put("num", num);
map.put("num2", num2);
map.put("rate", rate);
return AjaxResult.success(map);
}
@Override
public AjaxResult getMaintenanceByMonth(ParamsDto dto) {
HashMap<Object, Object> map = new HashMap<>(6);
int num = 0, num2 = 0, num3 = 0, num4 = 0;
String rate = "0%", rate2 = "0%", rate3 = "0%";
Map<String, String> monthDayMap = DateTimeHelper.getNowOneMonthDay();
dto.setStartDate(monthDayMap.get("beginDate"));
dto.setEndDate(monthDayMap.get("endDate"));
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null);
try {
List<ScrapAnalysisVo> list = mapper.getMaintenanceByMonth(dto);
List<Integer> valueList = commonUtil.setMaintenanceData(list);
num = valueList.get(0);
num2 = valueList.get(1);
num3 = valueList.get(2);
num4 = valueList.get(3);
rate = commonUtil.getRate(num4, num);
rate2 = commonUtil.getRate(num2, num);
rate3 = commonUtil.getRate(num3, num);
} catch (Exception e) {
log.error("当月维修分析", e);
}
map.put("num", num4);
map.put("num2", num2);
map.put("num3", num3);
map.put("rate", rate);
map.put("rate2", rate2);
map.put("rate3", rate3);
return AjaxResult.success(map);
}
@Override
public AjaxResult getCarUseByMonth() {
List<CarUseVo> list = new ArrayList<>();
CarUseVo carUseVo = new CarUseVo();
carUseVo.setCarNo("鲁VL6562");
carUseVo.setUseNum(24);
carUseVo.setSquander(173.0);
CarUseVo carUseVo2 = new CarUseVo();
carUseVo2.setCarNo("宁CY33G7");
carUseVo2.setUseNum(26);
carUseVo2.setSquander(98.0);
CarUseVo carUseVo3 = new CarUseVo();
carUseVo3.setCarNo("黑LB686Y");
carUseVo3.setUseNum(10);
carUseVo3.setSquander(193.0);
CarUseVo carUseVo4 = new CarUseVo();
carUseVo4.setCarNo("川S03VT5");
carUseVo4.setUseNum(12);
carUseVo4.setSquander(282.0);
CarUseVo carUseVo5 = new CarUseVo();
carUseVo5.setCarNo("苏K2J2W6");
carUseVo5.setUseNum(19);
carUseVo5.setSquander(105.0);
CarUseVo carUseVo6 = new CarUseVo();
carUseVo6.setCarNo("川UYA990");
carUseVo6.setUseNum(8);
carUseVo6.setSquander(261.1);
list.add(carUseVo);
list.add(carUseVo2);
list.add(carUseVo3);
list.add(carUseVo4);
list.add(carUseVo5);
list.add(carUseVo6);
return AjaxResult.success(list);
}
}

View File

@ -0,0 +1,256 @@
package com.bonus.sgzb.largeScreen.util;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.largeScreen.domain.CommonConstants;
import com.bonus.sgzb.largeScreen.domain.MaTypeDo;
import com.bonus.sgzb.largeScreen.domain.MaterialDataVo;
import com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author 10488
* 大屏公共util
*/
@Component
public class CommonUtil {
/**
* @param num
* @param totalNum
* @return String
* @description 百分比
* @author cwchen
* @date 2023/12/12 9:39
*/
public String getRate(int num, int totalNum) {
DecimalFormat decimalFormat = new DecimalFormat("0.00%");
if (totalNum == 0 || num == 0) {
return "0%";
} else {
return decimalFormat.format(num * 1.0 / totalNum * 1.0);
}
}
/**
* @param list
* @param maType
* @return Integer
* @description 新购验收入库分析-统计数量
* @author cwchen
* @date 2023/12/14 18:54
*/
public Integer totalValue(List<Map<String, String>> list, String maType) {
if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(maType)) return 0;
BigDecimal value = new BigDecimal(new Double(0).toString());
for (int i = 0; i < list.size(); i++) {
Map<String, String> map = list.get(i);
BigDecimal value2 = new BigDecimal(new Double(String.valueOf(map.get("num"))));
value = value.add(value2);
}
double doubleValue = value.doubleValue();
return (int) Math.round(doubleValue);
}
/**
* @param list
* @param maType
* @return Integer
* @description 当月领料分析-统计数量
* @author cwchen
* @date 2023/12/14 18:57
*/
public List<Integer> totalValue2(List<MaTypeDo> list, String maType) {
List<Integer> valueList = new ArrayList<>();
if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(maType)) {
valueList.add(0);
valueList.add(0);
return valueList;
}
;
BigDecimal numberValue = new BigDecimal(new Double(0).toString());
BigDecimal countValue = new BigDecimal(new Double(0).toString());
for (int i = 0; i < list.size(); i++) {
if (Objects.nonNull(list.get(i).getNum()) && Objects.equals("0", list.get(i).getManageType())) {
// 编号
BigDecimal value = new BigDecimal(new Double(list.get(i).getNum()).toString());
numberValue = numberValue.add(value);
} else if (Objects.nonNull(list.get(i).getNum()) && Objects.equals("1", list.get(i).getManageType())) {
// 计数
BigDecimal value = new BigDecimal(new Double(list.get(i).getNum()).toString());
countValue = countValue.add(value);
}
}
double doubleNumberValue = numberValue.doubleValue();
double doubleCountValue = countValue.doubleValue();
valueList.add((int) Math.round(doubleNumberValue));
valueList.add((int) Math.round(doubleCountValue));
return valueList;
}
/**
* @param list
* @return List<Integer>
* @description 领料数据-统计
* @author cwchen
* @date 2023/12/14 19:42
*/
public List<Integer> totalValue3(List<MaTypeDo> list) {
List<Integer> valueList = new ArrayList<>();
if (CollectionUtils.isEmpty(list)) {
valueList.add(0);
valueList.add(0);
return valueList;
}
BigDecimal jjValue = new BigDecimal(new Double(0).toString());
BigDecimal tsValue = new BigDecimal(new Double(0).toString());
for (int i = 0; i < list.size(); i++) {
if (Objects.equals(list.get(i).getCompanyName(), CommonConstants.JJ)) {
BigDecimal value = new BigDecimal(new Double(list.get(i).getNum()).toString());
jjValue = jjValue.add(value);
} else if (Objects.equals(list.get(i).getCompanyName(), CommonConstants.TS)) {
BigDecimal value = new BigDecimal(new Double(list.get(i).getNum()).toString());
tsValue = tsValue.add(value);
}
}
double doubleJJValue = jjValue.doubleValue();
double doubleTSValue = tsValue.doubleValue();
valueList.add((int) Math.round(doubleJJValue));
valueList.add((int) Math.round(doubleTSValue));
return valueList;
}
/**
* @param lyList
* @param bfList
* @return List<Object>
* @description 当月报废分析-数据统计
* @author cwchen
* @date 2023/12/15 10:02
*/
public List<Object> setScrapAnalysisData(List<MaterialDataVo> lyList, List<MaterialDataVo> bfList) {
List<Object> list = new ArrayList<>();
// 单位领用数量报废数量
List<String> nameList = new ArrayList<>();
List<Integer> valueList = new ArrayList<>();
List<Integer> valueList2 = new ArrayList<>();
if (CollectionUtils.isNotEmpty(lyList)) {
for (int i = 0; i < lyList.size(); i++) {
MaterialDataVo vo = lyList.get(i);
if (Objects.nonNull(vo.getUnitName())) {
nameList.add(vo.getUnitName());
valueList.add((int) Math.round(vo.getNum()));
for (int j = 0; j < bfList.size(); j++) {
MaterialDataVo vo2 = bfList.get(j);
if (Objects.nonNull(vo2.getUnitName()) && Objects.equals(vo.getUnitName(), vo2.getUnitName())) {
valueList2.add((int) Math.round(vo2.getNum()));
}
}
}
}
}
list.add(nameList);
list.add(valueList);
list.add(valueList2);
return list;
}
/**
* @param list
* @return List<Integer>
* @description 当月退料分析-统计
* @author cwchen
* @date 2023/12/15 14:59
*/
public List<Integer> setMaterialReturnData(List<ScrapAnalysisVo> list) {
List<Integer> valueList = new ArrayList<>();
if (CollectionUtils.isEmpty(list)) {
valueList.add(0);
valueList.add(0);
return valueList;
}
BigDecimal planValue = new BigDecimal(new Double(0).toString());
BigDecimal realityValue = new BigDecimal(new Double(0).toString());
for (int i = 0; i < list.size(); i++) {
ScrapAnalysisVo vo = list.get(i);
BigDecimal value = new BigDecimal(new Double(String.valueOf(vo.getPlanNum())));
BigDecimal value2 = new BigDecimal(new Double(String.valueOf(vo.getRealityNum())));
planValue = planValue.add(value);
realityValue = realityValue.add(value2);
}
double doublePlanValue = planValue.doubleValue();
double doubleRealityValue = realityValue.doubleValue();
valueList.add((int) Math.round(doublePlanValue));
valueList.add((int) Math.round(doubleRealityValue));
return valueList;
}
/**
* @param list
* @return List<Integer>
* @description 当月维修分析-统计
* @author cwchen
* @date 2023/12/15 15:20
*/
public List<Integer> setMaintenanceData(List<ScrapAnalysisVo> list) {
List<Integer> valueList = new ArrayList<>();
if (CollectionUtils.isEmpty(list)) {
for (int i = 0; i < 4; i++) {
valueList.add(0);
}
return valueList;
}
/*维修总量/维修合格数量/维修报废数量/待维修数量*/
BigDecimal repairValue = new BigDecimal(new Double(0).toString());
BigDecimal repairedValue = new BigDecimal(new Double(0).toString());
BigDecimal scrapValue = new BigDecimal(new Double(0).toString());
BigDecimal waitRepairedValue = new BigDecimal(new Double(0).toString());
for (int i = 0; i < list.size(); i++) {
ScrapAnalysisVo vo = list.get(i);
BigDecimal value = new BigDecimal(new Double(String.valueOf(vo.getRepairNum())));
BigDecimal value2 = new BigDecimal(new Double(String.valueOf(vo.getRepairedNum())));
BigDecimal value3 = new BigDecimal(new Double(String.valueOf(vo.getScrapNum())));
repairValue = repairValue.add(value);
repairedValue = repairedValue.add(value2);
scrapValue = scrapValue.add(value3);
}
waitRepairedValue = repairValue.subtract(repairedValue).subtract(scrapValue);
double doubleRepairValue = repairValue.doubleValue();
double doubleRepairedValue = repairedValue.doubleValue();
double doubleScrapValue = scrapValue.doubleValue();
double doubleWaitRepairedValue = waitRepairedValue.doubleValue();
valueList.add((int) Math.round(doubleRepairValue));
valueList.add((int) Math.round(doubleRepairedValue));
valueList.add((int) Math.round(doubleScrapValue));
valueList.add((int) Math.round(doubleWaitRepairedValue));
return valueList;
}
/**
* @param list
* @return Integer
* @description 保有量-在库
* @author cwchen
* @date 2023/12/15 19:21
*/
public Integer setZKData(List<ScrapAnalysisVo> list) {
if(CollectionUtils.isEmpty(list)) return 0;
BigDecimal totalValue = new BigDecimal(new Double(0).toString());
for (int i = 0; i < list.size(); i++) {
ScrapAnalysisVo vo = list.get(i);
BigDecimal value = new BigDecimal(new Double(String.valueOf(vo.getNum())));
totalValue = totalValue.add(value);
}
double doubleTotalValue = totalValue.doubleValue();
return (int) Math.round(doubleTotalValue);
}
}

View File

@ -4,4 +4,270 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.largeScreen.mapper.LargeScreenMapper">
<!--领料数据-->
<select id="getMaterialReqData" resultType="com.bonus.sgzb.largeScreen.domain.MaTypeDo">
SELECT SUM(lod.out_num) AS num,
lod.company_id AS companyId,
sd.dept_name AS companyName
FROM lease_out_details lod
LEFT JOIN sys_dept sd ON lod.company_id = sd.dept_id
WHERE lod.create_time BETWEEN CONCAT(#{nowDate}, ' 00:00:00') AND CONCAT(#{nowDate}, ' 23:59:59')
GROUP BY lod.company_id
</select>
<!--退料数据-->
<select id="getMaterialReturnData" resultType="com.bonus.sgzb.largeScreen.domain.MaTypeDo">
SELECT SUM(bcd.back_num) AS num,
bcd.company_id AS companyId,
sd.dept_name AS companyName
FROM back_check_details bcd
LEFT JOIN sys_dept sd ON bcd.company_id = sd.dept_id
WHERE bcd.create_time BETWEEN CONCAT(#{nowDate}, ' 00:00:00') AND CONCAT(#{nowDate}, ' 23:59:59')
GROUP BY bcd.company_id
</select>
<!--当月领料分析-->
<select id="getPickingAnalysisByMonth" resultType="com.bonus.sgzb.largeScreen.domain.MaTypeDo">
SELECT lod.out_num AS num,
a.typeName,
a.manage_type AS manageType
FROM lease_out_details lod
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName,mt.manage_type
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON lod.type_id = a.type_id
WHERE lod.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
</select>
<!--设备分布-->
<select id="getEquipmentDisByMap" resultType="com.bonus.sgzb.largeScreen.domain.EquipmentDisVo"></select>
<!--新购验收入库分析-->
<select id="getAcceptanceStorage" resultType="java.util.Map">
/*验收*/
<if test="type == 1">
SELECT pcd.check_num AS num,
a.typeName
FROM purchase_check_info pci
LEFT JOIN purchase_check_details pcd ON pci.task_id = pcd.task_id
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON pcd.type_id = a.type_id
WHERE pci.arrival_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
</if>
/*入库*/
<if test="type == 2">
SELECT mir.input_num,
a.typeName
FROM ma_input_record mir
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON mir.type_id = a.type_id
WHERE mir.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59') AND mir.input_type = '1'
<if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
</if>
</select>
<!--当月报废分析-->
<select id="getScrapAnalysisByMonth" resultType="com.bonus.sgzb.largeScreen.domain.MaterialDataVo">
/*领用*/
<if test="type == 1">
SELECT SUM(lod.out_num) AS num,
bui.unit_name AS unitName
FROM lease_out_details lod
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON lod.type_id = a.type_id
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id
<where>
<if test="maType!=null and maType == 1">
a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
</where>
GROUP BY bai.unit_id
ORDER BY num DESC
</if>
/*报废*/
<if test="type == 2">
SELECT SUM(scrap_num) AS num,
bui.unit_name AS unitName
FROM scrap_apply_details sad
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON sad.type_id = a.type_id
LEFT JOIN tm_task_agreement tta ON sad.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id
WHERE sad.status = '1'
<if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
GROUP BY bai.unit_id
ORDER BY num DESC
</if>
</select>
<!--当月退料分析-->
<select id="getMaterialReturnByMonth" resultType="com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo">
SELECT bad.pre_num AS planNum,
bad.audit_num AS realityNum,
a.typeName
FROM back_apply_details bad
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON bad.type_id = a.type_id
WHERE bad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
</select>
<!--当月维修分析-->
<select id="getMaintenanceByMonth" resultType="com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo">
SELECT rad.repair_num AS repairNum,
rad.repaired_num AS repairedNum,
rad.scrap_num AS scrapNum,
a.typeName
FROM repair_apply_details rad
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON rad.type_id = a.type_id
WHERE rad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
</select>
<!--施工机具/工器具总保有量-->
<select id="getTotalOwnership" resultType="com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo">
/*在库*/
<if test="type == 1">
SELECT mt4.type_name AS typeName,
mt.num AS num
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4' AND mt.del_flag = '0'
<if test="maType!=null and maType == 1">
AND mt4.type_name = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND mt4.type_name = #{maTypeName}
</if>
</if>
/*待入库 新购/修试*/
<if test="type == 2">
SELECT pcd.purchase_num AS num,
pcd.input_num AS num2,
a.typeName AS typeName
FROM purchase_check_details pcd
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON pcd.type_id = a.type_id
WHERE pcd.status = '1'
<if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
UNION ALL
SELECT rid.repair_num AS num,
rid.input_num AS num2,
a.typeName AS typeName
FROM repair_input_details rid
LEFT JOIN (
SELECT mt.type_id,mt4.type_name AS typeName
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON rid.type_id = a.type_id
<where>
<if test="maType!=null and maType == 1">
a.typeName = #{maTypeName}
</if>
<if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName}
</if>
</where>
</if>
/*在用*/
<if test="type == 3">
</if>
/*在修*/
<if test="type == 4">
</if>
/*报废*/
<if test="type == 5">
</if>
</select>
</mapper>