Merge remote-tracking branch 'origin/master'

master
陈恒杰 1 year ago
commit d189457891

@ -0,0 +1,28 @@
package com.op.system.api;
import com.op.common.core.constant.ServiceNameConstants;
import com.op.common.core.domain.R;
import com.op.system.api.domain.quality.QcCheckTaskIncomeDTO;
import com.op.system.api.factory.RemoteDeviceFallbackFactory;
import com.op.system.api.factory.RemoteQualityFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
*
*
* @author OP
*/
@FeignClient(contextId = "remoteQualityService", value = ServiceNameConstants.QMS_SERVICE, fallbackFactory = RemoteQualityFallbackFactory.class)
public interface RemoteQualityService {
@PostMapping("/qcProduce/createProduceXJTask")
public R createProduceXJTask();
@PostMapping("/qcIncome/createIncomeTask")
public R createIncomeTask(@RequestBody QcCheckTaskIncomeDTO qcCheckTaskIncome);
}

@ -69,14 +69,6 @@ public class ProOrderWorkorderDTO extends TreeEntity {
// 工艺名称
private String routeName;
public String getRouteName() {
return routeName;
}
public void setRouteName(String routeName) {
this.routeName = routeName;
}
/** 产线编码 */
@Excel(name = "线体")
private String prodLineCode;
@ -86,14 +78,6 @@ public class ProOrderWorkorderDTO extends TreeEntity {
// TODO 暂时存放线体编码
private String prodLineName;
public String getProdLineName() {
return prodLineName;
}
public void setProdLineName(String prodLineName) {
this.prodLineName = prodLineName;
}
/** 工单生产日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "工单生产日期", width = 30, dateFormat = "yyyy-MM-dd")
@ -138,14 +122,6 @@ public class ProOrderWorkorderDTO extends TreeEntity {
/** 是否为底层节点 1是 0不是 */
private Integer endFlag;
public Integer getEndFlag() {
return endFlag;
}
public void setEndFlag(Integer endFlag) {
this.endFlag = endFlag;
}
/** 班次名称(数据库无该字段,需自行查询) */
private String shiftDesc;
@ -153,14 +129,6 @@ public class ProOrderWorkorderDTO extends TreeEntity {
private Integer carNum;
private Integer sortNo;
public Integer getCarNum() {
return carNum;
}
public void setCarNum(Integer carNum) {
this.carNum = carNum;
}
// 料罐id湿料计划模块使用
private Integer bucketId;
@ -192,6 +160,36 @@ public class ProOrderWorkorderDTO extends TreeEntity {
private BigDecimal quantitySplits;
private String units;
public String getProdLineName() {
return prodLineName;
}
public void setProdLineName(String prodLineName) {
this.prodLineName = prodLineName;
}
public String getRouteName() {
return routeName;
}
public void setRouteName(String routeName) {
this.routeName = routeName;
}
public Integer getEndFlag() {
return endFlag;
}
public void setEndFlag(Integer endFlag) {
this.endFlag = endFlag;
}
public Integer getCarNum() {
return carNum;
}
public void setCarNum(Integer carNum) {
this.carNum = carNum;
}
public String getWorkorderCodes() {
return workorderCodes;
}

@ -1,4 +1,4 @@
package com.op.system.api.domain.dto.quality;
package com.op.system.api.domain.quality;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
@ -8,6 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* qc_check_task_income
@ -15,7 +16,7 @@ import java.util.Date;
* @author Open Platform
* @date 2023-10-19
*/
public class QcCheckTaskIncomeDto extends BaseEntity {
public class QcCheckTaskIncomeDTO extends BaseEntity {
private static final long serialVersionUID = 1L;
/** id */
@ -25,8 +26,10 @@ public class QcCheckTaskIncomeDto extends BaseEntity {
@Excel(name = "检验任务编号")
private String checkNo;
private String workorderCode;
/** 来料批次号 */
@Excel(name = "来料批次号")
@Excel(name = "批次号")
private String incomeBatchNo;
/** 订单号 */
@ -45,6 +48,9 @@ public class QcCheckTaskIncomeDto extends BaseEntity {
@Excel(name = "收货数量")
private BigDecimal quality;
@Excel(name = "不合格数量")
private BigDecimal noOkQuality;
/** 单位 */
@Excel(name = "单位")
private String unit;
@ -120,6 +126,95 @@ public class QcCheckTaskIncomeDto extends BaseEntity {
private String checkTimeEnd;
private String typeCode;
private String checkType;
private String qualityStatus;
private String batchCode;
private String batchId;
private List<QcCheckTaskDetailDTO> qcCheckTaskDetails;
private BigDecimal sampleQuality;
private BigDecimal aNoOkquality;
private BigDecimal bNoOkquality;
private BigDecimal cNoOkquality;
public BigDecimal getSampleQuality() {
return sampleQuality;
}
public void setSampleQuality(BigDecimal sampleQuality) {
this.sampleQuality = sampleQuality;
}
public BigDecimal getaNoOkquality() {
return aNoOkquality;
}
public void setaNoOkquality(BigDecimal aNoOkquality) {
this.aNoOkquality = aNoOkquality;
}
public void setbNoOkquality(BigDecimal bNoOkquality) {
this.bNoOkquality = bNoOkquality;
}
public void setcNoOkquality(BigDecimal cNoOkquality) {
this.cNoOkquality = cNoOkquality;
}
public BigDecimal getbNoOkquality() {
return bNoOkquality;
}
public BigDecimal getcNoOkquality() {
return cNoOkquality;
}
public List<QcCheckTaskDetailDTO> getQcCheckTaskDetails() {
return qcCheckTaskDetails;
}
public void setQcCheckTaskDetails(List<QcCheckTaskDetailDTO> qcCheckTaskDetails) {
this.qcCheckTaskDetails = qcCheckTaskDetails;
}
public String getBatchCode() {
return batchCode;
}
public void setBatchCode(String batchCode) {
this.batchCode = batchCode;
}
public String getBatchId() {
return batchId;
}
public void setBatchId(String batchId) {
this.batchId = batchId;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getQualityStatus() {
return qualityStatus;
}
public void setQualityStatus(String qualityStatus) {
this.qualityStatus = qualityStatus;
}
public BigDecimal getNoOkQuality() {
return noOkQuality;
}
public void setNoOkQuality(BigDecimal noOkQuality) {
this.noOkQuality = noOkQuality;
}
public String getCheckType() {
return checkType;

@ -148,6 +148,16 @@ public class QcCheckTaskProduceDTO extends BaseEntity {
@Excel(name = "C类不合格数量")
private BigDecimal cNoOkquality;
private String workorderCode;
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public Date getProduceDate() {
return produceDate;
}

@ -0,0 +1,38 @@
package com.op.system.api.factory;
import com.op.common.core.domain.R;
import com.op.system.api.RemoteDeviceService;
import com.op.system.api.RemoteQualityService;
import com.op.system.api.domain.quality.QcCheckTaskIncomeDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
*
*
* @author OP
*/
@Component
public class RemoteQualityFallbackFactory implements FallbackFactory<RemoteQualityService> {
private static final Logger log = LoggerFactory.getLogger(RemoteQualityFallbackFactory.class);
@Override
public RemoteQualityService create(Throwable throwable) {
log.error("Quality服务调用失败:{}", throwable.getMessage());
return new RemoteQualityService() {
@Override
public R createProduceXJTask() {
return R.fail("巡检计划创建失败:" + throwable.getMessage());
}
@Override
public R createIncomeTask(QcCheckTaskIncomeDTO qcCheckTaskIncome) {
return R.fail("来料计划创建失败:" + throwable.getMessage());
}
};
}
}

@ -6,3 +6,4 @@ com.op.system.api.factory.RemotePlanFallbackFactory
com.op.system.api.factory.RemoteTechnologyFallbackFactory
com.op.system.api.factory.RemoteSapFallbackFactory
com.op.system.api.factory.RemoteDeviceFallbackFactory
com.op.system.api.factory.RemoteQualityFallbackFactory

@ -48,4 +48,6 @@ public class ServiceNameConstants {
* serviceid
*/
public static final String DEVICE_SERVICE = "op-device";
/**质量模块**/
public static final String QMS_SERVICE = "op-quality";
}

@ -1,9 +1,6 @@
package com.op.job.task;
import com.op.system.api.RemoteDeviceService;
import com.op.system.api.RemoteMesService;
import com.op.system.api.RemotePlanService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.*;
import com.op.system.api.domain.sap.SapRouterQuery;
import com.op.system.api.domain.sap.SapShopOrderQuery;
import org.slf4j.Logger;
@ -35,6 +32,9 @@ public class RyTask {
@Autowired
private RemoteDeviceService remoteDeviceService;
@Autowired
private RemoteQualityService remoteQualityService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
}
@ -150,4 +150,12 @@ public class RyTask {
logger.info("++设备运行记录+数据库备份的数据+开始++equipmentBkTask+++++");
remoteDeviceService.equipmentBKTask();
}
/************质量管理系统定时任务开始*****************/
//过程巡检每15分钟执行一次
public void createProduceXJTask(){
logger.info("++质量管理系统+过程巡检+开始++createProduceXJTask+++++");
remoteQualityService.createProduceXJTask();
}
/************质量管理系统定时任务结束*****************/
}

@ -0,0 +1,29 @@
package com.op.mes.controller;
import com.op.mes.domain.MesBoard;
import com.op.mes.service.MesInterfaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* mes
*
* @author zxl
* @date 2023-11-15
*/
@RestController
@RequestMapping("/mesInterface")
public class MesInterfaceController {
@Autowired
private MesInterfaceService mesInterfaceService;
//工艺看板
@PostMapping("/getTechnologyBoard")
public List<MesBoard> getTechnologyBoard(@RequestBody MesBoard mesBoard) {
return mesInterfaceService.getTechnologyBoard(mesBoard);
}
}

@ -0,0 +1,118 @@
package com.op.mes.domain;
import com.op.common.core.domain.BaseFileData;
import java.util.List;
//看板实体类
public class MesBoard {
private String factoryCode;
private String workorderCode;
private String workorderCodeSap;
private String workorderName;
private String equipmentName;
private String productCode;
private String productName;
private String routeCode;
private String routeId;
private List<BaseFileData> files;
private String workshopCode;
private String workshopName;
public String getWorkshopCode() {
return workshopCode;
}
public void setWorkshopCode(String workshopCode) {
this.workshopCode = workshopCode;
}
public String getWorkshopName() {
return workshopName;
}
public void setWorkshopName(String workshopName) {
this.workshopName = workshopName;
}
public String getEquipmentName() {
return equipmentName;
}
public void setEquipmentName(String equipmentName) {
this.equipmentName = equipmentName;
}
public List<BaseFileData> getFiles() {
return files;
}
public void setFiles(List<BaseFileData> files) {
this.files = files;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getWorkorderCodeSap() {
return workorderCodeSap;
}
public void setWorkorderCodeSap(String workorderCodeSap) {
this.workorderCodeSap = workorderCodeSap;
}
public String getWorkorderName() {
return workorderName;
}
public void setWorkorderName(String workorderName) {
this.workorderName = workorderName;
}
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getRouteCode() {
return routeCode;
}
public void setRouteCode(String routeCode) {
this.routeCode = routeCode;
}
public String getRouteId() {
return routeId;
}
public void setRouteId(String routeId) {
this.routeId = routeId;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
}

@ -39,6 +39,7 @@ public class MesDailyReport extends BaseEntity {
private String manAvgActual;//人均效率-实际
private String manAvgDo;//人均效率-达成
private String actManHour;//实际人工时
@JsonFormat(pattern = "yyyy-MM-dd")
private Date productDate;//工单日期
private String productDateStr;//工单日期字符串
private String productStartDate;

@ -1,5 +1,7 @@
package com.op.mes.mapper;
import com.op.common.core.domain.BaseFileData;
import com.op.mes.domain.MesBoard;
import com.op.mes.domain.dto.BaseEquipmentDto;
import com.op.mes.domain.dto.LGInfoDto;
import com.op.system.api.domain.SysDept;
@ -58,4 +60,8 @@ public interface MesMapper {
List<Map<String, String>> selectdryingRoomListInfo();
void deleteDateByTableName0(@Param("table")String table,@Param("ymdhms")String ymdhms);
List<MesBoard> getTechnologyBoard(MesBoard mesBoard);
List<BaseFileData> getTechnologyFiles(MesBoard dto);
}

@ -0,0 +1,18 @@
package com.op.mes.service;
import com.op.mes.domain.MesBoard;
import com.op.mes.domain.dto.BaseEquipmentDto;
import java.util.List;
/**
* Service
*
* @author Open Platform
* @date 2023-07-13
*/
public interface MesInterfaceService {
List<MesBoard> getTechnologyBoard(MesBoard mesBoard);
}

@ -0,0 +1,41 @@
package com.op.mes.service.impl;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.mes.domain.MesBoard;
import com.op.mes.domain.dto.BaseEquipmentDto;
import com.op.mes.mapper.MesMapper;
import com.op.mes.service.MesInterfaceService;
import com.op.mes.service.PDAService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* wcs
*
* @author Open Platform
* @date 2023-07-13
*/
@Service
public class MesInterfaceServiceImpl implements MesInterfaceService {
@Autowired
private MesMapper mesMapper;
@Override
public List<MesBoard> getTechnologyBoard(MesBoard mesBoard) {
DynamicDataSourceContextHolder.push(mesBoard.getFactoryCode());
List<MesBoard> dtos= mesMapper.getTechnologyBoard(mesBoard);
for(MesBoard dto:dtos){
//取附件
List<BaseFileData> files = mesMapper.getTechnologyFiles(dto);
dto.setFiles(files);
}
return dtos;
}
}

@ -227,7 +227,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
for(MesDailyReport dto:dtos){
String spc = dto.getSpec();//规格
//本日产量-实际(盒数)
BigDecimal actCase = new BigDecimal(dto.getQuantityFeedback()).multiply(new BigDecimal(spc));
BigDecimal actCase = new BigDecimal(dto.getQuantityFeedback());
dto.setQuantityAct(actCase.toString());
//本日产量-完成率=实际箱数/计划箱数
BigDecimal completeRate = new BigDecimal(dto.getQuantityFeedback())

@ -205,4 +205,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from ${table} where #{ymdhms} > CONVERT(varchar(30),creter_time, 120)
</delete>
<select id="getTechnologyBoard" resultType="com.op.mes.domain.MesBoard">
select pow.workorder_code workorderCode,
pow.workorder_code_sap workorderCodeSap,
pow.workorder_name workorderName,
pow.product_code productCode,
pow.product_name productName,
pr.route_code routeCode,
pr.route_id routeId,
equ.equipment_name equipmentName,
equ.workshop_code workshopCode,
equ.workshop_name workshopName
from pro_order_workorder pow
left join pro_route pr on pow.route_code = pr.route_code
left join base_equipment equ on pow.workorder_name = equ.equipment_code
where pow.parent_order = '0'
and pow.product_date = CONVERT(varchar(10),GETDATE(), 120)
and pow.del_flag='0'
</select>
<select id="getTechnologyFiles" resultType="com.op.common.core.domain.BaseFileData">
select file_name fileName,
file_address fileAddress
from base_file
where source_id = #{routeId}
</select>
</mapper>

@ -192,23 +192,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getProductionList" resultType="com.op.mes.domain.MesReportProduction">
select sf2.factory_code factoryCode,
sf2.factory_name factoryName,
sf1.factory_code carCode,
sf1.factory_name carName,
sf.factory_code machineCode,
sf.factory_name machineName,
mrw.product_code productCode,
mrw.product_name productName,
mrw.quantity,
mrw.quantity_feedback quantityFeedback,
mrw.spec productSpc,
mrw.unit
sf2.factory_name factoryName,
sf1.factory_code carCode,
sf1.factory_name carName,
sf.equipment_code machineCode,
sf.equipment_name machineName,
mrw.product_code productCode,
mrw.product_name productName,
mrw.quantity,
mrw.quantity_feedback quantityFeedback,
mrw.spec productSpc,
mrw.unit
from mes_report_work mrw
left join sys_factory sf on sf.factory_code = mrw.machine_code <!--线体-->
left join sys_factory sf1 on sf.parent_id = sf1.factory_id <!--车间-->
left join sys_factory sf2 on sf1.parent_id = sf2.factory_id <!--工厂-->
where
1=1
left join base_equipment sf on sf.equipment_code = mrw.machine_code <!---线体-->
left join sys_factory sf1 on sf.workshop_code = sf1.factory_code <!--车间-->
left join sys_factory sf2 on sf1.parent_id = sf2.factory_id <!--工厂-->
where mrw.parent_order = '0' and mrw.del_flag = '0'
<if test="machineName != null and machineName != ''">and sf.factory_name like concat('%', #{machineName}, '%')</if>
<if test="carName != null and carName != ''">and sf1.factory_name like concat('%', #{carName}, '%')</if>
<if test="factoryName != null and factoryName != ''">and sf2.factory_name like concat('%', #{factoryName}, '%')</if>
@ -265,12 +264,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bpa.man_standar manStandar,
mrw.use_man useMan,
mrw.work_time workTime
from pro_order_workorder ow
left join mes_report_work mrw on ow.workorder_code = mrw.workorder_code
from mes_report_work mrw
left join pro_order_workorder ow on ow.workorder_code = mrw.workorder_code
left join base_team_t tm on mrw.team_code = tm.Team_Code
left join base_product_attached bpa on bpa.product_code = mrw.product_code
where CONVERT(varchar(100),ow.product_date, 23) = CONVERT(varchar(100), #{productDateStr}, 23)
and mrw.work_center = #{workCenter}
where CONVERT(varchar(10),ow.product_date, 23) = CONVERT(varchar(10), #{productDateStr}, 23)
and mrw.work_center = #{workCenter} and mrw.parent_order != '0'
order by ow.workorder_code
</select>
<select id="getTitleName" resultType="java.lang.String">

@ -83,6 +83,11 @@
<artifactId>op-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.6.10</version>
</dependency>
</dependencies>
<build>

@ -6,10 +6,12 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.quality.domain.*;
import com.op.system.api.domain.SysRole;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.quality.QcCheckTaskIncomeDTO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -118,6 +120,17 @@ public class QcCheckTaskIncomeController extends BaseController {
}
return error("添加失败:请检查物料的关联检测项");
}
@PostMapping("/createIncomeTask")
public AjaxResult createIncomeTask(@RequestBody QcCheckTaskIncomeDTO qcCheckTaskIncome0) {
QcCheckTaskIncome qcCheckTaskIncome = new QcCheckTaskIncome();
BeanUtils.copyProperties(qcCheckTaskIncome,qcCheckTaskIncome0);
int r = qcCheckTaskIncomeService.insertQcCheckTaskIncome(qcCheckTaskIncome);
if(r>0){
return toAjax(r);
}
return error("添加失败:请检查物料的关联检测项");
}
/**
*

@ -5,6 +5,7 @@ import java.time.format.DateTimeFormatter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.quality.domain.QcCheckType;
@ -160,4 +161,11 @@ public class QcCheckTaskProduceController extends BaseController {
public AjaxResult changeProduceStatus(@RequestBody QcCheckTaskProduce qcCheckTaskProduce) {
return toAjax(qcCheckTaskProduceService.changeProduceStatus(qcCheckTaskProduce));
}
/**生产过程检验:巡检任务生产**/
@PostMapping("/createProduceXJTask")
public R createProduceXJTask() {
qcCheckTaskProduceService.createProduceXJTask();
return R.ok();
}
}

@ -127,6 +127,15 @@ public class QcCheckTaskProduce extends BaseEntity {
private String checkTimeEnd;
private String typeCode;
private String checkType;
private String workorderCode;
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
@Excel(name = "抽样数量")
private BigDecimal sampleQuality;

@ -4,6 +4,8 @@ import java.util.List;
import com.op.quality.domain.QcCheckTaskProduce;
import com.op.quality.domain.QcCheckType;
import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
import com.op.system.api.domain.quality.QcCheckTaskProduceDTO;
import org.apache.ibatis.annotations.Mapper;
/**
@ -67,4 +69,6 @@ public interface QcCheckTaskProduceMapper {
int getTodayMaxNum(QcCheckTaskProduce qcCheckTaskProduce);
List<QcCheckType> getCheckTypes(QcCheckType qcCheckType);
List<QcCheckTaskProduce> getOrderWorks(ProOrderWorkorderDTO qoWork);
}

@ -1,6 +1,8 @@
package com.op.quality.service;
import java.util.List;
import com.op.common.core.web.domain.AjaxResult;
import com.op.quality.domain.QcCheckTaskProduce;
import com.op.quality.domain.QcCheckType;
@ -64,4 +66,6 @@ public interface IQcCheckTaskProduceService {
List<QcCheckType> getCheckTypes(QcCheckType qcCheckType);
int changeProduceStatus(QcCheckTaskProduce qcCheckTaskProduce);
AjaxResult createProduceXJTask();
}

@ -2,9 +2,17 @@ package com.op.quality.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils;
@ -14,18 +22,24 @@ import com.op.quality.domain.*;
import com.op.quality.mapper.QcCheckTaskDetailMapper;
import com.op.quality.mapper.QcCheckTypeProjectMapper;
import com.op.quality.mapper.QcMaterialGroupDetailMapper;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.quality.mapper.QcCheckTaskProduceMapper;
import com.op.quality.service.IQcCheckTaskProduceService;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import static com.op.common.core.web.domain.AjaxResult.error;
import static com.op.common.core.web.domain.AjaxResult.success;
/**
* Service
*
@ -34,6 +48,7 @@ import javax.servlet.http.HttpServletRequest;
*/
@Service
public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private QcCheckTaskProduceMapper qcCheckTaskProduceMapper;
@ -45,6 +60,8 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
@Autowired
private QcCheckTaskDetailMapper qcCheckTaskDetailMapper;
@Autowired
private RemoteUserService remoteUserService;
/**
*
@ -81,8 +98,15 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
@Override
@DS("#header.poolName")
public int insertQcCheckTaskProduce(QcCheckTaskProduce qcCheckTaskProduce) {
String factoryCode = "";
if(StringUtils.isNotBlank(qcCheckTaskProduce.getFactoryCode())){
DynamicDataSourceContextHolder.push("ds_"+qcCheckTaskProduce.getFactoryCode());
factoryCode= qcCheckTaskProduce.getFactoryCode();
}else{
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
factoryCode = request.getHeader(key.substring(8)).replace("ds_","");
}
qcCheckTaskProduce.setCreateTime(DateUtils.getNowDate());
@ -93,10 +117,6 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
String createBy = SecurityUtils.getUsername();
Date nowDate= DateUtils.getNowDate();
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String factoryCode = request.getHeader(key.substring(8)).replace("ds_","");
qcCheckTaskProduce.setCheckNo(bpDD+liushuiStr);
@ -197,4 +217,53 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
return qcCheckTaskProduceMapper.updateQcCheckTaskProduce(qcCheckTaskProduce);
}
@Override
public AjaxResult createProduceXJTask() {
// 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser();
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
ExecutorService executorService = new ThreadPoolExecutor(
dateSources.size(),
dateSources.size(),
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
try {
dateSources.forEach(dateSource -> {
if("ds_1000".equals(dateSource.get("poolName"))){
logger.info("++++++++++++" + dateSource.get("poolName") + "++++过程检验巡检开始++++++++++");
Runnable run = () -> createProduceXJFunc(dateSource.get("poolName"));
executorService.execute(run);
}
});
} catch (Exception e) {
logger.error("service == createProduceXJTask == exception", e);
return error("service == createProduceXJTask == exception");
} finally {
executorService.shutdown();
}
return success();
}
public void createProduceXJFunc(String poolName){
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
ProOrderWorkorderDTO qoWork = new ProOrderWorkorderDTO();
qoWork.setStatus("w2");
List<QcCheckTaskProduce> works = qcCheckTaskProduceMapper.getOrderWorks(qoWork);
for(QcCheckTaskProduce productTask:works){
productTask.setCheckType("checkTypeSCXJ");//过程检验-巡检
Date nowTime = DateUtils.getNowDate();
Date startTime = productTask.getCreateTime();
long mins = DateUtil.between(startTime, nowTime, DateUnit.MINUTE);
if(mins>=15){
int m = insertQcCheckTaskProduce(productTask);
logger.info("++++++++++++过程检验巡检任务生成" + m + "++++++++++++++");
}
}
logger.info("++++++++++++" + poolName + "++++过程检验巡检结束++++++++++");
}
}

@ -349,7 +349,7 @@ public class QcInterfaceServiceImpl implements IQcInterfaceService {
List<String> datas = new ArrayList<>();
for(String dayStr:xAxisDatas) {
QcInterface data0 = productdatas.get(productName + dayStr);
if (data0 != null) {
if (data0 != null && !"0.00".equals(data0.getQuality())) {
BigDecimal rate = new BigDecimal(data0.getNoOkQuality())
.multiply(new BigDecimal(100))
.divide(new BigDecimal(data0.getQuality()),2,BigDecimal.ROUND_HALF_UP);

@ -107,8 +107,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from qc_check_type
where type_code = #{typeCode} and del_flag='0'
</select>
<select id="getOrderWorks" resultType="com.op.quality.domain.QcCheckTaskProduce">
select pow.factory_code factoryCode,
powb.batch_code incomeBatchNo,
powb.qc_status,
pow.workorder_code workorderCode,
pow.product_code materialCode,
pow.product_name materialName,
pow.quantity_split quality,
pow.unit,
e.workshop_code supplierCode,
e.workshop_name supplierName,
pow.product_date incomeTime,
task.createTime
from pro_order_workorder pow
left join pro_order_workorder_batch powb on powb.workorder_id = pow.workorder_id
left join base_equipment e on e.equipment_code = pow.workorder_name
left join (
select max(create_time) createTime,income_batch_no from qc_check_task
where type_code = 'produce' and income_batch_no='20270104LJ20240105CBRA0L'
<!--生产放开and CONVERT(varchar(10),income_time, 120) = CONVERT(varchar(10),GETDATE(), 120)-->
GROUP BY income_batch_no
) task on task.income_batch_no = powb.batch_code
where pow.status = 'w2' and pow.parent_order = '0' and pow.del_flag ='0'
and powb.del_flag = '0' and pow.product_date >= '2023-12-22'
and task.createTime is not null
</select>
<insert id="insertQcCheckTaskProduce" parameterType="QcCheckTaskProduce">
<insert id="insertQcCheckTaskProduce" parameterType="QcCheckTaskProduce">
insert into qc_check_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="recordId != null">record_id,</if>

@ -612,10 +612,34 @@ public class OdsProcureOrderServiceImpl implements IOdsProcureOrderService {
SapPurchaseOrderQuery sapPurchaseOrderQuery=new SapPurchaseOrderQuery();
sapPurchaseOrderQuery.setEbeln(odsProcureOrder.getProcureCode());
R result= remoteSapService.sapPurchaseOrderSync(sapPurchaseOrderQuery);
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList=new ArrayList<>();
sapPurchaseOrderQueryList= (List<SapPurchaseOrderQuery>) result.getData();
// sapPurchaseOrderQueryList
return null;
List<Map<String, String>> mapList = new ArrayList<>();
mapList= (List<Map<String, String>>) result.getData();
for(Map<String, String> sapPurchaseOrderQuery1:mapList){
OdsProcureOrder order =new OdsProcureOrder();
order.setProcureCode(sapPurchaseOrderQuery1.get("ebeln"));
order.setSiteCode(sapPurchaseOrderQuery1.get("werks"));
order.setUserDefined3(sapPurchaseOrderQuery1.get("ebelp"));//批次
order.setMaterialCode(sapPurchaseOrderQuery1.get("matnr"));
order.setMaterialDesc(sapPurchaseOrderQuery1.get("maktx"));
order.setActive("1");
List<OdsProcureOrder> orderList= odsProcureOrderMapper.selectOdsProcureOrderList(order);
if (orderList.size()>0){
continue;
}
order.setPlanNumber(new BigDecimal(sapPurchaseOrderQuery1.get("menge")));
order.setUnit(sapPurchaseOrderQuery1.get("meins"));
order.setSupplierCode(sapPurchaseOrderQuery1.get("lifnr"));
order.setUserDefined9(sapPurchaseOrderQuery1.get("zmenge"));
order.setUserDefined10(sapPurchaseOrderQuery1.get("elikz"));
order.setUserDefined11(sapPurchaseOrderQuery1.get("eindt"));
order.setCreateBy(odsProcureOrder.getCreateBy());
order.setPlanDate(new Date());
order.setOrderStatus("0");
//order.setID(IdUtils.fastSimpleUUID());
order.setCreateDate(new Date());
odsProcureOrderMapper.insertOdsProcureOrder(order);
}
return AjaxResult.success();
}
public String DesignatedPalletOutboundWCS(WMSDesignatedPalle wmsDesignatedPalle){

Loading…
Cancel
Save