成品bug修改

highway
zhaoxiaolin 1 year ago
parent 0e6a6286f6
commit 3262f842a3

@ -0,0 +1,24 @@
package com.op.system.api;
import com.op.common.core.constant.ServiceNameConstants;
import com.op.common.core.domain.R;
import com.op.system.api.factory.RemoteDeviceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
*
*
* @author OP
*/
@FeignClient(contextId = "remoteDeviceService", value = ServiceNameConstants.DEVICE_SERVICE, fallbackFactory = RemoteDeviceFallbackFactory.class)
public interface RemoteDeviceService {
@PostMapping("/deviceTask/createSpotCheckPlanTask")
public R createSpotCheckPlanTask();
}

@ -102,6 +102,15 @@ public class BaseBomDTO extends BaseEntity {
private String productGroup;
private String productGroupName;
private String productCode;
private String workorderCode;
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getProductCode() {
return productCode;

@ -52,7 +52,7 @@ public class MesReportWorkDTO extends BaseEntity {
/** 排产数量 */
@Excel(name = "排产数量")
private BigDecimal quantity;
private BigDecimal quantitySplit;
/** 本次报工数量 */
@Excel(name = "本次报工数量")
private BigDecimal quantityFeedback;
@ -162,6 +162,14 @@ public class MesReportWorkDTO extends BaseEntity {
private String feedbackTimeStart;
private String feedbackTimeEnd;
public BigDecimal getQuantitySplit() {
return quantitySplit;
}
public void setQuantitySplit(BigDecimal quantitySplit) {
this.quantitySplit = quantitySplit;
}
public String getFeedbackTimeStart() {
return feedbackTimeStart;
}

@ -0,0 +1,33 @@
package com.op.system.api.factory;
import com.op.common.core.domain.R;
import com.op.system.api.RemoteDeviceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
*
* @author OP
*/
@Component
public class RemoteDeviceFallbackFactory implements FallbackFactory<RemoteDeviceService> {
private static final Logger log = LoggerFactory.getLogger(RemoteDeviceFallbackFactory.class);
@Override
public RemoteDeviceService create(Throwable throwable) {
log.error("Device服务调用失败:{}", throwable.getMessage());
return new RemoteDeviceService() {
@Override
public R createSpotCheckPlanTask() {
return R.fail("点检计划创建失败:" + throwable.getMessage());
}
};
}
}

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

@ -43,4 +43,9 @@ public class ServiceNameConstants {
* serviceid
*/
public static final String TECH_SERVICE = "op-technology";
/**
* serviceid
*/
public static final String DEVICE_SERVICE = "op-device";
}

@ -2,9 +2,11 @@ package com.op.common.core.utils.poi;
import com.alibaba.fastjson2.JSONObject;
import com.op.common.core.domain.ExcelCol;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
@ -53,37 +55,49 @@ public class ExcelMapUtil {
//将data中的值填充到excel
int rowNum = sheet.getLastRowNum()+1;
Iterator<T> iterator = data.iterator();
//遍历数据
for (;iterator.hasNext();){
Row dataRow = sheet.createRow(rowNum);//创建行
T obj = iterator.next();//获取当前行对应的数据
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(obj));
for (int i = 0 ; i < colSize ; i++ ){
Cell dataCell = dataRow.createCell(i);
dataCell.setCellStyle(getDataFont(workbook));
if(i>=2){
dataCell.setCellValue(getValueNum(jsonObject.get(excelCol.get(i).getField())));
}else{
dataCell.setCellValue(getValue(jsonObject.get(excelCol.get(i).getField())));
}
if(!CollectionUtils.isEmpty(data)){
Iterator<T> iterator = data.iterator();
//遍历数据
for (;iterator.hasNext();){
Row dataRow = sheet.createRow(rowNum);//创建行
T obj = iterator.next();//获取当前行对应的数据
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(obj));
for (int i = 0 ; i < colSize ; i++ ){
Cell dataCell = dataRow.createCell(i);
dataCell.setCellStyle(getDataFont(workbook));
if(i>=2){
dataCell.setCellValue(getValueNum(jsonObject.get(excelCol.get(i).getField())));
}else{
dataCell.setCellValue(getValue(jsonObject.get(excelCol.get(i).getField())));
}
}
iterator.remove();
rowNum++;
}
iterator.remove();
rowNum++;
}
return workbook;
}
//标题样式
public static CellStyle getHeaderFont(Workbook workbook){
Font font = workbook.createFont();
font.setFontHeightInPoints((short) 16);//字体大小
font.setFontHeightInPoints((short) 15);//字体大小
font.setBold(true);//加粗
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
cellStyle.setAlignment(HorizontalAlignment.CENTER_SELECTION);//设置水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置垂直居中
// 设置上边框
cellStyle.setBorderTop(BorderStyle.THIN);
// 设置下边框
cellStyle.setBorderBottom(BorderStyle.THIN);
// 设置左边框
cellStyle.setBorderLeft(BorderStyle.THIN);
// 设置右边框
cellStyle.setBorderRight(BorderStyle.THIN);
return cellStyle;
}

@ -0,0 +1,43 @@
package com.op.device.controller;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.EquOrder;
import com.op.device.domain.EquPlan;
import com.op.device.domain.EquRepairOrder;
import com.op.device.domain.EquRepairWorkOrder;
import com.op.device.service.IDevicePDAService;
import com.op.device.service.IDeviceTaskService;
import com.op.device.service.IEquRepairOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* DeviceTaskController
*
* @author wws
* @date 2023-10-23
*/
@RestController
@RequestMapping("/deviceTask")
public class DeviceTaskController {
@Autowired
private IDeviceTaskService taskService;
/**
*
* @return
*/
@PostMapping("/createSpotCheckPlanTask")
public R createSpotCheckPlanTask() {
EquPlan equPlan = new EquPlan();
AjaxResult result = taskService.createSpotCheckPlanTask(equPlan);
if(result.isSuccess()){
return R.ok("点检计划生成成功");
}
return R.fail("点检计划生成失败");
}
}

@ -147,6 +147,15 @@ public class EquOrder extends BaseEntity {
//维修单号
private String workCode;
private int days;
public int getDays() {
return days;
}
public void setDays(int days) {
this.days = days;
}
public String getRepairCode() {
return repairCode;

@ -12,7 +12,7 @@ import com.op.common.core.web.domain.BaseEntity;
/**
* equ_plan
*
*
* @author Open Platform
* @date 2023-10-16
*/

@ -0,0 +1,24 @@
package com.op.device.mapper;
import com.op.common.core.domain.BaseFileData;
import com.op.device.domain.EquFile;
import com.op.device.domain.EquOrder;
import com.op.device.domain.EquPlan;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author Open Platform
* @date 2023-07-10
*/
@Mapper
public interface DeviceTaskMapper {
List<EquPlan> getPlans(EquPlan equPlan);
EquOrder getNewTaskOrder(EquOrder equOrder);
}

@ -5,18 +5,20 @@ import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.device.domain.EquOrder;
import com.op.device.domain.dto.PDADTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
*
*
* @author wws
* @date 2023-10-23
*/
@Mapper
public interface EquOrderMapper {
/**
*
*
*
* @param orderCode
* @return
*/
@ -24,7 +26,7 @@ public interface EquOrderMapper {
/**
*
*
*
* @param equOrder
* @return
*/
@ -32,7 +34,7 @@ public interface EquOrderMapper {
/**
*
*
*
* @param equOrder
* @return
*/
@ -40,7 +42,7 @@ public interface EquOrderMapper {
/**
*
*
*
* @param equOrder
* @return
*/
@ -48,7 +50,7 @@ public interface EquOrderMapper {
/**
*
*
*
* @param orderId
* @return
*/
@ -56,7 +58,7 @@ public interface EquOrderMapper {
/**
*
*
*
* @param orderIds
* @return
*/
@ -76,6 +78,11 @@ public interface EquOrderMapper {
*/
String selectCenterNameByCenterCode(String planWorkshop);
/**
* list
* @return
*/
List<EquOrder> selectTodayTask(int userId);
/**
*

@ -0,0 +1,16 @@
package com.op.device.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.EquPlan;
/**
* TaskService
*
* @author wws
* @date 2023-10-23
*/
public interface IDeviceTaskService {
AjaxResult createSpotCheckPlanTask(EquPlan equPlan);
}

@ -0,0 +1,69 @@
package com.op.device.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.security.utils.SecurityUtils;
import com.op.device.domain.*;
import com.op.device.mapper.*;
import com.op.device.service.IDeviceTaskService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import static com.op.common.core.web.domain.AjaxResult.error;
import static com.op.common.core.web.domain.AjaxResult.success;
/**
* TaskService
*
* @author wws
* @date 2023-10-23
*/
@Service
public class DeviceTaskServiceImpl implements IDeviceTaskService {
@Autowired
private DeviceTaskMapper deviceTaskMapper;
@Autowired
private EquOrderMapper equOrderMapper;
/**
*
* **/
@Override
@DS("#header.poolName")
public AjaxResult createSpotCheckPlanTask(EquPlan equPlan) {
/**equ_plan equ_plan_equ**/
equPlan.setPlanType("spotInspection");
List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);
for(EquPlan plan:plans){
if("day".equals(plan.getPlanLoopType())){
EquOrder order = new EquOrder();
order.setPlanType("spotInspection");
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(order);
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
//生成点检计划
this.createSpotCheckPlan(plan);
}
}
}
return success();
}
private int createSpotCheckPlan(EquPlan plan){
/**equ_order**/
EquOrder order = new EquOrder();
BeanUtils.copyProperties(plan,order);
equOrderMapper.insertEquOrder(order);
/**equ_order_detail**/
List<EquOrderDetail> details = new ArrayList<>();
return 0;
}
}

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.device.mapper.DeviceTaskMapper">
<select id="getPlans" resultType="com.op.device.domain.EquPlan">
select ep.plan_code planCode,
ep.plan_name planName,
ep.plan_loop planLoop,
ep.plan_loop_type planLoopType,
ep.plan_loop_start planLoopStart,
ep.plan_loop_end planLoopEnd,
ep.plan_restrict planRestrict,
ep.plan_type planType,
ep.plan_outsource planOutsource,
epe.equipment_code equipmentCode,
epe.equipment_name equipmentName
from equ_plan ep
left join equ_plan_equ epe on ep.plan_code = epe.plan_code
where ep.del_flag = '0' and epe.del_flag = '0' and ep.plan_status = '0'
and ep.plan_type = #{planType}
and CONVERT(varchar(10),GETDATE(), 120) >= CONVERT(varchar(10),ep.plan_loop_start, 120)
</select>
<select id="getNewTaskOrder" resultType="com.op.device.domain.EquOrder">
select top 1 order_code orderCode,
create_time createTime,
DATEDIFF (day, create_time, GETDATE()) days
from equ_order
where plan_type = #{planType}
order by create_time desc
</select>
</mapper>

@ -1,5 +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;
@ -31,6 +32,9 @@ public class RyTask {
@Autowired
private RemotePlanService remotePlanService;
@Autowired
private RemoteDeviceService remoteDeviceService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
}
@ -117,4 +121,10 @@ public class RyTask {
logger.info("++数据库备份的数据+开始++dataBKTask+++++");
remoteMesService.dataBKTask();
}
/**每日点检计划生成**/
public void createSpotCheckPlanTask(){
logger.info("++点检计划+开始++createSpotCheckPlanTask+++++");
remoteDeviceService.createSpotCheckPlanTask();
}
}

@ -80,6 +80,13 @@ public class MesReportWorkConsumeController extends BaseController {
return toAjax(mesReportWorkConsumeService.insertMesReportWorkConsume(mesReportWorkConsume));
}
@PostMapping("/addConsumes")
public AjaxResult addConsumes(@RequestBody List<MesReportWorkConsume> mesReportWorkConsumes) {
return toAjax(mesReportWorkConsumeService.insertMesReportWorkConsumes(mesReportWorkConsumes));
}
/**
*
*/

@ -105,23 +105,6 @@ public class WCSInterfaceController extends BaseController {
return success(wCInterfaceService.getMesBoardEquProductionToday(boardDTO));
}
/**上位机报工**/
@PostMapping("/reportWork")
public AjaxResult reportWork(@RequestBody MesReportWork mesReportWork) {
if(StringUtils.isBlank(mesReportWork.getFactoryCode())){
return error("[factoryCode] is null");
}
if(StringUtils.isBlank(mesReportWork.getReportCode())){
return error("[reportCode] is null");
}
if(mesReportWork.getFactoryCode().indexOf("ds")<0){
mesReportWork.setFactoryCode("ds_"+mesReportWork.getFactoryCode());
}
return success(wCInterfaceService.reportWork(mesReportWork));
}
/************************************************************/
/****************************数据库清理************************/
/************************************************************/

@ -51,7 +51,7 @@ public class MesReportWork extends BaseEntity {
/** 排产数量 */
@Excel(name = "排产数量")
private BigDecimal quantity;
private BigDecimal quantitySplit;
/** 本次报工数量 */
@Excel(name = "本次报工数量")
private BigDecimal quantityFeedback;
@ -161,6 +161,14 @@ public class MesReportWork extends BaseEntity {
private String feedbackTimeStart;
private String feedbackTimeEnd;
public BigDecimal getQuantitySplit() {
return quantitySplit;
}
public void setQuantitySplit(BigDecimal quantitySplit) {
this.quantitySplit = quantitySplit;
}
public String getFeedbackTimeStart() {
return feedbackTimeStart;
}

@ -5,6 +5,7 @@ import java.util.List;
import com.op.mes.domain.MesReportWorkConsume;
import com.op.system.api.domain.dto.BaseBomDTO;
import com.op.system.api.domain.mes.BaseTeamTDTO;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@ -66,4 +67,6 @@ public interface MesReportWorkConsumeMapper {
List<BaseBomDTO> getMesListBom(BaseBomDTO dto);
List<BaseTeamTDTO> getTeamList(BaseTeamTDTO dto);
int insertMesReportWorkConsumes(@Param("list") List<MesReportWorkConsume> mesReportWorkConsumes);
}

@ -72,4 +72,6 @@ public interface IMesReportWorkConsumeService {
public List<BaseBomDTO> getMesListBom(BaseBomDTO dto);
public List<BaseTeamTDTO> getTeamList(BaseTeamTDTO dto);
int insertMesReportWorkConsumes(List<MesReportWorkConsume> mesReportWorkConsumes);
}

@ -319,8 +319,8 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
mesReportWorkMapper.updateSyncSapStatus(work);
//工单完成数量>工单数量:关闭订单
MesReportWork proResult = mesReportWorkMapper.getProdResult(work);
ProOrderWorkorder topOrder = this.getTopOrder(work.getWorkorderCode());
if(proResult.getQuantityFeedback().compareTo(new BigDecimal(topOrder.getQuantitySplit()))>=0){
//ProOrderWorkorder topOrder = this.getTopOrder(work.getWorkorderCode());
if(proResult.getQuantityFeedback().compareTo(work.getQuantitySplit())>=0){
//工单完成,关闭工单
remoteSapService.sapCloseOrder(work.getWorkorderCodeSap());
work.setStatus("w3");
@ -331,16 +331,16 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
return R.ok();
}
//根据工单子单编码获取最顶级订单的母单
private ProOrderWorkorder getTopOrder(String workorderCode) {
//pro_order_workorder
ProOrderWorkorder topOrder = mesReportWorkMapper.getOrderByCode(workorderCode);
while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
//pro_order_workorder
topOrder = mesReportWorkMapper.getOrderByCode(topOrder.getParentOrder());
}
return topOrder;
}
// //根据工单子单编码获取最顶级订单的母单
// private ProOrderWorkorder getTopOrder(String workorderCode) {
// //pro_order_workorder
// ProOrderWorkorder topOrder = mesReportWorkMapper.getOrderByCode(workorderCode);
// while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
// //pro_order_workorder
// topOrder = mesReportWorkMapper.getOrderByCode(topOrder.getParentOrder());
// }
// return topOrder;
// }
public void dateBKFunc(String poolName,List<String> tables){

@ -75,6 +75,18 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
return mesReportWorkConsumeMapper.insertMesReportWorkConsume(mesReportWorkConsume);
}
@Override
@DS("#header.poolName")
public int insertMesReportWorkConsumes(List<MesReportWorkConsume> mesReportWorkConsumes) {
for(MesReportWorkConsume mesReportWorkConsume:mesReportWorkConsumes){
mesReportWorkConsume.setRecordId(IdUtils.fastSimpleUUID());
mesReportWorkConsume.setCreateTime(DateUtils.getNowDate());
}
return mesReportWorkConsumeMapper.insertMesReportWorkConsumes(mesReportWorkConsumes);
}
/**
*
*
@ -123,5 +135,4 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
return mesReportWorkConsumeMapper.getTeamList(dto);
}
}

@ -63,9 +63,9 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
public List<MesReportWork> selectMesReportWorkList(MesReportWork mesReportWork) {
List<MesReportWork> dtos = mesReportWorkMapper.selectMesReportWorkList(mesReportWork);
for(MesReportWork dto:dtos){
ProOrderWorkorder topOrder = this.getTopOrder(dto.getWorkorderCode());
dto.setQuantity(new BigDecimal(topOrder.getQuantitySplit()));
dto.setUnit(topOrder.getUnit());
// ProOrderWorkorder topOrder = this.getTopOrder(dto.getWorkorderCode());
// dto.setQuantity(new BigDecimal(topOrder.getQuantitySplit()));
// dto.setUnit(topOrder.getUnit());
if("1".equals(dto.getUploadStatus())){
dto.setUploadStatus("sap报工成功");
}else if("2".equals(dto.getUploadStatus())){
@ -78,16 +78,16 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
return dtos;
}
//根据工单子单编码获取最顶级订单的母单
private ProOrderWorkorder getTopOrder(String workorderCode) {
//pro_order_workorder
ProOrderWorkorder topOrder = mesReportWorkMapper.getOrderByCode(workorderCode);
while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
//pro_order_workorder
topOrder = mesReportWorkMapper.getOrderByCode(topOrder.getParentOrder());
}
return topOrder;
}
// //根据工单子单编码获取最顶级订单的母单
// private ProOrderWorkorder getTopOrder(String workorderCode) {
// //pro_order_workorder
// ProOrderWorkorder topOrder = mesReportWorkMapper.getOrderByCode(workorderCode);
// while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
// //pro_order_workorder
// topOrder = mesReportWorkMapper.getOrderByCode(topOrder.getParentOrder());
// }
// return topOrder;
// }
/**
*
@ -370,6 +370,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
@Override
@DS("#header.poolName")
public List<ProOrderWorkorderDTO> getMesListWorkOrder(ProOrderWorkorderDTO proOrderWorkorderDTO) {
//母单
List<ProOrderWorkorderDTO> dtos = mesReportWorkMapper.getMesListWorkOrder(proOrderWorkorderDTO);
for(ProOrderWorkorderDTO dto:dtos){
StringBuilder prodLineName = new StringBuilder("");
@ -387,10 +388,10 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
}
dto.setProdLineCode(prodLineName.toString());
//把母单的排产数量搞出来
ProOrderWorkorder topOrder = this.getTopOrder(dto.getWorkorderCode());
dto.setQuantitySplit(topOrder.getQuantitySplit());
dto.setUnit(topOrder.getUnit());
// //把母单的排产数量搞出来
// ProOrderWorkorder topOrder = this.getTopOrder(dto.getWorkorderCode());
// dto.setQuantitySplit(topOrder.getQuantitySplit());
// dto.setUnit(topOrder.getUnit());
}
return dtos;
}

@ -68,8 +68,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.product_group_name productGroupName
from base_bom_component bbc
left join base_product bp on SUBSTRING(bp.product_code, 8, 12) = bbc.component
left join mes_report_work_consume wc on wc.material_code = bbc.component and wc.workorder_code = #{workorderCode}
where bbc.product_code = SUBSTRING(#{productCode}, 8, 12)
and bp.del_flag = '0'
and bp.del_flag = '0' and wc.material_code is null
<if test="component != null and component != ''"> and bbc.component like concat('%', #{component}, '%')</if>
<if test="componentName != null and componentName != ''"> bp.product_desc_zh like concat('%', #{componentName}, '%')</if>
<if test="productGroup != null and productGroup != ''"> and bp.product_group like concat('%', #{productGroup}, '%')</if>
@ -125,6 +126,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="factoryCode != null">#{factoryCode},</if>
</trim>
</insert>
<insert id="insertMesReportWorkConsumes">
insert into mes_report_work_consume
(record_id, workorder_code, material_code, material_name, material_spc,
quantity, unit,create_by, create_time,report_code)
VALUES
<foreach collection="list" index="index" item="item" separator=",">
(#{item.recordId},#{item.workorderCode},#{item.materialCode},#{item.materialName},#{item.materialSpc},
#{item.quantity},#{item.unit},#{item.createBy},#{item.createTime},#{item.reportCode})
</foreach>
</insert>
<update id="updateMesReportWorkConsume" parameterType="MesReportWorkConsume">
update mes_report_work_consume

@ -95,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mrw.feedback_time, mrw.record_user, mrw.status, mrw.remark, mrw.work_time, mrw.machine_code,
mrw.machine_name, mrw.team_code, mrw.shift_code, mrw.create_by,
mrw.create_time,mrw.upload_time,mrw.upload_status,mrw.upload_msg,
pow.order_code
pow.order_code,pow.quantity_split
from mes_report_work mrw
left join pro_order_workorder pow on mrw.workorder_code = pow.workorder_code
<where>
@ -211,10 +211,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productDateEnd != null "> and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120)</if>
</select>
<select id="getReportWorkList" resultType="com.op.mes.domain.MesReportWork">
select ow.order_code orderCode,
select
ow.order_code orderCode,
ow.workorder_code workorderCode,
ow.workorder_code_sap workorderCodeSap,
ow.route_code routeCode,
ow.quantity_split quantitySplit,
rte.tec_machine sac1,
rte.tec_man sac2,
rte.tec_depreciation sac3,
@ -412,7 +414,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
s.Shift_Desc shiftName
from pro_order_workorder pow
left join base_shifts_t s on pow.shift_id = s.Shift_Id
where pow.del_flag = '0' and pow.status = 'w2' and pow.end_flag ='1'
where pow.del_flag = '0' and pow.status = 'w2' and pow.parent_order ='0'
order by pow.product_date desc
<if test="workorderCode != null and workorderCode != ''">
and pow.workorder_code like concat('%', #{workorderCode}, '%')

@ -186,20 +186,20 @@ public class OpenServiceImpl implements OpenService {
sysSapLog.setCreateTime(DateUtils.getNowDate());
openMapper.addSapLog(sysSapLog);
R r = remoteSapService.sapRFWOrder(sapRFW);
//R r = remoteSapService.sapRFWOrder(sapRFW);
//上传成功更改mes_report_work状态
if (r.getCode() == 200) {
//if (r.getCode() == 200) {
work.setUploadStatus("1");
} else {
work.setUploadStatus("2");
work.setUploadMsg(r.getMsg());
}
//} else {
// work.setUploadStatus("2");
// work.setUploadMsg(r.getMsg());
//}
work.setUploadTime(DateUtils.getNowDate());
openMapper.updateSyncSapStatus(work);
//工单完成数量>工单数量:关闭订单
MesReportWorkDTO proResult = openMapper.getProdResult(work);
ProOrderWorkorderDTO topOrder = this.getTopOrder(work.getWorkorderCode());
if(proResult.getQuantityFeedback().compareTo(new BigDecimal(topOrder.getQuantitySplit()))>=0){
//ProOrderWorkorderDTO topOrder = this.getTopOrder(work.getWorkorderCode());
if(proResult.getQuantityFeedback().compareTo(work.getQuantitySplit())>=0){
//工单完成,关闭工单
remoteSapService.sapCloseOrder(work.getWorkorderCodeSap());
work.setStatus("w3");
@ -210,16 +210,16 @@ public class OpenServiceImpl implements OpenService {
return R.ok();
}
//根据工单子单编码获取最顶级订单的母单
private ProOrderWorkorderDTO getTopOrder(String workorderCode) {
//pro_order_workorder
ProOrderWorkorderDTO topOrder = openMapper.getOrderByCode(workorderCode);
while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
//pro_order_workorder
topOrder = openMapper.getOrderByCode(topOrder.getParentOrder());
}
return topOrder;
}
// //根据工单子单编码获取最顶级订单的母单
// private ProOrderWorkorderDTO getTopOrder(String workorderCode) {
// //pro_order_workorder
// ProOrderWorkorderDTO topOrder = openMapper.getOrderByCode(workorderCode);
// while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
// //pro_order_workorder
// topOrder = openMapper.getOrderByCode(topOrder.getParentOrder());
// }
// return topOrder;
// }
public static void main(String args[]){

@ -74,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ow.workorder_code workorderCode,
ow.workorder_code_sap workorderCodeSap,
ow.route_code routeCode,
ow.quantity_split quantitySplit,
rte.tec_machine sac1,
rte.tec_man sac2,
rte.tec_depreciation sac3,

@ -3,13 +3,19 @@ package com.op.plan.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.domain.ExcelCol;
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.poi.ExcelMapUtil;
import com.op.common.security.utils.SecurityUtils;
import com.op.plan.domain.dto.SplitOrderDTO;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -62,12 +68,12 @@ public class ProOrderController extends BaseController {
*/
@Log(title = "导入订单信息", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
@RequiresPermissions("mes:pro:order:import")
public AjaxResult importData(MultipartFile file) throws Exception {
// 创建接收对象
ExcelUtil<ProOrder> util = new ExcelUtil<>(ProOrder.class);
// 接收表格信息
List<ProOrder> orderList = util.importExcel(file.getInputStream());
return proOrderService.importOrder(orderList);
}
@ -80,28 +86,34 @@ public class ProOrderController extends BaseController {
@PostMapping("/importTemplate")
@Log(title = "生成订单模板", businessType = BusinessType.EXPORT)
public void importTemplate(HttpServletResponse response) throws IOException {
ExcelUtil<ProOrder> util = new ExcelUtil<>(ProOrder.class);
List<ProOrder> orderList = new ArrayList<>();
ProOrder example = new ProOrder();
example.setPlanFactoryCode("000000");
example.setOrderType("LJ01");
example.setOrderCode("000000");
example.setProdCode("000000");
example.setProdDesc("物料名称样例");
example.setQuantity(100L);
example.setUnit("KAR");
example.setWorkerOrder("510000");
example.setProdType("prod");
example.setStatus("o0");
example.setParentOrder("1000000");
example.setPlanComplete(DateUtils.getNowDate());
example.setPlanProDate(DateUtils.getNowDate());
example.setCreateBy(SecurityUtils.getUsername());
example.setCreateTime(DateUtils.getNowDate());
example.setUpdateTime(DateUtils.getNowDate());
orderList.add(example);
util.exportExcel(response, orderList, "订单基本信息");
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("订单类型","orderType",20));
excelCols.add(new ExcelCol("订单号","orderCode",20));
excelCols.add(new ExcelCol("父级订单","parentOrder",20));
excelCols.add(new ExcelCol("物料号","prodCode",20));
excelCols.add(new ExcelCol("订单数量","quantity",20));
excelCols.add(new ExcelCol("单位","unit",20));
excelCols.add(new ExcelCol("计划生产日期","planProDate",20));
excelCols.add(new ExcelCol("计划完成日期","planComplete",20));
String titleName = "成品订单导入";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename="+ titleName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(titleName, titleName, excelCols, null);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
}finally {
if (workbook!=null){
workbook.dispose();
}
}
}
@ -226,7 +238,7 @@ public class ProOrderController extends BaseController {
/**
*
*/
@RequiresPermissions("mes:pro:order:add")
@Log(title = "新增订单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ProOrder proOrder) {

@ -205,6 +205,21 @@ public class ProOrderWorkorder extends TreeEntity {
private String workorderCodeSap;
/** 批次号 */
private List<StringBuilder> batchCodeList;
private List<StringBuilder> batchNumList;
/** $column.columnComment */
private String factoryCode;
public List<StringBuilder> getBatchNumList() {
return batchNumList;
}
public void setBatchNumList(List<StringBuilder> batchNumList) {
this.batchNumList = batchNumList;
}
public String getWorkorderCodeSap() {
return workorderCodeSap;
}
@ -285,9 +300,6 @@ public class ProOrderWorkorder extends TreeEntity {
this.shiftDesc = shiftDesc;
}
/** 批次号 */
private List<StringBuilder> batchCodeList;
public List<StringBuilder> getBatchCodeList() {
return batchCodeList;
}
@ -296,9 +308,6 @@ public class ProOrderWorkorder extends TreeEntity {
this.batchCodeList = batchCodeList;
}
/** $column.columnComment */
private String factoryCode;
public void setWorkorderId(String workorderId) {
this.workorderId = workorderId;
}

@ -1,6 +1,7 @@
package com.op.plan.mapper;
import com.op.plan.domain.BaseProduct;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -10,6 +11,7 @@ import java.util.List;
* @author Open Platform
* @date 2023-09-03
*/
@Mapper
public interface BaseProductMapper {
/**

@ -133,7 +133,7 @@ public interface ProOrderMapper {
* @param workorderId
* @return
*/
List<String> selectBatchCodesById(String workorderId);
List<ProOrderWorkorderBatch> selectBatchCodesById(String workorderId);
/**
* 线list

@ -10,6 +10,7 @@ import java.util.stream.Collectors;
import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.op.common.core.utils.ServletUtils;
import com.op.plan.domain.vo.CascaderDTO;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
@ -67,11 +68,12 @@ public class ProOrderServiceImpl implements IProOrderService {
private ProRouteMapper proRouteMapper;
@Autowired
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
@Autowired
private RemoteSapService remoteSapService;
@Autowired
private RemoteUserService remoteUserService;
@Autowired
private BaseProductMapper baseProductMapper;
/**
*
*
@ -352,16 +354,19 @@ public class ProOrderServiceImpl implements IProOrderService {
proOrderWorkorder.setProdLineCode(prodLineName.toString());
// 通过工单id查询批次号
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
List<ProOrderWorkorderBatch> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
List<StringBuilder> batchCodes = new ArrayList<>();
List<StringBuilder> batchNums = new ArrayList<>();
// 格式化数据
for (String batchCode : batchCodeList) {
batchCodes.add(new StringBuilder(batchCode).append(";").append("\n"));
for (ProOrderWorkorderBatch batchCode : batchCodeList) {
batchCodes.add(new StringBuilder(batchCode.getBatchCode()).append(";"));
batchNums.add(new StringBuilder(batchCode.getBatchQuantity()+"").append(";"));
}
// 将查询结果设置到当前工单对象
proOrderWorkorder.setShiftDesc(shiftDesc);
proOrderWorkorder.setBatchCodeList(batchCodes);
proOrderWorkorder.setBatchNumList(batchNums);
// 通过母工单workorder_id查询子工单
List<ProOrderWorkorder> childWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorder.getWorkorderCode());
@ -533,6 +538,27 @@ public class ProOrderServiceImpl implements IProOrderService {
@DS("#header.poolName")
@Transactional
public AjaxResult importOrder(List<ProOrder> orderList) {
BaseProduct bpqo = null;
for(ProOrder order:orderList){
if(StringUtils.isBlank(order.getOrderType())){
order.setOrderType("LJ01");
}
String factoryCode = ServletUtils.getRequest().getHeader("PoolName").replace("ds_","");
order.setPlanFactoryCode(factoryCode);
order.setFactoryCode(factoryCode);
order.setCreateBy(SecurityUtils.getUsername());
order.setCreateTime(DateUtils.getNowDate());
order.setOrderType("LJ01");
order.setProdType("prod");
order.setStatus("o0");
bpqo = new BaseProduct();
bpqo.setProductCode(order.getProdCode());
List<BaseProduct> bp = baseProductMapper.selectBaseProductList(bpqo);
if(!CollectionUtils.isEmpty(bp)){
order.setProdDesc(bp.get(0).getProductDescZh());
}
}
// 数据校验
AjaxResult checkResult = checkImportOrder(orderList);
// 如果数据校验成功

@ -971,11 +971,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
proOrderWorkorder.setProdLineCode(prodLineName.toString());
// 通过工单id查询批次号
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
List<ProOrderWorkorderBatch> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
List<StringBuilder> batchCodes = new ArrayList<>();
// 格式化数据
for (String batchCode : batchCodeList) {
batchCodes.add(new StringBuilder(batchCode).append(";").append("\n"));
for (ProOrderWorkorderBatch batchCode : batchCodeList) {
batchCodes.add(new StringBuilder(batchCode.getBatchCode()).append(";").append("\n"));
}
// 将查询结果设置到当前工单对象
proOrderWorkorder.setShiftDesc(shiftDesc);

@ -303,11 +303,11 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService {
proOrderWorkorder.setProdLineCode(prodLineName.toString());
// 通过工单id查询批次号
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
List<ProOrderWorkorderBatch> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId());
List<StringBuilder> batchCodes = new ArrayList<>();
// 格式化数据
for (String batchCode : batchCodeList) {
batchCodes.add(new StringBuilder(batchCode).append(";").append("\n"));
for (ProOrderWorkorderBatch batchCode : batchCodeList) {
batchCodes.add(new StringBuilder(batchCode.getBatchCode()).append(";").append("\n"));
}
// 将查询结果设置到当前工单对象
proOrderWorkorder.setShiftDesc(shiftDesc);

@ -115,8 +115,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE sf.f_code = #{prodLineCode}
</select>
<select id="selectBatchCodesById" resultType="java.lang.String">
SELECT powb.batch_code
<select id="selectBatchCodesById" resultType="com.op.plan.domain.ProOrderWorkorderBatch">
SELECT powb.batch_code batchCode,
powb.batch_quantity batchQuantity
FROM pro_order_workorder_batch powb
LEFT JOIN pro_order_workorder pow
ON powb.workorder_id = pow.workorder_id

Loading…
Cancel
Save