|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.core.annotations.ManagerAuth; | 
|---|
|  |  |  | import com.core.common.Arith; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.DateUtils; | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.zy.asrs.domain.dto.AxisBean; | 
|---|
|  |  |  | import com.zy.asrs.domain.dto.WorkChartAxis; | 
|---|
|  |  |  | import com.zy.asrs.domain.enums.CrnStatusType; | 
|---|
|  |  |  | import com.zy.asrs.domain.enums.SiteStatusType; | 
|---|
|  |  |  | import com.zy.asrs.domain.param.SystemSwitchParam; | 
|---|
|  |  |  | import com.zy.asrs.domain.vo.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasDevp; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.mapper.BasCrnErrorMapper; | 
|---|
|  |  |  | import com.zy.asrs.mapper.LocMastMapper; | 
|---|
|  |  |  | import com.zy.asrs.mapper.ReportQueryMapper; | 
|---|
|  |  |  | import com.zy.asrs.mapper.TaskWrkMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.BasCrnpService; | 
|---|
|  |  |  | import com.zy.asrs.service.BasDevpService; | 
|---|
|  |  |  | import com.zy.asrs.service.DeviceErrorService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.common.CodeRes; | 
|---|
|  |  |  | import com.zy.core.CrnThread; | 
|---|
|  |  |  | import com.zy.core.DevpThread; | 
|---|
|  |  |  | import com.zy.core.Slave; | 
|---|
|  |  |  | import com.zy.core.cache.OutputQueue; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.CrnModeType; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.CrnSlave; | 
|---|
|  |  |  | import com.zy.core.model.DevpSlave; | 
|---|
|  |  |  | import com.zy.core.model.protocol.CrnProtocol; | 
|---|
|  |  |  | import com.zy.core.model.protocol.StaProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | import com.zy.core.properties.SystemProperties; | 
|---|
|  |  |  | import com.zy.core.thread.DevpThread; | 
|---|
|  |  |  | import com.zy.core.thread.BarcodeThread; | 
|---|
|  |  |  | import com.zy.core.thread.ScaleThread; | 
|---|
|  |  |  | import com.zy.core.thread.SiemensCrnThread; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestParam; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.concurrent.atomic.AtomicInteger; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 主控图接口 | 
|---|
|  |  |  | * Created by vincent on 2020-06-01 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/console") | 
|---|
|  |  |  | public class ConsoleController { | 
|---|
|  |  |  | 
|---|
|  |  |  | private WrkMastService wrkMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasDevpService basDevpService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocMastMapper locMastMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasCrnErrorMapper basCrnErrorMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ReportQueryMapper reportQueryMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceErrorService deviceErrorService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasCrnpService basCrnpService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static AtomicInteger integer = new AtomicInteger(); | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private TaskWrkMapper taskWrkMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/system/running/status") | 
|---|
|  |  |  | @ManagerAuth(memo = "系统运行状态") | 
|---|
|  |  |  | public R systemRunningStatus(){ | 
|---|
|  |  |  | public R systemRunningStatus() { | 
|---|
|  |  |  | return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/system/switch") | 
|---|
|  |  |  | @ManagerAuth(memo = "系统运行开关操作") | 
|---|
|  |  |  | public R systemSwitch(SystemSwitchParam param) throws InterruptedException { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getOperatorType())){ | 
|---|
|  |  |  | if (Cools.isEmpty(param.getOperatorType())) { | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (param.getOperatorType() == 0) { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getPassword())){ | 
|---|
|  |  |  | if (Cools.isEmpty(param.getPassword())) { | 
|---|
|  |  |  | return R.error("请输入口令"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)){ | 
|---|
|  |  |  | if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)) { | 
|---|
|  |  |  | return R.error("口令错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Thread.sleep(2000L); | 
|---|
|  |  |  | SystemProperties.WCS_RUNNING_STATUS.set(param.getOperatorType()==1?Boolean.TRUE:Boolean.FALSE); | 
|---|
|  |  |  | Thread.sleep(200L); | 
|---|
|  |  |  | SystemProperties.WCS_RUNNING_STATUS.set(param.getOperatorType() == 1 ? Boolean.TRUE : Boolean.FALSE); | 
|---|
|  |  |  | return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/latest/data/site") | 
|---|
|  |  |  | @ManagerAuth(memo = "站点实时数据") | 
|---|
|  |  |  | public R siteLatestData(){ | 
|---|
|  |  |  | public R siteLatestData() { | 
|---|
|  |  |  | List<SiteLatestDataVo> vos = new ArrayList<>(); | 
|---|
|  |  |  | Map<Integer, StaProtocol> stations = new HashMap<>(); | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | StaProtocol staProtocol = entry.getValue(); | 
|---|
|  |  |  | vo.setSiteId(String.valueOf(entry.getKey())); // 站点编号 | 
|---|
|  |  |  | vo.setWorkNo(staProtocol.getWorkNo()); // 工作号 | 
|---|
|  |  |  | vo.setSiteStatus(SiteStatusType.process(staProtocol));  // 状态 | 
|---|
|  |  |  | String faultDescription = staProtocol.getFaultDescription(); | 
|---|
|  |  |  | vo.setSiteStatus(Cools.isEmpty(faultDescription) ? SiteStatusType.process(staProtocol) : SiteStatusType.SITE_ERROR);  // 状态 | 
|---|
|  |  |  | vo.setNearbySta(staProtocol.getNearbySta());  //RGV位置 | 
|---|
|  |  |  | vos.add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(vos); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/latest/data/crn") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机实时数据") | 
|---|
|  |  |  | public R crnLatestData(){ | 
|---|
|  |  |  | public R crnLatestData() { | 
|---|
|  |  |  | List<CrnLatestDataVo> vos = new ArrayList<>(); | 
|---|
|  |  |  | for (int i =1; i<=2; i++){ | 
|---|
|  |  |  | for (CrnSlave crn : slaveProperties.getCrn()) { | 
|---|
|  |  |  | // 获取堆垛机信息 | 
|---|
|  |  |  | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); | 
|---|
|  |  |  | if (crnThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); | 
|---|
|  |  |  | if (crnProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | CrnLatestDataVo vo = new CrnLatestDataVo(); | 
|---|
|  |  |  | vo.setCrnId(i); | 
|---|
|  |  |  | vo.setOffset((double) new Random().nextInt(560)); | 
|---|
|  |  |  | vo.setCrnId(crn.getId());   //  堆垛机编号 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            Short totalBay = locMastMapper.selectTotalBay(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setOffset((double) new Random().nextInt(560));     //  堆垛机偏移量 | 
|---|
|  |  |  | vo.setBay(crnProtocol.getBay());    //  当前列 | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机状态判断 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | if (crnProtocol.getAlarm1() > 0) { | 
|---|
|  |  |  | vo.setCrnStatus(CrnStatusType.MACHINE_ERROR); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (crnProtocol.getTaskNo() > 0) { | 
|---|
|  |  |  | //                    WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(crnProtocol.getTaskNo())); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | vo.setCrnStatus(CrnStatusType.process(taskWrk.getIoType())); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setCrnStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO : CrnStatusType.MACHINE_UN_AUTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setCrnStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO : CrnStatusType.MACHINE_UN_AUTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vos.add(vo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(vos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/latest/data/barcode") | 
|---|
|  |  |  | @ManagerAuth(memo = "条码扫描仪实时数据") | 
|---|
|  |  |  | public R barcodeLatestData(){ | 
|---|
|  |  |  | integer.getAndIncrement(); | 
|---|
|  |  |  | public R barcodeLatestData() { | 
|---|
|  |  |  | List<BarcodeDataVo> list = new ArrayList<>(); | 
|---|
|  |  |  | for (int i=1;i<=1;i++){ | 
|---|
|  |  |  | BarcodeDataVo vo = new BarcodeDataVo(); | 
|---|
|  |  |  | vo.setBarcodeId("1"); | 
|---|
|  |  |  | if (integer.get()%5 != 0) { | 
|---|
|  |  |  | vo.setCodeValue("0"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | vo.setCodeValue(String.valueOf(new Random().nextInt(5000))); | 
|---|
|  |  |  | for (Slave barcode : slaveProperties.getBarcode()) { | 
|---|
|  |  |  | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcode.getId()); | 
|---|
|  |  |  | if (null == barcodeThread) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BarcodeDataVo vo = new BarcodeDataVo(); | 
|---|
|  |  |  | vo.setBarcodeId(barcode.getId()); | 
|---|
|  |  |  | vo.setCodeValue(barcodeThread.getBarcode()); | 
|---|
|  |  |  | list.add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/latest/data/scale") | 
|---|
|  |  |  | @ManagerAuth(memo = "磅秤实时数据") | 
|---|
|  |  |  | public R scaleLatestData() { | 
|---|
|  |  |  | List<ScaleDataVo> list = new ArrayList<>(); | 
|---|
|  |  |  | for (Slave scale : slaveProperties.getScale()) { | 
|---|
|  |  |  | ScaleThread scaleThread = (ScaleThread) SlaveConnection.get(SlaveType.Scale, scale.getId()); | 
|---|
|  |  |  | if (null == scaleThread) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ScaleDataVo vo = new ScaleDataVo(); | 
|---|
|  |  |  | vo.setScaleId(scale.getId()); | 
|---|
|  |  |  | vo.setValue(String.valueOf(Arith.multiplys(1, scaleThread.getScale(), 1))); | 
|---|
|  |  |  | list.add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取设备详情 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/deviceInfo") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R getDeviceInfo() { | 
|---|
|  |  |  | ArrayList<HashMap<String, Object>> list = new ArrayList<>(); | 
|---|
|  |  |  | for (CrnSlave crn : slaveProperties.getCrn()) { | 
|---|
|  |  |  | // 获取堆垛机信息 | 
|---|
|  |  |  | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); | 
|---|
|  |  |  | if (crnThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); | 
|---|
|  |  |  | if (crnProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("device", "堆垛机"); | 
|---|
|  |  |  | map.put("deviceId", crn.getId()); | 
|---|
|  |  |  | map.put("battery", ""); | 
|---|
|  |  |  | map.put("error", crnProtocol.getFault()); | 
|---|
|  |  |  | map.put("status", crnProtocol.getStatusType().desc); | 
|---|
|  |  |  | list.add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (DevpSlave devp : slaveProperties.getDevp()) { | 
|---|
|  |  |  | DeviceError deviceError = deviceErrorService.selectByDeviceAndDeviceId("devp", devp.getId()); | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("device", "输送线"); | 
|---|
|  |  |  | map.put("deviceId", devp.getId()); | 
|---|
|  |  |  | map.put("battery", ""); | 
|---|
|  |  |  | map.put("error", deviceError != null); | 
|---|
|  |  |  | map.put("status", deviceError == null ? "" : deviceError.getMsg()); | 
|---|
|  |  |  | list.add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (Slave scale : slaveProperties.getScale()) { | 
|---|
|  |  |  | DeviceError deviceError = deviceErrorService.selectByDeviceAndDeviceId("scale", scale.getId()); | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("device", "磅秤"); | 
|---|
|  |  |  | map.put("deviceId", scale.getId()); | 
|---|
|  |  |  | map.put("battery", ""); | 
|---|
|  |  |  | map.put("error", deviceError != null); | 
|---|
|  |  |  | map.put("status", deviceError == null ? "" : deviceError.getMsg()); | 
|---|
|  |  |  | list.add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HashMap<String, Object> hashMap = new HashMap<>(); | 
|---|
|  |  |  | hashMap.put("records", list); | 
|---|
|  |  |  | return R.ok().add(hashMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /****************************************************************/ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/site/detail") | 
|---|
|  |  |  | @ManagerAuth(memo = "输送设备数据详情") | 
|---|
|  |  |  | public R siteDetail(@RequestParam Integer siteId){ | 
|---|
|  |  |  | if (Cools.isEmpty(siteId)){ | 
|---|
|  |  |  | public R siteDetail(@RequestParam Integer siteId) { | 
|---|
|  |  |  | if (Cools.isEmpty(siteId)) { | 
|---|
|  |  |  | return R.parse(CodeRes.EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | SiteDetailVo vo = new SiteDetailVo(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (basDevp == null) { | 
|---|
|  |  |  | return R.error("数据库维护异常"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setDevpNo(siteId);   // 站点编号 | 
|---|
|  |  |  | vo.setSiteId(siteId);   // 站点编号 | 
|---|
|  |  |  | vo.setWorkNo(staProtocol.getWorkNo());   // 工作号 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (staProtocol.getWorkNo() > 0) { | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectById(staProtocol.getWorkNo()); | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | vo.setWorkStatus(wrkMast.getWrkSts$());   // 工作状态 | 
|---|
|  |  |  | vo.setIoType(wrkMast.getIoType$());   //  入出库类型 | 
|---|
|  |  |  | vo.setSourceStaNo(wrkMast.getSourceStaNo$()); | 
|---|
|  |  |  | vo.setStaNo(wrkMast.getStaNo$()); | 
|---|
|  |  |  | vo.setSourceStock(wrkMast.getSourceLocNo$()); | 
|---|
|  |  |  | vo.setStock(wrkMast.getLocNo$()); | 
|---|
|  |  |  | //                        WrkMast wrkMast = wrkMastService.selectById(staProtocol.getWorkNo()); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(staProtocol.getWorkNo())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | vo.setWrkSts(taskWrk.getWrkSts$());   // 工作状态 | 
|---|
|  |  |  | vo.setIoType(taskWrk.getIoType$());   //  入出库类型 | 
|---|
|  |  |  | vo.setSourceStaNo(taskWrk.getStartPoint()); | 
|---|
|  |  |  | vo.setStaNo(taskWrk.getTargetPoint()); | 
|---|
|  |  |  | vo.setSourceLocNo(taskWrk.getStartPoint()); | 
|---|
|  |  |  | vo.setLocNo(taskWrk.getTargetPoint()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); //  自动 | 
|---|
|  |  |  | vo.setLoading(staProtocol.isLoading()?"Y":"N"); //  有物 | 
|---|
|  |  |  | vo.setAutoing(staProtocol.isAutoing() ? "Y" : "N"); //  自动 | 
|---|
|  |  |  | vo.setLoading(staProtocol.isLoading() ? "Y" : "N"); //  有物 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | vo.setCanining(basDevp.getCanining());  //  能入 | 
|---|
|  |  |  | vo.setCanouting(basDevp.getCanouting());    //  能出 | 
|---|
|  |  |  | vo.setError(staProtocol.getFaultDescription()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/crn/detail") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机设备数据详情") | 
|---|
|  |  |  | public R crnDetail(@RequestParam String crnNo){ | 
|---|
|  |  |  | if (Cools.isEmpty(crnNo)){ | 
|---|
|  |  |  | public R crnDetail(@RequestParam Integer crnNo) { | 
|---|
|  |  |  | if (Cools.isEmpty(crnNo)) { | 
|---|
|  |  |  | return R.parse(CodeRes.EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | CrnDetailVo vo = new CrnDetailVo(); | 
|---|
|  |  |  | vo.setCrnNo(crnNo); | 
|---|
|  |  |  | vo.setWorkNo("3387"); | 
|---|
|  |  |  | vo.setSourceStaNo("2303"); | 
|---|
|  |  |  | vo.setStaNo("2410"); | 
|---|
|  |  |  | vo.setWorkStatus("3.吊车入库中"); | 
|---|
|  |  |  | vo.setIoType("1.入库"); | 
|---|
|  |  |  | vo.setSourceStock(""); | 
|---|
|  |  |  | vo.setStock("05050040"); | 
|---|
|  |  |  | vo.setCrnStatus("取货中"); | 
|---|
|  |  |  | vo.setError("0"); | 
|---|
|  |  |  | return R.ok().add(vo); | 
|---|
|  |  |  | for (CrnSlave crnSlave : slaveProperties.getCrn()) { | 
|---|
|  |  |  | if (crnSlave.getId().equals(crnNo)) { | 
|---|
|  |  |  | BasCrnp basCrnp = basCrnpService.selectById(crnNo); | 
|---|
|  |  |  | if (basCrnp == null) { | 
|---|
|  |  |  | return R.error("数据库维护异常"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SiemensCrnThread crnThread = (SiemensCrnThread) SlaveConnection.get(SlaveType.Crn, crnSlave.getId()); | 
|---|
|  |  |  | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); | 
|---|
|  |  |  | vo.setCrnNo(crnNo); | 
|---|
|  |  |  | vo.setWorkNo(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | vo.setCrnStatus(crnProtocol.getStatusType().desc); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (crnProtocol.getAlarm1() > 0) { | 
|---|
|  |  |  | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1()); | 
|---|
|  |  |  | vo.setError(crnError == null ? "未知异常" : crnError.getErrName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (crnProtocol.getTaskNo() > 0) { | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(crnProtocol.getTaskNo())); | 
|---|
|  |  |  | //                    WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | vo.setSourceStaNo(taskWrk.getStartPoint()); | 
|---|
|  |  |  | vo.setStaNo(taskWrk.getTargetPoint()); | 
|---|
|  |  |  | vo.setWrkSts(taskWrk.getWrkSts$());   // 工作状态 | 
|---|
|  |  |  | vo.setIoType(taskWrk.getIoType$());   //  入出库类型 | 
|---|
|  |  |  | vo.setSourceLocNo(taskWrk.getStartPoint()); | 
|---|
|  |  |  | vo.setLocNo(taskWrk.getTargetPoint()); | 
|---|
|  |  |  | vo.setCrnStatus(crnProtocol.getStatusType().desc); | 
|---|
|  |  |  | vo.setError("");    // todo | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | vo.setInEnable(basCrnp.getInEnable());//可入 | 
|---|
|  |  |  | vo.setOutEnable(basCrnp.getOutEnable());//可出 | 
|---|
|  |  |  | return R.ok().add(vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Deprecated | 
|---|
|  |  |  | @PostMapping("/site/update") | 
|---|
|  |  |  | @ManagerAuth(memo = "输送设备数据修改") | 
|---|
|  |  |  | public R updateSite(){ | 
|---|
|  |  |  | public R updateSite() { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Deprecated | 
|---|
|  |  |  | @PostMapping("/crn/update") | 
|---|
|  |  |  | @ManagerAuth(memo = "堆垛机数据修改") | 
|---|
|  |  |  | public R updateCrn(){ | 
|---|
|  |  |  | public R updateCrn() { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/barcode/output/site") | 
|---|
|  |  |  | public R crnOutput() { | 
|---|
|  |  |  | ArrayList<JSONObject> jsonObjects = new ArrayList<>(OutputQueue.SCALE); | 
|---|
|  |  |  | jsonObjects.sort(new Comparator<JSONObject>() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public int compare(JSONObject o1, JSONObject o2) { | 
|---|
|  |  |  | Date o1Time = DateUtils.convert(o1.getString("time"), DateUtils.yyyyMMddHHmmss_F); | 
|---|
|  |  |  | Date o2Time = DateUtils.convert(o2.getString("time"), DateUtils.yyyyMMddHHmmss_F); | 
|---|
|  |  |  | return (int) (o2Time.getTime() - o1Time.getTime()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return R.ok().add(JSON.toJSONString(jsonObjects)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("loc/pie/charts") | 
|---|
|  |  |  | public R dsa() { | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<String, Object>(); | 
|---|
|  |  |  | List<ChartBean> list = new ArrayList<ChartBean>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocChartPie locUseRate = reportQueryMapper.getLocUseRate(); | 
|---|
|  |  |  | if (locUseRate != null) { | 
|---|
|  |  |  | ChartBean fqty = new ChartBean(); | 
|---|
|  |  |  | fqty.setName("在库库位"); | 
|---|
|  |  |  | fqty.setY(locUseRate.getFqty()); | 
|---|
|  |  |  | list.add(fqty); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ChartBean oqty = new ChartBean(); | 
|---|
|  |  |  | oqty.setName("空库位"); | 
|---|
|  |  |  | oqty.setY(locUseRate.getOqty()); | 
|---|
|  |  |  | list.add(oqty); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ChartBean uqty = new ChartBean(); | 
|---|
|  |  |  | uqty.setName("使用库位"); | 
|---|
|  |  |  | uqty.setY(locUseRate.getUqty()); | 
|---|
|  |  |  | list.add(uqty); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ChartBean xqty = new ChartBean(); | 
|---|
|  |  |  | xqty.setName("禁用库位"); | 
|---|
|  |  |  | xqty.setY(locUseRate.getXqty()); | 
|---|
|  |  |  | list.add(xqty); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | map.put("rows", list); | 
|---|
|  |  |  | return R.ok(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("locIo/line/charts") | 
|---|
|  |  |  | public R locIoLineCharts() { | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<String, Object>(); | 
|---|
|  |  |  | List<AxisBean> list = new ArrayList<AxisBean>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WorkChartAxis> listChart = reportQueryMapper.getChartAxis(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (listChart != null) { | 
|---|
|  |  |  | ArrayList<Integer> data1 = new ArrayList<Integer>(); | 
|---|
|  |  |  | ArrayList<Integer> data2 = new ArrayList<Integer>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); | 
|---|
|  |  |  | Calendar calendar = Calendar.getInstance(); | 
|---|
|  |  |  | calendar.add(Calendar.DATE, -12); | 
|---|
|  |  |  | for (int i = 0; i < 12; i++) { | 
|---|
|  |  |  | boolean flag = true; | 
|---|
|  |  |  | calendar.add(Calendar.DATE, 1); | 
|---|
|  |  |  | String str = sf.format(calendar.getTime()); | 
|---|
|  |  |  | for (WorkChartAxis workChart : listChart) { | 
|---|
|  |  |  | if (str.equals(workChart.getYmd())) { | 
|---|
|  |  |  | data1.add(workChart.getInqty()); | 
|---|
|  |  |  | data2.add(workChart.getOutqty()); | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (flag) { | 
|---|
|  |  |  | data1.add(0); | 
|---|
|  |  |  | data2.add(0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | AxisBean inqty = new AxisBean(); | 
|---|
|  |  |  | inqty.setName("入库数量"); | 
|---|
|  |  |  | Integer[] array1 = new Integer[data1.size()]; | 
|---|
|  |  |  | inqty.setData(data1.toArray(array1)); | 
|---|
|  |  |  | list.add(inqty); | 
|---|
|  |  |  | AxisBean outqty = new AxisBean(); | 
|---|
|  |  |  | outqty.setName("出库数量"); | 
|---|
|  |  |  | Integer[] array2 = new Integer[data2.size()]; | 
|---|
|  |  |  | outqty.setData(data2.toArray(array2)); | 
|---|
|  |  |  | list.add(outqty); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | map.put("rows", list); | 
|---|
|  |  |  | return R.ok(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|