Compare commits
3 Commits
main
...
yem_locusz
Author | SHA1 | Date | |
---|---|---|---|
![]() |
da2cf3906b | ||
![]() |
a06208f61f | ||
![]() |
517493fdab |
@ -0,0 +1,183 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.algo.DataSet;
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.IFormView;
|
||||
import kd.bos.form.chart.ItemValue;
|
||||
import kd.bos.form.chart.PieChart;
|
||||
import kd.bos.form.chart.PieSeries;
|
||||
import kd.bos.orm.ORM;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import yem.base.common.utils.DateUtil;
|
||||
import yem.base.common.utils.RptUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author power
|
||||
* @ClassName
|
||||
* @description: 中右侧饼图
|
||||
* @date 2024/12/25
|
||||
*/
|
||||
public class CentreRightRrice extends AbstractBillPlugIn implements Plugin {
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
IFormView view = this.getView();
|
||||
Date yearFirst = DateUtil.getLastMonthFirstDay(new Date());
|
||||
view.getModel().setValue("yem_date",yearFirst);
|
||||
setData(view);
|
||||
}
|
||||
@Override
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
String name = e.getProperty().getName();
|
||||
IFormView view = this.getView();
|
||||
switch (name){
|
||||
case "yem_operator":
|
||||
case "yem_date":
|
||||
setData(view);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void setData(IFormView view){
|
||||
Date yearFirst = DateUtil.getMonthFirstDay((Date) view.getModel().getValue("yem_date"));
|
||||
Date yearLast = DateUtil.getMonthEndDay((Date) view.getModel().getValue("yem_date"));
|
||||
DynamicObject yem_operator = (DynamicObject) view.getModel().getValue("yem_operator");
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
if (null!=yem_operator){
|
||||
|
||||
|
||||
DynamicObject[] result = BusinessDataServiceHelper.load("yem_im_inquiryprice",
|
||||
"yem_commcountryid.name,yem_materialentry,yem_materialentry.yem_material,",
|
||||
new QFilter[]{
|
||||
new QFilter("yem_combofield3", QCP.not_equals,"C"),
|
||||
new QFilter("yem_bizdate",QCP.large_equals,yearFirst),
|
||||
new QFilter("yem_bizdate",QCP.less_equals,yearLast),
|
||||
new QFilter("yem_commcountryid",QCP.equals,yem_operator)
|
||||
});
|
||||
// str = getRandColor(result);
|
||||
// 构建饼图
|
||||
PieChart pieChart = this.getControl("yem_piechartap");
|
||||
pieChart.clearData();
|
||||
pieChart.setShowTooltip(true);
|
||||
PieSeries series = pieChart
|
||||
.createPieSeries("商品种类数量占比"); // 创建饼图系列
|
||||
series.setRadius("0", "100"); // 设置饼图内外半径
|
||||
List<ItemValue> dataList = new ArrayList<>();
|
||||
for(DynamicObject obj:result){
|
||||
// String countryname = obj.getString("countryname");
|
||||
if (map.get(obj.getString("yem_commcountryid.name"))!=null){
|
||||
map.put(obj.getString("yem_commcountryid.name"),map.get(obj.getString("yem_commcountryid.name"))+obj.getDynamicObjectCollection("yem_materialentry").size());
|
||||
}
|
||||
if (map.get(obj.getString("yem_commcountryid.name"))==null){
|
||||
map.put(obj.getString("yem_commcountryid.name"),obj.getDynamicObjectCollection("yem_materialentry").size());
|
||||
}
|
||||
|
||||
// String msg = needtype.equals("A") ?"运营类需求":"项目类需求";
|
||||
// String color = needtype.equals("A") ?"#FFC107":"#00A0E9";
|
||||
// int i = result.indexOf(obj);
|
||||
// ItemValue itemValues = new ItemValue(countryname,obj.getBigDecimal("yem_materialint"),str[i]);
|
||||
// dataList.add(itemValues);
|
||||
}
|
||||
// series.setData(dataList.toArray(new ItemValue[0]));
|
||||
}
|
||||
if (null==yem_operator){
|
||||
// DataSet data = ORM.create().queryDataSet(className,"yem_im_inquiry",
|
||||
// "yem_commcountryid,yem_materialentry.yem_material,yem_materialint",new QFilter[]{
|
||||
// new QFilter("yem_combofield3", QCP.not_equals,"C"),
|
||||
// new QFilter("yem_bizdate",QCP.large_equals,yearFirst),
|
||||
// new QFilter("yem_bizdate",QCP.less_equals,yearLast),
|
||||
// });
|
||||
// DataSet Countrydata = ORM.create().queryDataSet(className,"bd_country","id countryid,name countryname",new QFilter[]{
|
||||
// null});
|
||||
// //连接 最终交单
|
||||
// DataSet dataResult = data.leftJoin(Countrydata).on("yem_commcountryid","countryid")
|
||||
// .select(RptUtil.getDataSetFiledAlias(data), RptUtil.getDataSetFiledAlias(Countrydata)).finish();
|
||||
//
|
||||
// DataSet material = ORM.create().queryDataSet(className,"bd_material","id materialid,name materialname",new QFilter[]{
|
||||
// null});
|
||||
// dataResult = dataResult.leftJoin(material).on("yem_materialentry.yem_material","materialid")
|
||||
// .select(RptUtil.getDataSetFiledAlias(dataResult), RptUtil.getDataSetFiledAlias(material)).finish();
|
||||
// dataResult = data.groupBy(new String[]{"countryname"}).sum("yem_materialint").finish();
|
||||
//// yem_im_inquiry.yem_materialentry.yem_material
|
||||
// DynamicObjectCollection result = ORM.create().toPlainDynamicObjectCollection(dataResult);
|
||||
DynamicObject[] result = BusinessDataServiceHelper.load("yem_im_inquiryprice",
|
||||
"yem_commcountryid.name,yem_materialentry,yem_materialentry.yem_material,",
|
||||
new QFilter[]{
|
||||
new QFilter("yem_combofield3", QCP.not_equals,"C"),
|
||||
new QFilter("yem_bizdate",QCP.large_equals,yearFirst),
|
||||
new QFilter("yem_bizdate",QCP.less_equals,yearLast),
|
||||
// new QFilter("yem_commcountryid",QCP.equals,yem_operator)
|
||||
});
|
||||
// String[] str = getRandColor(result);
|
||||
|
||||
// // 构建饼图
|
||||
// PieChart pieChart = this.getControl("yem_piechartap");
|
||||
// pieChart.clearData();
|
||||
// pieChart.setShowTooltip(true);
|
||||
// PieSeries series = pieChart
|
||||
// .createPieSeries("商品种类数量占比"); // 创建饼图系列
|
||||
// series.setRadius("0", "100"); // 设置饼图内外半径
|
||||
// List<ItemValue> dataList = new ArrayList<>();
|
||||
for(DynamicObject obj:result){
|
||||
if (map.get(obj.getString("yem_commcountryid.name"))!=null){
|
||||
map.put(obj.getString("yem_commcountryid.name"),map.get(obj.getString("yem_commcountryid.name"))+obj.getDynamicObjectCollection("yem_materialentry").size());
|
||||
}
|
||||
if (map.get(obj.getString("yem_commcountryid.name"))==null){
|
||||
map.put(obj.getString("yem_commcountryid.name"),obj.getDynamicObjectCollection("yem_materialentry").size());
|
||||
}
|
||||
// String countryname = obj.getString("countryname");
|
||||
// String msg = needtype.equals("A") ?"运营类需求":"项目类需求";
|
||||
// String color = needtype.equals("A") ?"#FFC107":"#00A0E9";
|
||||
// int i = result.indexOf(obj);
|
||||
// ItemValue itemValues = new ItemValue(countryname,obj.getBigDecimal("yem_materialint"),str[i]);
|
||||
// dataList.add(itemValues);
|
||||
}
|
||||
// series.setData(dataList.toArray(new ItemValue[0]));
|
||||
}
|
||||
String[] str = getRandColor(map);
|
||||
// 构建饼图
|
||||
PieChart pieChart = this.getControl("yem_piechartap");
|
||||
pieChart.clearData();
|
||||
pieChart.setShowTooltip(true);
|
||||
PieSeries series = pieChart
|
||||
.createPieSeries("商品种类数量占比"); // 创建饼图系列
|
||||
series.setRadius("0", "100"); // 设置饼图内外半径
|
||||
List<ItemValue> dataList = new ArrayList<>();
|
||||
int a =0;
|
||||
for (String i : map.keySet()) {
|
||||
ItemValue itemValues = new ItemValue(i,map.get(i),str[a]);
|
||||
dataList.add(itemValues);
|
||||
++a;
|
||||
}
|
||||
series.setData(dataList.toArray(new ItemValue[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机生成颜色
|
||||
*/
|
||||
public static String[] getRandColor(HashMap<String, Integer> dataMap) {
|
||||
String[] str = new String[dataMap.size()];
|
||||
String r, g, b;
|
||||
for (int i = 0; i < str.length; i++) {
|
||||
Random random = new Random();
|
||||
r = Integer.toHexString(random.nextInt(256)).toUpperCase();
|
||||
g = Integer.toHexString(random.nextInt(256)).toUpperCase();
|
||||
b = Integer.toHexString(random.nextInt(256)).toUpperCase();
|
||||
|
||||
r = r.length() == 1 ? "0" + r : r;
|
||||
g = g.length() == 1 ? "0" + g : g;
|
||||
b = b.length() == 1 ? "0" + b : b;
|
||||
str[i] = "#" + r + g + b;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.algo.DataSet;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.form.IFormView;
|
||||
import kd.bos.form.chart.*;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.orm.ORM;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import yem.base.common.utils.DateUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author power
|
||||
* @ClassName
|
||||
* @description: 底部右侧柱状图
|
||||
* @date 2024/12/26
|
||||
*/
|
||||
public class DownRightPrice extends AbstractFormPlugin implements Plugin {
|
||||
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
super.afterCreateNewData(e);
|
||||
String className = this.getClass().getName();
|
||||
IFormView view = this.getView();
|
||||
Date yearFirst = DateUtil.getLastMonthFirstDay(new Date());
|
||||
view.getModel().setValue("yem_date",yearFirst);
|
||||
List<DynamicObject> data = queyData(view);
|
||||
Map<String, Double> equtypeMap = new HashMap<>();
|
||||
for(DynamicObject object:data){
|
||||
equtypeMap.put(object.getString("yem_commcountryid"),
|
||||
object.getBigDecimal("yem_qty").doubleValue());
|
||||
}
|
||||
if (equtypeMap.size() > 0)HistogramChart(equtypeMap);
|
||||
// HistogramChart(equtypeMap);
|
||||
}
|
||||
|
||||
|
||||
private List<DynamicObject> queyData(IFormView view){
|
||||
|
||||
|
||||
Date yearFirst = DateUtil.getMonthFirstDay((Date) view.getModel().getValue("yem_date"));
|
||||
Date yearLast = DateUtil.getMonthEndDay((Date) view.getModel().getValue("yem_date"));
|
||||
DynamicObject yem_operator = (DynamicObject) view.getModel().getValue("yem_operator");
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
|
||||
DataSet data = ORM.create().queryDataSet("yem_im_inquiryprice","yem_im_inquiryprice",
|
||||
"yem_commcountryid.name yem_commcountryid,yem_materialentry.yem_qty yem_qty",
|
||||
new QFilter[]{
|
||||
new QFilter("yem_combofield3", QCP.not_equals,"C"),
|
||||
new QFilter("yem_bizdate",QCP.large_equals,yearFirst),
|
||||
new QFilter("yem_bizdate",QCP.less_equals,yearLast),
|
||||
// new QFilter("yem_commcountryid",QCP.equals,yem_operator)
|
||||
});
|
||||
data = data.groupBy(new String[]{"yem_commcountryid"}).sum("yem_qty").finish()
|
||||
.orderBy(new String[]{"yem_qty"});
|
||||
DynamicObjectCollection datas = ORM.create().toPlainDynamicObjectCollection(data.copy());
|
||||
List<DynamicObject> result = datas;
|
||||
// List<DynamicObject> result = datas.subList(0, 10);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 柱状图
|
||||
*/
|
||||
private void HistogramChart(Map<String, Double> equtypeMap) {
|
||||
List<String> keysList = new ArrayList<>();
|
||||
List<Number> valuesList = new ArrayList<>();
|
||||
for (Map.Entry<String, Double> entry : equtypeMap.entrySet()) {
|
||||
keysList.add(entry.getKey()); // 添加键
|
||||
valuesList.add(entry.getValue()); // 添加值
|
||||
}
|
||||
Collections.sort(valuesList, (a, b) -> Double.compare(a.doubleValue(), b.doubleValue()));
|
||||
BarChart barchart = this.getControl("yem_histogramchartap");
|
||||
//设置是否显示图例
|
||||
barchart.setShowLegend(true);
|
||||
barchart.setLegendVertical(true);
|
||||
boolean isLegendVertical = true;
|
||||
barchart.setLegendVertical(isLegendVertical);
|
||||
Map<String, Object> titlePropValue = new HashMap<>();
|
||||
// 主标题内容:text
|
||||
titlePropValue.put("text", "区域信息");
|
||||
// 设置触发提示框的类型为axis:坐标轴触发
|
||||
barchart.addTooltip("trigger", "axis");
|
||||
// 字符串模板格式
|
||||
List<Object> toolTipFuncPath = new ArrayList<>();
|
||||
String formatter = "{b0}: {c0}";
|
||||
barchart.addTooltip("formatter", formatter);
|
||||
toolTipFuncPath.add("tooltip");
|
||||
toolTipFuncPath.add("formatter");
|
||||
barchart.addFuncPath(toolTipFuncPath);
|
||||
barchart.setShowTooltip(true);
|
||||
// 设置图例位置为中上
|
||||
barchart.setLegendAlign(XAlign.center, YAlign.top);
|
||||
//AxisType可以调整纵轴或横轴显示数据AxisType.category AxisType.value
|
||||
Axis x = barchart.createXAxis("国家地区", AxisType.category);
|
||||
Axis y = barchart.createYAxis("数量", AxisType.value);
|
||||
Map<String, Object> axisTick = new HashMap<>();
|
||||
axisTick.put("interval", 0);
|
||||
|
||||
y.setPropValue("minInterval", 1);
|
||||
x.setPropValue("data", keysList);
|
||||
x.setPropValue("axisTick", axisTick);
|
||||
BarSeries barseries = barchart.createSeries("");
|
||||
// 设置系列中数据的内容
|
||||
createBarSeries(barseries,valuesList);
|
||||
// barseries.setBarWidth("25px");
|
||||
barchart.refresh();
|
||||
|
||||
|
||||
// //设置是否显示图例
|
||||
// barchart.setShowLegend(true);
|
||||
// boolean isLegendVertical = true;
|
||||
// barchart.setLegendVertical(isLegendVertical);
|
||||
// Map<String, Object> titlePropValue = new HashMap<>();
|
||||
// // 主标题内容:text
|
||||
// titlePropValue.put("text", "条形图");
|
||||
// // 设置触发提示框的类型为axis:坐标轴触发
|
||||
// barchart.addTooltip("trigger", "axis");
|
||||
// // 字符串模板格式
|
||||
// List<Object> toolTipFuncPath = new ArrayList<>();
|
||||
// String formatter = "{b0}: {c0}";
|
||||
// barchart.addTooltip("formatter", formatter);
|
||||
// toolTipFuncPath.add("tooltip");
|
||||
// toolTipFuncPath.add("formatter");
|
||||
// barchart.addFuncPath(toolTipFuncPath);
|
||||
// barchart.setShowTooltip(true);
|
||||
// // 设置图例位置为中上
|
||||
// barchart.setLegendAlign(XAlign.center, YAlign.top);
|
||||
// //AxisType可以调整纵轴或横轴显示数据
|
||||
// Axis x = barchart.createXAxis("国别", AxisType.category);
|
||||
// Axis y = barchart.createYAxis("数量", AxisType.value);
|
||||
// // 设置X轴类目数据(如果没有设置,则需要再series中设置)
|
||||
// String[] data2 = {"中国", "美国", "英国", "法国", "日本"};
|
||||
// x.setPropValue("data", data2);
|
||||
// // 创建系列为“辅助”的系列
|
||||
// BarSeries barseries = barchart.createSeries("辅助");
|
||||
// // 设置系列名称,用于tooltip的显示,legend 的图例筛选.
|
||||
// barseries.setName("来源");
|
||||
// // 设置数据堆叠,同个类目轴上系列配置相同的stack值可以堆叠放置
|
||||
// barseries.setStack("数量");
|
||||
// // 设置系列中数据的内容
|
||||
// Number[] number = {234, 354, 137, 685, 400};
|
||||
// barseries.setData(number);
|
||||
// // 设置柱条颜色(直接设置颜色值和渐变设置)
|
||||
// barseries.setColor("blue");
|
||||
// barchart.refresh();
|
||||
|
||||
}
|
||||
|
||||
private void createBarSeries(BarSeries barSeries,List<Number> values) {
|
||||
|
||||
barSeries.setAnimationDuration(2000);// 动画2秒
|
||||
List<ItemValue> itemValuesList = new ArrayList<>();
|
||||
//根据数据建立不同据条的颜色数据信息
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
Number num = values.get(i);
|
||||
// 偶数基数使用 #496283,奇数基数使用 #1BC85E
|
||||
String color = (i % 2 == 0) ? "#496283" : "#1BC85E"; // 根据索引而不是值来选择颜色
|
||||
ItemValue data = new ItemValue(num, color); // 创建 ItemValue 实例
|
||||
itemValuesList.add(data); // 将 ItemValue 添加到列表
|
||||
}
|
||||
ItemValue[] itemValuesArray = itemValuesList.toArray(new ItemValue[0]);
|
||||
barSeries.setData(itemValuesArray);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.bill.OperationStatus;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.IFormView;
|
||||
import kd.bos.form.ShowType;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author zlp
|
||||
* @Date 2024/12/27 15:51
|
||||
* @PackageName:yem.wmc.ydn.formplugin.dynamic
|
||||
* @ClassName: Priceshow
|
||||
* @Description: 询价单情况看板
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class Priceshow extends AbstractFormPlugin {
|
||||
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("yem_representative", "yem_flexpanelap3");
|
||||
map.put("yem_amountreally", "yem_flexpanelap4");
|
||||
map.put("yem_tnpnanalysis", "yem_flexpanelap31");
|
||||
map.put("yem_ptqnanalysis", "yem_flexpanelap32");
|
||||
map.put("yem_centrerightprice", "yem_flexpanelap41");
|
||||
map.put("yem_downrightprice", "yem_flexpanelap42");
|
||||
showForm(map);
|
||||
}
|
||||
|
||||
public void showForm(Map<String, String> map) {
|
||||
for (String key : map.keySet()) {
|
||||
IFormView view = this.getView();
|
||||
FormShowParameter showParameter = new FormShowParameter();
|
||||
showParameter.setStatus(OperationStatus.EDIT);
|
||||
showParameter.getOpenStyle().setShowType(ShowType.InContainer);
|
||||
showParameter.getOpenStyle().setTargetKey(map.get(key));
|
||||
showParameter.setSendToClient(true);
|
||||
showParameter.setFormId(key);
|
||||
view.showForm(showParameter);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.form.chart.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author zlp
|
||||
* @Date 2024/12/24 17:10
|
||||
* @PackageName:yem.wmc.ydn.formplugin.dynamic
|
||||
* @ClassName: PtqnanalysisDynamic
|
||||
* @Description: 商品报价分析(折线图)
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class PtqnanalysisDynamic extends AbstractBillPlugIn {
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
PointLineChart pointLineChart = this.getControl("yem_pointlinechartap");
|
||||
PointLineChartHelper pointLineChartHelper = new PointLineChartHelper();
|
||||
pointLineChartHelper.drawChart(pointLineChart);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PointLineChartHelper {
|
||||
public void drawChart(PointLineChart pointLineChart) {
|
||||
|
||||
boolean isX = true;
|
||||
|
||||
// 创建分类轴,X轴方式展现
|
||||
Axis categoryAxis = this.createCategoryAxis(pointLineChart, "月度", isX);
|
||||
|
||||
// 设置分类轴nametextstyle属性,
|
||||
Map<String, Object> nametextstyle = new HashMap<>();
|
||||
nametextstyle.put("color", "#000000");
|
||||
// nametextstyle.put("fontStyle", "italic");
|
||||
nametextstyle.put("fontSize", 18);
|
||||
categoryAxis.setPropValue("nameTextStyle", nametextstyle);
|
||||
|
||||
// 设置分类轴名称位置属性,end表示在最后
|
||||
categoryAxis.setPropValue("nameLocation", new String("end"));
|
||||
|
||||
// 设置分类轴分类值显示位置,bottom表示在下
|
||||
categoryAxis.setPropValue("position", "bottom");
|
||||
// 设置分类轴分类值liaxisLabel属性
|
||||
Map<String, Object> axislabel = new HashMap<>();
|
||||
Map<String, Object> textstyle = new HashMap<>();
|
||||
textstyle.put("color", "#000000");
|
||||
textstyle.put("fontSize", "16");
|
||||
axislabel.put("textStyle", textstyle);
|
||||
categoryAxis.setPropValue("axisLabel", axislabel);
|
||||
|
||||
// 创建数据轴,name为其名字。
|
||||
Axis ValueAxis = this.createValueAxis(pointLineChart, "千(元)", !isX);
|
||||
// 设置数据轴的nameTextStyle属性
|
||||
Map<String, Object> yAxisnametextstyle = new HashMap<>();
|
||||
yAxisnametextstyle.put("color", "#000000");
|
||||
yAxisnametextstyle.put("fontSize", 18);
|
||||
// yAxisnametextstyle.put("fontStyle", "oblique");
|
||||
ValueAxis.setPropValue("nameTextStyle", yAxisnametextstyle);
|
||||
|
||||
// 设置分类轴数据
|
||||
categoryAxis.setCategorys(contructCatetoryData());
|
||||
|
||||
// 创建折线并赋值
|
||||
this.createLineSeries(pointLineChart, "最高价", contructValueData(), "red");
|
||||
|
||||
// 创建多个折线按如下方式添加
|
||||
this.createLineSeries(pointLineChart, "最低价", contructValue2Data(), "#0000CD");
|
||||
List<BigDecimal> list = new ArrayList<>();
|
||||
list.add(new BigDecimal(3000));
|
||||
list.add(new BigDecimal(3500));
|
||||
list.add(new BigDecimal(2800));
|
||||
list.add(new BigDecimal(2700));
|
||||
list.add(new BigDecimal(3100));
|
||||
list.add(new BigDecimal(3000));
|
||||
|
||||
|
||||
this.createLineSeries(pointLineChart,"平均价",list , "#282828");
|
||||
|
||||
// 设置图的边距
|
||||
pointLineChart.setMargin(Position.right, "80px");
|
||||
pointLineChart.setMargin(Position.top, "80px");
|
||||
pointLineChart.setMargin(Position.left, "80px");
|
||||
pointLineChart.setShowLegend(true);
|
||||
// 设置图例的位置
|
||||
pointLineChart.setLegendPropValue("top", "8%");
|
||||
// 设置图例中文字的字体大小和颜色等
|
||||
Map<String, Object> legendtextstyle = new HashMap<>();
|
||||
legendtextstyle.put("fontSize", 18);
|
||||
legendtextstyle.put("color", "#000000");
|
||||
pointLineChart.setLegendPropValue("textStyle", legendtextstyle);
|
||||
|
||||
// 刷新图标
|
||||
pointLineChart.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建类目型坐标轴
|
||||
*
|
||||
* @param name
|
||||
* 坐标轴名称
|
||||
* @param isx
|
||||
* 是否X轴,ture创建X轴,false创建Y轴
|
||||
*/
|
||||
private Axis createCategoryAxis(PointLineChart pointLineChart, String name, boolean isx) {
|
||||
Axis axis = null;
|
||||
if (isx)
|
||||
axis = pointLineChart.createXAxis(name, AxisType.category);
|
||||
else
|
||||
axis = pointLineChart.createYAxis(name, AxisType.category);
|
||||
|
||||
// 创建一个map存储x轴的复杂属性的属性-值对
|
||||
Map<String, Object> axisTick = new HashMap<>();
|
||||
axisTick.put("interval", Integer.valueOf(0));
|
||||
|
||||
axisTick.put("show", true);
|
||||
axisTick.put("grid", Position.left);
|
||||
axis.setPropValue("axisTick", axisTick);
|
||||
return axis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建值类型坐标轴
|
||||
*
|
||||
* @param name
|
||||
* 坐标轴名称
|
||||
* @param isx
|
||||
* 是否X轴,ture创建X轴,false创建Y轴
|
||||
*/
|
||||
private Axis createValueAxis(PointLineChart pointLineChart, String name, boolean isx) {
|
||||
Axis axis = null;
|
||||
if (isx)
|
||||
axis = pointLineChart.createXAxis(name, AxisType.value);
|
||||
else
|
||||
axis = pointLineChart.createYAxis(name, AxisType.value);
|
||||
|
||||
// 创建一个map存储y轴的复杂属性的属性-值对
|
||||
Map<String, Object> axisTick = new HashMap<>();
|
||||
axisTick.put("show", true);
|
||||
axis.setPropValue("axisTick", axisTick);
|
||||
|
||||
// 创建一个map存储y轴的复杂属性的属性-值对
|
||||
Map<String, Object> splitLine = new HashMap<>();
|
||||
Map<String, Object> lineStyle = new HashMap<>();
|
||||
lineStyle.put("type", "dotted");
|
||||
lineStyle.put("color", "#E2E2E2");
|
||||
splitLine.put("lineStyle", lineStyle);
|
||||
axis.setPropValue("splitLine", splitLine);
|
||||
pointLineChart.setShowTooltip(true);
|
||||
return axis;
|
||||
}
|
||||
|
||||
private List<String> contructCatetoryData() {
|
||||
|
||||
// 此处需修改成实际分类数据,以下为案例数据
|
||||
List<String> categoryData = new ArrayList<>();
|
||||
categoryData.add("2019.1");
|
||||
categoryData.add("2019.2");
|
||||
categoryData.add("2019.3");
|
||||
categoryData.add("2019.4");
|
||||
categoryData.add("2019.5");
|
||||
categoryData.add("2019.6");
|
||||
return categoryData;
|
||||
};
|
||||
|
||||
private List<BigDecimal> contructValueData() {
|
||||
|
||||
// 此处需添加实际数构建,以下为案例数据
|
||||
List<BigDecimal> valueData = new ArrayList<>();
|
||||
|
||||
valueData.add(new BigDecimal(2566));
|
||||
valueData.add(new BigDecimal(1552));
|
||||
valueData.add(new BigDecimal(3786));
|
||||
valueData.add(new BigDecimal(2865));
|
||||
valueData.add(new BigDecimal(4098));
|
||||
valueData.add(new BigDecimal(7834));
|
||||
|
||||
return valueData;
|
||||
}
|
||||
|
||||
private List<BigDecimal> contructValue2Data() {
|
||||
|
||||
// 此处需添加实际数构建,以下为案例数据
|
||||
List<BigDecimal> valueData = new ArrayList<>();
|
||||
|
||||
valueData.add(new BigDecimal(934));
|
||||
valueData.add(new BigDecimal(1035));
|
||||
valueData.add(new BigDecimal(2342));
|
||||
valueData.add(new BigDecimal(2274));
|
||||
valueData.add(new BigDecimal(5067));
|
||||
valueData.add(new BigDecimal(6654));
|
||||
|
||||
return valueData;
|
||||
}
|
||||
|
||||
// 创建折线
|
||||
private void createLineSeries(PointLineChart pointLineChart, String name, List<BigDecimal> values, String color) {
|
||||
// 折线的名字
|
||||
LineSeries expireSeries = pointLineChart.createSeries(name);
|
||||
|
||||
// 设置折线上文本的相关属性
|
||||
Label label = new Label();
|
||||
label.setShow(true);
|
||||
label.setColor("#000000");
|
||||
expireSeries.setLabel(label);
|
||||
// 连线颜色
|
||||
expireSeries.setItemColor(color);
|
||||
// 动画效果
|
||||
expireSeries.setAnimationDuration(2000);
|
||||
// 该点纵坐标的值setData(Number[] data)
|
||||
expireSeries.setData((Number[]) values.toArray(new Number[0]));
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* @Author zlp
|
||||
* @Date 2024/12/24 16:02
|
||||
* @PackageName:yem.wmc.ydn.formplugin.dynamic
|
||||
* @ClassName: RepresentativeDynamic
|
||||
* @Description: zlp 代办统计卡片 表单插件
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class RepresentativeDynamic extends AbstractFormPlugin {
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
DynamicObject[] yem_ffm_inquiryWait = BusinessDataServiceHelper.load("yem_ffm_inquiry", "yem_supquonum,billstatus",
|
||||
new QFilter[]{
|
||||
new QFilter("billstatus", QCP.equals, "C"),
|
||||
// new QFilter("yem_supquonum", QCP.less_equals, 0)
|
||||
});
|
||||
DynamicObject[] yem_ffm_inquiryIn = BusinessDataServiceHelper.load("yem_ffm_inquiry", "yem_supquonum,billstatus",
|
||||
new QFilter[]{
|
||||
new QFilter("billstatus", QCP.equals, "C"),
|
||||
new QFilter("yem_supquonum", QCP.large_than, 0)
|
||||
});
|
||||
this.getModel().setValue("yem_pendingquotation",yem_ffm_inquiryWait.length);
|
||||
this.getModel().setValue("yem_inthequotation",yem_ffm_inquiryIn.length);
|
||||
}
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.form.chart.*;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.events.ChartClickEvent;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author zlp
|
||||
* @Date 2024/12/24 17:32
|
||||
* @PackageName:yem.wmc.ydn.formplugin.dynamic
|
||||
* @ClassName: TnpnanalysisDynamic
|
||||
* @Description: 成交占比分析(横向柱状图)
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class TnpnanalysisDynamic extends AbstractBillPlugIn {
|
||||
|
||||
@Override
|
||||
public void click(EventObject evt) {
|
||||
String key = ((Control)evt.getSource()).getKey();
|
||||
if (key.equals("yem_histogramchartap")) {
|
||||
ChartClickEvent e = (ChartClickEvent)evt;
|
||||
this.getView().showMessage("SeriesName:" + e.getSeriesName() + "; Name: " + e.getName() + "; Value: " + e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
Control _barchart = this.getControl("yem_histogramchartap");
|
||||
if (_barchart instanceof HistogramChart) {
|
||||
HistogramChart barchart = (HistogramChart) _barchart;
|
||||
// boolean isShowTitle = true;
|
||||
// barchart.setShowTitle(isShowTitle);
|
||||
boolean isShowLegend = true;
|
||||
barchart.setShowLegend(isShowLegend);
|
||||
boolean isLegendVertical = true;
|
||||
barchart.setLegendVertical(isLegendVertical);
|
||||
barchart.setShowTooltip(true);
|
||||
// 设置两个图例:支出,收入
|
||||
// Map<String, Object> legendData = new HashMap<>();
|
||||
// String[] data = {"支出", "收入"};
|
||||
// legendData.put("data", data);
|
||||
// barchart.setLegendPropValue("legend",legendData);
|
||||
|
||||
// 设置图例位置为中上
|
||||
barchart.setLegendAlign(XAlign.center, YAlign.top);
|
||||
// Map<String, Object> titlePropValue = new HashMap<>();// 主标题内容:text
|
||||
// titlePropValue.put("text", "条形图");
|
||||
|
||||
// 副标题内容:subtext
|
||||
// titlePropValue.put("subtext", "barchart");
|
||||
|
||||
// 点击副标题跳转的超链接:sublink
|
||||
// titlePropValue.put("sublink", "https://www.echartsjs.com/examples/zh/index.html#chart-type-bar");
|
||||
// barchart.setTitlePropValue("title", titlePropValue);
|
||||
|
||||
// 设置触发提示框的类型为axis:坐标轴触发
|
||||
// barchart.addTooltip("trigger", "axis");
|
||||
|
||||
// 设置指示器配置项为阴影,更多配置参考echarts官网再添加相应的参数即可
|
||||
// Map<String, Object> axisPointType = new HashMap<>();
|
||||
// axisPointType.put("type", "shadow");
|
||||
// barchart.addTooltip("axisPointer", axisPointType);
|
||||
|
||||
// 设置提示框浮层内容格式器,参数含义可查阅echarts官网,这里不一一列举
|
||||
// 字符串模板格式
|
||||
// List<Object> toolTipFuncPath = new ArrayList<>();
|
||||
// String formatter = "{b0}: {c0}<br />{b1}: {c1}";
|
||||
// barchart.addTooltip("formatter", formatter);
|
||||
// toolTipFuncPath.add("tooltip");
|
||||
// toolTipFuncPath.add("formatter");
|
||||
// barchart.addFuncPath(toolTipFuncPath);
|
||||
//
|
||||
//// 回调函数模式
|
||||
// List<Object> toolTipFuncPaths = new ArrayList<>();
|
||||
// String formatters = "function(param){if(param.dataIndex===0){return 'placeholder0';} if(param.dataIndex==1){return 'placeholder1';}if(param.dataIndex==2){return 'placeholder2'}}";
|
||||
// barchart.addTooltip("formatter", formatters);
|
||||
// toolTipFuncPath.add("tooltip");
|
||||
// toolTipFuncPath.add("formatter");
|
||||
// barchart.addFuncPath(toolTipFuncPath);
|
||||
|
||||
|
||||
// 设置X轴的坐标轴名称为日期,类型为category(类目),Y轴的名称为总量,类型为value
|
||||
Axis x = barchart.createXAxis("日期", AxisType.value);
|
||||
Axis y = barchart.createYAxis("总量",AxisType.category);
|
||||
|
||||
// 设置X轴类目数据(如果没有设置,则需要再series中设置)
|
||||
String[] datas = {"周一", "周二", "周三", "周四", "周五", "周六", "周日"};
|
||||
y.setPropValue("data", datas);
|
||||
|
||||
// 坐标轴刻度标签文字相关设置,格式化刻度标签显示内容
|
||||
// Map<String, Object> datad = new HashMap<>();
|
||||
// String dataFormatter = "function (params) {var level = placeholder0;var date = placeholder1;var job = placeholder2;return '职级:' + level[params[0].dataIndex] + '<br />' + '职级时长:' + date[params[0].dataIndex] + '<br />' + '职位:' + job[params[0].dataIndex];}";
|
||||
// datad.put("formatter", dataFormatter);
|
||||
// x.setPropValue("axisLabel", datad);
|
||||
|
||||
// 坐标轴刻度相关设置,设置是否显示坐标轴刻度
|
||||
// Map<String, Object> axisTick = new HashMap<>();
|
||||
// axisTick.put("show", false);
|
||||
// x.setPropValue("axisTick", axisTick);
|
||||
//
|
||||
//// 坐标轴线相关设置,设置坐标轴箭头样式
|
||||
// Map<String, Object> axisLine = new HashMap<>();
|
||||
// String[] symbolArr = {"none", "arrow"};
|
||||
// axisLine.put("symbol", symbolArr);
|
||||
// x.setPropValue("axisLine", axisLine);
|
||||
//
|
||||
//// 坐标轴在grid区域中的分隔线相关设置,设置分隔线不显示
|
||||
// Map<String, Object> splitLine = new HashMap<>();
|
||||
// splitLine.put("show", false);
|
||||
// x.setPropValue("splitLine", splitLine);
|
||||
// 创建系列为“辅助”的系列
|
||||
BarSeries barseries = barchart.createSeries("合同");
|
||||
Label label = new Label();
|
||||
label.setShow(false);
|
||||
barseries.setLabel(label);
|
||||
// 设置系列名称,用于tooltip的显示,legend 的图例筛选.
|
||||
barseries.setName("合同金额");
|
||||
|
||||
// 设置数据堆叠,同个类目轴上系列配置相同的stack值可以堆叠放置
|
||||
barseries.setStack("产品");
|
||||
|
||||
// 设置系列中数据的内容
|
||||
Number[] numbers = {1, 2, 3, 4, 5, 6};
|
||||
barseries.setData(numbers);
|
||||
|
||||
// 设置柱条颜色(直接设置颜色值和渐变设置)
|
||||
barseries.setColor("#000000");
|
||||
|
||||
BarSeries barseries2 = barchart.createSeries("询价单");
|
||||
Label label2 = new Label();
|
||||
label2.setShow(false);
|
||||
barseries2.setLabel(label);
|
||||
|
||||
// 设置系列名称,用于tooltip的显示,legend 的图例筛选.
|
||||
barseries2.setName("询价单金额");
|
||||
|
||||
// 设置数据堆叠,同个类目轴上系列配置相同的stack值可以堆叠放置
|
||||
barseries2.setStack("产品");
|
||||
|
||||
// 设置系列中数据的内容
|
||||
Number[] numbers2 = {5, 6, 7, 8, 9, 9};
|
||||
barseries2.setData(numbers2);
|
||||
|
||||
// 设置柱条颜色(直接设置颜色值和渐变设置)
|
||||
barseries2.setColor("#FFC107");
|
||||
// barseries.setColor("new echarts.graphic.LinearGradient(0, 0, 1, 0, [{offset: 0, color: '[#B177FF](http://fd.kingdee.com:9001/?key=%23B177FF)' },{offset: 1, color: '[#828FFF](http://fd.kingdee.com:9001/?key=%23828FFF)'}], false)");
|
||||
// barchart.setMerge(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user