查询模组档位统计分布图 修改
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.cnbm.packing.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cnbm.admin.annotation.LogOperation;
|
||||
import com.cnbm.dispatch.enums.kuka.step1.Step1Mes2PlcVar;
|
||||
import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar;
|
||||
@@ -11,11 +13,14 @@ import com.cnbm.packing.dto.CamlineSubIdDTO;
|
||||
import com.cnbm.packing.dto.CamlineSubIdForImportDTO;
|
||||
import com.cnbm.packing.dto.PowerReportDTO;
|
||||
import com.cnbm.packing.entity.WoPackagingBoxSubstrate;
|
||||
import com.cnbm.packing.mapper.WoPackagingBoxSubstrateMapper;
|
||||
import com.cnbm.packing.param.PowerReportQueryParam;
|
||||
import com.cnbm.packing.param.SubIdQueryParam;
|
||||
import com.cnbm.packing.service.DynamicDataSourceService;
|
||||
import com.cnbm.packing.service.WoPackagingBoxServiceBiz;
|
||||
import com.cnbm.packing.service.WoPackagingBoxSubstrateServiceBiz;
|
||||
import com.cnbm.packing.vo.PowerReportVo;
|
||||
import com.cnbm.packing.vo.SubIdPageVo;
|
||||
import com.cnbm.s7.entity.R;
|
||||
import com.cnbm.s7.s7connector.enmuc.S7Client;
|
||||
import com.cnbm.s7.s7connector.type.PlcVar;
|
||||
@@ -26,15 +31,19 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.cnbm.common.utils.Result;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.Format;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -58,6 +67,10 @@ public class TestController {
|
||||
@Autowired
|
||||
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||
|
||||
@Autowired
|
||||
WoPackagingBoxSubstrateMapper subMapper;
|
||||
|
||||
|
||||
private Object read(S7Client s7Client,Step1Plc2MesVar var) throws UnsupportedEncodingException, ParseException {
|
||||
try {
|
||||
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
|
||||
@@ -120,6 +133,16 @@ public class TestController {
|
||||
System.out.println(Step2Plc2MesVar.SubIdList.getName()+" : "+Arrays.toString(s));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/subPageMapper")
|
||||
@ApiOperation(value = "基板表 left join box表 分页查询")
|
||||
|
||||
public com.cnbm.packing.vo.R<IPage<SubIdPageVo>> subPageMapper(@Validated({Default.class}) @RequestBody SubIdQueryParam param) {
|
||||
|
||||
return boxServiceBiz.subIdPage(param);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/forImport")
|
||||
public R forImport() throws UnsupportedEncodingException, ParseException {
|
||||
List<CamlineSubIdForImportDTO> alllCamlineSubForImp = service.getAlllCamlineSubForImp();
|
||||
@@ -135,6 +158,74 @@ public class TestController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/forTestMix")
|
||||
public R forTestMix() throws UnsupportedEncodingException, ParseException {
|
||||
String[] s = new String[20];
|
||||
s[0]= "30110012303021614";
|
||||
s[1]= "30110012303022415";
|
||||
s[2]= "30110012303022801";
|
||||
s[3]= "30110012303040003";
|
||||
s[4]= "30110012303030488";
|
||||
s[5]= "30110012303020247";
|
||||
s[6]= "30110012303021008";
|
||||
s[7]= "30110012303022434";
|
||||
s[8]= "30110012303012878";
|
||||
s[9]= "30110012302281212";
|
||||
s[10]= "30110012302281213";
|
||||
s[11]= "30110012302281215";
|
||||
s[12]= "30110012302271160";
|
||||
s[13]= "30110012302271154";
|
||||
s[14]= "30110012303050321";
|
||||
s[15]= "30110012303050331";
|
||||
s[16]= "30110012303020036";
|
||||
s[17]= "30110012303022606";
|
||||
s[18]= "30110012303030009";
|
||||
s[19]= "30110012303021795";
|
||||
System.out.println(isMixLevel(s));;
|
||||
WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(s[0]);
|
||||
System.out.println(bySubId.getSapMaterial());
|
||||
System.out.println(getErrorBoxId(bySubId.getSapMaterial()));
|
||||
System.out.println(getBoxId(bySubId.getSapMaterial()));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
public String formateString(Integer a){
|
||||
Format f1 = new DecimalFormat("000");
|
||||
return f1.format(a);
|
||||
}
|
||||
public String getBoxId(String sapMaterial){
|
||||
Integer todayBoxNum = service.getTodayBoxNum()+1;
|
||||
String nowTime = DateUtil.format(new Date(), "yyMMdd");
|
||||
|
||||
todayBoxNum+=500;
|
||||
String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum);
|
||||
return res;
|
||||
}
|
||||
public String getErrorBoxId(String sapMaterial){
|
||||
|
||||
String nowTime = DateUtil.format(new Date(), "yyMMdd");
|
||||
String mixBoxError = "001";
|
||||
String res = "Err"+sapMaterial+nowTime+mixBoxError;
|
||||
return res;
|
||||
}
|
||||
private boolean isMixLevel(String[] subIds){
|
||||
String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel();
|
||||
String errMsg = "以下基板ID出现混档:";
|
||||
boolean res = false;
|
||||
for(int i=1;i<subIds.length;i++){
|
||||
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||
|
||||
if(!powerLevel.equals(correctLevel)){
|
||||
errMsg+="基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
if(res){
|
||||
logger.error(errMsg);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/testReadAll")
|
||||
|
||||
@@ -36,8 +36,10 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,33 +126,72 @@ public class WoPackagingBoxSubstrateController {
|
||||
return new Result<Long>().ok(dto.getId());
|
||||
}
|
||||
|
||||
@ApiOperation("查询模组档位统计分布图powerReportTY")
|
||||
@LogOperation("查询模组档位统计分布图powerReportTY")
|
||||
@PostMapping("/powerReportTY")
|
||||
public Result<Boolean> powerReportTY(@RequestBody PowerReportQueryParam queryParam){
|
||||
List<PowerReportDTO> powerReportDTOS = boxServiceBiz.powerReport(queryParam);
|
||||
System.out.println(powerReportDTOS);
|
||||
return new Result<Boolean>().ok(true);
|
||||
}
|
||||
|
||||
@ApiOperation("查询模组档位统计分布图")
|
||||
@LogOperation("查询模组档位统计分布图")
|
||||
@PostMapping("/powerReport")
|
||||
public Result<PowerReportVo> powerReport(@RequestBody PowerReportQueryParam queryParam){
|
||||
List<PowerReportDTO> powerReportDTOS = boxServiceBiz.powerReport(queryParam);
|
||||
System.out.println(powerReportDTOS.toString());
|
||||
List<PowerReportDTO> powerReportList = new ArrayList<>();
|
||||
powerReportList.add(new PowerReportDTO(0,"115",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"120",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"125",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"130",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"135",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"140",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"145",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"150",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"155",0f,"0%"));
|
||||
powerReportList.add(new PowerReportDTO(0,"160",0f,"0%"));
|
||||
|
||||
|
||||
for(PowerReportDTO power : powerReportList){
|
||||
for(PowerReportDTO inner : powerReportDTOS){
|
||||
if(Objects.equals(power.getSubLevel(), inner.getSubLevel())){
|
||||
power.setProportion(inner.getProportion());
|
||||
power.setSubNum(inner.getSubNum());
|
||||
power.setSumPMPP(inner.getSumPMPP());
|
||||
power.setSubLevel(inner.getSubLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(powerReportList.toString());
|
||||
PowerReportVo powerReportVo = new PowerReportVo();
|
||||
Float totalLevelPower = new Float(0);
|
||||
Float totalCompensatePower = new Float(0);
|
||||
Float diversePower = new Float(0);
|
||||
Integer totalSubNum = 0;
|
||||
for(PowerReportDTO power : powerReportDTOS){
|
||||
for(PowerReportDTO power : powerReportList){
|
||||
Integer subLevel = Integer.valueOf(power.getSubLevel());
|
||||
Integer subNum = power.getSubNum();
|
||||
if(power.getSumPMPP()==null){
|
||||
return new Result<PowerReportVo>().error("基板等级:"+subLevel+",基板数量:"+subNum+", 的总和为null");
|
||||
}
|
||||
Float sumPMPP = power.getSumPMPP();
|
||||
totalLevelPower += subLevel*subNum;
|
||||
totalCompensatePower += sumPMPP*subNum;
|
||||
totalSubNum+= subNum;
|
||||
}
|
||||
for(PowerReportDTO power : powerReportDTOS){
|
||||
for(PowerReportDTO power : powerReportList){
|
||||
Float prop = (Float.valueOf(power.getSubNum())/Float.valueOf(totalSubNum))*100;
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String propS = df.format(prop)+"%";
|
||||
power.setProportion(propS);
|
||||
}
|
||||
|
||||
|
||||
diversePower = totalCompensatePower - totalLevelPower;
|
||||
powerReportVo.setPowerReports(powerReportDTOS);
|
||||
powerReportVo.setPowerReports(powerReportList);
|
||||
powerReportVo.setDiversePower(diversePower);
|
||||
powerReportVo.setTotalCompensatePower(totalCompensatePower);
|
||||
powerReportVo.setTotalLevelPower(totalLevelPower);
|
||||
|
||||
Reference in New Issue
Block a user