add:统计分析
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package org.nl.wms.analysis_manage.productCapacity.controller;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/10/8 10:24
|
||||
*/
|
||||
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.analysis_manage.productCapacity.dto.ProductCapQuery;
|
||||
import org.nl.wms.product_manage.service.workorder.IPdmProduceWorkorderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/productCap")
|
||||
@Slf4j
|
||||
public class ProductCapController {
|
||||
|
||||
@Autowired
|
||||
private IPdmProduceWorkorderService workorderService;
|
||||
|
||||
@GetMapping()
|
||||
@Log("查询产能利用率")
|
||||
public ResponseEntity<Object> byMaterial(ProductCapQuery query, PageQuery page) {
|
||||
Page<Object> result = PageHelper.startPage(page.getPage() + 1, page.getSize());
|
||||
List<Map> list = workorderService.productCap(query);
|
||||
TableDataInfo build = TableDataInfo.build(list);
|
||||
build.setTotalElements(result.getTotal());
|
||||
return new ResponseEntity<>(build, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.nl.wms.analysis_manage.productCapacity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/10/8 10:25
|
||||
*/
|
||||
@Data
|
||||
public class ProductCapQuery {
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
private String device_code;
|
||||
/**
|
||||
* 工序id
|
||||
*/
|
||||
private String workprocedure_id;
|
||||
/**
|
||||
* 车间
|
||||
*/
|
||||
private String product_area;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private String[] create_time;
|
||||
private String start_time;
|
||||
private String end_time;
|
||||
|
||||
|
||||
public void setCreate_time(String[] create_time) {
|
||||
this.create_time = create_time;
|
||||
if (create_time!=null && create_time.length == 2){
|
||||
this.start_time = create_time[0];
|
||||
this.end_time = create_time[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.nl.wms.analysis_manage.scrapRate.controller;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/10/8 10:24
|
||||
*/
|
||||
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.analysis_manage.scrapRate.service.dto.ScrapRateQuery;
|
||||
import org.nl.wms.analysis_manage.workingGoods.service.dto.ByProcessQuery;
|
||||
import org.nl.wms.product_manage.service.workorder.IPdmProduceWorkorderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/scrapRate")
|
||||
@Slf4j
|
||||
public class ScrapRateController {
|
||||
|
||||
@Autowired
|
||||
private IPdmProduceWorkorderService workorderService;
|
||||
|
||||
@GetMapping()
|
||||
@Log("查询废品率")
|
||||
public ResponseEntity<Object> byMaterial(ScrapRateQuery query, PageQuery page) {
|
||||
Page<Object> result = PageHelper.startPage(page.getPage() + 1, page.getSize());
|
||||
List<Map> list = workorderService.scrapRate(query);
|
||||
TableDataInfo build = TableDataInfo.build(list);
|
||||
build.setTotalElements(result.getTotal());
|
||||
return new ResponseEntity<>(build, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.nl.wms.analysis_manage.scrapRate.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/10/8 10:25
|
||||
*/
|
||||
@Data
|
||||
public class ScrapRateQuery {
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
private String device_code;
|
||||
/**
|
||||
* 工序id
|
||||
*/
|
||||
private String workprocedure_id;
|
||||
/**
|
||||
* 车间
|
||||
*/
|
||||
private String product_area;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private String[] create_time;
|
||||
private String start_time;
|
||||
private String end_time;
|
||||
|
||||
|
||||
public void setCreate_time(String[] create_time) {
|
||||
this.create_time = create_time;
|
||||
if (create_time!=null && create_time.length == 2){
|
||||
this.start_time = create_time[0];
|
||||
this.end_time = create_time[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.nl.wms.analysis_manage.workingGoods.service.dto;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/10/7 10:11
|
||||
*/
|
||||
public class ByMaterialQuery {
|
||||
|
||||
public void sdfds(){
|
||||
System.out.println(this.getClass().getName()+"调用方法");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
System.out.println("对象被释放");
|
||||
}
|
||||
}
|
||||
class demo{
|
||||
public static void main(String[] args) {
|
||||
ByMaterialQuery query = new ByMaterialQuery();
|
||||
query.sdfds();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.ext_manage.acs.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -53,9 +54,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -357,11 +361,24 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
return;
|
||||
}
|
||||
Iterator<String> iterator = param.keySet().iterator();
|
||||
Map<String, PdmProduceWorkorder> map = workorderService.list(new QueryWrapper<PdmProduceWorkorder>()
|
||||
.in("workorder_code", param.keySet()))
|
||||
.stream().collect(HashMap::new, (k, v) -> k.put(v.getWorkorder_code(), v), HashMap::putAll);
|
||||
Date now = new Date();
|
||||
BigDecimal divide = new BigDecimal(0);
|
||||
while (iterator.hasNext()){
|
||||
String workorderCode = iterator.next();
|
||||
BigDecimal dq_real_qty = param.getBigDecimal(workorderCode);
|
||||
PdmProduceWorkorder workorder = map.get(workorderCode);
|
||||
BigDecimal subtract = dq_real_qty.subtract(workorder.getDq_real_qty());
|
||||
if (workorder.getUpdate_time() !=null){
|
||||
divide = subtract.divide(new BigDecimal(DateUtil.between(workorder.getUpdate_time(), now, DateUnit.SECOND)), 3, RoundingMode.HALF_UP);
|
||||
}
|
||||
workorderService.update(new UpdateWrapper<PdmProduceWorkorder>()
|
||||
.set("dq_real_qty",dq_real_qty).eq("workorder_code",workorderCode));
|
||||
.set("dq_real_qty",dq_real_qty)
|
||||
.set("update_time",DateUtil.now())
|
||||
.set("slope",divide)
|
||||
.eq("workorder_code",workorderCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -408,6 +408,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService{
|
||||
map.put("update_id", currentUserId);
|
||||
map.put("update_name", nickName);
|
||||
map.put("update_time", DateUtil.now());
|
||||
map.put("confirm_time", DateUtil.now());
|
||||
map.put("realproduceend_date", DateUtil.now());
|
||||
wo.update(map, "workorder_id = '" + workorder_id + "'");
|
||||
//2.设置实际数量:数量待确认: 是否需要从报工记录表统计
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.analysis_manage.productCapacity.dto.ProductCapQuery;
|
||||
import org.nl.wms.analysis_manage.scrapRate.service.dto.ScrapRateQuery;
|
||||
import org.nl.wms.analysis_manage.workingGoods.service.dto.ByProcessQuery;
|
||||
import org.nl.wms.product_manage.service.workorder.dao.PdmProduceWorkorder;
|
||||
import org.nl.wms.product_manage.service.workorder.dto.PdmProduceWorkorderDto;
|
||||
@@ -155,8 +157,27 @@ public interface IPdmProduceWorkorderService extends IService<PdmProduceWorkorde
|
||||
|
||||
List<Map> reportQuery(ReportQuery query);
|
||||
|
||||
/**
|
||||
* 在制品统计分析
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<Map> goodAnilysis(ByProcessQuery query);
|
||||
|
||||
/**
|
||||
* 不合格品分析
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<Map> scrapRate(ScrapRateQuery query);
|
||||
|
||||
/**
|
||||
* 不合格品分析
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<Map> productCap(ProductCapQuery query);
|
||||
|
||||
void download(Map map, HttpServletResponse response)
|
||||
throws IOException;
|
||||
}
|
||||
|
||||
@@ -176,6 +176,18 @@ public class PdmProduceWorkorder implements Serializable{
|
||||
* 下发时间
|
||||
*/
|
||||
private String down_time;
|
||||
|
||||
/**
|
||||
* 开工时间
|
||||
*/
|
||||
private String open_time;
|
||||
|
||||
|
||||
/**
|
||||
* 增长率
|
||||
*/
|
||||
private BigDecimal slope;
|
||||
|
||||
/**
|
||||
* 完工人
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.nl.wms.product_manage.service.workorder.dao.mapper;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.analysis_manage.productCapacity.dto.ProductCapQuery;
|
||||
import org.nl.wms.analysis_manage.scrapRate.service.dto.ScrapRateQuery;
|
||||
import org.nl.wms.analysis_manage.workingGoods.service.dto.ByProcessQuery;
|
||||
import org.nl.wms.product_manage.service.workorder.dao.PdmProduceWorkorder;
|
||||
import org.nl.wms.product_manage.service.workorder.dto.PdmProduceWorkorderDto;
|
||||
@@ -47,4 +49,17 @@ public interface PdmProduceWorkorderMapper extends BaseMapper<PdmProduceWorkorde
|
||||
*/
|
||||
List<Map> goodAnalysis(ByProcessQuery query);
|
||||
|
||||
/**
|
||||
* 不合格品统计
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<Map> scrapRate(ScrapRateQuery query);
|
||||
/**
|
||||
* 不合格品统计
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<Map> productCap(ProductCapQuery query);
|
||||
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@
|
||||
<if test="product_area != null and product_area != ''">
|
||||
and pdm_produce_workorder.product_area >= #{product_area}
|
||||
</if>
|
||||
<if test="start_time != null and start_time != ''">
|
||||
<if test="end_time != null and end_time != ''">
|
||||
and #{end_time} >= pdm_produce_workorder.create_time
|
||||
</if>
|
||||
<if test="blurry != null and blurry != ''">
|
||||
@@ -269,6 +269,76 @@
|
||||
md_me_materialbase.material_code,
|
||||
pdm_bi_workprocedure.workprocedure_name
|
||||
</select>
|
||||
<select id="scrapRate" resultType="java.util.Map">
|
||||
SELECT
|
||||
pdm_produce_workorder.product_area,
|
||||
pdm_produce_workorder.device_code,
|
||||
sum( real_qty ) real_qty,
|
||||
sum( nok_qty ) nok_qty,
|
||||
pdm_bi_device.device_name,
|
||||
pdm_bi_workprocedure.workprocedure_name,
|
||||
IF
|
||||
( sum( real_qty ) > 0, sum( nok_qty ) / sum( real_qty ), 99 ) AS nok_rate
|
||||
FROM
|
||||
pdm_produce_workorder
|
||||
LEFT JOIN pdm_bi_device ON pdm_bi_device.device_code = pdm_produce_workorder.device_code
|
||||
LEFT JOIN pdm_bi_workprocedure ON pdm_bi_workprocedure.workprocedure_id = pdm_produce_workorder.workprocedure_id
|
||||
WHERE
|
||||
workorder_status IN ( '6', '7' )
|
||||
<if test="device_code != null and device_code != ''">
|
||||
and pdm_produce_workorder.device_code = #{device_code}
|
||||
</if>
|
||||
<if test="workprocedure_id != null and workprocedure_id != ''">
|
||||
and pdm_produce_workorder.workprocedure_id = #{workprocedure_id}
|
||||
</if>
|
||||
<if test="start_time != null and start_time != ''">
|
||||
and pdm_produce_workorder.create_time >= #{start_time}
|
||||
</if>
|
||||
<if test="product_area != null and product_area != ''">
|
||||
and pdm_produce_workorder.product_area >= #{product_area}
|
||||
</if>
|
||||
<if test="end_time != null and end_time != ''">
|
||||
and #{end_time} >= create_time
|
||||
</if>
|
||||
GROUP BY pdm_produce_workorder.device_code
|
||||
|
||||
</select>
|
||||
<select id="productCap" resultType="java.util.Map">
|
||||
SELECT GROUP_CONCAT(pdm_produce_workorder.workorder_code) orders,
|
||||
pdm_produce_workorder.product_area,
|
||||
pdm_produce_workorder.device_code,
|
||||
pdm_bi_device.device_name,
|
||||
REPLACE(pdm_bi_bomdtl.manufacture,'ph','') theory,
|
||||
sum(real_qty)/sum( TIMESTAMPDIFF( HOUR, confirm_time, open_time ) ) realty,
|
||||
pdm_bi_workprocedure.workprocedure_name,
|
||||
sum( real_qty ) real_qty,
|
||||
sum( plan_qty ) plan_qty,
|
||||
sum( TIMESTAMPDIFF( HOUR, confirm_time, open_time ) ) hours
|
||||
FROM
|
||||
pdm_produce_workorder
|
||||
LEFT JOIN pdm_bi_device ON pdm_bi_device.device_code = pdm_produce_workorder.device_code
|
||||
LEFT JOIN pdm_bi_workprocedure ON pdm_bi_workprocedure.workprocedure_id = pdm_produce_workorder.workprocedure_id
|
||||
LEFT JOIN pdm_bi_bomdtl on pdm_bi_device.device_name = pdm_bi_bomdtl.resources
|
||||
WHERE
|
||||
workorder_status IN ( '6', '7' )
|
||||
<if test="device_code != null and device_code != ''">
|
||||
and pdm_produce_workorder.device_code = #{device_code}
|
||||
</if>
|
||||
<if test="workprocedure_id != null and workprocedure_id != ''">
|
||||
and pdm_produce_workorder.workprocedure_id = #{workprocedure_id}
|
||||
</if>
|
||||
<if test="start_time != null and start_time != ''">
|
||||
and pdm_produce_workorder.create_time >= #{start_time}
|
||||
</if>
|
||||
<if test="product_area != null and product_area != ''">
|
||||
and pdm_produce_workorder.product_area >= #{product_area}
|
||||
</if>
|
||||
<if test="end_time != null and end_time != ''">
|
||||
and #{end_time} >= pdm_produce_workorder.create_time
|
||||
</if>
|
||||
GROUP BY
|
||||
device_code
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ import org.nl.common.utils.api.RestBusinessTemplate;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.wms.analysis_manage.productCapacity.dto.ProductCapQuery;
|
||||
import org.nl.wms.analysis_manage.scrapRate.service.dto.ScrapRateQuery;
|
||||
import org.nl.wms.analysis_manage.workingGoods.service.dto.ByProcessQuery;
|
||||
import org.nl.wms.ext_manage.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.masterdata_manage.master.service.classstandard.IMdPbClassstandardService;
|
||||
@@ -203,7 +205,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
this.update(updateWrapper);
|
||||
});
|
||||
}
|
||||
this.update(new UpdateWrapper<PdmProduceWorkorder>().set("workorder_status", WorkerOrderEnum.SEND.getCode()).set("down_id", SecurityUtils.getCurrentUserId()).set("down_name", SecurityUtils.getCurrentNickName()).set("down_time", new Date()).in("workorder_id", ids));
|
||||
this.update(new UpdateWrapper<PdmProduceWorkorder>().set("workorder_status", WorkerOrderEnum.SEND.getCode()).set("down_id", SecurityUtils.getCurrentUserId()).set("down_name", SecurityUtils.getCurrentNickName()).set("update_time", new Date()).set("down_time", new Date()).in("workorder_id", ids));
|
||||
this.recordWorkOrder(OptionRecord.OptionEnum.UPDATE, ids.toArray(new String[0]));
|
||||
}
|
||||
|
||||
@@ -269,6 +271,9 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
workorder.setRealproduceend_date(DateUtil.now().replace("-", "/"));
|
||||
workorder.setWorkorder_status(WorkerOrderEnum.COMPLETE.getCode());
|
||||
workorder.setAps_workorder_status("B");
|
||||
workorder.setConfirm_time(DateUtil.now());
|
||||
workorder.setConfirm_id(SecurityUtils.getCurrentUserId());
|
||||
workorder.setConfirm_name(SecurityUtils.getCurrentNickName());
|
||||
}
|
||||
else{
|
||||
workorder.setWorkorder_status(WorkerOrderEnum.STOP.getCode());
|
||||
@@ -685,6 +690,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
workOrder.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
workOrder.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
workOrder.setReal_qty(null);
|
||||
workOrder.setOpen_time(DateUtil.now());
|
||||
this.update(workOrder, new QueryWrapper<PdmProduceWorkorder>().eq("workorder_id", param.getString("workorder_id")));
|
||||
//开工为首道工序时,更新订单状态为开工
|
||||
PdmBiWorkprocedure isFirst = workprocedureService.getOne(new LambdaUpdateWrapper<PdmBiWorkprocedure>().eq(PdmBiWorkprocedure::getWorkprocedure_id, workOrder.getWorkprocedure_id()).eq(PdmBiWorkprocedure::getIs_first, 1));
|
||||
@@ -876,4 +882,15 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
public List<Map> goodAnilysis(ByProcessQuery query) {
|
||||
return this.baseMapper.goodAnalysis(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> scrapRate(ScrapRateQuery query) {
|
||||
return this.baseMapper.scrapRate(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> productCap(ProductCapQuery query) {
|
||||
List<Map> maps = this.baseMapper.productCap(query);
|
||||
return maps;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user