| | |
| | | |
| | | 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.mapper.LocMastMapper; |
| | | 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 |
| | |
| | | private DigitalTwinMapper digitalTwinMapper; |
| | | @Resource |
| | | private LocCountMapper locCountMapper; |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | |
| | | @Autowired |
| | | private LocMastMapper locMastMapper; |
| | | |
| | | /** |
| | | * 总览:总库位、已用库位、剩余库位、今日出库、今日入库、剩余库位 |
| | |
| | | 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); |
| | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // 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; |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getLocInfo() { |
| | | List<LocMast> LocMasts = locMastMapper.selectList(new EntityWrapper<>()); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | |
| | | // 初始化计数器 |
| | | int emptyLocCount = 0; |
| | | int fullZpalletCount = 0; |
| | | int emptyZpalletCount = 0; |
| | | int pickOutCount = 0; |
| | | int pickInCount = 0; |
| | | int outboundCount = 0; |
| | | int inboundCount = 0; |
| | | int disableCount = 0; |
| | | int mergeCount = 0; |
| | | |
| | | // 统计每种状态的库位数量 |
| | | for (LocMast locMast : LocMasts) { |
| | | String locSts = locMast.getLocSts(); |
| | | if (locSts.equals("O")) { |
| | | emptyLocCount++; |
| | | } else if (locSts.equals("F")) { |
| | | fullZpalletCount++; |
| | | } else if (locSts.equals("D")) { |
| | | emptyZpalletCount++; |
| | | } else if (locSts.equals("P")) { |
| | | pickOutCount++; |
| | | } else if (locSts.equals("Q")) { |
| | | pickInCount++; |
| | | } else if (locSts.equals("R")) { |
| | | outboundCount++; |
| | | } else if (locSts.equals("S")) { |
| | | inboundCount++; |
| | | } else if (locSts.equals("X")) { |
| | | disableCount++; |
| | | } else if (locSts.equals("Y")) { |
| | | mergeCount++; |
| | | } |
| | | } |
| | | |
| | | // 将统计结果放入Map中 |
| | | result.put("EmptyLoc", emptyLocCount); |
| | | result.put("FullZpallet", fullZpalletCount); |
| | | result.put("EmptyZpallet", emptyZpalletCount); |
| | | result.put("PickOut", pickOutCount); |
| | | result.put("PickIn", pickInCount); |
| | | result.put("Outbound", outboundCount); |
| | | result.put("Inbound", inboundCount); |
| | | result.put("Disable", disableCount); |
| | | result.put("Merge", mergeCount); |
| | | |
| | | return result; |
| | | } |
| | | } |