|
@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.bscommon.sys.dao.*;
|
|
|
import com.rongwei.bscommon.sys.service.*;
|
|
@@ -22,6 +24,10 @@ import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
+import com.rongwei.rwcommon.vo.ColumnQueryType;
|
|
|
+import com.rongwei.rwcommon.vo.CriteriaQuery;
|
|
|
+import com.rongwei.rwcommon.vo.SearchColumnVo;
|
|
|
+import com.rongwei.rwcommon.vo.SearchOrderVo;
|
|
|
import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
import com.rongwei.safecommon.utils.SaveConstans;
|
|
|
import org.slf4j.Logger;
|
|
@@ -2668,4 +2674,194 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, hour);
|
|
|
return calendar.getTime();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R productPlanReport(CriteriaQuery req) {
|
|
|
+ //解析入参
|
|
|
+ //每页数量
|
|
|
+ Integer size = req.getSize();
|
|
|
+ //页数
|
|
|
+ Integer current = req.getCurrent();
|
|
|
+ //查询条件
|
|
|
+ /**
|
|
|
+ * 客户名称:模糊查询;
|
|
|
+ * 客户订单号:模糊查询;
|
|
|
+ * 承诺交货日期:日历选择日期范围
|
|
|
+ * 坯料计划编号:模糊查询;
|
|
|
+ */
|
|
|
+ //页签查询:订单产品生产状态
|
|
|
+
|
|
|
+ ProductPlanReportParamVo param = new ProductPlanReportParamVo();
|
|
|
+
|
|
|
+ List<ColumnQueryType> columnQueryTypes = req.getColumnQueryTypes();
|
|
|
+ for (ColumnQueryType columnQueryType : columnQueryTypes) {
|
|
|
+ for (SearchColumnVo column : columnQueryType.getColumns()) {
|
|
|
+ if (column.getField().equals("customname")) {
|
|
|
+ param.setCustomName(column.getValue());
|
|
|
+ }
|
|
|
+ if (column.getField().equals("customorderno")) {
|
|
|
+ param.setCustomOrderNo(column.getValue());
|
|
|
+ }
|
|
|
+ if (column.getField().equals("promiseDateStart")) {
|
|
|
+ param.setStartDate(column.getStartDate());
|
|
|
+ param.setEndDate(column.getEndDate());
|
|
|
+ }
|
|
|
+ if (column.getField().equals("blankNumber")) {
|
|
|
+ param.setBlankNumber(column.getValue());
|
|
|
+ }
|
|
|
+ if (column.getField().equals("productionOrderStatus")) {
|
|
|
+ param.setProductionOrderStatus(column.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //排序规则
|
|
|
+ String order = "";
|
|
|
+ List<SearchOrderVo> orders = req.getOrders();
|
|
|
+ if (ObjectUtil.isNotEmpty(orders)) {
|
|
|
+ for (SearchOrderVo searchOrderVo : orders) {
|
|
|
+ if (searchOrderVo.getOrderName().equals("auditdate")) {
|
|
|
+ order = "a.auditdate " + searchOrderVo.getOrderType() + ",";
|
|
|
+ }
|
|
|
+ if (searchOrderVo.getOrderName().equals("customname")) {
|
|
|
+ order = "a.customname " + searchOrderVo.getOrderType() + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ param.setOrders(order);
|
|
|
+
|
|
|
+ Page<ProductPlanReportVo> queryPage = new Page<>(current, size);
|
|
|
+
|
|
|
+
|
|
|
+ IPage<ProductPlanReportVo> res = this.baseMapper.selectPageReport(queryPage, param);
|
|
|
+
|
|
|
+ //分页查询结束,拼接结果字段信息
|
|
|
+ List<ProductPlanReportVo> records = res.getRecords();
|
|
|
+ //当前页面的坯料计划的ID集合
|
|
|
+ List<String> blankIdList = records.stream().map(ProductPlanReportVo::getBlankId).distinct().collect(Collectors.toList());
|
|
|
+ List<BlankIdAndWorkShopVo> blankIdAndWorkShopList = new LinkedList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(blankIdList)) {
|
|
|
+ //查询坯料计划对应的 坯料 加工车间
|
|
|
+ blankIdAndWorkShopList = apsProcessOperationDao.getWorkShopByBlankId(blankIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询坯料计划对应的工序作业信息
|
|
|
+ List<ApsProcessOperationDo> processOperationDoList = apsProcessOperationService.list(new QueryWrapper<ApsProcessOperationDo>().lambda().in(ApsProcessOperationDo::getBlankid, blankIdList));
|
|
|
+
|
|
|
+ //构造生产进度
|
|
|
+ //获取所有的最终工序ID集合
|
|
|
+ List<String> lastProcessIdList = records.stream().filter(item -> ObjectUtil.isNotEmpty(item.getLastProcessId())).map(ProductPlanReportVo::getLastProcessId).distinct().collect(Collectors.toList());
|
|
|
+ //组装map《最终工序ID,生产进度》
|
|
|
+ Map<String, String> processLoadingMap = new HashMap<>();
|
|
|
+ doSetMapLoading(processLoadingMap, lastProcessIdList, processOperationDoList);
|
|
|
+
|
|
|
+ for (ProductPlanReportVo record : records) {
|
|
|
+ //加工车间
|
|
|
+ if (ObjectUtil.isNotEmpty(blankIdAndWorkShopList)) {
|
|
|
+ BlankIdAndWorkShopVo blankIdAndWorkShopVo = blankIdAndWorkShopList.stream().filter(item -> item.getBlankId().equals(record.getBlankId())).findFirst().orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(blankIdAndWorkShopVo)) {
|
|
|
+ record.setProcessWorkShop(blankIdAndWorkShopVo.getPrcessWorkShop());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //计划转料日期
|
|
|
+ //实际转料日期
|
|
|
+ //已投料数量
|
|
|
+ List<ApsProcessOperationDo> operationDoList = processOperationDoList.stream().filter(item -> item.getBlankid().equals(record.getBlankId()) && item.getIfblankprocess().equals("否")).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(operationDoList)) {
|
|
|
+ ApsProcessOperationDo processOperationDo1 = operationDoList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getPlanstartdate())).min(Comparator.comparing(ApsProcessOperationDo::getPlanstartdate)).orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(processOperationDo1)) {
|
|
|
+ record.setPlanChangeBlankDate(processOperationDo1.getPlanstartdate());
|
|
|
+ record.setHadStartRoll(processOperationDo1.getStartingroll());
|
|
|
+ }
|
|
|
+ ApsProcessOperationDo processOperationDo2 = operationDoList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getActualstartdate())).min(Comparator.comparing(ApsProcessOperationDo::getActualstartdate)).orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(processOperationDo2)) {
|
|
|
+ record.setActualChangeBlankDate(processOperationDo2.getActualstartdate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //生产进度
|
|
|
+ if (ObjectUtil.isNotEmpty(record.getLastProcessId()) && processLoadingMap.containsKey(record.getLastProcessId())) {
|
|
|
+ record.setProductLoading(processLoadingMap.get(record.getLastProcessId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //计划开工时间
|
|
|
+ //计划完工时间
|
|
|
+ //实际开工时间
|
|
|
+ //实际完工时间
|
|
|
+ List<ApsProcessOperationDo> operationDoList2 = processOperationDoList.stream().filter(item -> item.getBlankid().equals(record.getBlankId())).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(operationDoList2)) {
|
|
|
+ ApsProcessOperationDo processOperationDo1 = operationDoList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getPlanstartdate())).min(Comparator.comparing(ApsProcessOperationDo::getPlanstartdate)).orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(processOperationDo1)) {
|
|
|
+ record.setPlanStartDate(processOperationDo1.getPlanstartdate());
|
|
|
+ }
|
|
|
+
|
|
|
+ ApsProcessOperationDo processOperationDo2 = operationDoList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getPlanenddate())).max(Comparator.comparing(ApsProcessOperationDo::getPlanenddate)).orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(processOperationDo2)) {
|
|
|
+ record.setPlanEndDate(processOperationDo2.getPlanstartdate());
|
|
|
+ }
|
|
|
+
|
|
|
+ ApsProcessOperationDo processOperationDo3 = operationDoList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getActualstartdate())).min(Comparator.comparing(ApsProcessOperationDo::getActualstartdate)).orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(processOperationDo3)) {
|
|
|
+ record.setActualStartDate(processOperationDo3.getActualstartdate());
|
|
|
+ }
|
|
|
+
|
|
|
+ ApsProcessOperationDo processOperationDo4 = operationDoList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getActualfinishdate())).max(Comparator.comparing(ApsProcessOperationDo::getActualfinishdate)).orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(processOperationDo4)) {
|
|
|
+ record.setActualEndDate(processOperationDo4.getActualfinishdate());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return R.ok(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void doSetMapLoading(Map<String, String> processLoadingMap, List<String> lastProcessIdList, List<ApsProcessOperationDo> processOperationDoList) {
|
|
|
+ for (String s : lastProcessIdList) {
|
|
|
+
|
|
|
+ LinkedList<String> stack = new LinkedList<>();
|
|
|
+ //迭代处理
|
|
|
+ setStack(processLoadingMap, processOperationDoList, s, stack, s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //迭代处理,组装生产进度,赋值stack
|
|
|
+ private void setStack(Map<String, String> processLoadingMap, List<ApsProcessOperationDo> processOperationDoList, String s, LinkedList<String> stack, String lastProcessId) {
|
|
|
+ //获取该工序详情
|
|
|
+ ApsProcessOperationDo processOperationDo = processOperationDoList.stream().filter(item -> item.getId().equals(s)).findFirst().orElse(null);
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(processOperationDo)) {
|
|
|
+ setMap(s, processLoadingMap, stack, lastProcessId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //组装赋值,先进后出
|
|
|
+ String processname = processOperationDo.getProcessname();
|
|
|
+ Integer reportroll = processOperationDo.getReportroll();
|
|
|
+ Integer planprocessrall = processOperationDo.getPlanprocessrall();
|
|
|
+ stack.push(processname + "(" + reportroll + "/" + planprocessrall + ")");
|
|
|
+
|
|
|
+ //如果前道工序为空,表示结束
|
|
|
+ if (ObjectUtil.isEmpty(processOperationDo.getPreviousprocessid())) {
|
|
|
+ setMap(s, processLoadingMap, stack, lastProcessId);
|
|
|
+ } else {//不为空,继续迭代
|
|
|
+ setStack(processLoadingMap, processOperationDoList, processOperationDo.getPreviousprocessid(), stack, lastProcessId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //赋值map
|
|
|
+ private void setMap(String s, Map<String, String> processLoadingMap, LinkedList<String> stack, String lastProcessId) {
|
|
|
+ //判断栈中 是否为空,如果为空,则赋值空字符串
|
|
|
+ if (stack.size() <= 0) {
|
|
|
+ processLoadingMap.put(s, "");
|
|
|
+ } else {//否则,顺序取出并拼接字符串
|
|
|
+ String processLoading = String.join("-", stack);
|
|
|
+ processLoadingMap.put(lastProcessId, processLoading);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|