| | |
| | | import com.fzzy.igds.service.DepotService; |
| | | import com.fzzy.igds.service.FileService; |
| | | import com.fzzy.igds.service.QuantityService; |
| | | import com.fzzy.igds.utils.Base64Util; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Slf4j |
| | | @Component("fzzy.quantityAnalysisService") |
| | | public class AnalysisService{ |
| | | public class AnalysisService { |
| | | |
| | | @Autowired |
| | | private DepotService depotService; |
| | |
| | | + progressData.getProgress()); |
| | | notifyWebInvoker.notifyQuantityProgress(progressData); |
| | | //根据进度抓拍 |
| | | if (progressData.getProgress() >= 1 && progressData.getProgress() <= 25) { |
| | | if (progressData.getProgress() >= 5 && progressData.getProgress() <= 15) { |
| | | remoteQuantity.sendMsg(ip, port, CommandBuilder.getInstance().build2006Message(message)); |
| | | } |
| | | if (progressData.getProgress() > 25 && progressData.getProgress() <= 50) { |
| | | if (progressData.getProgress() > 25 && progressData.getProgress() <= 35) { |
| | | remoteQuantity.sendMsg(ip, port, CommandBuilder.getInstance().build2006Message(message)); |
| | | } |
| | | if (progressData.getProgress() > 50 && progressData.getProgress() <= 75) { |
| | | if (progressData.getProgress() > 35 && progressData.getProgress() <= 45) { |
| | | remoteQuantity.sendMsg(ip, port, CommandBuilder.getInstance().build2006Message(message)); |
| | | } |
| | | if (progressData.getProgress() > 75 && progressData.getProgress() <= 99) { |
| | | if (progressData.getProgress() > 45 && progressData.getProgress() <= 55) { |
| | | remoteQuantity.sendMsg(ip, port, CommandBuilder.getInstance().build2006Message(message)); |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | Depot depot = depotService.getCacheDepot(conf.getCompanyId(), conf.getDepotId()); |
| | | |
| | | Quantity quantityData = new Quantity(); |
| | | quantityData.setBatchId(request.getBatchId()); |
| | | quantityData.setReceiveDate(new Date()); |
| | |
| | | quantityData.setCompanyId(depot.getCompanyId()); |
| | | quantityData.setPoints(""); |
| | | quantityData.setCheckUser(request.getExeUser()); |
| | | |
| | | Double real = 0.0; |
| | | if (null != depot.getStorageReal()) { |
| | | real = depot.getStorageReal(); |
| | | } |
| | | Double num1 = content.getWeight() - real; |
| | | if (num1 < 0) { |
| | | num1 = 0 - num1; |
| | | } |
| | | String per = "--"; |
| | | if (real > 0) { |
| | | per = new DecimalFormat("0.00").format(num1 / real * 100); |
| | | } |
| | | |
| | | String remark = "检测重量为" + content.getWeight() + " KG,实际重量为" + real + " KG,误差小于" + per + "% 。"; |
| | | quantityData.setRemark(remark); |
| | | quantityService.saveData(quantityData); |
| | | //直接返回 |
| | | remoteQuantity.sendMsg(ip, port, CommandBuilder.getInstance().build2004Message(message)); |
| | |
| | | log.error("没有获取到发送命令,取消解析:" + message.toString()); |
| | | return; |
| | | } |
| | | String fileName = ContextUtil.generateId()+ ".jpg"; |
| | | String fileName = ContextUtil.generateId() + ".jpg"; |
| | | String savePath = fileService.getFileSavePath("QUANTITY"); |
| | | String filePath = savePath+fileName; |
| | | fileService.baseImg2Disk(filePath, content.getData()); |
| | | FileInfo data = new FileInfo(); |
| | | data.setId(ContextUtil.UUID()); |
| | | data.setCreateTime(new Date()); |
| | | data.setFileName(fileName); |
| | | data.setFilePath(filePath.replace(FrameworkConfig.getProfile(), "/profile/")); |
| | | data.setBizId(res.getBatchId()); |
| | | data.setBizTag("quantity"); |
| | | data.setCompanyId(conf.getCompanyId()); |
| | | fileService.saveFile(data); |
| | | String filePath = savePath + fileName; |
| | | |
| | | String msg = Base64Util.base64ToImg(content.getData(), filePath); |
| | | if (null != msg) { |
| | | //文件保存成功,则保存文件记录 |
| | | FileInfo data = new FileInfo(); |
| | | data.setId(ContextUtil.UUID()); |
| | | data.setCreateTime(new Date()); |
| | | data.setCreateBy(res.getExeUser()); |
| | | data.setFileName(fileName); |
| | | data.setFilePath(filePath.replace(FrameworkConfig.getProfile(), "/profile/")); |
| | | data.setBizId(res.getBatchId()); |
| | | data.setBizTag("quantity"); |
| | | data.setCompanyId(conf.getCompanyId()); |
| | | fileService.saveFile(data); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public String checkMsg(IoMessage message) { |
| | | if (StringUtils.isEmpty(message.getResult())) return null; |
| | | if (ServerUtils.RESP_0.equals(message.getResult())) return null; |
| | | |
| | | |
| | | if (ServerUtils.RESP_1.equals(message.getResult())) return "命令格式错误"; |
| | | if (ServerUtils.RESP_2.equals(message.getResult())) return "命令数据检验异常"; |
| | | if (ServerUtils.RESP_3.equals(message.getResult())) return "发送超时错误"; |