| | |
| | | import com.zy.asrs.entity.mes.StockDetl; |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | |
| | | 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; |
| | | |
| | | /** |
| | | * 总览:总库位、已用库位、剩余库位、今日出库、今日入库、剩余库位 |
| | |
| | | endTime = now; |
| | | |
| | | } else { |
| | | SimpleDateFormat sdf = |
| | | new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); |
| | | |
| | | 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); |
| | |
| | | endTime = now; |
| | | |
| | | } else { |
| | | SimpleDateFormat sdf = |
| | | new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); |
| | | |
| | | 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 |
| | | |
| | | @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; |
| | | } |
| | | } |