highway
zhaoxiaolin 1 year ago
parent 87bb08a360
commit 1b53ac43d9

@ -8,6 +8,7 @@ import com.op.common.core.utils.uuid.IdUtils;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.SysFactoryDto;
import com.op.mes.mapper.MesReportWorkMapper;
import org.apache.commons.lang.StringUtils;
@ -181,6 +182,13 @@ public class MesReportWorkController extends BaseController {
public List<SysFactoryDto> getWorkcenterList(MesDailyReport mesDailyReport) {
return mesReportWorkService.getWorkcenterList(mesDailyReport);
}
/**首页柱状图**/
@GetMapping("/getLineChartData")
public LineChartDto getLineChartData(MesReportProduction mesReportProduction) {
return mesReportWorkService.getLineChartData(mesReportProduction);
}
}

@ -45,6 +45,24 @@ public class MesReportProduction extends BaseEntity {
private String unit;
private String productDateStart;
private String productDateEnd;
private String feedbackTime;
private String nameDate;
public String getNameDate() {
return nameDate;
}
public void setNameDate(String nameDate) {
this.nameDate = nameDate;
}
public String getFeedbackTime() {
return feedbackTime;
}
public void setFeedbackTime(String feedbackTime) {
this.feedbackTime = feedbackTime;
}
public String getFactoryCode() {
return factoryCode;

@ -0,0 +1,39 @@
package com.op.mes.domain.dto;
import java.util.List;
/**
* echart
*
* @author Open Platform
* @date 2023-07-03
*/
public class LineChartDto{
private List<String> seriesNames;
private List<String> xAxisDatas;
private List<LineChartSeriesDto> seriesDatas;
public List<String> getSeriesNames() {
return seriesNames;
}
public void setSeriesNames(List<String> seriesNames) {
this.seriesNames = seriesNames;
}
public List<String> getxAxisDatas() {
return xAxisDatas;
}
public void setxAxisDatas(List<String> xAxisDatas) {
this.xAxisDatas = xAxisDatas;
}
public List<LineChartSeriesDto> getSeriesDatas() {
return seriesDatas;
}
public void setSeriesDatas(List<LineChartSeriesDto> seriesDatas) {
this.seriesDatas = seriesDatas;
}
}

@ -0,0 +1,50 @@
package com.op.mes.domain.dto;
import com.op.common.core.web.domain.TreeEntity;
import java.util.List;
/**
* echart
*
* @author Open Platform
* @date 2023-07-03
*/
public class LineChartSeriesDto {
private String name;
private String type;
private String stack;
private List<String> data;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getStack() {
return stack;
}
public void setStack(String stack) {
this.stack = stack;
}
public List<String> getData() {
return data;
}
public void setData(List<String> data) {
this.data = data;
}
}

@ -1,12 +1,14 @@
package com.op.mes.mapper;
import java.util.List;
import java.util.Map;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.dto.SysFactoryDto;
import org.apache.ibatis.annotations.MapKey;
/**
* Mapper
@ -78,4 +80,8 @@ public interface MesReportWorkMapper {
List<SysFactoryDto> getWorkcenterList(MesDailyReport mesDailyReport);
public void updateWorkOrderStatus(MesReportWork work);
@MapKey("nameDate")
Map<String,MesReportProduction> getLineChartsDatas(MesReportProduction mesReportProduction);
List<String> getLineChartsNames(MesReportProduction mesReportProduction);
}

@ -6,6 +6,7 @@ import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.SysFactoryDto;
/**
@ -72,4 +73,6 @@ public interface IMesReportWorkService {
String getTitleName(MesDailyReport mesDailyReport);
List<SysFactoryDto> getWorkcenterList(MesDailyReport mesDailyReport);
LineChartDto getLineChartData(MesReportProduction mesReportProduction);
}

@ -1,14 +1,18 @@
package com.op.mes.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.LineChartSeriesDto;
import com.op.mes.domain.dto.SysFactoryDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -226,4 +230,101 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
return mesReportWorkMapper.getWorkcenterList(mesDailyReport);
}
/**
* seriesNames: ['(18)', '(60)', '(288)', '(30)', '(60)'],
* xAxisDatas: ['2023/08/01', '2023/08/02', '2023/08/03', '2023/08/04', '2023/08/05', '2023/08/06', '2023/08/07',
* '2023/08/08','2023/08/09','2023/08/10','2023/08/11','2023/08/12','2023/08/13','2023/08/14',
* ],
* seriesDatas: [
* {
* name: '(18)',
* type: 'bar',//line
* stack: 'Total',
* data: [120, 132, 101, 134, 90, 230, 210,120, 132, 101, 134, 90, 230, 210]
* }
* ]
* @param mesDailyReport
* @return
*/
@Override
@DS("#header.poolName")
public LineChartDto getLineChartData(MesReportProduction mesReportProduction) {
LineChartDto lineChartDto = new LineChartDto();
Calendar calendar = Calendar.getInstance();
Date now = calendar.getTime();
calendar.set(Calendar.DAY_OF_MONTH, 1);
Date firstDayOfMonth = calendar.getTime();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String startTime = dateFormat.format(firstDayOfMonth);
String endTime = dateFormat.format(now);
mesReportProduction.setProductDateStart(startTime);
mesReportProduction.setProductDateEnd(endTime);
//图例名称
List<String> seriesNames = mesReportWorkMapper.getLineChartsNames(mesReportProduction);
lineChartDto.setSeriesNames(seriesNames);
//日期名称数组
List<String> xAxisDatas = getDays(startTime,endTime);
lineChartDto.setxAxisDatas(xAxisDatas);
Map<String,MesReportProduction> productdatas = mesReportWorkMapper.getLineChartsDatas(mesReportProduction);
//值
List<LineChartSeriesDto> seriesDatas = new ArrayList<>();
LineChartSeriesDto lineChartSeriesDto = null;
for(String productName:seriesNames){
lineChartSeriesDto = new LineChartSeriesDto();
lineChartSeriesDto.setName(productName);
lineChartSeriesDto.setType("bar");
lineChartSeriesDto.setStack("Total");
List<String> datas = new ArrayList<>();
for(String dayStr:xAxisDatas) {
MesReportProduction data0 = productdatas.get(productName + dayStr);
if (data0 != null) {
datas.add(data0.getQuantity());
} else {
datas.add("0");
}
}
lineChartSeriesDto.setData(datas);
seriesDatas.add(lineChartSeriesDto);
}
lineChartDto.setSeriesDatas(seriesDatas);
return lineChartDto;
}
/**两个日期之间的所有日期**/
public static List<String> getDays(String startTime,String endTime) {
// 返回的日期集合
List<String> days = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Date start = dateFormat.parse(startTime);
Date end = dateFormat.parse(endTime);
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
while (tempStart.before(tempEnd)) {
days.add(dateFormat.format(tempStart.getTime()));
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return days;
}
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
Date now = calendar.getTime();
calendar.set(Calendar.DAY_OF_MONTH, 1);
Date firstDayOfMonth = calendar.getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = format.format(firstDayOfMonth);
System.out.println("当前日期: " + format.format(now));
System.out.println("当月的第一天: " + formattedDate);
}
}

@ -211,8 +211,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
factory_code factoryCode
from sys_factory where f_type = 'c'
</select>
<select id="getLineChartsDatas" resultType="com.op.mes.domain.MesReportProduction">
select
mrw.product_name+CONVERT(varchar(10),mrw.feedback_time, 120) nameDate,
mrw.product_code productCode,
mrw.product_name productName,
CONVERT(varchar(10),mrw.feedback_time, 120) feedbackTime,
sum(mrw.quantity_feedback) quantity
from mes_report_work mrw
where
CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120)
group by mrw.product_code,mrw.product_name,mrw.feedback_time
order by mrw.feedback_time
</select>
<select id="getLineChartsNames" resultType="java.lang.String">
select
distinct mrw.product_name productName
from mes_report_work mrw
where
CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120)
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>

