代码更新

This commit is contained in:
2022-10-20 21:17:12 +08:00
13 changed files with 244 additions and 68 deletions

View File

@@ -52,6 +52,12 @@ public class PerformancemstController {
return new ResponseEntity<>(performancemstService.workLoadStatQuery(whereJson,page),HttpStatus.OK);
}
@ApiOperation("导出数据")
@GetMapping(value = "/workloadstat/download")
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
performancemstService.download(whereJson, response);
}
@PostMapping
@Log("新增工作量汇报")
@ApiOperation("新增工作量汇报")

View File

@@ -457,11 +457,8 @@ public class DailyplanServiceImpl implements DailyplanService {
if (StrUtil.isNotEmpty(query.getString("nowstart_date"))) {
String nowstart_date2 = query.getString("nowstart_date").substring(0,10);
Date date2 = DateUtil.parse(nowstart_date2);
//指定日期小于最晚的日计划日期
if(date2.getTime() >= date.getTime()){
nowstart_date = nowstart_date2;
date = date2;
}
nowstart_date = nowstart_date2;
date = date2;
}
}

View File

@@ -20,6 +20,7 @@ import org.nl.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
@@ -81,6 +82,9 @@ public class AutoformulaServiceImpl implements AutoformulaService {
double new_qty = workorder_qty;
//纯粉重量
double net_qty = workorder_qty;
//rf最高开单重量
HashMap<String,JSONObject> rf_plan_map = new HashMap<String,JSONObject>();
if(waste_limit_down==0 && waste_limit_up==0){//不添加软废
//新料配粉环节
JSONObject ret = this.autoCalculationBy01_xinliao(json);
@@ -129,6 +133,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
for(int i=0;i<MaterialSets.size();i++){
JSONObject MaterialSet = MaterialSets.getJSONObject(i);
String set_material_id = MaterialSet.getString("set_material_id");
double add_rate = MaterialSet.getDouble("add_rate");
JSONArray now_ivts = WQL.getWO("QPF_AUTOFORMULA01")
.addParam("material_id",set_material_id)
.addParam("is_active",value_is_active)
@@ -136,7 +141,21 @@ public class AutoformulaServiceImpl implements AutoformulaService {
.addParam("workorder_id",workorder_id)
.addParam("flag","22")
.process().getResultJSONArray(0);
ivts.addAll(now_ivts);
for(int j=0;j<now_ivts.size();j++){
JSONObject jo = now_ivts.getJSONObject(j);
double can_qty = net_qty*add_rate/100.0;
JSONObject jo2 = new JSONObject();
jo2.put("can_qty",can_qty);
jo2.put("can_left_qty",can_qty);
rf_plan_map.put(set_material_id,jo2);
double sum_ivt_qty = jo.getDouble("sum_ivt_qty");
if(can_qty >= sum_ivt_qty){
jo.put("can_qty",sum_ivt_qty);
}else{
jo.put("can_qty",can_qty);
}
ivts.add(jo);
}
}
if(ivts.size()!=0){
//软废纯粉库存总量
@@ -145,7 +164,13 @@ public class AutoformulaServiceImpl implements AutoformulaService {
for(int i=0;i<ivts.size();i++){
JSONObject ivt = ivts.getJSONObject(i);
String ivt_material_id = ivt.getString("material_id");
if(ivt.getDouble("sum_ivt_qty")<=0 || ivt.getDouble("sum_ivt_qty")<0.01){
double can_qty = ivt.getDouble("can_qty");
if(can_qty<=0 || can_qty<0.01){
continue;
}
JSONObject can_jo = rf_plan_map.get(ivt_material_id);
double can_left_qty = can_jo.getDouble("can_left_qty");
if(can_left_qty <=0){
continue;
}
JSONObject ProductMaterialExt = MD_ME_ProductMaterialExt.query("material_id='"+ivt_material_id+"'").uniqueResult(0);
@@ -156,7 +181,15 @@ public class AutoformulaServiceImpl implements AutoformulaService {
if(net_rate==0){
throw new BadRequestException("软废"+ivt.getString("material_code")+" "+ivt.getString("material_name")+"未配置纯粉系数!");
}
double ivt_qty = ivt.getDouble("sum_ivt_qty")*net_rate/100.0;
if(can_qty <= can_left_qty){
can_qty = can_qty;
can_jo.put("can_left_qty",can_left_qty-can_qty);
}else{
can_qty = can_left_qty;
can_jo.put("can_left_qty",can_left_qty-can_qty);
}
rf_plan_map.put(ivt_material_id,can_jo);
double ivt_qty = can_qty*net_rate/100.0;
//Rp*纯粉系数
ivt.put("net_rate_qty",ivt_qty);
//纯粉系数
@@ -1580,6 +1613,8 @@ public class AutoformulaServiceImpl implements AutoformulaService {
double new_qty = workorder_qty;
//纯粉重量
double net_qty = workorder_qty;
//rf最高开单重量
HashMap<String,JSONObject> rf_plan_map = new HashMap<String,JSONObject>();
//1.需添加软废
if(waste_limit_down==100 || waste_limit_up== 100){
throw new BadRequestException("软废含量上限或下限不能等于100%");
@@ -1620,7 +1655,22 @@ public class AutoformulaServiceImpl implements AutoformulaService {
.addParam("quality_scode","02")
.addParam("flag","22")
.process().getResultJSONArray(0);
ivts.addAll(now_ivts);
double add_rate = MaterialSet.getDouble("add_rate");
for(int j=0;j<now_ivts.size();j++){
JSONObject jo = now_ivts.getJSONObject(j);
double can_qty = net_qty*add_rate/100.0;
JSONObject jo2 = new JSONObject();
jo2.put("can_qty",can_qty);
jo2.put("can_left_qty",can_qty);
rf_plan_map.put(set_material_id,jo2);
double sum_ivt_qty = jo.getDouble("sum_ivt_qty");
if(can_qty >= sum_ivt_qty){
jo.put("can_qty",sum_ivt_qty);
}else{
jo.put("can_qty",can_qty);
}
ivts.add(jo);
}
}
if(ivts.size()!=0){
//软废纯粉库存总量
@@ -1628,7 +1678,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
JSONArray ivts_new = new JSONArray();
for(int i=0;i<ivts.size();i++){
JSONObject ivt = ivts.getJSONObject(i);
if(ivt.getDouble("sum_ivt_qty")<=0 || ivt.getDouble("sum_ivt_qty")<0.01){
if(ivt.getDouble("can_qty")<=0 || ivt.getDouble("can_qty")<0.01){
continue;
}
String ivt_material_id = ivt.getString("material_id");
@@ -1640,7 +1690,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
if(net_rate==0){
throw new BadRequestException("软废"+ivt.getString("material_code")+" "+ivt.getString("material_name")+"未配置纯粉系数!");
}
double ivt_qty = ivt.getDouble("sum_ivt_qty")*net_rate/100.0;
double ivt_qty = ivt.getDouble("can_qty")*net_rate/100.0;
//Rp*纯粉系数
ivt.put("net_rate_qty",ivt_qty);
//纯粉系数
@@ -1651,7 +1701,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
rf_ivts = rf_ivts + ivt_qty;
}
if(rf_ivts>=waste_limit_down_weight){
Number rf_left_weight = waste_limit_up_weight;;
Number rf_left_weight = waste_limit_up_weight;
//需配软废总重
double rf_total_weight = 0;
//需配软废纯粉总重
@@ -1659,7 +1709,8 @@ public class AutoformulaServiceImpl implements AutoformulaService {
for(int i=0;i<ivts_new.size();i++){
JSONObject ivt_new = ivts_new.getJSONObject(i);
//可分配库存重量
double ivt_qty = ivt_new.getDouble("sum_ivt_qty");
double ivt_qty = ivt_new.getDouble("can_qty");
//纯粉系数
double net_rate = ivt_new.getDouble("net_rate");
ivt_qty = NumberUtil.roundDown(ivt_qty,3).doubleValue();
@@ -1670,6 +1721,19 @@ public class AutoformulaServiceImpl implements AutoformulaService {
}else{
formula_qty = rf_up;
}
String rf_material_id = ivt_new.getString("material_id");
JSONObject can_jo = rf_plan_map.get(rf_material_id);
double can_left_qty = can_jo.getDouble("can_left_qty");
if(can_left_qty <=0){
continue;
}
if(can_left_qty<= formula_qty){
formula_qty = can_left_qty;
}else{
formula_qty = formula_qty;
}
double now_ivt_qty = formula_qty * net_rate / 100.0;
//已分配软废总量
@@ -1678,6 +1742,10 @@ public class AutoformulaServiceImpl implements AutoformulaService {
rf_left_weight = NumberUtil.round(NumberUtil.sub(rf_left_weight,now_ivt_qty),3);
//累加软废纯粉重量
rf_net_total_weight = rf_net_total_weight + now_ivt_qty;
BigDecimal formula_qty_now = NumberUtil.round(formula_qty,3);
can_jo.put("can_left_qty",can_left_qty-formula_qty_now.doubleValue());
rf_plan_map.put(rf_material_id,can_jo);
//分配软废重量
ivt_new.put("formula_qty",NumberUtil.round(formula_qty,3));
//纯粉重量
@@ -1686,9 +1754,7 @@ public class AutoformulaServiceImpl implements AutoformulaService {
ivt_new.put("is_need_move","1");
ivt_new.put("is_need_manage","1");
ivt_new.put("is_rf_xl","1");
//获取软废Bom统计软废总含碳化钨
String rf_material_id = ivt_new.getString("material_id");
JSONArray rf_bomdlts = WQL.getWO("QPF_AUTOFORMULA01")
.addParam("material_id",rf_material_id)
.addParam("is_need_manage","1")
@@ -2826,6 +2892,10 @@ public class AutoformulaServiceImpl implements AutoformulaService {
double new_qty = workorder_qty;
//纯粉重量
double net_qty = workorder_qty;
//rf最高开单重量
HashMap<String,JSONObject> rf_plan_map = new HashMap<String,JSONObject>();
if(waste_limit_up!=0){//添加软废
//R下
double waste_limit_down_weight = workorder_qty * waste_limit_down/100.0;
@@ -2869,7 +2939,23 @@ public class AutoformulaServiceImpl implements AutoformulaService {
.addParam("workorder_id",workorder_id)
.addParam("flag","22")
.process().getResultJSONArray(0);
ivts.addAll(now_ivts);
double add_rate = MaterialSet.getDouble("add_rate");
for(int j=0;j<now_ivts.size();j++){
JSONObject jo = now_ivts.getJSONObject(j);
double can_qty = net_qty*add_rate/100.0;
JSONObject jo2 = new JSONObject();
jo2.put("can_qty",can_qty);
jo2.put("can_left_qty",can_qty);
rf_plan_map.put(set_material_id,jo2);
double sum_ivt_qty = jo.getDouble("sum_ivt_qty");
if(can_qty >= sum_ivt_qty){
jo.put("can_qty",sum_ivt_qty);
}else{
jo.put("can_qty",can_qty);
}
ivts.add(jo);
}
}
if(ivts.size()!=0){
//软废纯粉库存总量
@@ -2877,10 +2963,17 @@ public class AutoformulaServiceImpl implements AutoformulaService {
JSONArray ivts_new = new JSONArray();
for(int i=0;i<ivts.size();i++){
JSONObject ivt = ivts.getJSONObject(i);
if(ivt.getDouble("sum_ivt_qty") <=0 || ivt.getDouble("sum_ivt_qty") <0.01){
double can_qty = ivt.getDouble("can_qty");
if(ivt.getDouble("can_qty") <=0 || ivt.getDouble("can_qty") <0.01){
continue;
}
String ivt_material_id = ivt.getString("material_id");
JSONObject can_jo = rf_plan_map.get(ivt_material_id);
double can_left_qty = can_jo.getDouble("can_left_qty");
if(can_left_qty <=0){
continue;
}
JSONObject ProductMaterialExt = MD_ME_ProductMaterialExt.query("material_id='"+ivt_material_id+"'").uniqueResult(0);
if(ProductMaterialExt ==null){
throw new BadRequestException("软废"+ivt.getString("material_code")+" "+ivt.getString("material_name")+"未配置成品物料扩展信息!");
@@ -2889,7 +2982,15 @@ public class AutoformulaServiceImpl implements AutoformulaService {
if(net_rate==0){
throw new BadRequestException("软废"+ivt.getString("material_code")+" "+ivt.getString("material_name")+"未配置纯粉系数!");
}
double ivt_qty = ivt.getDouble("sum_ivt_qty")*net_rate/100.0;
if(can_qty <= can_left_qty){
can_qty = can_qty;
can_jo.put("can_left_qty",can_left_qty-can_qty);
}else{
can_qty = can_left_qty;
can_jo.put("can_left_qty",can_left_qty-can_qty);
}
rf_plan_map.put(ivt_material_id,can_jo);
double ivt_qty = can_qty*net_rate/100.0;
//Rp*纯粉系数
ivt.put("net_rate_qty",ivt_qty);
//纯粉系数
@@ -3140,6 +3241,9 @@ public class AutoformulaServiceImpl implements AutoformulaService {
//1.需添加软废
//R下
double waste_limit_down_weight = workorder_qty * waste_limit_down/100.0;
//rf最高开单重量
HashMap<String,JSONObject> rf_plan_map = new HashMap<String,JSONObject>();
//获取可分配的软废集合
JSONArray MaterialSets = WQL.getWO("QPF_AUTOFORMULA01")
.addParam("material_id",material_id)
@@ -3171,7 +3275,23 @@ public class AutoformulaServiceImpl implements AutoformulaService {
.addParam("workorder_id",workorder_id)
.addParam("flag","22")
.process().getResultJSONArray(0);
ivts.addAll(now_ivts);
double add_rate = MaterialSet.getDouble("add_rate");
for(int j=0;j<now_ivts.size();j++){
JSONObject jo = now_ivts.getJSONObject(j);
double can_qty = net_qty*add_rate/100.0;
JSONObject jo2 = new JSONObject();
jo2.put("can_qty",can_qty);
jo2.put("can_left_qty",can_qty);
rf_plan_map.put(set_material_id,jo2);
double sum_ivt_qty = jo.getDouble("sum_ivt_qty");
if(can_qty >= sum_ivt_qty){
jo.put("can_qty",sum_ivt_qty);
}else{
jo.put("can_qty",can_qty);
}
ivts.add(jo);
}
}
if(ivts.size()!=0){
//1.计算配粉所需重量环节
@@ -3211,10 +3331,11 @@ public class AutoformulaServiceImpl implements AutoformulaService {
JSONArray ivts_new = new JSONArray();
for(int i=0;i<ivts.size();i++){
JSONObject ivt = ivts.getJSONObject(i);
if(ivt.getDouble("sum_ivt_qty") <=0 || ivt.getDouble("sum_ivt_qty") <0.01){
if(ivt.getDouble("can_qty") <=0 || ivt.getDouble("can_qty") <0.01){
continue;
}
String ivt_material_id = ivt.getString("material_id");
JSONObject ProductMaterialExt = MD_ME_ProductMaterialExt.query("material_id='"+ivt_material_id+"'").uniqueResult(0);
if(ProductMaterialExt ==null){
throw new BadRequestException("软废"+ivt.getString("material_code")+" "+ivt.getString("material_name")+"未配置成品物料扩展信息!");
@@ -3223,7 +3344,8 @@ public class AutoformulaServiceImpl implements AutoformulaService {
if(net_rate==0){
throw new BadRequestException("软废"+ivt.getString("material_code")+" "+ivt.getString("material_name")+"未配置纯粉系数!");
}
double net_rate_qty = ivt.getDouble("sum_ivt_qty")*net_rate/100.0;
double net_rate_qty = ivt.getDouble("can_qty")*net_rate/100.0;
//Rp*纯粉系数
ivt.put("net_rate_qty",net_rate_qty);
//纯粉系数
@@ -3241,18 +3363,26 @@ public class AutoformulaServiceImpl implements AutoformulaService {
outer:
for(int i=0;i<ivts_new.size();i++){
JSONObject ivt_new = ivts_new.getJSONObject(i);
double ivt_qty = ivt_new.getDouble("sum_ivt_qty");
double ivt_qty = ivt_new.getDouble("can_qty");
ivt_qty = NumberUtil.roundDown(ivt_qty,3).doubleValue();
if(ivt_qty <=0){
continue;
}
String rf_material_id = ivt_new.getString("material_id");
JSONObject can_jo = rf_plan_map.get(rf_material_id);
double can_left_qty = can_jo.getDouble("can_left_qty");
if(can_left_qty <=0){
continue;
}
//软废纯粉系数
double net_rate = ivt_new.getDouble("net_rate");
String rf_material_id = ivt_new.getString("material_id");
//计算R1p=min(Y1/h1/纯粉系数X1/h2/纯粉系数X2/h3/纯粉系数...)
//c、更新R1p=min(R1,R1p)
List<Double> doubles = new ArrayList<Double>();
doubles.add(ivt_qty);
doubles.add(can_left_qty);
//doubles集合
HashMap<String,JSONObject> doubles_map = new HashMap<String,JSONObject>();
//获取软废Bom
@@ -3294,6 +3424,10 @@ public class AutoformulaServiceImpl implements AutoformulaService {
//进行集合排序
Collections.sort(doubles);
double rf_up_formula_qty = doubles.get(0);
can_jo.put("can_left_qty",can_left_qty-rf_up_formula_qty);
rf_plan_map.put(rf_material_id,can_jo);
//计算不需要移库的添加剂
doubles_map.forEach((key,fi_bomdtl)->{
String fi_bomdtl_material_id = fi_bomdtl.getString("material_id");

View File

@@ -339,6 +339,7 @@
WHERE
1 = 1
and producmaterialext.net_rate>0
and ProductMaterialSet.add_rate>0
OPTION 输入.material_id <> ""
ProductMaterialSet.material_id = 输入.material_id
ENDOPTION

View File

@@ -115,7 +115,7 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
//1、库存现存量现有库存 - 开单领料重量
JSONObject mater_ivt = WQL.getWO("statistical_report_query_01").addParam("flag", "4").addParam("material_id", material_id).process().uniqueResult(0);
//查询开单领料重量
JSONObject form_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "5").addParam("material_id", material_id).addParam("begin_time",begin_time).addParam("end_time",end_time).process().uniqueResult(0);
JSONObject form_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "5").addParam("material_id", material_id).process().uniqueResult(0);
double now_ivt = 0;
double need_qty = 0;
@@ -126,15 +126,15 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
need_qty = form_qty.getDoubleValue("qty");
}
BigDecimal canuse_num = NumberUtil.sub(now_ivt - need_qty);
jo1.put(material_id, String.format("%.3f",canuse_num));
jo1.put(material_id, String.format("%.3f", canuse_num));
//2、排产需求量(未开单的工令重量+排产未生成工令日计划重量)根据bom计算需要多少原料库存重量
JSONObject nedd_mater = WQL.getWO("statistical_report_query_01").addParam("flag", "6").addParam("material_id", material_id).addParam("begin_time",begin_time).addParam("end_time",end_time).process().uniqueResult(0);
JSONObject nedd_mater = WQL.getWO("statistical_report_query_01").addParam("flag", "6").addParam("material_id", material_id).addParam("begin_time", begin_time).addParam("end_time", end_time).process().uniqueResult(0);
double bom_qty = 0;
if (ObjectUtil.isNotEmpty(nedd_mater)) {
bom_qty = nedd_mater.getDoubleValue("qty");
}
jo2.put(material_id, String.format("%.3f",bom_qty));
jo2.put(material_id, String.format("%.3f", bom_qty));
//3、待检入库量sum(此物料未确认的到货单的单据数-入库数)
JSONObject num_jo = WQL.getWO("statistical_report_query_01").addParam("flag", "7").addParam("material_id", material_id).process().uniqueResult(0);
@@ -158,13 +158,13 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
notqty = 0;
}
}
jo4.put(material_id, String.format("%.3f",noin_qty));
jo4.put(material_id, String.format("%.3f", noin_qty));
//4、合同在途订单量-到货量
jo6.put(material_id, String.format("%.3f",notqty));
jo6.put(material_id, String.format("%.3f", notqty));
//5、库/需差额量 :库存现存量-排产需求量
jo3.put(material_id, String.format("%.3f",(Double.parseDouble(canuse_num + "") - bom_qty)));
jo3.put(material_id, String.format("%.3f", (Double.parseDouble(canuse_num + "") - bom_qty)));
//7、最低储备定额物料的安全库存量下限
JSONObject safe_jo = WQLObject.getWQLObject("ST_IVT_MaterialSafeIvt").query("material_id = '" + material_id + "'").uniqueResult(0);
@@ -172,29 +172,29 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
if (ObjectUtil.isNotEmpty(safe_jo)) {
safe_qty = safe_jo.getDoubleValue("safe_ivt_down");
}
jo7.put(material_id, String.format("%.3f",safe_qty));
jo7.put(material_id, String.format("%.3f", safe_qty));
//8、采购缺口库存+待检+在途+最低储备-排产量
double buy_qty = bom_qty - (now_ivt + noqty + notqty + safe_qty);
jo8.put(material_id, String.format("%.3f",buy_qty));
double buy_qty = bom_qty + safe_qty - (canuse_num.doubleValue() + noin_qty + notqty);
jo8.put(material_id, String.format("%.3f", buy_qty));
//6、覆盖日期物料库存可坚持到哪一天库存现存量减每天需求量哪天<0,取前一天
for (int j = 1; j <= betweenDay; j++) {
DateTime newDate = DateUtil.offsetDay(date1, j);
//查询该物料当天的需求量
JSONObject today_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "8").addParam("material_id", material_id).addParam("begin_time",newDate).process().uniqueResult(0);
JSONObject today_qty = WQL.getWO("statistical_report_query_01").addParam("flag", "8").addParam("material_id", material_id).addParam("begin_time", newDate.toString().substring(0, 10) + "%").process().uniqueResult(0);
double need_weight = 0;
if (ObjectUtil.isNotEmpty(today_qty)){
if (ObjectUtil.isNotEmpty(today_qty)) {
need_weight = today_qty.getDoubleValue("qty");
}
if (now_ivt<need_weight){
jo5.put(material_id,DateUtil.offsetDay(newDate, -1).toString().substring(0,10));
if (now_ivt < need_weight) {
jo5.put(material_id, DateUtil.offsetDay(newDate, -1).toString().substring(0, 10));
break;
}else {
} else {
now_ivt -= need_weight;
}
if (j==betweenDay){
jo5.put(material_id,end_time.substring(0,10));
if (j == betweenDay) {
jo5.put(material_id, end_time.substring(0, 10));
}
}
}
@@ -207,26 +207,27 @@ public class StatisticalReportServiceImpl implements StatisticalReportService {
public Map<String, Object> materPlanDtlQuery(Map whereJson) {
String begin_time = MapUtil.getStr(whereJson, "begin_time");
String end_time = MapUtil.getStr(whereJson, "end_time");
String org_id = MapUtil.getStr(whereJson, "org_id");
//查询日期内的排产日计划物料信息
JSONArray jsonArr = WQL.getWO("statistical_report_query_01").addParam("flag", "9").addParam("begin_time",begin_time).addParam("end_time",end_time).process().getResultJSONArray(0);
JSONArray jsonArr = WQL.getWO("statistical_report_query_01").addParam("flag", "9").addParam("begin_time", begin_time).addParam("end_time", end_time).addParam("org_id", org_id).process().getResultJSONArray(0);
JSONArray rows = new JSONArray();
for (int i = 0; i < jsonArr.size(); i++) {
JSONObject row = jsonArr.getJSONObject(i);
String material_code = row.getString("material_code");
JSONObject bom = WQLObject.getWQLObject("md_pd_productbom").query("material_id = '"+row.get("material_id")+"'").uniqueResult(0);
if (ObjectUtil.isEmpty(bom)){
throw new BadRequestException("未查询到该产品 "+material_code+" 对应BOM信息");
JSONObject bom = WQLObject.getWQLObject("md_pd_productbom").query("material_id = '" + row.get("material_id") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(bom)) {
throw new BadRequestException("未查询到该产品 " + material_code + " 对应BOM信息");
}
row.put("1",row.getString("planstart_date"));
row.put("2",row.getString("old_mark"));
row.put("3",row.getString("product_num"));
row.put("1", row.getString("planstart_date"));
row.put("2", row.getString("old_mark"));
row.put("3", row.getString("product_num"));
//查询该物料对应的bom明细
JSONArray bom_dtl = WQLObject.getWQLObject("md_pd_productbomdtl").query("bom_id = '"+bom.getString("bom_id")+"'").getResultJSONArray(0);
JSONArray bom_dtl = WQLObject.getWQLObject("md_pd_productbomdtl").query("bom_id = '" + bom.getString("bom_id") + "'").getResultJSONArray(0);
for (int j = 0; j < bom_dtl.size(); j++) {
JSONObject dtl = bom_dtl.getJSONObject(j);
double standard_rate = dtl.getDoubleValue("standard_rate");
double qty = standard_rate * row.getDoubleValue("product_weight") * 0.01;
row.put(dtl.getString("material_id"),String.format("%.3f",qty));
row.put(dtl.getString("material_id"), String.format("%.3f", qty));
}
rows.add(row);
}

View File

@@ -27,6 +27,7 @@
输入.create_mode TYPEAS s_string
输入.bill_status TYPEAS s_string
输入.material_id TYPEAS s_string
输入.org_id TYPEAS s_string
[临时表]
@@ -474,6 +475,7 @@
mps_bd_productdailyplan plan
LEFT JOIN md_me_producmaterialext ext ON ext.material_id = plan.material_id
LEFT JOIN md_me_materialbase materialbase ON materialbase.material_id = plan.material_id
LEFT JOIN sys_dept dept ON dept.`code` = plan.plan_org_code
WHERE
plan.status = '01'
OPTION 输入.begin_time <> ""
@@ -482,11 +484,14 @@
OPTION 输入.end_time <> ""
plan.planstart_date <= 输入.end_time
ENDOPTION
OPTION 输入.org_id <> ""
dept.dept_id = 输入.org_id
ENDOPTION
UNION ALL
SELECT
wo.planstart_time AS planstart_date,
LEFT(wo.planstart_time,10) AS planstart_date,
COUNT(wo.workorder_id) AS product_num,
MAX(ext.old_mark) AS old_mark,
SUM(wo.workorder_qty) AS product_weight,
@@ -505,6 +510,9 @@
ENDOPTION
OPTION 输入.end_time <> ""
wo.planstart_time <= 输入.end_time
ENDOPTION
OPTION 输入.org_id <> ""
wo.org_id = 输入.org_id
ENDOPTION
GROUP BY
planstart_time,wo.material_id