增加 按小时查询产量

master
wangh 4 years ago
parent c829fe058b
commit 5d209d8e5e

@ -2,11 +2,8 @@ package com.ruoyi.web.controller.broad;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.IBroadDataService; import com.ruoyi.system.service.IBroadDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -15,8 +12,6 @@ import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author wanghao * @author wanghao
@ -36,77 +31,70 @@ public class BoxBroadController {
@PostMapping("/planCompletion") @PostMapping("/planCompletion")
@ResponseBody @ResponseBody
@ApiOperation("查询计划数量完成情况") @ApiOperation("箱壳查询计划数量完成情况")
public String selectplanCompletion() { public String selectplanCompletion() {
BoxPlanCompletion completion= service.selectplanCompletion(); BoxPlanCompletion completion = service.selectplanCompletion();
return JSONObject.toJSONString(completion); return JSONObject.toJSONString(completion);
} }
// 库存
// 库存
@PostMapping("/selectStock/{id}") @PostMapping("/selectStock/{id}")
@ResponseBody @ResponseBody
public String selectStock(@PathVariable("id")String id){ @ApiOperation("箱壳查询库存")
public String selectStock(@PathVariable("id") String id) {
List<Long> seriesInfo = new ArrayList<Long>(); List<Long> seriesInfo = new ArrayList<Long>();
List<String> xAxisInfo = new ArrayList<String>(); List<String> xAxisInfo = new ArrayList<String>();
List<BoxStock> list=service.selectStock(id); List<BoxStock> list = service.selectStock(id);
list.stream().forEach(t->{ list.stream().forEach(t -> {
seriesInfo.add(Long.valueOf(t.getStock())); seriesInfo.add(Long.valueOf(t.getStock()));
xAxisInfo.add(t.getOrder_type()); xAxisInfo.add(t.getOrder_type());
}); });
return JSONObject.toJSONString(new EchartsDTO(xAxisInfo,seriesInfo)); return JSONObject.toJSONString(new EchartsDTO(xAxisInfo, seriesInfo));
} }
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 按类型查询产量
@PostMapping("/selectOutputByType") @PostMapping("/selectOutputByType")
@ResponseBody @ResponseBody
public String selectOutputByType(){ @ApiOperation("箱壳按类型查询产量")
public String selectOutputByType() {
EchartsDTO echarts = new EchartsDTO(); List<BoxOutput> info = service.selectOutputByType();
List<Long> seriesInfo = new ArrayList<Long>(); String jsonInfo = JSONArray.toJSONString(info);
List<String> xAxisInfo = new ArrayList<String>(); System.out.println("根据型号统计产量:" + jsonInfo);
List<BoxOutputByType> info = service.selectOutputByType();
// Map<String,List<BoxOutputByType>> orderInfoMap = info.stream().collect(Collectors.groupingBy(BoxOutputByType:: getPlan_type));
//
// for (String key : orderInfoMap.keySet()) {
// xAxisInfo.add(key);
// seriesInfo.add(Convert.toLong(orderInfoMap.get(key).stream().mapToDouble(BoxOutputByType:: getActual_production).sum()));
// }
for (BoxOutputByType byType:info ) {
xAxisInfo.add(byType.getPlan_type());
seriesInfo.add(Long.valueOf(byType.getActual_production()));
}
echarts.setSeriesInfo(seriesInfo);
echarts.setXAxisInfo(xAxisInfo);
String jsonInfo = JSONArray.toJSONString(echarts);
System.out.println("根据型号统计产量:"+jsonInfo);
return jsonInfo; return jsonInfo;
} }
@PostMapping("/selectOutputByTime")
@ResponseBody
@ApiOperation("箱壳按小时查询产量")
public String selectOutputByTime() {
List<BoxOutput> info = service.selectOutputByTime();
String jsonInfo = JSONArray.toJSONString(info);
System.out.println("根据型号统计产量:" + jsonInfo);
return jsonInfo;
}
@PostMapping("/getProductPlanInfo") @PostMapping("/getProductPlanInfo")
@ResponseBody @ResponseBody
public String getProductPlanInfo(){ public String getProductPlanInfo() {
List<List<Object>> planInfoList = new ArrayList<List<Object>>(); List<List<Object>> planInfoList = new ArrayList<List<Object>>();
List<OrderInfo> planInfo = service.getUHullPlanInfo(); List<OrderInfo> planInfo = service.getUHullPlanInfo();
planInfo.forEach(x->{ planInfo.forEach(x -> {
planInfoList.add( planInfoList.add(
new ArrayList<Object>() { new ArrayList<Object>() {
{ {
this.add(x.getOrderType()); this.add(x.getOrderType());
this.add(x.getPlannedProduction()); this.add(x.getPlannedProduction());
this.add(x.getActualProduction()); this.add(x.getActualProduction());
this.add(x.getPlannedProduction()-x.getActualProduction()); this.add(x.getPlannedProduction() - x.getActualProduction());
if(x.getPlannedProduction() == 0 || x.getActualProduction() ==0){ if (x.getPlannedProduction() == 0 || x.getActualProduction() == 0) {
this.add("0%"); this.add("0%");
}else { } else {
this.add(((double)x.getActualProduction()/(double)x.getPlannedProduction()*100)+"%"); this.add(((double) x.getActualProduction() / (double) x.getPlannedProduction() * 100) + "%");
} }
if (x.getEndTime() != null) { if (x.getEndTime() != null) {
this.add(dateFormat.format(x.getEndTime())); this.add(dateFormat.format(x.getEndTime()));
@ -119,7 +107,7 @@ public class BoxBroadController {
String jsonInfo = JSONArray.toJSONString(planInfoList); String jsonInfo = JSONArray.toJSONString(planInfoList);
System.out.println("MES生产计划信息查询"+jsonInfo); System.out.println("MES生产计划信息查询" + jsonInfo);
return jsonInfo; return jsonInfo;
} }

@ -505,7 +505,8 @@
{ {
type: 'category', type: 'category',
axisTick: { axisTick: {
alignWithLabel: true alignWithLabel: true,
interval:0
}, },
axisLabel: { axisLabel: {
color: '#ffffff', color: '#ffffff',
@ -556,7 +557,7 @@
], ],
series: [ series: [
{ {
name: '内胆库', name: '内胆积存库',
type: 'bar', type: 'bar',
barWidth: '20rem', barWidth: '20rem',
itemStyle: { itemStyle: {
@ -588,7 +589,7 @@
}, },
}, },
{ {
name: '箱体壳', name: '围板积存库',
type: 'bar', type: 'bar',
barWidth: '20rem', barWidth: '20rem',
itemStyle: { itemStyle: {

@ -0,0 +1,26 @@
package com.ruoyi.system.domain;
/**
* @author wanghao
* @date 2022/7/7 19:03
*/
public class BoxOutput {
private String name;
private int qty;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
}

@ -1,26 +0,0 @@
package com.ruoyi.system.domain;
/**
* @author wanghao
* @date 2022/7/7 19:03
*/
public class BoxOutputByType {
private String plan_type;
private int actual_production;
public String getPlan_type() {
return plan_type;
}
public void setPlan_type(String plan_type) {
this.plan_type = plan_type;
}
public int getActual_production() {
return actual_production;
}
public void setActual_production(int actual_production) {
this.actual_production = actual_production;
}
}

@ -1,14 +1,11 @@
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import com.ruoyi.common.annotation.DataSource; import com.ruoyi.system.domain.BoxOutput;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.BoxOutputByType;
import com.ruoyi.system.domain.BoxPlanCompletion; import com.ruoyi.system.domain.BoxPlanCompletion;
import com.ruoyi.system.domain.BoxStock; import com.ruoyi.system.domain.BoxStock;
import com.ruoyi.system.domain.OrderInfo; import com.ruoyi.system.domain.OrderInfo;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.swing.*;
import java.util.List; import java.util.List;
/** /**
@ -21,7 +18,9 @@ public interface BroadDataMapper {
List<BoxStock> selectStock(String id); List<BoxStock> selectStock(String id);
List<BoxOutputByType> selectOutputByType(); List<BoxOutput> selectOutputByType();
List<OrderInfo> getUHullPlanInfo(); List<OrderInfo> getUHullPlanInfo();
List<BoxOutput> selectOutputByTime();
} }

@ -15,7 +15,9 @@ public interface IBroadDataService {
List<BoxStock> selectStock(String id); List<BoxStock> selectStock(String id);
List<BoxOutputByType> selectOutputByType(); List<BoxOutput> selectOutputByType();
List<OrderInfo> getUHullPlanInfo(); List<OrderInfo> getUHullPlanInfo();
List<BoxOutput> selectOutputByTime();
} }

@ -1,22 +1,13 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.CacheUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.BroadDataMapper; import com.ruoyi.system.mapper.BroadDataMapper;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.IBroadDataService; import com.ruoyi.system.service.IBroadDataService;
import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List; import java.util.List;
/** /**
@ -43,7 +34,7 @@ public class BroadDataServiceImpl implements IBroadDataService
} }
@Override @Override
public List<BoxOutputByType> selectOutputByType() { public List<BoxOutput> selectOutputByType() {
return mapper.selectOutputByType(); return mapper.selectOutputByType();
} }
@ -51,4 +42,9 @@ public class BroadDataServiceImpl implements IBroadDataService
public List<OrderInfo> getUHullPlanInfo() { public List<OrderInfo> getUHullPlanInfo() {
return mapper.getUHullPlanInfo(); return mapper.getUHullPlanInfo();
} }
@Override
public List<BoxOutput> selectOutputByTime() {
return mapper.selectOutputByTime();
}
} }

@ -17,7 +17,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
plan_shift plan_shift
from IMOS_PR_PLAN from IMOS_PR_PLAN
where plan_date is not null where plan_date is not null
-- and factory_code = '2701'
and process_code = '1002' and process_code = '1002'
and detial_type_code = '1002' and detial_type_code = '1002'
and delete_flag = '0' and delete_flag = '0'
@ -51,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by material_name order by material_name
</select> </select>
<select id="selectOutputByType" resultType="com.ruoyi.system.domain.BoxOutputByType"> <select id="selectOutputByType" resultType="com.ruoyi.system.domain.BoxOutput">
select substr(MATERIAL_NAME, select substr(MATERIAL_NAME,
case case
when instr(MATERIAL_NAME, '/', 1, 1) = 0 then instr(MATERIAL_NAME, ',', 1, 1) + 1 when instr(MATERIAL_NAME, '/', 1, 1) = 0 then instr(MATERIAL_NAME, ',', 1, 1) + 1
@ -65,12 +64,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
case case
when instr(MATERIAL_NAME, '/', 1, 1) = 0 then instr(MATERIAL_NAME, ',', 1, 1) + 1 when instr(MATERIAL_NAME, '/', 1, 1) = 0 then instr(MATERIAL_NAME, ',', 1, 1) + 1
else instr(MATERIAL_NAME, '/', 1, 1) + 1 else instr(MATERIAL_NAME, '/', 1, 1) + 1
end) as plan_type, end) as name,
SUM(ACTUAL_QTY) as actual_production SUM(ACTUAL_QTY) as qty
from IMOS_PR_PLAN from IMOS_PR_PLAN
where to_char(plan_date, 'yyyy-MM-dd') = to_char(sysdate, 'yyyy-MM-dd') where to_char(plan_date, 'yyyy-MM-dd') = to_char(sysdate, 'yyyy-MM-dd')
and PROCESS_CODE = 1002 and PROCESS_CODE = 1002
group by MATERIAL_NAME; group by MATERIAL_NAME
</select> </select>
<resultMap type="com.ruoyi.system.domain.OrderInfo" id="OrderInfoResult"> <resultMap type="com.ruoyi.system.domain.OrderInfo" id="OrderInfoResult">
<result property="orderType" column="order_type" /> <result property="orderType" column="order_type" />
@ -98,4 +97,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by PLAN_NO, MATERIAL_NAME group by PLAN_NO, MATERIAL_NAME
</select> </select>
<select id="selectOutputByTime" resultType="com.ruoyi.system.domain.BoxOutput">
select TO_CHAR(CREATION_DATE, 'hh24') as name ,Count(TASK_ID) as qty
from IMOS_LO_TASK_HISTORY
where detial_type_code = '1002' and TASK_TYPE='I'
and TO_CHAR(CREATION_DATE, 'YYYY-MM-DD') = TO_CHAR(SYSDATE, 'YYYY-MM-DD')
group by TO_CHAR(CREATION_DATE, 'hh24')
order by TO_CHAR(CREATION_DATE, 'hh24')
</select>
</mapper> </mapper>
Loading…
Cancel
Save