@ -23,7 +23,7 @@ import com.op.system.service.ISysDeptService;
/**
*
*
*
* @author OP
*/
@Service
@ -36,7 +36,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param dept
* @return
*/
@ -48,7 +48,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param dept
* @return
*/
@ -60,7 +60,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param depts
* @return
*/
@ -83,7 +83,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param depts
* @return
*/
@ -95,7 +95,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
* ID
*
*
* @param roleId ID
* @return
*/
@ -107,7 +107,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
* ID
*
*
* @param deptId ID
* @return
*/
@ -118,7 +118,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
* ID
*
*
* @param deptId ID
* @return
*/
@ -129,7 +129,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param deptId ID
* @return
*/
@ -141,7 +141,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param deptId ID
* @return true false
*/
@ -153,7 +153,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param dept
* @return
*/
@ -169,7 +169,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param deptId id
*/
@Override
@ -186,7 +186,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param dept
* @return
*/
@ -198,12 +198,13 @@ public class SysDeptServiceImpl implements ISysDeptService {
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
dept.setDelFlag("0");
return deptMapper.insertDept(dept);
}
/**
*
*
*
* @param dept
* @return
*/
@ -228,7 +229,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param dept
*/
private void updateParentDeptStatusNormal(SysDept dept) {
@ -239,7 +240,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param deptId ID
* @param newAncestors ID
* @param oldAncestors ID
@ -256,7 +257,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
/**
*
*
*
* @param deptId ID
* @return
*/

@ -99,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
@ -111,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
GETDATE()
)

Loading…
Cancel
Save