自动化立体仓库 - WMS系统
zyh
20 小时以前 3bf6f972604761c9ac59a2cb9ea01eeacaec2189
src/main/java/com/zy/asrs/service/impl/DigitalTwinServiceImpl.java
@@ -2,26 +2,28 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.LocCount;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.digitaltwin.*;
import com.zy.asrs.entity.digitaltwin.AllLocationsVo;
import com.zy.asrs.mapper.DigitalTwinMapper;
import com.zy.asrs.mapper.LocCountMapper;
import com.zy.asrs.mapper.LocDetlMapper;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.DigitalTwinService;
import com.zy.asrs.service.LocDetlService;
import com.zy.asrs.service.LocMastService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -31,6 +33,8 @@
    private DigitalTwinMapper digitalTwinMapper;
    @Resource
    private LocCountMapper locCountMapper;
    @Autowired
    private LocDetlMapper locDetlMapper;
    /**
     * 总览:总库位、已用库位、剩余库位、今日出库、今日入库、剩余库位
@@ -74,15 +78,37 @@
            startTime = calendar.getTime();
            endTime = now;
        } else {
            SimpleDateFormat sdf =
                    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        }else {
            SimpleDateFormat sdf;
            try {
                startTime  = sdf.parse(startDate);
                endTime = sdf.parse(endDate);
                // 尝试解析yyyyMMdd格式
                if (startDate.length() == 8 && endDate.length() == 8) {
                    sdf = new SimpleDateFormat("yyyyMMdd");
                    startTime = sdf.parse(startDate);
                    endTime = sdf.parse(endDate);
                    // 设置结束时间为当天的23:59:59.999
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(endTime);
                    calendar.set(Calendar.HOUR_OF_DAY, 23);
                    calendar.set(Calendar.MINUTE, 59);
                    calendar.set(Calendar.SECOND, 59);
                    calendar.set(Calendar.MILLISECOND, 999);
                    endTime = calendar.getTime();
                } else {
                    // 尝试解析yyyy-MM-dd HH:mm:ss.SSS格式
                    sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                    startTime = sdf.parse(startDate);
                    endTime = sdf.parse(endDate);
                }
            } catch (ParseException e) {
                e.printStackTrace();
                // 解析失败时使用默认的7天时间范围
                Date now = new Date();
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(now);
                calendar.add(Calendar.DAY_OF_MONTH, -7);
                startTime = calendar.getTime();
                endTime = now;
            }
        }
        List<DtOrderVo> dbOrder = digitalTwinMapper.recentOrder(startTime, endTime);
@@ -114,15 +140,37 @@
            startTime = calendar.getTime();
            endTime = now;
        } else {
            SimpleDateFormat sdf =
                    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        }  else {
            SimpleDateFormat sdf;
            try {
                startTime  = sdf.parse(startDate);
                endTime = sdf.parse(endDate);
                // 尝试解析yyyyMMdd格式
                if (startDate.length() == 8 && endDate.length() == 8) {
                    sdf = new SimpleDateFormat("yyyyMMdd");
                    startTime = sdf.parse(startDate);
                    endTime = sdf.parse(endDate);
                    // 设置结束时间为当天的23:59:59.999
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(endTime);
                    calendar.set(Calendar.HOUR_OF_DAY, 23);
                    calendar.set(Calendar.MINUTE, 59);
                    calendar.set(Calendar.SECOND, 59);
                    calendar.set(Calendar.MILLISECOND, 999);
                    endTime = calendar.getTime();
                } else {
                    // 尝试解析yyyy-MM-dd HH:mm:ss.SSS格式
                    sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                    startTime = sdf.parse(startDate);
                    endTime = sdf.parse(endDate);
                }
            } catch (ParseException e) {
                e.printStackTrace();
                // 解析失败时使用默认的7天时间范围
                Date now = new Date();
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(now);
                calendar.add(Calendar.DAY_OF_MONTH, -7);
                startTime = calendar.getTime();
                endTime = now;
            }
        }
@@ -301,4 +349,51 @@
    // endregion
    // endregion
    @Resource
    private LocDetlService locDetlService;
    @Override
    public R getAllLocations() {
        List<AllLocationsVo> allLocationsVos = new ArrayList<>();
        List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<>());
        locMastList.forEach(locMast -> {
            AllLocationsVo allLocationsVo = new AllLocationsVo();
            allLocationsVo.setLocNo(locMast.getLocNo());
            String locSts = locMast.getLocSts();
            allLocationsVo.setLocSts(locSts);
            // 有库存
            if (locSts.equals("F") || locSts.equals("P") || locSts.equals("Q") || locSts.equals("R")) {
                List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
                if (!locDetls.isEmpty()) {
                    List<AllLocationsVo.LocDetl> locDetlList = locDetls.stream().map(locDetl -> {
                                AllLocationsVo.LocDetl locDetl1 = new AllLocationsVo.LocDetl();
                                BeanUtils.copyProperties(locDetl, locDetl1);
                                return locDetl1;
                            }
                    ).collect(Collectors.toList());
                    allLocationsVo.setLocDetls(locDetlList);
                }
            }
            allLocationsVos.add(allLocationsVo);
        });
        return R.ok(allLocationsVos);
    }
    public List<Map<String, Object>> getLocalDetal() {
        List<LocDetl> locDetls = locDetlMapper.selectList(new EntityWrapper<>());
        List<Map<String, Object>> result = new ArrayList<>();
        for (LocDetl locDetl : locDetls) {
            Map<String, Object> item = new HashMap<>();
            item.put("zpallet", locDetl.getZpallet());
            item.put("anfme", locDetl.getAnfme());
            item.put("matnr", locDetl.getMatnr());
            item.put("maktx", locDetl.getMaktx());
            result.add(item);
        }
        return result;
    }
}